File indexing completed on 2024-11-24 04:43:02

0001 /*
0002    SPDX-FileCopyrightText: 2014-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "mergecontactinfowidgettest.h"
0008 
0009 #include "widgets/mergecontactinfowidget.h"
0010 #include <QStackedWidget>
0011 #include <QStandardPaths>
0012 #include <QTest>
0013 using namespace KABMergeContacts;
0014 
0015 MergeContactInfoWidgetTest::MergeContactInfoWidgetTest() = default;
0016 
0017 void MergeContactInfoWidgetTest::initTestCase()
0018 {
0019     QStandardPaths::setTestModeEnabled(true);
0020 }
0021 
0022 void MergeContactInfoWidgetTest::shouldHaveDefaultValueOnCreation()
0023 {
0024     MergeContactInfoWidget infoWidget;
0025     auto stackedWidget = infoWidget.findChild<QStackedWidget *>(QStringLiteral("stackedwidget"));
0026     QVERIFY(stackedWidget);
0027     QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("nocontact"));
0028 }
0029 
0030 void MergeContactInfoWidgetTest::shouldHaveActivateDisplayWidgetWhenSelectOneContact()
0031 {
0032     MergeContactInfoWidget infoWidget;
0033     Akonadi::Item item(4);
0034     infoWidget.setContact(item);
0035     auto stackedWidget = infoWidget.findChild<QStackedWidget *>(QStringLiteral("stackedwidget"));
0036     QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("contactwidget"));
0037 }
0038 
0039 void MergeContactInfoWidgetTest::shouldHaveActivateNoWidgetWhenSelectNoContact()
0040 {
0041     MergeContactInfoWidget infoWidget;
0042     Akonadi::Item item(4);
0043     infoWidget.setContact(item);
0044     auto stackedWidget = infoWidget.findChild<QStackedWidget *>(QStringLiteral("stackedwidget"));
0045     QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("contactwidget"));
0046     infoWidget.setContact(Akonadi::Item());
0047     QCOMPARE(stackedWidget->currentWidget()->objectName(), QStringLiteral("nocontact"));
0048 }
0049 
0050 QTEST_MAIN(MergeContactInfoWidgetTest)
0051 
0052 #include "moc_mergecontactinfowidgettest.cpp"