author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 12:15:23 +0300 | |
branch | RCL_3 |
changeset 12 | cc75c76972ee |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite module 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 |
#include <QtGui> |
|
43 |
#include <QtTest> |
|
44 |
||
45 |
#include "ui_form.h" |
|
46 |
#include "touchwidget.h" |
|
47 |
||
48 |
class MultitouchTestWidget : public QWidget, public Ui::Form |
|
49 |
{ |
|
50 |
Q_OBJECT |
|
51 |
||
52 |
public: |
|
53 |
MultitouchTestWidget(QWidget *parent = 0) |
|
54 |
: QWidget(parent) |
|
55 |
{ |
|
56 |
setAttribute(Qt::WA_QuitOnClose, false); |
|
57 |
setupUi(this); |
|
58 |
} |
|
59 |
||
60 |
void closeEvent(QCloseEvent *event) |
|
61 |
{ |
|
62 |
event->accept(); |
|
63 |
QTimer::singleShot(1000, qApp, SLOT(quit())); |
|
64 |
} |
|
65 |
}; |
|
66 |
||
67 |
class tst_ManualMultitouch : public QObject |
|
68 |
{ |
|
69 |
Q_OBJECT |
|
70 |
||
71 |
public: |
|
72 |
tst_ManualMultitouch(); |
|
73 |
~tst_ManualMultitouch(); |
|
74 |
||
75 |
private slots: |
|
76 |
void ignoringTouchEventsEmulatesMouseEvents(); |
|
77 |
void basicSingleTouchEventHandling(); |
|
78 |
void basicMultiTouchEventHandling(); |
|
79 |
void acceptingTouchBeginStopsPropagation(); |
|
80 |
void ignoringTouchBeginPropagatesToParent(); |
|
81 |
void secondTouchPointOnParentGoesToChild(); |
|
82 |
void secondTouchPointOnChildGoesToParent(); |
|
83 |
void secondTouchPointOnSiblingGoesToSibling(); |
|
84 |
void secondTouchPointOnCousinGoesToCousin(); |
|
85 |
}; |
|
86 |
||
87 |
tst_ManualMultitouch::tst_ManualMultitouch() |
|
88 |
{ } |
|
89 |
||
90 |
tst_ManualMultitouch::~tst_ManualMultitouch() |
|
91 |
{ } |
|
92 |
||
93 |
void tst_ManualMultitouch::ignoringTouchEventsEmulatesMouseEvents() |
|
94 |
{ |
|
95 |
// first, make sure that we get mouse events when not enabling touch events |
|
96 |
MultitouchTestWidget testWidget; |
|
97 |
testWidget.testNameLabel->setText("Mouse Event Emulation Test"); |
|
98 |
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the green widget."); |
|
99 |
testWidget.redWidget->hide(); |
|
100 |
testWidget.blueWidget->hide(); |
|
101 |
testWidget.greenWidget->closeWindowOnMouseRelease = true; |
|
102 |
testWidget.showMaximized(); |
|
103 |
(void) qApp->exec(); |
|
104 |
QVERIFY(!testWidget.greenWidget->seenTouchBegin); |
|
105 |
// QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
106 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
107 |
QVERIFY(testWidget.greenWidget->seenMousePress); |
|
108 |
// QVERIFY(testWidget.greenWidget->seenMouseMove); |
|
109 |
QVERIFY(testWidget.greenWidget->seenMouseRelease); |
|
110 |
||
111 |
// enable touch, but don't accept the events |
|
112 |
testWidget.greenWidget->reset(); |
|
113 |
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
114 |
testWidget.greenWidget->closeWindowOnMouseRelease = true; |
|
115 |
testWidget.showMaximized(); |
|
116 |
(void) qApp->exec(); |
|
117 |
QVERIFY(testWidget.greenWidget->seenTouchBegin); |
|
118 |
// QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
119 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
120 |
QVERIFY(testWidget.greenWidget->seenMousePress); |
|
121 |
// QVERIFY(testWidget.greenWidget->seenMouseMove); |
|
122 |
QVERIFY(testWidget.greenWidget->seenMouseRelease); |
|
123 |
} |
|
124 |
||
125 |
void tst_ManualMultitouch::basicSingleTouchEventHandling() |
|
126 |
{ |
|
127 |
// now enable touch and make sure we get the touch events |
|
128 |
MultitouchTestWidget testWidget; |
|
129 |
testWidget.testNameLabel->setText("Basic Single-Touch Event Handling Test"); |
|
130 |
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the green widget."); |
|
131 |
testWidget.redWidget->hide(); |
|
132 |
testWidget.blueWidget->hide(); |
|
133 |
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
134 |
testWidget.greenWidget->acceptTouchBegin = true; |
|
135 |
testWidget.greenWidget->acceptTouchUpdate = true; |
|
136 |
testWidget.greenWidget->acceptTouchEnd = true; |
|
137 |
testWidget.greenWidget->closeWindowOnTouchEnd = true; |
|
138 |
testWidget.showMaximized(); |
|
139 |
(void) qApp->exec(); |
|
140 |
QVERIFY(testWidget.greenWidget->seenTouchBegin); |
|
141 |
// QVERIFY(testWidget.greenWidget->seenTouchUpdate); |
|
142 |
QVERIFY(testWidget.greenWidget->seenTouchEnd); |
|
143 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
144 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
145 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
146 |
||
147 |
// again, ignoring the TouchEnd |
|
148 |
testWidget.greenWidget->reset(); |
|
149 |
testWidget.greenWidget->acceptTouchBegin = true; |
|
150 |
testWidget.greenWidget->acceptTouchUpdate = true; |
|
151 |
// testWidget.greenWidget->acceptTouchEnd = true; |
|
152 |
testWidget.greenWidget->closeWindowOnTouchEnd = true; |
|
153 |
testWidget.showMaximized(); |
|
154 |
(void) qApp->exec(); |
|
155 |
QVERIFY(testWidget.greenWidget->seenTouchBegin); |
|
156 |
// QVERIFY(testWidget.greenWidget->seenTouchUpdate); |
|
157 |
QVERIFY(testWidget.greenWidget->seenTouchEnd); |
|
158 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
159 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
160 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
161 |
||
162 |
// again, ignoring TouchUpdates |
|
163 |
testWidget.greenWidget->reset(); |
|
164 |
testWidget.greenWidget->acceptTouchBegin = true; |
|
165 |
// testWidget.greenWidget->acceptTouchUpdate = true; |
|
166 |
testWidget.greenWidget->acceptTouchEnd = true; |
|
167 |
testWidget.greenWidget->closeWindowOnTouchEnd = true; |
|
168 |
testWidget.showMaximized(); |
|
169 |
(void) qApp->exec(); |
|
170 |
QVERIFY(testWidget.greenWidget->seenTouchBegin); |
|
171 |
// QVERIFY(testWidget.greenWidget->seenTouchUpdate); |
|
172 |
QVERIFY(testWidget.greenWidget->seenTouchEnd); |
|
173 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
174 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
175 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
176 |
||
177 |
// last time, ignoring TouchUpdates and TouchEnd |
|
178 |
testWidget.greenWidget->reset(); |
|
179 |
testWidget.greenWidget->acceptTouchBegin = true; |
|
180 |
// testWidget.greenWidget->acceptTouchUpdate = true; |
|
181 |
// testWidget.greenWidget->acceptTouchEnd = true; |
|
182 |
testWidget.greenWidget->closeWindowOnTouchEnd = true; |
|
183 |
testWidget.showMaximized(); |
|
184 |
(void) qApp->exec(); |
|
185 |
QVERIFY(testWidget.greenWidget->seenTouchBegin); |
|
186 |
// QVERIFY(testWidget.greenWidget->seenTouchUpdate); |
|
187 |
QVERIFY(testWidget.greenWidget->seenTouchEnd); |
|
188 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
189 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
190 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
191 |
} |
|
192 |
||
193 |
void tst_ManualMultitouch::basicMultiTouchEventHandling() |
|
194 |
{ |
|
195 |
// repeat, this time looking for multiple fingers |
|
196 |
MultitouchTestWidget testWidget; |
|
197 |
testWidget.testNameLabel->setText("Basic Multi-Touch Event Handling Test"); |
|
198 |
testWidget.testDescriptionLabel->setText("Touch, hold, and release several fingers on the red widget."); |
|
199 |
testWidget.greenWidget->hide(); |
|
200 |
testWidget.greyWidget->hide(); |
|
201 |
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
202 |
testWidget.redWidget->acceptTouchBegin = true; |
|
203 |
testWidget.redWidget->acceptTouchUpdate = true; |
|
204 |
testWidget.redWidget->acceptTouchEnd = true; |
|
205 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
206 |
testWidget.showMaximized(); |
|
207 |
(void) qApp->exec(); |
|
208 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
209 |
QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
210 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
211 |
QVERIFY(testWidget.redWidget->touchPointCount > 1); |
|
212 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
213 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
214 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
215 |
||
216 |
testWidget.redWidget->reset(); |
|
217 |
testWidget.redWidget->acceptTouchBegin = true; |
|
218 |
// testWidget.redWidget->acceptTouchUpdate = true; |
|
219 |
testWidget.redWidget->acceptTouchEnd = true; |
|
220 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
221 |
testWidget.showMaximized(); |
|
222 |
(void) qApp->exec(); |
|
223 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
224 |
QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
225 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
226 |
QVERIFY(testWidget.redWidget->touchPointCount > 1); |
|
227 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
228 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
229 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
230 |
||
231 |
testWidget.redWidget->reset(); |
|
232 |
testWidget.redWidget->acceptTouchBegin = true; |
|
233 |
testWidget.redWidget->acceptTouchUpdate = true; |
|
234 |
// testWidget.redWidget->acceptTouchEnd = true; |
|
235 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
236 |
testWidget.showMaximized(); |
|
237 |
(void) qApp->exec(); |
|
238 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
239 |
QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
240 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
241 |
QVERIFY(testWidget.redWidget->touchPointCount > 1); |
|
242 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
243 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
244 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
245 |
||
246 |
testWidget.redWidget->reset(); |
|
247 |
testWidget.redWidget->acceptTouchBegin = true; |
|
248 |
// testWidget.redWidget->acceptTouchUpdate = true; |
|
249 |
// testWidget.redWidget->acceptTouchEnd = true; |
|
250 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
251 |
testWidget.showMaximized(); |
|
252 |
(void) qApp->exec(); |
|
253 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
254 |
QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
255 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
256 |
QVERIFY(testWidget.redWidget->touchPointCount > 1); |
|
257 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
258 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
259 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
260 |
} |
|
261 |
||
262 |
void tst_ManualMultitouch::acceptingTouchBeginStopsPropagation() |
|
263 |
{ |
|
264 |
// test that accepting the TouchBegin event on the |
|
265 |
// blueWidget stops propagation to the greenWidget |
|
266 |
MultitouchTestWidget testWidget; |
|
267 |
testWidget.testNameLabel->setText("Touch Event Propagation Test: Accepting in Blue Blocks Green"); |
|
268 |
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the blue widget."); |
|
269 |
testWidget.redWidget->hide(); |
|
270 |
testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
271 |
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
272 |
testWidget.blueWidget->acceptTouchBegin = true; |
|
273 |
testWidget.blueWidget->acceptTouchUpdate = true; |
|
274 |
testWidget.blueWidget->acceptTouchEnd = true; |
|
275 |
testWidget.blueWidget->closeWindowOnTouchEnd = true; |
|
276 |
testWidget.showMaximized(); |
|
277 |
(void) qApp->exec(); |
|
278 |
QVERIFY(testWidget.blueWidget->seenTouchBegin); |
|
279 |
// QVERIFY(testWidget.blueWidget->seenTouchUpdate); |
|
280 |
QVERIFY(testWidget.blueWidget->seenTouchEnd); |
|
281 |
QVERIFY(!testWidget.blueWidget->seenMousePress); |
|
282 |
QVERIFY(!testWidget.blueWidget->seenMouseMove); |
|
283 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
284 |
QVERIFY(!testWidget.greenWidget->seenTouchBegin); |
|
285 |
QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
286 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
287 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
288 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
289 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
290 |
||
291 |
// ignoring TouchEnd |
|
292 |
testWidget.blueWidget->reset(); |
|
293 |
testWidget.greenWidget->reset(); |
|
294 |
testWidget.blueWidget->acceptTouchBegin = true; |
|
295 |
testWidget.blueWidget->acceptTouchUpdate = true; |
|
296 |
// testWidget.blueWidget->acceptTouchEnd = true; |
|
297 |
testWidget.blueWidget->closeWindowOnTouchEnd = true; |
|
298 |
testWidget.showMaximized(); |
|
299 |
(void) qApp->exec(); |
|
300 |
QVERIFY(testWidget.blueWidget->seenTouchBegin); |
|
301 |
// QVERIFY(testWidget.blueWidget->seenTouchUpdate); |
|
302 |
QVERIFY(testWidget.blueWidget->seenTouchEnd); |
|
303 |
QVERIFY(!testWidget.blueWidget->seenMousePress); |
|
304 |
QVERIFY(!testWidget.blueWidget->seenMouseMove); |
|
305 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
306 |
QVERIFY(!testWidget.greenWidget->seenTouchBegin); |
|
307 |
QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
308 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
309 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
310 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
311 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
312 |
||
313 |
// ignoring TouchUpdate |
|
314 |
testWidget.blueWidget->reset(); |
|
315 |
testWidget.greenWidget->reset(); |
|
316 |
testWidget.blueWidget->acceptTouchBegin = true; |
|
317 |
// testWidget.blueWidget->acceptTouchUpdate = true; |
|
318 |
testWidget.blueWidget->acceptTouchEnd = true; |
|
319 |
testWidget.blueWidget->closeWindowOnTouchEnd = true; |
|
320 |
testWidget.showMaximized(); |
|
321 |
(void) qApp->exec(); |
|
322 |
QVERIFY(testWidget.blueWidget->seenTouchBegin); |
|
323 |
// QVERIFY(testWidget.blueWidget->seenTouchUpdate); |
|
324 |
QVERIFY(testWidget.blueWidget->seenTouchEnd); |
|
325 |
QVERIFY(!testWidget.blueWidget->seenMousePress); |
|
326 |
QVERIFY(!testWidget.blueWidget->seenMouseMove); |
|
327 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
328 |
QVERIFY(!testWidget.greenWidget->seenTouchBegin); |
|
329 |
QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
330 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
331 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
332 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
333 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
334 |
||
335 |
// ignoring TouchUpdate and TouchEnd |
|
336 |
testWidget.blueWidget->reset(); |
|
337 |
testWidget.greenWidget->reset(); |
|
338 |
testWidget.blueWidget->acceptTouchBegin = true; |
|
339 |
// testWidget.blueWidget->acceptTouchUpdate = true; |
|
340 |
// testWidget.blueWidget->acceptTouchEnd = true; |
|
341 |
testWidget.blueWidget->closeWindowOnTouchEnd = true; |
|
342 |
testWidget.showMaximized(); |
|
343 |
(void) qApp->exec(); |
|
344 |
QVERIFY(testWidget.blueWidget->seenTouchBegin); |
|
345 |
// QVERIFY(testWidget.blueWidget->seenTouchUpdate); |
|
346 |
QVERIFY(testWidget.blueWidget->seenTouchEnd); |
|
347 |
QVERIFY(!testWidget.blueWidget->seenMousePress); |
|
348 |
QVERIFY(!testWidget.blueWidget->seenMouseMove); |
|
349 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
350 |
QVERIFY(!testWidget.greenWidget->seenTouchBegin); |
|
351 |
QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
352 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
353 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
354 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
355 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
356 |
} |
|
357 |
||
358 |
void tst_ManualMultitouch::ignoringTouchBeginPropagatesToParent() |
|
359 |
{ |
|
360 |
// repeat the test above, now ignoring touch events in the |
|
361 |
// greyWidget, they should be propagated to the redWidget |
|
362 |
MultitouchTestWidget testWidget; |
|
363 |
testWidget.testNameLabel->setText("Touch Event Propagation Test: Ignoring in Grey Propagates to Red"); |
|
364 |
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the grey widget."); |
|
365 |
testWidget.greenWidget->hide(); |
|
366 |
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents, false); |
|
367 |
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
368 |
testWidget.greyWidget->reset(); |
|
369 |
testWidget.redWidget->reset(); |
|
370 |
testWidget.redWidget->acceptTouchBegin = true; |
|
371 |
testWidget.redWidget->acceptTouchUpdate = true; |
|
372 |
testWidget.redWidget->acceptTouchEnd = true; |
|
373 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
374 |
testWidget.showMaximized(); |
|
375 |
(void) qApp->exec(); |
|
376 |
QVERIFY(!testWidget.greyWidget->seenTouchBegin); |
|
377 |
QVERIFY(!testWidget.greyWidget->seenTouchUpdate); |
|
378 |
QVERIFY(!testWidget.greyWidget->seenTouchEnd); |
|
379 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
380 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
381 |
QVERIFY(!testWidget.greyWidget->seenMouseRelease); |
|
382 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
383 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
384 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
385 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
386 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
387 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
388 |
||
389 |
// again, but this time greyWidget should see the TouchBegin |
|
390 |
testWidget.greyWidget->reset(); |
|
391 |
testWidget.redWidget->reset(); |
|
392 |
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
393 |
testWidget.redWidget->acceptTouchBegin = true; |
|
394 |
testWidget.redWidget->acceptTouchUpdate = true; |
|
395 |
testWidget.redWidget->acceptTouchEnd = true; |
|
396 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
397 |
testWidget.showMaximized(); |
|
398 |
(void) qApp->exec(); |
|
399 |
QVERIFY(testWidget.greyWidget->seenTouchBegin); |
|
400 |
QVERIFY(!testWidget.greyWidget->seenTouchUpdate); |
|
401 |
QVERIFY(!testWidget.greyWidget->seenTouchEnd); |
|
402 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
403 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
404 |
QVERIFY(!testWidget.greyWidget->seenMouseRelease); |
|
405 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
406 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
407 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
408 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
409 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
410 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
411 |
||
412 |
// again, ignoring the TouchEnd |
|
413 |
testWidget.greyWidget->reset(); |
|
414 |
testWidget.redWidget->reset(); |
|
415 |
testWidget.redWidget->acceptTouchBegin = true; |
|
416 |
testWidget.redWidget->acceptTouchUpdate = true; |
|
417 |
// testWidget.redWidget->acceptTouchEnd = true; |
|
418 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
419 |
testWidget.showMaximized(); |
|
420 |
(void) qApp->exec(); |
|
421 |
QVERIFY(testWidget.greyWidget->seenTouchBegin); |
|
422 |
QVERIFY(!testWidget.greyWidget->seenTouchUpdate); |
|
423 |
QVERIFY(!testWidget.greyWidget->seenTouchEnd); |
|
424 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
425 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
426 |
QVERIFY(!testWidget.greyWidget->seenMouseRelease); |
|
427 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
428 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
429 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
430 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
431 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
432 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
433 |
||
434 |
// again, ignoring TouchUpdates |
|
435 |
testWidget.greyWidget->reset(); |
|
436 |
testWidget.redWidget->reset(); |
|
437 |
testWidget.redWidget->acceptTouchBegin = true; |
|
438 |
// testWidget.redWidget->acceptTouchUpdate = true; |
|
439 |
testWidget.redWidget->acceptTouchEnd = true; |
|
440 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
441 |
testWidget.showMaximized(); |
|
442 |
(void) qApp->exec(); |
|
443 |
QVERIFY(testWidget.greyWidget->seenTouchBegin); |
|
444 |
QVERIFY(!testWidget.greyWidget->seenTouchUpdate); |
|
445 |
QVERIFY(!testWidget.greyWidget->seenTouchEnd); |
|
446 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
447 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
448 |
QVERIFY(!testWidget.greyWidget->seenMouseRelease); |
|
449 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
450 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
451 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
452 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
453 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
454 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
455 |
||
456 |
// last time, ignoring TouchUpdates and TouchEnd |
|
457 |
testWidget.greyWidget->reset(); |
|
458 |
testWidget.redWidget->reset(); |
|
459 |
testWidget.redWidget->acceptTouchBegin = true; |
|
460 |
// testWidget.redWidget->acceptTouchUpdate = true; |
|
461 |
// testWidget.redWidget->acceptTouchEnd = true; |
|
462 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
463 |
testWidget.showMaximized(); |
|
464 |
(void) qApp->exec(); |
|
465 |
QVERIFY(testWidget.greyWidget->seenTouchBegin); |
|
466 |
QVERIFY(!testWidget.greyWidget->seenTouchUpdate); |
|
467 |
QVERIFY(!testWidget.greyWidget->seenTouchEnd); |
|
468 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
469 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
470 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
471 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
472 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
473 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
474 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
475 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
476 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
477 |
} |
|
478 |
||
479 |
void tst_ManualMultitouch::secondTouchPointOnParentGoesToChild() |
|
480 |
{ |
|
481 |
MultitouchTestWidget testWidget; |
|
482 |
testWidget.testNameLabel->setText("Additional Touch-Points Outside Child's Rect Go to Child"); |
|
483 |
testWidget.testDescriptionLabel->setText("Press and hold a finger on the blue widget, then on the green one, and release."); |
|
484 |
testWidget.redWidget->hide(); |
|
485 |
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
486 |
testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
487 |
testWidget.blueWidget->acceptTouchBegin = true; |
|
488 |
testWidget.greenWidget->acceptTouchBegin = true; |
|
489 |
testWidget.blueWidget->closeWindowOnTouchEnd = true; |
|
490 |
testWidget.showMaximized(); |
|
491 |
(void) qApp->exec(); |
|
492 |
QVERIFY(testWidget.blueWidget->seenTouchBegin); |
|
493 |
// QVERIFY(testWidget.blueWidget->seenTouchUpdate); |
|
494 |
QVERIFY(testWidget.blueWidget->seenTouchEnd); |
|
495 |
QVERIFY(!testWidget.blueWidget->seenMousePress); |
|
496 |
QVERIFY(!testWidget.blueWidget->seenMouseMove); |
|
497 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
498 |
QVERIFY(testWidget.blueWidget->touchPointCount > 1); |
|
499 |
QVERIFY(!testWidget.greenWidget->seenTouchBegin); |
|
500 |
QVERIFY(!testWidget.greenWidget->seenTouchUpdate); |
|
501 |
QVERIFY(!testWidget.greenWidget->seenTouchEnd); |
|
502 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
503 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
504 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
505 |
} |
|
506 |
||
507 |
void tst_ManualMultitouch::secondTouchPointOnChildGoesToParent() |
|
508 |
{ |
|
509 |
MultitouchTestWidget testWidget; |
|
510 |
testWidget.testNameLabel->setText("Additional Touch-Points Over Child's Rect Go to Parent"); |
|
511 |
testWidget.testDescriptionLabel->setText("Press and hold a finger on the red widget, then on the grey one, and release."); |
|
512 |
testWidget.greenWidget->hide(); |
|
513 |
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
514 |
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
515 |
testWidget.greyWidget->acceptTouchBegin = true; |
|
516 |
testWidget.redWidget->acceptTouchBegin = true; |
|
517 |
testWidget.redWidget->closeWindowOnTouchEnd = true; |
|
518 |
testWidget.showMaximized(); |
|
519 |
(void) qApp->exec(); |
|
520 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
521 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
522 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
523 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
524 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
525 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
526 |
QVERIFY(testWidget.redWidget->touchPointCount > 1); |
|
527 |
QVERIFY(!testWidget.greyWidget->seenTouchBegin); |
|
528 |
QVERIFY(!testWidget.greyWidget->seenTouchUpdate); |
|
529 |
QVERIFY(!testWidget.greyWidget->seenTouchEnd); |
|
530 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
531 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
532 |
QVERIFY(!testWidget.greyWidget->seenMouseRelease); |
|
533 |
} |
|
534 |
||
535 |
void tst_ManualMultitouch::secondTouchPointOnSiblingGoesToSibling() |
|
536 |
{ |
|
537 |
MultitouchTestWidget testWidget; |
|
538 |
testWidget.testNameLabel->setText("Multi-Touch Interaction Test, Unrelated Widgets Get Separate Events"); |
|
539 |
testWidget.testDescriptionLabel->setText("Press and hold a finger on the green widget, then the red one, and release."); |
|
540 |
testWidget.blueWidget->hide(); |
|
541 |
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
542 |
testWidget.greenWidget->acceptTouchBegin = true; |
|
543 |
testWidget.greenWidget->closeWindowOnTouchEnd = true; |
|
544 |
testWidget.greyWidget->hide(); |
|
545 |
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
546 |
testWidget.redWidget->acceptTouchBegin = true; |
|
547 |
testWidget.showMaximized(); |
|
548 |
(void) qApp->exec(); |
|
549 |
QVERIFY(testWidget.greenWidget->seenTouchBegin); |
|
550 |
// QVERIFY(testWidget.greenWidget->seenTouchUpdate); |
|
551 |
QVERIFY(testWidget.greenWidget->seenTouchEnd); |
|
552 |
QVERIFY(!testWidget.greenWidget->seenMousePress); |
|
553 |
QVERIFY(!testWidget.greenWidget->seenMouseMove); |
|
554 |
QVERIFY(!testWidget.greenWidget->seenMouseRelease); |
|
555 |
QVERIFY(testWidget.redWidget->seenTouchBegin); |
|
556 |
// QVERIFY(testWidget.redWidget->seenTouchUpdate); |
|
557 |
QVERIFY(testWidget.redWidget->seenTouchEnd); |
|
558 |
QVERIFY(!testWidget.redWidget->seenMousePress); |
|
559 |
QVERIFY(!testWidget.redWidget->seenMouseMove); |
|
560 |
QVERIFY(!testWidget.redWidget->seenMouseRelease); |
|
561 |
QVERIFY(testWidget.greenWidget->touchPointCount == 1); |
|
562 |
QVERIFY(testWidget.redWidget->touchPointCount == 1); |
|
563 |
} |
|
564 |
||
565 |
void tst_ManualMultitouch::secondTouchPointOnCousinGoesToCousin() |
|
566 |
{ |
|
567 |
MultitouchTestWidget testWidget; |
|
568 |
testWidget.testNameLabel->setText("Multi-Touch Interaction Test, Unrelated Widgets Get Separate Events"); |
|
569 |
testWidget.testDescriptionLabel->setText("Press and hold a finger on the blue widget, then the grey one, and release."); |
|
570 |
testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
571 |
testWidget.blueWidget->acceptTouchBegin = true; |
|
572 |
testWidget.blueWidget->closeWindowOnTouchEnd = true; |
|
573 |
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
|
574 |
testWidget.greyWidget->acceptTouchBegin = true; |
|
575 |
testWidget.showMaximized(); |
|
576 |
(void) qApp->exec(); |
|
577 |
QVERIFY(testWidget.blueWidget->seenTouchBegin); |
|
578 |
// QVERIFY(testWidget.blueWidget->seenTouchUpdate); |
|
579 |
QVERIFY(testWidget.blueWidget->seenTouchEnd); |
|
580 |
QVERIFY(!testWidget.blueWidget->seenMousePress); |
|
581 |
QVERIFY(!testWidget.blueWidget->seenMouseMove); |
|
582 |
QVERIFY(!testWidget.blueWidget->seenMouseRelease); |
|
583 |
QVERIFY(testWidget.greyWidget->seenTouchBegin); |
|
584 |
// QVERIFY(testWidget.greyWidget->seenTouchUpdate); |
|
585 |
QVERIFY(testWidget.greyWidget->seenTouchEnd); |
|
586 |
QVERIFY(!testWidget.greyWidget->seenMousePress); |
|
587 |
QVERIFY(!testWidget.greyWidget->seenMouseMove); |
|
588 |
QVERIFY(!testWidget.greyWidget->seenMouseRelease); |
|
589 |
QVERIFY(testWidget.blueWidget->touchPointCount == 1); |
|
590 |
QVERIFY(testWidget.greyWidget->touchPointCount == 1); |
|
591 |
} |
|
592 |
||
593 |
QTEST_MAIN(tst_ManualMultitouch) |
|
594 |
||
595 |
#include "main.moc" |