File indexing completed on 2025-01-05 04:49:50
0001 /* 0002 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "selectimapwidgettest.h" 0008 #include "../selectimapwidget.h" 0009 0010 #include <QHBoxLayout> 0011 #include <QLineEdit> 0012 #include <QTest> 0013 #include <QToolButton> 0014 0015 SelectImapWidgetTest::SelectImapWidgetTest(QObject *parent) 0016 : QObject(parent) 0017 { 0018 } 0019 0020 SelectImapWidgetTest::~SelectImapWidgetTest() = default; 0021 0022 void SelectImapWidgetTest::shouldHaveDefaultValue() 0023 { 0024 SelectImapWidget w; 0025 auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainlayout")); 0026 QVERIFY(mainLayout); 0027 QCOMPARE(mainLayout->contentsMargins(), QMargins()); 0028 0029 auto mLineEdit = w.findChild<QLineEdit *>(QStringLiteral("lineedit")); 0030 QVERIFY(mLineEdit); 0031 QVERIFY(mLineEdit->text().isEmpty()); 0032 0033 auto mToolButton = w.findChild<QToolButton *>(QStringLiteral("toolbutton")); 0034 QVERIFY(mToolButton); 0035 QVERIFY(!mToolButton->text().isEmpty()); 0036 } 0037 0038 void SelectImapWidgetTest::shouldAssignText() 0039 { 0040 SelectImapWidget w; 0041 auto mLineEdit = w.findChild<QLineEdit *>(QStringLiteral("lineedit")); 0042 QString text = QStringLiteral("foo"); 0043 w.setText(text); 0044 QCOMPARE(w.text(), text); 0045 QCOMPARE(mLineEdit->text(), text); 0046 w.setText(QString()); 0047 QVERIFY(w.text().isEmpty()); 0048 } 0049 0050 QTEST_MAIN(SelectImapWidgetTest) 0051 0052 #include "moc_selectimapwidgettest.cpp"