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

0001 /*
0002    SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "mergecontactloseinformationwarningtest.h"
0008 #include "../widgets/mergecontactloseinformationwarning.h"
0009 #include <QAction>
0010 #include <QSignalSpy>
0011 #include <QTest>
0012 #include <qtestmouse.h>
0013 
0014 MergeContactLoseInformationWarningTest::MergeContactLoseInformationWarningTest(QObject *parent)
0015     : QObject(parent)
0016 {
0017 }
0018 
0019 void MergeContactLoseInformationWarningTest::shouldHaveDefaultValue()
0020 {
0021     KABMergeContacts::MergeContactLoseInformationWarning w;
0022     QVERIFY(!w.isCloseButtonVisible());
0023     QVERIFY(!w.isVisible());
0024     auto customize = w.findChild<QAction *>(QStringLiteral("customize"));
0025     QVERIFY(customize);
0026     auto automatic = w.findChild<QAction *>(QStringLiteral("automatic"));
0027     QVERIFY(automatic);
0028 }
0029 
0030 void MergeContactLoseInformationWarningTest::shouldEmitSignals()
0031 {
0032     KABMergeContacts::MergeContactLoseInformationWarning w;
0033     w.show();
0034     QVERIFY(QTest::qWaitForWindowExposed(&w));
0035     QVERIFY(w.isVisible());
0036     auto customize = w.findChild<QAction *>(QStringLiteral("customize"));
0037     auto automatic = w.findChild<QAction *>(QStringLiteral("automatic"));
0038     QSignalSpy spy1(&w, &KABMergeContacts::MergeContactLoseInformationWarning::continueMerging);
0039     QSignalSpy spy2(&w, &KABMergeContacts::MergeContactLoseInformationWarning::customizeMergingContacts);
0040     customize->trigger();
0041     QCOMPARE(spy1.count(), 0);
0042     QCOMPARE(spy2.count(), 1);
0043     automatic->trigger();
0044     QCOMPARE(spy2.count(), 1);
0045     QCOMPARE(spy1.count(), 1);
0046 }
0047 
0048 QTEST_MAIN(MergeContactLoseInformationWarningTest)
0049 
0050 #include "moc_mergecontactloseinformationwarningtest.cpp"