|
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 $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 class tst_QTouchEventWidget : public QWidget |
|
46 { |
|
47 public: |
|
48 QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints; |
|
49 bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; |
|
50 bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; |
|
51 |
|
52 tst_QTouchEventWidget() |
|
53 : QWidget() |
|
54 { |
|
55 reset(); |
|
56 } |
|
57 |
|
58 void reset() |
|
59 { |
|
60 touchBeginPoints.clear(); |
|
61 touchUpdatePoints.clear(); |
|
62 touchEndPoints.clear(); |
|
63 seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; |
|
64 acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; |
|
65 } |
|
66 |
|
67 bool event(QEvent *event) |
|
68 { |
|
69 switch (event->type()) { |
|
70 case QEvent::TouchBegin: |
|
71 if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin"); |
|
72 if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin"); |
|
73 if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin"); |
|
74 seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; |
|
75 touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
76 event->setAccepted(acceptTouchBegin); |
|
77 break; |
|
78 case QEvent::TouchUpdate: |
|
79 if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); |
|
80 if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate"); |
|
81 seenTouchUpdate = seenTouchBegin && !seenTouchEnd; |
|
82 touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
83 event->setAccepted(acceptTouchUpdate); |
|
84 break; |
|
85 case QEvent::TouchEnd: |
|
86 if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); |
|
87 if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd"); |
|
88 seenTouchEnd = seenTouchBegin && !seenTouchEnd; |
|
89 touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
90 event->setAccepted(acceptTouchEnd); |
|
91 break; |
|
92 default: |
|
93 return QWidget::event(event); |
|
94 } |
|
95 return true; |
|
96 } |
|
97 }; |
|
98 |
|
99 class tst_QTouchEventGraphicsItem : public QGraphicsItem |
|
100 { |
|
101 public: |
|
102 QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints; |
|
103 bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; |
|
104 bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; |
|
105 |
|
106 tst_QTouchEventGraphicsItem() |
|
107 : QGraphicsItem() |
|
108 { |
|
109 reset(); |
|
110 } |
|
111 |
|
112 void reset() |
|
113 { |
|
114 touchBeginPoints.clear(); |
|
115 touchUpdatePoints.clear(); |
|
116 touchEndPoints.clear(); |
|
117 seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; |
|
118 acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; |
|
119 } |
|
120 |
|
121 QRectF boundingRect() const { return QRectF(0, 0, 10, 10); } |
|
122 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) { } |
|
123 |
|
124 bool sceneEvent(QEvent *event) |
|
125 { |
|
126 switch (event->type()) { |
|
127 case QEvent::TouchBegin: |
|
128 if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin"); |
|
129 if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin"); |
|
130 if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin"); |
|
131 seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; |
|
132 touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
133 event->setAccepted(acceptTouchBegin); |
|
134 break; |
|
135 case QEvent::TouchUpdate: |
|
136 if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); |
|
137 if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate"); |
|
138 seenTouchUpdate = seenTouchBegin && !seenTouchEnd; |
|
139 touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
140 event->setAccepted(acceptTouchUpdate); |
|
141 break; |
|
142 case QEvent::TouchEnd: |
|
143 if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); |
|
144 if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd"); |
|
145 seenTouchEnd = seenTouchBegin && !seenTouchEnd; |
|
146 touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
147 event->setAccepted(acceptTouchEnd); |
|
148 break; |
|
149 default: |
|
150 return QGraphicsItem::sceneEvent(event); |
|
151 } |
|
152 return true; |
|
153 } |
|
154 }; |
|
155 |
|
156 class tst_QTouchEvent : public QObject |
|
157 { |
|
158 Q_OBJECT |
|
159 public: |
|
160 tst_QTouchEvent() { } |
|
161 ~tst_QTouchEvent() { } |
|
162 |
|
163 private slots: |
|
164 void touchDisabledByDefault(); |
|
165 void touchEventAcceptedByDefault(); |
|
166 void touchBeginPropagatesWhenIgnored(); |
|
167 void touchUpdateAndEndNeverPropagate(); |
|
168 void basicRawEventTranslation(); |
|
169 void multiPointRawEventTranslationOnTouchScreen(); |
|
170 void multiPointRawEventTranslationOnTouchPad(); |
|
171 }; |
|
172 |
|
173 void tst_QTouchEvent::touchDisabledByDefault() |
|
174 { |
|
175 // QWidget |
|
176 { |
|
177 // the widget attribute is not enabled by default |
|
178 QWidget widget; |
|
179 QVERIFY(!widget.testAttribute(Qt::WA_AcceptTouchEvents)); |
|
180 |
|
181 // events should not be accepted since they are not enabled |
|
182 QList<QTouchEvent::TouchPoint> touchPoints; |
|
183 touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
184 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
185 QTouchEvent::TouchScreen, |
|
186 Qt::NoModifier, |
|
187 Qt::TouchPointPressed, |
|
188 touchPoints); |
|
189 bool res = QApplication::sendEvent(&widget, &touchEvent); |
|
190 QVERIFY(!res); |
|
191 QVERIFY(!touchEvent.isAccepted()); |
|
192 } |
|
193 |
|
194 // QGraphicsView |
|
195 { |
|
196 QGraphicsScene scene; |
|
197 tst_QTouchEventGraphicsItem item; |
|
198 QGraphicsView view(&scene); |
|
199 scene.addItem(&item); |
|
200 item.setPos(100, 100); |
|
201 view.resize(200, 200); |
|
202 view.fitInView(scene.sceneRect()); |
|
203 |
|
204 // touch events are not accepted by default |
|
205 QVERIFY(!item.acceptTouchEvents()); |
|
206 |
|
207 // compose an event to the scene that is over the item |
|
208 QTouchEvent::TouchPoint touchPoint(0); |
|
209 touchPoint.setState(Qt::TouchPointPressed); |
|
210 touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); |
|
211 touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
212 touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
213 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
214 QTouchEvent::TouchScreen, |
|
215 Qt::NoModifier, |
|
216 Qt::TouchPointPressed, |
|
217 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
218 bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
219 QVERIFY(!res); |
|
220 QVERIFY(!touchEvent.isAccepted()); |
|
221 QVERIFY(!item.seenTouchBegin); |
|
222 } |
|
223 } |
|
224 |
|
225 void tst_QTouchEvent::touchEventAcceptedByDefault() |
|
226 { |
|
227 // QWidget |
|
228 { |
|
229 // enabling touch events should automatically accept touch events |
|
230 QWidget widget; |
|
231 widget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
232 |
|
233 // QWidget handles touch event by converting them into a mouse event, so the event is both |
|
234 // accepted and handled (res == true) |
|
235 QList<QTouchEvent::TouchPoint> touchPoints; |
|
236 touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
237 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
238 QTouchEvent::TouchScreen, |
|
239 Qt::NoModifier, |
|
240 Qt::TouchPointPressed, |
|
241 touchPoints); |
|
242 bool res = QApplication::sendEvent(&widget, &touchEvent); |
|
243 QVERIFY(res); |
|
244 QVERIFY(touchEvent.isAccepted()); |
|
245 |
|
246 // tst_QTouchEventWidget does handle, sending succeeds |
|
247 tst_QTouchEventWidget touchWidget; |
|
248 touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
249 touchEvent.ignore(); |
|
250 res = QApplication::sendEvent(&touchWidget, &touchEvent); |
|
251 QVERIFY(res); |
|
252 QVERIFY(touchEvent.isAccepted()); |
|
253 } |
|
254 |
|
255 // QGraphicsView |
|
256 { |
|
257 QGraphicsScene scene; |
|
258 tst_QTouchEventGraphicsItem item; |
|
259 QGraphicsView view(&scene); |
|
260 scene.addItem(&item); |
|
261 item.setPos(100, 100); |
|
262 view.resize(200, 200); |
|
263 view.fitInView(scene.sceneRect()); |
|
264 |
|
265 // enabling touch events on the item also enables events on the viewport |
|
266 item.setAcceptTouchEvents(true); |
|
267 QVERIFY(view.viewport()->testAttribute(Qt::WA_AcceptTouchEvents)); |
|
268 |
|
269 // compose an event to the scene that is over the item |
|
270 QTouchEvent::TouchPoint touchPoint(0); |
|
271 touchPoint.setState(Qt::TouchPointPressed); |
|
272 touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); |
|
273 touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
274 touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
275 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
276 QTouchEvent::TouchScreen, |
|
277 Qt::NoModifier, |
|
278 Qt::TouchPointPressed, |
|
279 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
280 bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
281 QVERIFY(res); |
|
282 QVERIFY(touchEvent.isAccepted()); |
|
283 QVERIFY(item.seenTouchBegin); |
|
284 } |
|
285 } |
|
286 |
|
287 void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() |
|
288 { |
|
289 // QWidget |
|
290 { |
|
291 tst_QTouchEventWidget window, child, grandchild; |
|
292 child.setParent(&window); |
|
293 grandchild.setParent(&child); |
|
294 |
|
295 // all widgets accept touch events, grandchild ignores, so child sees the event, but not window |
|
296 window.setAttribute(Qt::WA_AcceptTouchEvents); |
|
297 child.setAttribute(Qt::WA_AcceptTouchEvents); |
|
298 grandchild.setAttribute(Qt::WA_AcceptTouchEvents); |
|
299 grandchild.acceptTouchBegin = false; |
|
300 |
|
301 QList<QTouchEvent::TouchPoint> touchPoints; |
|
302 touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
303 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
304 QTouchEvent::TouchScreen, |
|
305 Qt::NoModifier, |
|
306 Qt::TouchPointPressed, |
|
307 touchPoints); |
|
308 bool res = QApplication::sendEvent(&grandchild, &touchEvent); |
|
309 QVERIFY(res); |
|
310 QVERIFY(touchEvent.isAccepted()); |
|
311 QVERIFY(grandchild.seenTouchBegin); |
|
312 QVERIFY(child.seenTouchBegin); |
|
313 QVERIFY(!window.seenTouchBegin); |
|
314 |
|
315 // disable touch on grandchild. even though it doesn't accept it, child should still get the |
|
316 // TouchBegin |
|
317 grandchild.reset(); |
|
318 child.reset(); |
|
319 window.reset(); |
|
320 grandchild.setAttribute(Qt::WA_AcceptTouchEvents, false); |
|
321 |
|
322 touchEvent.ignore(); |
|
323 res = QApplication::sendEvent(&grandchild, &touchEvent); |
|
324 QVERIFY(res); |
|
325 QVERIFY(touchEvent.isAccepted()); |
|
326 QVERIFY(!grandchild.seenTouchBegin); |
|
327 QVERIFY(child.seenTouchBegin); |
|
328 QVERIFY(!window.seenTouchBegin); |
|
329 } |
|
330 |
|
331 // QGraphicsView |
|
332 { |
|
333 QGraphicsScene scene; |
|
334 tst_QTouchEventGraphicsItem root, child, grandchild; |
|
335 QGraphicsView view(&scene); |
|
336 scene.addItem(&root); |
|
337 root.setPos(100, 100); |
|
338 child.setParentItem(&root); |
|
339 grandchild.setParentItem(&child); |
|
340 view.resize(200, 200); |
|
341 view.fitInView(scene.sceneRect()); |
|
342 |
|
343 // all items accept touch events, grandchild ignores, so child sees the event, but not root |
|
344 root.setAcceptTouchEvents(true); |
|
345 child.setAcceptTouchEvents(true); |
|
346 grandchild.setAcceptTouchEvents(true); |
|
347 grandchild.acceptTouchBegin = false; |
|
348 |
|
349 // compose an event to the scene that is over the grandchild |
|
350 QTouchEvent::TouchPoint touchPoint(0); |
|
351 touchPoint.setState(Qt::TouchPointPressed); |
|
352 touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); |
|
353 touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
354 touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
355 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
356 QTouchEvent::TouchScreen, |
|
357 Qt::NoModifier, |
|
358 Qt::TouchPointPressed, |
|
359 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
360 bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
361 QVERIFY(res); |
|
362 QVERIFY(touchEvent.isAccepted()); |
|
363 QVERIFY(grandchild.seenTouchBegin); |
|
364 QVERIFY(child.seenTouchBegin); |
|
365 QVERIFY(!root.seenTouchBegin); |
|
366 } |
|
367 |
|
368 // QGraphicsView |
|
369 { |
|
370 QGraphicsScene scene; |
|
371 tst_QTouchEventGraphicsItem root, child, grandchild; |
|
372 QGraphicsView view(&scene); |
|
373 scene.addItem(&root); |
|
374 root.setPos(100, 100); |
|
375 child.setParentItem(&root); |
|
376 grandchild.setParentItem(&child); |
|
377 view.resize(200, 200); |
|
378 view.fitInView(scene.sceneRect()); |
|
379 |
|
380 // leave touch disabled on grandchild. even though it doesn't accept it, child should |
|
381 // still get the TouchBegin |
|
382 root.setAcceptTouchEvents(true); |
|
383 child.setAcceptTouchEvents(true); |
|
384 |
|
385 // compose an event to the scene that is over the grandchild |
|
386 QTouchEvent::TouchPoint touchPoint(0); |
|
387 touchPoint.setState(Qt::TouchPointPressed); |
|
388 touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); |
|
389 touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
390 touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
391 QTouchEvent touchEvent(QEvent::TouchBegin, |
|
392 QTouchEvent::TouchScreen, |
|
393 Qt::NoModifier, |
|
394 Qt::TouchPointPressed, |
|
395 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
396 bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
397 QVERIFY(res); |
|
398 QVERIFY(touchEvent.isAccepted()); |
|
399 QVERIFY(!grandchild.seenTouchBegin); |
|
400 QVERIFY(child.seenTouchBegin); |
|
401 QVERIFY(!root.seenTouchBegin); |
|
402 } |
|
403 } |
|
404 |
|
405 void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() |
|
406 { |
|
407 // QWidget |
|
408 { |
|
409 tst_QTouchEventWidget window, child; |
|
410 child.setParent(&window); |
|
411 |
|
412 window.setAttribute(Qt::WA_AcceptTouchEvents); |
|
413 child.setAttribute(Qt::WA_AcceptTouchEvents); |
|
414 child.acceptTouchUpdate = false; |
|
415 child.acceptTouchEnd = false; |
|
416 |
|
417 QList<QTouchEvent::TouchPoint> touchPoints; |
|
418 touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
419 QTouchEvent touchBeginEvent(QEvent::TouchBegin, |
|
420 QTouchEvent::TouchScreen, |
|
421 Qt::NoModifier, |
|
422 Qt::TouchPointPressed, |
|
423 touchPoints); |
|
424 bool res = QApplication::sendEvent(&child, &touchBeginEvent); |
|
425 QVERIFY(res); |
|
426 QVERIFY(touchBeginEvent.isAccepted()); |
|
427 QVERIFY(child.seenTouchBegin); |
|
428 QVERIFY(!window.seenTouchBegin); |
|
429 |
|
430 // send the touch update to the child, but ignore it, it doesn't propagate |
|
431 QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, |
|
432 QTouchEvent::TouchScreen, |
|
433 Qt::NoModifier, |
|
434 Qt::TouchPointMoved, |
|
435 touchPoints); |
|
436 res = QApplication::sendEvent(&child, &touchUpdateEvent); |
|
437 QVERIFY(res); |
|
438 QVERIFY(!touchUpdateEvent.isAccepted()); |
|
439 QVERIFY(child.seenTouchUpdate); |
|
440 QVERIFY(!window.seenTouchUpdate); |
|
441 |
|
442 // send the touch end, same thing should happen as with touch update |
|
443 QTouchEvent touchEndEvent(QEvent::TouchEnd, |
|
444 QTouchEvent::TouchScreen, |
|
445 Qt::NoModifier, |
|
446 Qt::TouchPointReleased, |
|
447 touchPoints); |
|
448 res = QApplication::sendEvent(&child, &touchEndEvent); |
|
449 QVERIFY(res); |
|
450 QVERIFY(!touchEndEvent.isAccepted()); |
|
451 QVERIFY(child.seenTouchEnd); |
|
452 QVERIFY(!window.seenTouchEnd); |
|
453 } |
|
454 |
|
455 // QGraphicsView |
|
456 { |
|
457 QGraphicsScene scene; |
|
458 tst_QTouchEventGraphicsItem root, child, grandchild; |
|
459 QGraphicsView view(&scene); |
|
460 scene.addItem(&root); |
|
461 root.setPos(100, 100); |
|
462 child.setParentItem(&root); |
|
463 grandchild.setParentItem(&child); |
|
464 view.resize(200, 200); |
|
465 view.fitInView(scene.sceneRect()); |
|
466 |
|
467 root.setAcceptTouchEvents(true); |
|
468 child.setAcceptTouchEvents(true); |
|
469 child.acceptTouchUpdate = false; |
|
470 child.acceptTouchEnd = false; |
|
471 |
|
472 // compose an event to the scene that is over the child |
|
473 QTouchEvent::TouchPoint touchPoint(0); |
|
474 touchPoint.setState(Qt::TouchPointPressed); |
|
475 touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); |
|
476 touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
477 touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
478 QTouchEvent touchBeginEvent(QEvent::TouchBegin, |
|
479 QTouchEvent::TouchScreen, |
|
480 Qt::NoModifier, |
|
481 Qt::TouchPointPressed, |
|
482 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
483 bool res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); |
|
484 QVERIFY(res); |
|
485 QVERIFY(touchBeginEvent.isAccepted()); |
|
486 QVERIFY(child.seenTouchBegin); |
|
487 QVERIFY(!root.seenTouchBegin); |
|
488 |
|
489 // send the touch update to the child, but ignore it, it doesn't propagate |
|
490 touchPoint.setState(Qt::TouchPointMoved); |
|
491 QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, |
|
492 QTouchEvent::TouchScreen, |
|
493 Qt::NoModifier, |
|
494 Qt::TouchPointMoved, |
|
495 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
496 res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); |
|
497 QVERIFY(res); |
|
498 // the scene accepts the event, since it found an item to send the event to |
|
499 QVERIFY(touchUpdateEvent.isAccepted()); |
|
500 QVERIFY(child.seenTouchUpdate); |
|
501 QVERIFY(!root.seenTouchUpdate); |
|
502 |
|
503 // send the touch end, same thing should happen as with touch update |
|
504 touchPoint.setState(Qt::TouchPointReleased); |
|
505 QTouchEvent touchEndEvent(QEvent::TouchEnd, |
|
506 QTouchEvent::TouchScreen, |
|
507 Qt::NoModifier, |
|
508 Qt::TouchPointReleased, |
|
509 (QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
510 res = QApplication::sendEvent(view.viewport(), &touchEndEvent); |
|
511 QVERIFY(res); |
|
512 // the scene accepts the event, since it found an item to send the event to |
|
513 QVERIFY(touchEndEvent.isAccepted()); |
|
514 QVERIFY(child.seenTouchEnd); |
|
515 QVERIFY(!root.seenTouchEnd); |
|
516 } |
|
517 } |
|
518 |
|
519 QPointF normalized(const QPointF &pos, const QRectF &rect) |
|
520 { |
|
521 return QPointF(pos.x() / rect.width(), pos.y() / rect.height()); |
|
522 } |
|
523 |
|
524 void tst_QTouchEvent::basicRawEventTranslation() |
|
525 { |
|
526 tst_QTouchEventWidget touchWidget; |
|
527 touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
528 touchWidget.setGeometry(100, 100, 400, 300); |
|
529 |
|
530 QPointF pos = touchWidget.rect().center(); |
|
531 QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint()); |
|
532 QPointF delta(10, 10); |
|
533 QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
|
534 |
|
535 QTouchEvent::TouchPoint rawTouchPoint; |
|
536 rawTouchPoint.setId(0); |
|
537 |
|
538 // this should be translated to a TouchBegin |
|
539 rawTouchPoint.setState(Qt::TouchPointPressed); |
|
540 rawTouchPoint.setScreenPos(screenPos); |
|
541 rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); |
|
542 qt_translateRawTouchEvent(&touchWidget, |
|
543 QTouchEvent::TouchScreen, |
|
544 QList<QTouchEvent::TouchPoint>() << rawTouchPoint); |
|
545 QVERIFY(touchWidget.seenTouchBegin); |
|
546 QVERIFY(!touchWidget.seenTouchUpdate); |
|
547 QVERIFY(!touchWidget.seenTouchEnd); |
|
548 QCOMPARE(touchWidget.touchBeginPoints.count(), 1); |
|
549 QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); |
|
550 QCOMPARE(touchBeginPoint.id(), rawTouchPoint.id()); |
|
551 QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state()); |
|
552 QCOMPARE(touchBeginPoint.pos(), pos); |
|
553 QCOMPARE(touchBeginPoint.startPos(), pos); |
|
554 QCOMPARE(touchBeginPoint.lastPos(), pos); |
|
555 QCOMPARE(touchBeginPoint.scenePos(), rawTouchPoint.screenPos()); |
|
556 QCOMPARE(touchBeginPoint.startScenePos(), rawTouchPoint.screenPos()); |
|
557 QCOMPARE(touchBeginPoint.lastScenePos(), rawTouchPoint.screenPos()); |
|
558 QCOMPARE(touchBeginPoint.screenPos(), rawTouchPoint.screenPos()); |
|
559 QCOMPARE(touchBeginPoint.startScreenPos(), rawTouchPoint.screenPos()); |
|
560 QCOMPARE(touchBeginPoint.lastScreenPos(), rawTouchPoint.screenPos()); |
|
561 QCOMPARE(touchBeginPoint.normalizedPos(), rawTouchPoint.normalizedPos()); |
|
562 QCOMPARE(touchBeginPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
563 QCOMPARE(touchBeginPoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
564 QCOMPARE(touchBeginPoint.rect(), QRectF(pos, QSizeF(0, 0))); |
|
565 QCOMPARE(touchBeginPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); |
|
566 QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect()); |
|
567 QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); |
|
568 |
|
569 // moving the point should translate to TouchUpdate |
|
570 rawTouchPoint.setState(Qt::TouchPointMoved); |
|
571 rawTouchPoint.setScreenPos(screenPos + delta); |
|
572 rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); |
|
573 qt_translateRawTouchEvent(&touchWidget, |
|
574 QTouchEvent::TouchScreen, |
|
575 QList<QTouchEvent::TouchPoint>() << rawTouchPoint); |
|
576 QVERIFY(touchWidget.seenTouchBegin); |
|
577 QVERIFY(touchWidget.seenTouchUpdate); |
|
578 QVERIFY(!touchWidget.seenTouchEnd); |
|
579 QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); |
|
580 QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); |
|
581 QCOMPARE(touchUpdatePoint.id(), rawTouchPoint.id()); |
|
582 QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state()); |
|
583 QCOMPARE(touchUpdatePoint.pos(), pos + delta); |
|
584 QCOMPARE(touchUpdatePoint.startPos(), pos); |
|
585 QCOMPARE(touchUpdatePoint.lastPos(), pos); |
|
586 QCOMPARE(touchUpdatePoint.scenePos(), rawTouchPoint.screenPos()); |
|
587 QCOMPARE(touchUpdatePoint.startScenePos(), screenPos); |
|
588 QCOMPARE(touchUpdatePoint.lastScenePos(), screenPos); |
|
589 QCOMPARE(touchUpdatePoint.screenPos(), rawTouchPoint.screenPos()); |
|
590 QCOMPARE(touchUpdatePoint.startScreenPos(), screenPos); |
|
591 QCOMPARE(touchUpdatePoint.lastScreenPos(), screenPos); |
|
592 QCOMPARE(touchUpdatePoint.normalizedPos(), rawTouchPoint.normalizedPos()); |
|
593 QCOMPARE(touchUpdatePoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
594 QCOMPARE(touchUpdatePoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
595 QCOMPARE(touchUpdatePoint.rect(), QRectF(pos + delta, QSizeF(0, 0))); |
|
596 QCOMPARE(touchUpdatePoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); |
|
597 QCOMPARE(touchUpdatePoint.sceneRect(), touchUpdatePoint.screenRect()); |
|
598 QCOMPARE(touchUpdatePoint.pressure(), qreal(1.)); |
|
599 |
|
600 // releasing the point translates to TouchEnd |
|
601 rawTouchPoint.setState(Qt::TouchPointReleased); |
|
602 rawTouchPoint.setScreenPos(screenPos + delta + delta); |
|
603 rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); |
|
604 qt_translateRawTouchEvent(&touchWidget, |
|
605 QTouchEvent::TouchScreen, |
|
606 QList<QTouchEvent::TouchPoint>() << rawTouchPoint); |
|
607 QVERIFY(touchWidget.seenTouchBegin); |
|
608 QVERIFY(touchWidget.seenTouchUpdate); |
|
609 QVERIFY(touchWidget.seenTouchEnd); |
|
610 QCOMPARE(touchWidget.touchEndPoints.count(), 1); |
|
611 QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); |
|
612 QCOMPARE(touchEndPoint.id(), rawTouchPoint.id()); |
|
613 QCOMPARE(touchEndPoint.state(), rawTouchPoint.state()); |
|
614 QCOMPARE(touchEndPoint.pos(), pos + delta + delta); |
|
615 QCOMPARE(touchEndPoint.startPos(), pos); |
|
616 QCOMPARE(touchEndPoint.lastPos(), pos + delta); |
|
617 QCOMPARE(touchEndPoint.scenePos(), rawTouchPoint.screenPos()); |
|
618 QCOMPARE(touchEndPoint.startScenePos(), screenPos); |
|
619 QCOMPARE(touchEndPoint.lastScenePos(), screenPos + delta); |
|
620 QCOMPARE(touchEndPoint.screenPos(), rawTouchPoint.screenPos()); |
|
621 QCOMPARE(touchEndPoint.startScreenPos(), screenPos); |
|
622 QCOMPARE(touchEndPoint.lastScreenPos(), screenPos + delta); |
|
623 QCOMPARE(touchEndPoint.normalizedPos(), rawTouchPoint.normalizedPos()); |
|
624 QCOMPARE(touchEndPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
625 QCOMPARE(touchEndPoint.lastNormalizedPos(), touchUpdatePoint.normalizedPos()); |
|
626 QCOMPARE(touchEndPoint.rect(), QRectF(pos + delta + delta, QSizeF(0, 0))); |
|
627 QCOMPARE(touchEndPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); |
|
628 QCOMPARE(touchEndPoint.sceneRect(), touchEndPoint.screenRect()); |
|
629 QCOMPARE(touchEndPoint.pressure(), qreal(0.)); |
|
630 } |
|
631 |
|
632 void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() |
|
633 { |
|
634 tst_QTouchEventWidget touchWidget; |
|
635 touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
636 touchWidget.setGeometry(100, 100, 400, 300); |
|
637 |
|
638 tst_QTouchEventWidget leftWidget; |
|
639 leftWidget.setParent(&touchWidget); |
|
640 leftWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
641 leftWidget.setGeometry(0, 100, 100, 100); |
|
642 leftWidget.show(); |
|
643 |
|
644 tst_QTouchEventWidget rightWidget; |
|
645 rightWidget.setParent(&touchWidget); |
|
646 rightWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
647 rightWidget.setGeometry(300, 100, 100, 100); |
|
648 rightWidget.show(); |
|
649 |
|
650 QPointF leftPos = leftWidget.rect().center(); |
|
651 QPointF rightPos = rightWidget.rect().center(); |
|
652 QPointF centerPos = touchWidget.rect().center(); |
|
653 QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint()); |
|
654 QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint()); |
|
655 QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint()); |
|
656 QPointF delta(10, 10); |
|
657 QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
|
658 |
|
659 QList<QTouchEvent::TouchPoint> rawTouchPoints; |
|
660 rawTouchPoints.append(QTouchEvent::TouchPoint(0)); |
|
661 rawTouchPoints.append(QTouchEvent::TouchPoint(1)); |
|
662 |
|
663 // generate TouchBegins on both leftWidget and rightWidget |
|
664 rawTouchPoints[0].setState(Qt::TouchPointPressed); |
|
665 rawTouchPoints[0].setScreenPos(leftScreenPos); |
|
666 rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
667 rawTouchPoints[1].setState(Qt::TouchPointPressed); |
|
668 rawTouchPoints[1].setScreenPos(rightScreenPos); |
|
669 rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
670 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
|
671 QVERIFY(!touchWidget.seenTouchBegin); |
|
672 QVERIFY(!touchWidget.seenTouchUpdate); |
|
673 QVERIFY(!touchWidget.seenTouchEnd); |
|
674 QVERIFY(leftWidget.seenTouchBegin); |
|
675 QVERIFY(!leftWidget.seenTouchUpdate); |
|
676 QVERIFY(!leftWidget.seenTouchEnd); |
|
677 QVERIFY(rightWidget.seenTouchBegin); |
|
678 QVERIFY(!rightWidget.seenTouchUpdate); |
|
679 QVERIFY(!rightWidget.seenTouchEnd); |
|
680 QCOMPARE(leftWidget.touchBeginPoints.count(), 1); |
|
681 QCOMPARE(rightWidget.touchBeginPoints.count(), 1); |
|
682 { |
|
683 QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first(); |
|
684 QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
685 QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
686 QCOMPARE(leftTouchPoint.pos(), leftPos); |
|
687 QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
688 QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
689 QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); |
|
690 QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
691 QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
692 QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); |
|
693 QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
694 QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
695 QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
696 QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
697 QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
698 QCOMPARE(leftTouchPoint.rect(), QRectF(leftPos, QSizeF(0, 0))); |
|
699 QCOMPARE(leftTouchPoint.sceneRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
700 QCOMPARE(leftTouchPoint.screenRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
701 QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
702 |
|
703 QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first(); |
|
704 QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
705 QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
706 QCOMPARE(rightTouchPoint.pos(), rightPos); |
|
707 QCOMPARE(rightTouchPoint.startPos(), rightPos); |
|
708 QCOMPARE(rightTouchPoint.lastPos(), rightPos); |
|
709 QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); |
|
710 QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
711 QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
712 QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); |
|
713 QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
714 QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
715 QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
716 QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
717 QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
718 QCOMPARE(rightTouchPoint.rect(), QRectF(rightPos, QSizeF(0, 0))); |
|
719 QCOMPARE(rightTouchPoint.sceneRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
720 QCOMPARE(rightTouchPoint.screenRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
721 QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
722 } |
|
723 |
|
724 // generate TouchUpdates on both leftWidget and rightWidget |
|
725 rawTouchPoints[0].setState(Qt::TouchPointMoved); |
|
726 rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
727 rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
728 rawTouchPoints[1].setState(Qt::TouchPointMoved); |
|
729 rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
730 rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
731 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
|
732 QVERIFY(!touchWidget.seenTouchBegin); |
|
733 QVERIFY(!touchWidget.seenTouchUpdate); |
|
734 QVERIFY(!touchWidget.seenTouchEnd); |
|
735 QVERIFY(leftWidget.seenTouchBegin); |
|
736 QVERIFY(leftWidget.seenTouchUpdate); |
|
737 QVERIFY(!leftWidget.seenTouchEnd); |
|
738 QVERIFY(rightWidget.seenTouchBegin); |
|
739 QVERIFY(rightWidget.seenTouchUpdate); |
|
740 QVERIFY(!rightWidget.seenTouchEnd); |
|
741 QCOMPARE(leftWidget.touchUpdatePoints.count(), 1); |
|
742 QCOMPARE(rightWidget.touchUpdatePoints.count(), 1); |
|
743 { |
|
744 QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.first(); |
|
745 QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
746 QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
747 QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
748 QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
749 QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
750 QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
751 QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
752 QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
753 QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
754 QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
755 QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
756 QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
757 QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
758 QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
759 QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
760 QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
761 QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
762 QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
763 |
|
764 QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first(); |
|
765 QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
766 QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
767 QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); |
|
768 QCOMPARE(rightTouchPoint.startPos(), rightPos); |
|
769 QCOMPARE(rightTouchPoint.lastPos(), rightPos); |
|
770 QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
771 QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
772 QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
773 QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
774 QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
775 QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
776 QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
777 QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
778 QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
779 QCOMPARE(rightTouchPoint.rect(), QRectF(rightWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
780 QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
781 QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
782 QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
783 } |
|
784 |
|
785 // generate TouchEnds on both leftWidget and rightWidget |
|
786 rawTouchPoints[0].setState(Qt::TouchPointReleased); |
|
787 rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
788 rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
789 rawTouchPoints[1].setState(Qt::TouchPointReleased); |
|
790 rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
791 rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
792 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
|
793 QVERIFY(!touchWidget.seenTouchBegin); |
|
794 QVERIFY(!touchWidget.seenTouchUpdate); |
|
795 QVERIFY(!touchWidget.seenTouchEnd); |
|
796 QVERIFY(leftWidget.seenTouchBegin); |
|
797 QVERIFY(leftWidget.seenTouchUpdate); |
|
798 QVERIFY(leftWidget.seenTouchEnd); |
|
799 QVERIFY(rightWidget.seenTouchBegin); |
|
800 QVERIFY(rightWidget.seenTouchUpdate); |
|
801 QVERIFY(rightWidget.seenTouchEnd); |
|
802 QCOMPARE(leftWidget.touchEndPoints.count(), 1); |
|
803 QCOMPARE(rightWidget.touchEndPoints.count(), 1); |
|
804 { |
|
805 QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.first(); |
|
806 QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
807 QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
808 QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
809 QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
810 QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.pos()); |
|
811 QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
812 QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
813 QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePos()); |
|
814 QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
815 QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
816 QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.screenPos()); |
|
817 QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
818 QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
819 QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
820 QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
821 QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
822 QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
823 QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); |
|
824 |
|
825 QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first(); |
|
826 QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
827 QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
828 QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); |
|
829 QCOMPARE(rightTouchPoint.startPos(), rightPos); |
|
830 QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.pos()); |
|
831 QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
832 QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
833 QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePos()); |
|
834 QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
835 QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
836 QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.screenPos()); |
|
837 QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
838 QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
839 QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
840 QCOMPARE(rightTouchPoint.rect(), QRectF(rightWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
841 QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
842 QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
843 QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); |
|
844 } |
|
845 } |
|
846 |
|
847 void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() |
|
848 { |
|
849 tst_QTouchEventWidget touchWidget; |
|
850 touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
851 touchWidget.setGeometry(100, 100, 400, 300); |
|
852 |
|
853 tst_QTouchEventWidget leftWidget; |
|
854 leftWidget.setParent(&touchWidget); |
|
855 leftWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
856 leftWidget.setGeometry(0, 100, 100, 100); |
|
857 leftWidget.show(); |
|
858 |
|
859 tst_QTouchEventWidget rightWidget; |
|
860 rightWidget.setParent(&touchWidget); |
|
861 rightWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
862 rightWidget.setGeometry(300, 100, 100, 100); |
|
863 rightWidget.show(); |
|
864 |
|
865 QPointF leftPos = leftWidget.rect().center(); |
|
866 QPointF rightPos = rightWidget.rect().center(); |
|
867 QPointF centerPos = touchWidget.rect().center(); |
|
868 QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint()); |
|
869 QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint()); |
|
870 QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint()); |
|
871 QPointF delta(10, 10); |
|
872 QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
|
873 |
|
874 QList<QTouchEvent::TouchPoint> rawTouchPoints; |
|
875 rawTouchPoints.append(QTouchEvent::TouchPoint(0)); |
|
876 rawTouchPoints.append(QTouchEvent::TouchPoint(1)); |
|
877 |
|
878 // generate TouchBegin on leftWidget only |
|
879 rawTouchPoints[0].setState(Qt::TouchPointPressed); |
|
880 rawTouchPoints[0].setScreenPos(leftScreenPos); |
|
881 rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
882 rawTouchPoints[1].setState(Qt::TouchPointPressed); |
|
883 rawTouchPoints[1].setScreenPos(rightScreenPos); |
|
884 rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
885 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints); |
|
886 QVERIFY(!touchWidget.seenTouchBegin); |
|
887 QVERIFY(!touchWidget.seenTouchUpdate); |
|
888 QVERIFY(!touchWidget.seenTouchEnd); |
|
889 QVERIFY(leftWidget.seenTouchBegin); |
|
890 QVERIFY(!leftWidget.seenTouchUpdate); |
|
891 QVERIFY(!leftWidget.seenTouchEnd); |
|
892 QVERIFY(!rightWidget.seenTouchBegin); |
|
893 QVERIFY(!rightWidget.seenTouchUpdate); |
|
894 QVERIFY(!rightWidget.seenTouchEnd); |
|
895 QCOMPARE(leftWidget.touchBeginPoints.count(), 2); |
|
896 QCOMPARE(rightWidget.touchBeginPoints.count(), 0); |
|
897 { |
|
898 QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0); |
|
899 QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
900 QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
901 QCOMPARE(leftTouchPoint.pos(), leftPos); |
|
902 QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
903 QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
904 QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); |
|
905 QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
906 QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
907 QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); |
|
908 QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
909 QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
910 QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
911 QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
912 QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
913 QCOMPARE(leftTouchPoint.rect(), QRectF(leftPos, QSizeF(0, 0))); |
|
914 QCOMPARE(leftTouchPoint.sceneRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
915 QCOMPARE(leftTouchPoint.screenRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
916 QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
917 |
|
918 QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchBeginPoints.at(1); |
|
919 QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
920 QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
921 QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
922 QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
923 QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
924 QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); |
|
925 QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
926 QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
927 QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); |
|
928 QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
929 QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
930 QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
931 QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
932 QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
933 QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()), QSizeF(0, 0))); |
|
934 QCOMPARE(rightTouchPoint.sceneRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
935 QCOMPARE(rightTouchPoint.screenRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
936 QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
937 } |
|
938 |
|
939 // generate TouchUpdate on leftWidget |
|
940 rawTouchPoints[0].setState(Qt::TouchPointMoved); |
|
941 rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
942 rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
943 rawTouchPoints[1].setState(Qt::TouchPointMoved); |
|
944 rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
945 rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
946 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints); |
|
947 QVERIFY(!touchWidget.seenTouchBegin); |
|
948 QVERIFY(!touchWidget.seenTouchUpdate); |
|
949 QVERIFY(!touchWidget.seenTouchEnd); |
|
950 QVERIFY(leftWidget.seenTouchBegin); |
|
951 QVERIFY(leftWidget.seenTouchUpdate); |
|
952 QVERIFY(!leftWidget.seenTouchEnd); |
|
953 QVERIFY(!rightWidget.seenTouchBegin); |
|
954 QVERIFY(!rightWidget.seenTouchUpdate); |
|
955 QVERIFY(!rightWidget.seenTouchEnd); |
|
956 QCOMPARE(leftWidget.touchUpdatePoints.count(), 2); |
|
957 QCOMPARE(rightWidget.touchUpdatePoints.count(), 0); |
|
958 { |
|
959 QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0); |
|
960 QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
961 QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
962 QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
963 QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
964 QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
965 QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
966 QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
967 QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
968 QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
969 QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
970 QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
971 QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
972 QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
973 QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
974 QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
975 QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
976 QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
977 QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
978 |
|
979 QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchUpdatePoints.at(1); |
|
980 QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
981 QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
982 QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
983 QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
984 QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
985 QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
986 QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
987 QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
988 QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
989 QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
990 QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
991 QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
992 QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
993 QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
994 QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
995 QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
996 QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
997 QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
998 } |
|
999 |
|
1000 // generate TouchEnd on leftWidget |
|
1001 rawTouchPoints[0].setState(Qt::TouchPointReleased); |
|
1002 rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
1003 rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
1004 rawTouchPoints[1].setState(Qt::TouchPointReleased); |
|
1005 rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
1006 rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
1007 qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints); |
|
1008 QVERIFY(!touchWidget.seenTouchBegin); |
|
1009 QVERIFY(!touchWidget.seenTouchUpdate); |
|
1010 QVERIFY(!touchWidget.seenTouchEnd); |
|
1011 QVERIFY(leftWidget.seenTouchBegin); |
|
1012 QVERIFY(leftWidget.seenTouchUpdate); |
|
1013 QVERIFY(leftWidget.seenTouchEnd); |
|
1014 QVERIFY(!rightWidget.seenTouchBegin); |
|
1015 QVERIFY(!rightWidget.seenTouchUpdate); |
|
1016 QVERIFY(!rightWidget.seenTouchEnd); |
|
1017 QCOMPARE(leftWidget.touchEndPoints.count(), 2); |
|
1018 QCOMPARE(rightWidget.touchEndPoints.count(), 0); |
|
1019 { |
|
1020 QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.at(0); |
|
1021 QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
1022 QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
1023 QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
1024 QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
1025 QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.pos()); |
|
1026 QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
1027 QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
1028 QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePos()); |
|
1029 QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
1030 QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
1031 QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.screenPos()); |
|
1032 QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1033 QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1034 QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1035 QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
1036 QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1037 QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1038 QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); |
|
1039 |
|
1040 QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchEndPoints.at(1); |
|
1041 QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
1042 QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
1043 QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
1044 QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
1045 QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.pos()); |
|
1046 QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
1047 QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
1048 QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePos()); |
|
1049 QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
1050 QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
1051 QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.screenPos()); |
|
1052 QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1053 QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1054 QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1055 QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
1056 QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1057 QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1058 QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); |
|
1059 } |
|
1060 } |
|
1061 |
|
1062 QTEST_MAIN(tst_QTouchEvent) |
|
1063 |
|
1064 #include "tst_qtouchevent.moc" |