File indexing completed on 2024-12-15 04:54:35

0001 /*
0002   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-only
0005 */
0006 
0007 #include "quicksearchwarningtest.h"
0008 #include "../src/core/widgets/quicksearchwarning.h"
0009 #include <QAction>
0010 #include <QTest>
0011 QuickSearchWarningTest::QuickSearchWarningTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 QuickSearchWarningTest::~QuickSearchWarningTest() = default;
0017 
0018 void QuickSearchWarningTest::shouldHaveDefaultValue()
0019 {
0020     MessageList::Core::QuickSearchWarning w;
0021     QVERIFY(!w.isVisible());
0022     auto act = w.findChild<QAction *>(QStringLiteral("donotshowagain"));
0023     QVERIFY(act);
0024 }
0025 
0026 void QuickSearchWarningTest::shouldSetVisible()
0027 {
0028     MessageList::Core::QuickSearchWarning w;
0029     w.setSearchText(QStringLiteral("1"));
0030     QVERIFY(w.isVisible());
0031 }
0032 
0033 void QuickSearchWarningTest::shouldSetSearchText()
0034 {
0035     QFETCH(QString, input);
0036     QFETCH(bool, visible);
0037     MessageList::Core::QuickSearchWarning w;
0038     w.setSearchText(input);
0039     QCOMPARE(w.isVisible(), visible);
0040 }
0041 
0042 void QuickSearchWarningTest::shouldSetSearchText_data()
0043 {
0044     QTest::addColumn<QString>("input");
0045     QTest::addColumn<bool>("visible");
0046     QTest::newRow("bigword") << QStringLiteral("foofoofoo") << false;
0047     QTest::newRow("1character") << QStringLiteral("f") << true;
0048     QTest::newRow("multibigword") << QStringLiteral("foo foo foo") << false;
0049     QTest::newRow("multibigwordwithasmallone") << QStringLiteral("foo foo foo 1") << true;
0050     QTest::newRow("aspace") << QStringLiteral(" ") << false;
0051     QTest::newRow("multispace") << QStringLiteral("            ") << false;
0052 }
0053 
0054 QTEST_MAIN(QuickSearchWarningTest)
0055 
0056 #include "moc_quicksearchwarningtest.cpp"