]> cloud.milkyroute.net Git - dolphin.git/blob - src/tests/dolphinsearchboxtest.cpp
Merge branch 'release/20.08' into master
[dolphin.git] / src / tests / dolphinsearchboxtest.cpp
1 /*
2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "search/dolphinsearchbox.h"
8
9 #include <QTest>
10
11 class DolphinSearchBoxTest : public QObject
12 {
13 Q_OBJECT
14
15 private slots:
16 void init();
17 void cleanup();
18
19 void testTextClearing();
20
21 private:
22 DolphinSearchBox* m_searchBox;
23 };
24
25 void DolphinSearchBoxTest::init()
26 {
27 m_searchBox = new DolphinSearchBox();
28 }
29
30 void DolphinSearchBoxTest::cleanup()
31 {
32 delete m_searchBox;
33 }
34
35 /**
36 * The test verifies whether the automatic clearing of the text works correctly.
37 * The text may not get cleared when the searchbox gets visible or invisible,
38 * as this would clear the text when switching between tabs.
39 */
40 void DolphinSearchBoxTest::testTextClearing()
41 {
42 m_searchBox->show();
43 QVERIFY(m_searchBox->text().isEmpty());
44
45 m_searchBox->setText("xyz");
46 m_searchBox->hide();
47 m_searchBox->show();
48 QCOMPARE(m_searchBox->text(), QString("xyz"));
49
50 QTest::keyClick(m_searchBox, Qt::Key_Escape);
51 QVERIFY(m_searchBox->text().isEmpty());
52 }
53
54 QTEST_MAIN(DolphinSearchBoxTest)
55
56 #include "dolphinsearchboxtest.moc"