File indexing completed on 2024-05-26 05:05:56
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 "myaccountpreferenceconfigurewidgettest.h" 0008 #include "myaccount/myaccountpreferenceconfigurewidget.h" 0009 #include <QCheckBox> 0010 #include <QComboBox> 0011 #include <QLabel> 0012 #include <QLineEdit> 0013 #include <QPushButton> 0014 #include <QSpinBox> 0015 #include <QTest> 0016 #include <QVBoxLayout> 0017 QTEST_MAIN(MyAccountPreferenceConfigureWidgetTest) 0018 MyAccountPreferenceConfigureWidgetTest::MyAccountPreferenceConfigureWidgetTest(QObject *parent) 0019 : QObject(parent) 0020 { 0021 } 0022 0023 void MyAccountPreferenceConfigureWidgetTest::shouldHaveDefaultValues() 0024 { 0025 MyAccountPreferenceConfigureWidget w(nullptr); 0026 0027 auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout")); 0028 QVERIFY(mainLayout); 0029 0030 auto highlightWordsLabel = w.findChild<QLabel *>(QStringLiteral("highlightWordsLabel")); 0031 QVERIFY(highlightWordsLabel); 0032 QCOMPARE(highlightWordsLabel->textFormat(), Qt::PlainText); 0033 QVERIFY(!highlightWordsLabel->text().isEmpty()); 0034 0035 auto mHighlightWords = w.findChild<QLineEdit *>(QStringLiteral("mHighlightWords")); 0036 QVERIFY(mHighlightWords); 0037 QVERIFY(mHighlightWords->text().isEmpty()); 0038 0039 auto mDesktopNotification = w.findChild<QComboBox *>(QStringLiteral("mDesktopNotification")); 0040 QVERIFY(mDesktopNotification); 0041 auto mEmailNotification = w.findChild<QComboBox *>(QStringLiteral("mEmailNotification")); 0042 QVERIFY(mEmailNotification); 0043 auto mPushNotification = w.findChild<QComboBox *>(QStringLiteral("mPushNotification")); 0044 QVERIFY(mPushNotification); 0045 0046 auto desktopNotificationLabel = w.findChild<QLabel *>(QStringLiteral("desktopNotificationLabel")); 0047 QVERIFY(desktopNotificationLabel); 0048 QCOMPARE(desktopNotificationLabel->textFormat(), Qt::PlainText); 0049 QVERIFY(!desktopNotificationLabel->text().isEmpty()); 0050 0051 auto emailNotificationLabel = w.findChild<QLabel *>(QStringLiteral("emailNotificationLabel")); 0052 QVERIFY(emailNotificationLabel); 0053 QCOMPARE(emailNotificationLabel->textFormat(), Qt::PlainText); 0054 QVERIFY(!emailNotificationLabel->text().isEmpty()); 0055 0056 auto pushNotificationLabel = w.findChild<QLabel *>(QStringLiteral("pushNotificationLabel")); 0057 QVERIFY(pushNotificationLabel); 0058 QCOMPARE(pushNotificationLabel->textFormat(), Qt::PlainText); 0059 QVERIFY(!pushNotificationLabel->text().isEmpty()); 0060 0061 auto mUseEmojis = w.findChild<QCheckBox *>(QStringLiteral("mUseEmojis")); 0062 QVERIFY(mUseEmojis); 0063 QVERIFY(!mUseEmojis->isChecked()); // False by default as we didn't load values yet 0064 QVERIFY(!mUseEmojis->text().isEmpty()); 0065 0066 auto mConvertAsciiEmoji = w.findChild<QCheckBox *>(QStringLiteral("mConvertAsciiEmoji")); 0067 QVERIFY(mConvertAsciiEmoji); 0068 QVERIFY(!mConvertAsciiEmoji->isChecked()); // False by default as we didn't load values yet 0069 QVERIFY(!mConvertAsciiEmoji->text().isEmpty()); 0070 0071 auto mHideRoles = w.findChild<QCheckBox *>(QStringLiteral("mHideRoles")); 0072 QVERIFY(mHideRoles); 0073 QVERIFY(!mHideRoles->isChecked()); 0074 QVERIFY(!mHideRoles->text().isEmpty()); 0075 0076 auto mDisplayAvatars = w.findChild<QCheckBox *>(QStringLiteral("mDisplayAvatars")); 0077 QVERIFY(mDisplayAvatars); 0078 QVERIFY(!mDisplayAvatars->isChecked()); 0079 QVERIFY(!mDisplayAvatars->text().isEmpty()); 0080 0081 auto downloadLayout = w.findChild<QHBoxLayout *>(QStringLiteral("downloadLayout")); 0082 QVERIFY(downloadLayout); 0083 QCOMPARE(downloadLayout->contentsMargins(), QMargins{}); 0084 0085 auto downloadDataButton = w.findChild<QPushButton *>(QStringLiteral("downloadDataButton")); 0086 QVERIFY(downloadDataButton); 0087 QVERIFY(!downloadDataButton->text().isEmpty()); 0088 0089 auto exportDataButton = w.findChild<QPushButton *>(QStringLiteral("exportDataButton")); 0090 QVERIFY(exportDataButton); 0091 QVERIFY(!exportDataButton->text().isEmpty()); 0092 0093 auto mReceiveLoginDetectionEmails = w.findChild<QCheckBox *>(QStringLiteral("mReceiveLoginDetectionEmails")); 0094 QVERIFY(mReceiveLoginDetectionEmails); 0095 QVERIFY(!mReceiveLoginDetectionEmails->isChecked()); // False by default as we didn't load values yet 0096 QVERIFY(!mReceiveLoginDetectionEmails->text().isEmpty()); 0097 QVERIFY(!mReceiveLoginDetectionEmails->toolTip().isEmpty()); 0098 0099 auto mAutomaticAways = w.findChild<QCheckBox *>(QStringLiteral("mAutomaticAways")); 0100 QVERIFY(mAutomaticAways); 0101 QVERIFY(!mAutomaticAways->isChecked()); // False by default as we didn't load values yet 0102 QVERIFY(!mAutomaticAways->text().isEmpty()); 0103 0104 auto idleTimeLimitLabel = w.findChild<QLabel *>(QStringLiteral("idleTimeLimitLabel")); 0105 QVERIFY(idleTimeLimitLabel); 0106 QCOMPARE(idleTimeLimitLabel->textFormat(), Qt::PlainText); 0107 QVERIFY(!idleTimeLimitLabel->text().isEmpty()); 0108 0109 auto mIdleTimeLimit = w.findChild<QSpinBox *>(QStringLiteral("mIdleTimeLimit")); 0110 QVERIFY(mIdleTimeLimit); 0111 QVERIFY(!mIdleTimeLimit->toolTip().isEmpty()); 0112 } 0113 0114 #include "moc_myaccountpreferenceconfigurewidgettest.cpp"