~ubuntu-branches/ubuntu/oneiric/kde4libs/oneiric-security

« back to all changes in this revision

Viewing changes to kdeui/tests/klistwidgetsearchlinetest.cpp

  • Committer: Package Import Robot
  • Author(s): Michał Zając, Michał Zając, Jonathan Riddell
  • Date: 2011-02-27 14:10:59 UTC
  • mfrom: (1.14.3 upstream)
  • Revision ID: package-import@ubuntu.com-20110227141059-asgzcw48ao08rvkp
Tags: 4:4.6.1-0ubuntu1
[ Michał Zając ]
* New upstream release
* Refreshed kubuntu_06_user_disk_mounting.diff
* Refreshed kubuntu_77_ksambashare.diff
* Refreshed *.install files

[ Jonathan Riddell ]
* Add back kubuntu_77_no_kbookmark_write_error.diff workaround for LP:
  #627815

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2011 by Frank Reininghaus (frank78ac@googlemail.com)    *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
 
 
20
#include <qtest_kde.h>
 
21
 
 
22
#include <klistwidgetsearchline.h>
 
23
 
 
24
#include <QListWidget>
 
25
 
 
26
class KListWidgetSearchLineTest : public QObject
 
27
{
 
28
    Q_OBJECT
 
29
 
 
30
private slots:
 
31
 
 
32
    void testAddItems();
 
33
 
 
34
};
 
35
 
 
36
/**
 
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
 
39
 *
 
40
 * https://bugs.kde.org/show_bug.cgi?id=265709
 
41
 */
 
42
 
 
43
void KListWidgetSearchLineTest::testAddItems()
 
44
{
 
45
    QListWidget listWidget;
 
46
    listWidget.addItem("Matching test item");
 
47
    listWidget.addItem("Another test item");
 
48
 
 
49
    KListWidgetSearchLine searchLine(0, &listWidget);
 
50
    searchLine.setText("match");
 
51
 
 
52
    // The initial filtering is delayed; we have to wait
 
53
    while(!listWidget.item(1)->isHidden()) {
 
54
        QTest::qWait(50);
 
55
    }
 
56
 
 
57
    QVERIFY(!listWidget.item(0)->isHidden());
 
58
    QVERIFY(listWidget.item(1)->isHidden());
 
59
 
 
60
    // Add two items
 
61
    listWidget.addItem("Another item that matches the search pattern");
 
62
    listWidget.addItem("This item should be hidden");
 
63
 
 
64
    QVERIFY(!listWidget.item(0)->isHidden());
 
65
    QVERIFY(listWidget.item(1)->isHidden());
 
66
    QVERIFY(!listWidget.item(2)->isHidden());
 
67
    QVERIFY(listWidget.item(3)->isHidden());
 
68
 
 
69
    // Modify an item
 
70
    listWidget.item(3)->setText("Now this item matches");
 
71
 
 
72
    QVERIFY(!listWidget.item(0)->isHidden());
 
73
    QVERIFY(listWidget.item(1)->isHidden());
 
74
    QVERIFY(!listWidget.item(2)->isHidden());
 
75
    QVERIFY(!listWidget.item(3)->isHidden());
 
76
}
 
77
 
 
78
QTEST_KDEMAIN(KListWidgetSearchLineTest, GUI)
 
79
 
 
80
#include "klistwidgetsearchlinetest.moc"
 
 
b'\\ No newline at end of file'