1
/***************************************************************************
2
* Copyright (C) 2011 by Frank Reininghaus (frank78ac@googlemail.com) *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18
***************************************************************************/
20
#include <qtest_kde.h>
22
#include <klistwidgetsearchline.h>
24
#include <QListWidget>
26
class KListWidgetSearchLineTest : public QObject
37
* If items are added to the list view or modified, KListWidgetSearchLine
38
* should hide them if they do not match the search string, see
40
* https://bugs.kde.org/show_bug.cgi?id=265709
43
void KListWidgetSearchLineTest::testAddItems()
45
QListWidget listWidget;
46
listWidget.addItem("Matching test item");
47
listWidget.addItem("Another test item");
49
KListWidgetSearchLine searchLine(0, &listWidget);
50
searchLine.setText("match");
52
// The initial filtering is delayed; we have to wait
53
while(!listWidget.item(1)->isHidden()) {
57
QVERIFY(!listWidget.item(0)->isHidden());
58
QVERIFY(listWidget.item(1)->isHidden());
61
listWidget.addItem("Another item that matches the search pattern");
62
listWidget.addItem("This item should be hidden");
64
QVERIFY(!listWidget.item(0)->isHidden());
65
QVERIFY(listWidget.item(1)->isHidden());
66
QVERIFY(!listWidget.item(2)->isHidden());
67
QVERIFY(listWidget.item(3)->isHidden());
70
listWidget.item(3)->setText("Now this item matches");
72
QVERIFY(!listWidget.item(0)->isHidden());
73
QVERIFY(listWidget.item(1)->isHidden());
74
QVERIFY(!listWidget.item(2)->isHidden());
75
QVERIFY(!listWidget.item(3)->isHidden());
78
QTEST_KDEMAIN(KListWidgetSearchLineTest, GUI)
80
#include "klistwidgetsearchlinetest.moc"
b'\\ No newline at end of file'