0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the test suite of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
|
|
43 |
#include <QtTest/QtTest>
|
|
44 |
#include <QWidget>
|
|
45 |
|
|
46 |
#include "qtestalive.cpp"
|
|
47 |
|
|
48 |
class tst_Alive: public QObject
|
|
49 |
{
|
|
50 |
Q_OBJECT
|
|
51 |
|
|
52 |
private slots:
|
|
53 |
void alive();
|
|
54 |
void addMouseDClick() const;
|
|
55 |
void compareQStringLists() const;
|
|
56 |
void compareQStringLists_data() const;
|
|
57 |
};
|
|
58 |
|
|
59 |
void tst_Alive::alive()
|
|
60 |
{
|
|
61 |
QTestAlive a;
|
|
62 |
a.start();
|
|
63 |
|
|
64 |
sleep(5);
|
|
65 |
QCoreApplication::processEvents();
|
|
66 |
qDebug("CUT");
|
|
67 |
sleep(5);
|
|
68 |
}
|
|
69 |
|
|
70 |
void tst_Alive::addMouseDClick() const
|
|
71 |
{
|
|
72 |
class DClickListener : public QWidget
|
|
73 |
{
|
|
74 |
public:
|
|
75 |
DClickListener() : isTested(false)
|
|
76 |
{
|
|
77 |
}
|
|
78 |
|
|
79 |
bool isTested;
|
|
80 |
protected:
|
|
81 |
virtual void mouseDoubleClickEvent(QMouseEvent * event)
|
|
82 |
{
|
|
83 |
isTested = true;
|
|
84 |
QCOMPARE(event->type(), QEvent::MouseButtonDblClick);
|
|
85 |
}
|
|
86 |
};
|
|
87 |
|
|
88 |
DClickListener listener;
|
|
89 |
|
|
90 |
QTestEventList list;
|
|
91 |
list.addMouseDClick(Qt::LeftButton);
|
|
92 |
|
|
93 |
list.simulate(&listener);
|
|
94 |
/* Check that we have been called at all. */
|
|
95 |
QVERIFY(listener.isTested);
|
|
96 |
}
|
|
97 |
|
|
98 |
void tst_Alive::compareQStringLists() const
|
|
99 |
{
|
|
100 |
QFETCH(QStringList, opA);
|
|
101 |
QFETCH(QStringList, opB);
|
|
102 |
|
|
103 |
QCOMPARE(opA, opB);
|
|
104 |
}
|
|
105 |
|
|
106 |
void tst_Alive::compareQStringLists_data() const
|
|
107 |
{
|
|
108 |
QTest::addColumn<QStringList>("opA");
|
|
109 |
QTest::addColumn<QStringList>("opB");
|
|
110 |
|
|
111 |
{
|
|
112 |
QStringList opA;
|
|
113 |
opA.append(QLatin1String("string1"));
|
|
114 |
opA.append(QLatin1String("string2"));
|
|
115 |
|
|
116 |
QStringList opB(opA);
|
|
117 |
opA.append(QLatin1String("string3"));
|
|
118 |
opB.append(QLatin1String("DIFFERS"));
|
|
119 |
|
|
120 |
QTest::newRow("") << opA << opB;
|
|
121 |
}
|
|
122 |
|
|
123 |
{
|
|
124 |
QStringList opA;
|
|
125 |
opA.append(QLatin1String("string1"));
|
|
126 |
opA.append(QLatin1String("string2"));
|
|
127 |
|
|
128 |
QStringList opB(opA);
|
|
129 |
opA.append(QLatin1String("string3"));
|
|
130 |
opA.append(QLatin1String("string4"));
|
|
131 |
|
|
132 |
opB.append(QLatin1String("DIFFERS"));
|
|
133 |
opB.append(QLatin1String("string4"));
|
|
134 |
|
|
135 |
QTest::newRow("") << opA << opB;
|
|
136 |
}
|
|
137 |
|
|
138 |
{
|
|
139 |
QStringList opA;
|
|
140 |
opA.append(QLatin1String("string1"));
|
|
141 |
opA.append(QLatin1String("string2"));
|
|
142 |
|
|
143 |
QStringList opB;
|
|
144 |
opB.append(QLatin1String("string1"));
|
|
145 |
|
|
146 |
QTest::newRow("") << opA << opB;
|
|
147 |
}
|
|
148 |
|
|
149 |
{
|
|
150 |
QStringList opA;
|
|
151 |
opA.append(QLatin1String("openInNewWindow"));
|
|
152 |
opA.append(QLatin1String("openInNewTab"));
|
|
153 |
opA.append(QLatin1String("separator"));
|
|
154 |
opA.append(QLatin1String("bookmark_add"));
|
|
155 |
opA.append(QLatin1String("savelinkas"));
|
|
156 |
opA.append(QLatin1String("copylinklocation"));
|
|
157 |
opA.append(QLatin1String("separator"));
|
|
158 |
opA.append(QLatin1String("openWith_submenu"));
|
|
159 |
opA.append(QLatin1String("preview1"));
|
|
160 |
opA.append(QLatin1String("actions_submenu"));
|
|
161 |
opA.append(QLatin1String("separator"));
|
|
162 |
opA.append(QLatin1String("viewDocumentSource"));
|
|
163 |
|
|
164 |
QStringList opB;
|
|
165 |
opB.append(QLatin1String("viewDocumentSource"));
|
|
166 |
|
|
167 |
QTest::newRow("") << opA << opB;
|
|
168 |
|
|
169 |
QTest::newRow("") << opB << opA;
|
|
170 |
}
|
|
171 |
}
|
|
172 |
|
|
173 |
QTEST_MAIN(tst_Alive)
|
|
174 |
#include "tst_alive.moc"
|