File indexing completed on 2024-12-22 04:46:03
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "messagelinewidgettest.h" 0008 #include "room/messagelinewidget.h" 0009 #include "room/messagetextedit.h" 0010 #include <QHBoxLayout> 0011 #include <QStandardPaths> 0012 #include <QTest> 0013 #include <QToolButton> 0014 0015 QTEST_MAIN(MessageLineWidgetTest) 0016 0017 MessageLineWidgetTest::MessageLineWidgetTest(QObject *parent) 0018 : QObject(parent) 0019 { 0020 QStandardPaths::setTestModeEnabled(true); 0021 } 0022 0023 void MessageLineWidgetTest::shouldHaveDefaultValues() 0024 { 0025 MessageLineWidget w; 0026 QCOMPARE(w.mode(), MessageLineWidget::EditingMode::NewMessage); 0027 QVERIFY(w.threadMessageId().isEmpty()); 0028 0029 auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainLayout")); 0030 QVERIFY(mainLayout); 0031 QCOMPARE(mainLayout->contentsMargins(), QMargins{}); 0032 QCOMPARE(mainLayout->spacing(), 0); 0033 0034 auto mMessageTextEdit = w.findChild<MessageTextEdit *>(QStringLiteral("mMessageTextEdit")); 0035 QVERIFY(mMessageTextEdit); 0036 0037 auto mSendFileButton = w.findChild<QToolButton *>(QStringLiteral("mSendFileButton")); 0038 QVERIFY(mSendFileButton); 0039 QVERIFY(!mSendFileButton->icon().isNull()); 0040 QVERIFY(mSendFileButton->autoRaise()); 0041 0042 auto mEmoticonButton = w.findChild<QToolButton *>(QStringLiteral("mEmoticonButton")); 0043 QVERIFY(mEmoticonButton); 0044 QVERIFY(!mEmoticonButton->icon().isNull()); 0045 QCOMPARE(mEmoticonButton->popupMode(), QToolButton::InstantPopup); 0046 QVERIFY(mEmoticonButton->autoRaise()); 0047 0048 auto mSendMessageButton = w.findChild<QToolButton *>(QStringLiteral("mSendMessageButton")); 0049 QVERIFY(mSendMessageButton); 0050 QVERIFY(!mSendMessageButton->icon().isNull()); 0051 QVERIFY(mSendMessageButton->autoRaise()); 0052 0053 auto mVideoMessageButton = w.findChild<QToolButton *>(QStringLiteral("mVideoMessageButton")); 0054 QVERIFY(mVideoMessageButton); 0055 QVERIFY(!mVideoMessageButton->icon().isNull()); 0056 QVERIFY(mVideoMessageButton->autoRaise()); 0057 0058 auto mSoundMessageButton = w.findChild<QToolButton *>(QStringLiteral("mSoundMessageButton")); 0059 QVERIFY(mSoundMessageButton); 0060 QVERIFY(!mSoundMessageButton->icon().isNull()); 0061 QVERIFY(mSoundMessageButton->autoRaise()); 0062 0063 QVERIFY(w.roomId().isEmpty()); 0064 QVERIFY(w.messageIdBeingEdited().isEmpty()); 0065 0066 QVERIFY(w.quoteText().isEmpty()); 0067 QVERIFY(w.quotePermalink().isEmpty()); 0068 } 0069 0070 // TODO test signal/slot 0071 0072 #include "moc_messagelinewidgettest.cpp"