author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
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 $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; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd; |
0 | 52 |
|
53 |
tst_QTouchEventWidget() |
|
54 |
: QWidget() |
|
55 |
{ |
|
56 |
reset(); |
|
57 |
} |
|
58 |
||
59 |
void reset() |
|
60 |
{ |
|
61 |
touchBeginPoints.clear(); |
|
62 |
touchUpdatePoints.clear(); |
|
63 |
touchEndPoints.clear(); |
|
64 |
seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; |
|
65 |
acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false; |
0 | 67 |
} |
68 |
||
69 |
bool event(QEvent *event) |
|
70 |
{ |
|
71 |
switch (event->type()) { |
|
72 |
case QEvent::TouchBegin: |
|
73 |
if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin"); |
|
74 |
if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin"); |
|
75 |
if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin"); |
|
76 |
seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; |
|
77 |
touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
78 |
event->setAccepted(acceptTouchBegin); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
if (deleteInTouchBegin) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
delete this; |
0 | 81 |
break; |
82 |
case QEvent::TouchUpdate: |
|
83 |
if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); |
|
84 |
if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate"); |
|
85 |
seenTouchUpdate = seenTouchBegin && !seenTouchEnd; |
|
86 |
touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
87 |
event->setAccepted(acceptTouchUpdate); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
if (deleteInTouchUpdate) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
delete this; |
0 | 90 |
break; |
91 |
case QEvent::TouchEnd: |
|
92 |
if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); |
|
93 |
if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd"); |
|
94 |
seenTouchEnd = seenTouchBegin && !seenTouchEnd; |
|
95 |
touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
|
96 |
event->setAccepted(acceptTouchEnd); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
if (deleteInTouchEnd) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
delete this; |
0 | 99 |
break; |
100 |
default: |
|
101 |
return QWidget::event(event); |
|
102 |
} |
|
103 |
return true; |
|
104 |
} |
|
105 |
}; |
|
106 |
||
107 |
class tst_QTouchEventGraphicsItem : public QGraphicsItem |
|
108 |
{ |
|
109 |
public: |
|
110 |
QList<QTouchEvent::TouchPoint> touchBeginPoints, touchUpdatePoints, touchEndPoints; |
|
111 |
bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
112 |
int touchBeginCounter, touchUpdateCounter, touchEndCounter; |
0 | 113 |
bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
bool deleteInTouchBegin, deleteInTouchUpdate, deleteInTouchEnd; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
tst_QTouchEventGraphicsItem **weakpointer; |
0 | 116 |
|
117 |
tst_QTouchEventGraphicsItem() |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
: QGraphicsItem(), weakpointer(0) |
0 | 119 |
{ |
120 |
reset(); |
|
121 |
} |
|
122 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
~tst_QTouchEventGraphicsItem() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
if (weakpointer) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
*weakpointer = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
128 |
|
0 | 129 |
void reset() |
130 |
{ |
|
131 |
touchBeginPoints.clear(); |
|
132 |
touchUpdatePoints.clear(); |
|
133 |
touchEndPoints.clear(); |
|
134 |
seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
135 |
touchBeginCounter = touchUpdateCounter = touchEndCounter = 0; |
0 | 136 |
acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false; |
0 | 138 |
} |
139 |
||
140 |
QRectF boundingRect() const { return QRectF(0, 0, 10, 10); } |
|
141 |
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) { } |
|
142 |
||
143 |
bool sceneEvent(QEvent *event) |
|
144 |
{ |
|
145 |
switch (event->type()) { |
|
146 |
case QEvent::TouchBegin: |
|
147 |
if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin"); |
|
148 |
if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin"); |
|
149 |
if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin"); |
|
150 |
seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
151 |
++touchBeginCounter; |
0 | 152 |
touchBeginPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
153 |
event->setAccepted(acceptTouchBegin); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
154 |
if (deleteInTouchBegin) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
delete this; |
0 | 156 |
break; |
157 |
case QEvent::TouchUpdate: |
|
158 |
if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); |
|
159 |
if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate"); |
|
160 |
seenTouchUpdate = seenTouchBegin && !seenTouchEnd; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
161 |
++touchUpdateCounter; |
0 | 162 |
touchUpdatePoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
163 |
event->setAccepted(acceptTouchUpdate); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
if (deleteInTouchUpdate) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
delete this; |
0 | 166 |
break; |
167 |
case QEvent::TouchEnd: |
|
168 |
if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); |
|
169 |
if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd"); |
|
170 |
seenTouchEnd = seenTouchBegin && !seenTouchEnd; |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
171 |
++touchEndCounter; |
0 | 172 |
touchEndPoints = static_cast<QTouchEvent *>(event)->touchPoints(); |
173 |
event->setAccepted(acceptTouchEnd); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
if (deleteInTouchEnd) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
delete this; |
0 | 176 |
break; |
177 |
default: |
|
178 |
return QGraphicsItem::sceneEvent(event); |
|
179 |
} |
|
180 |
return true; |
|
181 |
} |
|
182 |
}; |
|
183 |
||
184 |
class tst_QTouchEvent : public QObject |
|
185 |
{ |
|
186 |
Q_OBJECT |
|
187 |
public: |
|
188 |
tst_QTouchEvent() { } |
|
189 |
~tst_QTouchEvent() { } |
|
190 |
||
191 |
private slots: |
|
192 |
void touchDisabledByDefault(); |
|
193 |
void touchEventAcceptedByDefault(); |
|
194 |
void touchBeginPropagatesWhenIgnored(); |
|
195 |
void touchUpdateAndEndNeverPropagate(); |
|
196 |
void basicRawEventTranslation(); |
|
197 |
void multiPointRawEventTranslationOnTouchScreen(); |
|
198 |
void multiPointRawEventTranslationOnTouchPad(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
void deleteInEventHandler(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
void deleteInRawEventTranslation(); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
201 |
void crashInQGraphicsSceneAfterNotHandlingTouchBegin(); |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
202 |
void touchBeginWithGraphicsWidget(); |
0 | 203 |
}; |
204 |
||
205 |
void tst_QTouchEvent::touchDisabledByDefault() |
|
206 |
{ |
|
207 |
// QWidget |
|
208 |
{ |
|
209 |
// the widget attribute is not enabled by default |
|
210 |
QWidget widget; |
|
211 |
QVERIFY(!widget.testAttribute(Qt::WA_AcceptTouchEvents)); |
|
212 |
||
213 |
// events should not be accepted since they are not enabled |
|
214 |
QList<QTouchEvent::TouchPoint> touchPoints; |
|
215 |
touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
216 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
217 |
QTouchEvent::TouchScreen, |
|
218 |
Qt::NoModifier, |
|
219 |
Qt::TouchPointPressed, |
|
220 |
touchPoints); |
|
221 |
bool res = QApplication::sendEvent(&widget, &touchEvent); |
|
222 |
QVERIFY(!res); |
|
223 |
QVERIFY(!touchEvent.isAccepted()); |
|
224 |
} |
|
225 |
||
226 |
// QGraphicsView |
|
227 |
{ |
|
228 |
QGraphicsScene scene; |
|
229 |
tst_QTouchEventGraphicsItem item; |
|
230 |
QGraphicsView view(&scene); |
|
231 |
scene.addItem(&item); |
|
232 |
item.setPos(100, 100); |
|
233 |
view.resize(200, 200); |
|
234 |
view.fitInView(scene.sceneRect()); |
|
235 |
||
236 |
// touch events are not accepted by default |
|
237 |
QVERIFY(!item.acceptTouchEvents()); |
|
238 |
||
239 |
// compose an event to the scene that is over the item |
|
240 |
QTouchEvent::TouchPoint touchPoint(0); |
|
241 |
touchPoint.setState(Qt::TouchPointPressed); |
|
242 |
touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); |
|
243 |
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
244 |
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
245 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
246 |
QTouchEvent::TouchScreen, |
|
247 |
Qt::NoModifier, |
|
248 |
Qt::TouchPointPressed, |
|
249 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
250 |
bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
251 |
QVERIFY(!res); |
|
252 |
QVERIFY(!touchEvent.isAccepted()); |
|
253 |
QVERIFY(!item.seenTouchBegin); |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
void tst_QTouchEvent::touchEventAcceptedByDefault() |
|
258 |
{ |
|
259 |
// QWidget |
|
260 |
{ |
|
261 |
// enabling touch events should automatically accept touch events |
|
262 |
QWidget widget; |
|
263 |
widget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
264 |
||
265 |
// QWidget handles touch event by converting them into a mouse event, so the event is both |
|
266 |
// accepted and handled (res == true) |
|
267 |
QList<QTouchEvent::TouchPoint> touchPoints; |
|
268 |
touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
269 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
270 |
QTouchEvent::TouchScreen, |
|
271 |
Qt::NoModifier, |
|
272 |
Qt::TouchPointPressed, |
|
273 |
touchPoints); |
|
274 |
bool res = QApplication::sendEvent(&widget, &touchEvent); |
|
275 |
QVERIFY(res); |
|
276 |
QVERIFY(touchEvent.isAccepted()); |
|
277 |
||
278 |
// tst_QTouchEventWidget does handle, sending succeeds |
|
279 |
tst_QTouchEventWidget touchWidget; |
|
280 |
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
281 |
touchEvent.ignore(); |
|
282 |
res = QApplication::sendEvent(&touchWidget, &touchEvent); |
|
283 |
QVERIFY(res); |
|
284 |
QVERIFY(touchEvent.isAccepted()); |
|
285 |
} |
|
286 |
||
287 |
// QGraphicsView |
|
288 |
{ |
|
289 |
QGraphicsScene scene; |
|
290 |
tst_QTouchEventGraphicsItem item; |
|
291 |
QGraphicsView view(&scene); |
|
292 |
scene.addItem(&item); |
|
293 |
item.setPos(100, 100); |
|
294 |
view.resize(200, 200); |
|
295 |
view.fitInView(scene.sceneRect()); |
|
296 |
||
297 |
// enabling touch events on the item also enables events on the viewport |
|
298 |
item.setAcceptTouchEvents(true); |
|
299 |
QVERIFY(view.viewport()->testAttribute(Qt::WA_AcceptTouchEvents)); |
|
300 |
||
301 |
// compose an event to the scene that is over the item |
|
302 |
QTouchEvent::TouchPoint touchPoint(0); |
|
303 |
touchPoint.setState(Qt::TouchPointPressed); |
|
304 |
touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); |
|
305 |
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
306 |
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
307 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
308 |
QTouchEvent::TouchScreen, |
|
309 |
Qt::NoModifier, |
|
310 |
Qt::TouchPointPressed, |
|
311 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
312 |
bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
313 |
QVERIFY(res); |
|
314 |
QVERIFY(touchEvent.isAccepted()); |
|
315 |
QVERIFY(item.seenTouchBegin); |
|
316 |
} |
|
317 |
} |
|
318 |
||
319 |
void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() |
|
320 |
{ |
|
321 |
// QWidget |
|
322 |
{ |
|
323 |
tst_QTouchEventWidget window, child, grandchild; |
|
324 |
child.setParent(&window); |
|
325 |
grandchild.setParent(&child); |
|
326 |
||
327 |
// all widgets accept touch events, grandchild ignores, so child sees the event, but not window |
|
328 |
window.setAttribute(Qt::WA_AcceptTouchEvents); |
|
329 |
child.setAttribute(Qt::WA_AcceptTouchEvents); |
|
330 |
grandchild.setAttribute(Qt::WA_AcceptTouchEvents); |
|
331 |
grandchild.acceptTouchBegin = false; |
|
332 |
||
333 |
QList<QTouchEvent::TouchPoint> touchPoints; |
|
334 |
touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
335 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
336 |
QTouchEvent::TouchScreen, |
|
337 |
Qt::NoModifier, |
|
338 |
Qt::TouchPointPressed, |
|
339 |
touchPoints); |
|
340 |
bool res = QApplication::sendEvent(&grandchild, &touchEvent); |
|
341 |
QVERIFY(res); |
|
342 |
QVERIFY(touchEvent.isAccepted()); |
|
343 |
QVERIFY(grandchild.seenTouchBegin); |
|
344 |
QVERIFY(child.seenTouchBegin); |
|
345 |
QVERIFY(!window.seenTouchBegin); |
|
346 |
||
347 |
// disable touch on grandchild. even though it doesn't accept it, child should still get the |
|
348 |
// TouchBegin |
|
349 |
grandchild.reset(); |
|
350 |
child.reset(); |
|
351 |
window.reset(); |
|
352 |
grandchild.setAttribute(Qt::WA_AcceptTouchEvents, false); |
|
353 |
||
354 |
touchEvent.ignore(); |
|
355 |
res = QApplication::sendEvent(&grandchild, &touchEvent); |
|
356 |
QVERIFY(res); |
|
357 |
QVERIFY(touchEvent.isAccepted()); |
|
358 |
QVERIFY(!grandchild.seenTouchBegin); |
|
359 |
QVERIFY(child.seenTouchBegin); |
|
360 |
QVERIFY(!window.seenTouchBegin); |
|
361 |
} |
|
362 |
||
363 |
// QGraphicsView |
|
364 |
{ |
|
365 |
QGraphicsScene scene; |
|
366 |
tst_QTouchEventGraphicsItem root, child, grandchild; |
|
367 |
QGraphicsView view(&scene); |
|
368 |
scene.addItem(&root); |
|
369 |
root.setPos(100, 100); |
|
370 |
child.setParentItem(&root); |
|
371 |
grandchild.setParentItem(&child); |
|
372 |
view.resize(200, 200); |
|
373 |
view.fitInView(scene.sceneRect()); |
|
374 |
||
375 |
// all items accept touch events, grandchild ignores, so child sees the event, but not root |
|
376 |
root.setAcceptTouchEvents(true); |
|
377 |
child.setAcceptTouchEvents(true); |
|
378 |
grandchild.setAcceptTouchEvents(true); |
|
379 |
grandchild.acceptTouchBegin = false; |
|
380 |
||
381 |
// compose an event to the scene that is over the grandchild |
|
382 |
QTouchEvent::TouchPoint touchPoint(0); |
|
383 |
touchPoint.setState(Qt::TouchPointPressed); |
|
384 |
touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); |
|
385 |
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
386 |
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
387 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
388 |
QTouchEvent::TouchScreen, |
|
389 |
Qt::NoModifier, |
|
390 |
Qt::TouchPointPressed, |
|
391 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
392 |
bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
393 |
QVERIFY(res); |
|
394 |
QVERIFY(touchEvent.isAccepted()); |
|
395 |
QVERIFY(grandchild.seenTouchBegin); |
|
396 |
QVERIFY(child.seenTouchBegin); |
|
397 |
QVERIFY(!root.seenTouchBegin); |
|
398 |
} |
|
399 |
||
400 |
// QGraphicsView |
|
401 |
{ |
|
402 |
QGraphicsScene scene; |
|
403 |
tst_QTouchEventGraphicsItem root, child, grandchild; |
|
404 |
QGraphicsView view(&scene); |
|
405 |
scene.addItem(&root); |
|
406 |
root.setPos(100, 100); |
|
407 |
child.setParentItem(&root); |
|
408 |
grandchild.setParentItem(&child); |
|
409 |
view.resize(200, 200); |
|
410 |
view.fitInView(scene.sceneRect()); |
|
411 |
||
412 |
// leave touch disabled on grandchild. even though it doesn't accept it, child should |
|
413 |
// still get the TouchBegin |
|
414 |
root.setAcceptTouchEvents(true); |
|
415 |
child.setAcceptTouchEvents(true); |
|
416 |
||
417 |
// compose an event to the scene that is over the grandchild |
|
418 |
QTouchEvent::TouchPoint touchPoint(0); |
|
419 |
touchPoint.setState(Qt::TouchPointPressed); |
|
420 |
touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); |
|
421 |
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
422 |
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
423 |
QTouchEvent touchEvent(QEvent::TouchBegin, |
|
424 |
QTouchEvent::TouchScreen, |
|
425 |
Qt::NoModifier, |
|
426 |
Qt::TouchPointPressed, |
|
427 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
428 |
bool res = QApplication::sendEvent(view.viewport(), &touchEvent); |
|
429 |
QVERIFY(res); |
|
430 |
QVERIFY(touchEvent.isAccepted()); |
|
431 |
QVERIFY(!grandchild.seenTouchBegin); |
|
432 |
QVERIFY(child.seenTouchBegin); |
|
433 |
QVERIFY(!root.seenTouchBegin); |
|
434 |
} |
|
435 |
} |
|
436 |
||
437 |
void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() |
|
438 |
{ |
|
439 |
// QWidget |
|
440 |
{ |
|
441 |
tst_QTouchEventWidget window, child; |
|
442 |
child.setParent(&window); |
|
443 |
||
444 |
window.setAttribute(Qt::WA_AcceptTouchEvents); |
|
445 |
child.setAttribute(Qt::WA_AcceptTouchEvents); |
|
446 |
child.acceptTouchUpdate = false; |
|
447 |
child.acceptTouchEnd = false; |
|
448 |
||
449 |
QList<QTouchEvent::TouchPoint> touchPoints; |
|
450 |
touchPoints.append(QTouchEvent::TouchPoint(0)); |
|
451 |
QTouchEvent touchBeginEvent(QEvent::TouchBegin, |
|
452 |
QTouchEvent::TouchScreen, |
|
453 |
Qt::NoModifier, |
|
454 |
Qt::TouchPointPressed, |
|
455 |
touchPoints); |
|
456 |
bool res = QApplication::sendEvent(&child, &touchBeginEvent); |
|
457 |
QVERIFY(res); |
|
458 |
QVERIFY(touchBeginEvent.isAccepted()); |
|
459 |
QVERIFY(child.seenTouchBegin); |
|
460 |
QVERIFY(!window.seenTouchBegin); |
|
461 |
||
462 |
// send the touch update to the child, but ignore it, it doesn't propagate |
|
463 |
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, |
|
464 |
QTouchEvent::TouchScreen, |
|
465 |
Qt::NoModifier, |
|
466 |
Qt::TouchPointMoved, |
|
467 |
touchPoints); |
|
468 |
res = QApplication::sendEvent(&child, &touchUpdateEvent); |
|
469 |
QVERIFY(res); |
|
470 |
QVERIFY(!touchUpdateEvent.isAccepted()); |
|
471 |
QVERIFY(child.seenTouchUpdate); |
|
472 |
QVERIFY(!window.seenTouchUpdate); |
|
473 |
||
474 |
// send the touch end, same thing should happen as with touch update |
|
475 |
QTouchEvent touchEndEvent(QEvent::TouchEnd, |
|
476 |
QTouchEvent::TouchScreen, |
|
477 |
Qt::NoModifier, |
|
478 |
Qt::TouchPointReleased, |
|
479 |
touchPoints); |
|
480 |
res = QApplication::sendEvent(&child, &touchEndEvent); |
|
481 |
QVERIFY(res); |
|
482 |
QVERIFY(!touchEndEvent.isAccepted()); |
|
483 |
QVERIFY(child.seenTouchEnd); |
|
484 |
QVERIFY(!window.seenTouchEnd); |
|
485 |
} |
|
486 |
||
487 |
// QGraphicsView |
|
488 |
{ |
|
489 |
QGraphicsScene scene; |
|
490 |
tst_QTouchEventGraphicsItem root, child, grandchild; |
|
491 |
QGraphicsView view(&scene); |
|
492 |
scene.addItem(&root); |
|
493 |
root.setPos(100, 100); |
|
494 |
child.setParentItem(&root); |
|
495 |
grandchild.setParentItem(&child); |
|
496 |
view.resize(200, 200); |
|
497 |
view.fitInView(scene.sceneRect()); |
|
498 |
||
499 |
root.setAcceptTouchEvents(true); |
|
500 |
child.setAcceptTouchEvents(true); |
|
501 |
child.acceptTouchUpdate = false; |
|
502 |
child.acceptTouchEnd = false; |
|
503 |
||
504 |
// compose an event to the scene that is over the child |
|
505 |
QTouchEvent::TouchPoint touchPoint(0); |
|
506 |
touchPoint.setState(Qt::TouchPointPressed); |
|
507 |
touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); |
|
508 |
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
|
509 |
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
|
510 |
QTouchEvent touchBeginEvent(QEvent::TouchBegin, |
|
511 |
QTouchEvent::TouchScreen, |
|
512 |
Qt::NoModifier, |
|
513 |
Qt::TouchPointPressed, |
|
514 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
515 |
bool res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); |
|
516 |
QVERIFY(res); |
|
517 |
QVERIFY(touchBeginEvent.isAccepted()); |
|
518 |
QVERIFY(child.seenTouchBegin); |
|
519 |
QVERIFY(!root.seenTouchBegin); |
|
520 |
||
521 |
// send the touch update to the child, but ignore it, it doesn't propagate |
|
522 |
touchPoint.setState(Qt::TouchPointMoved); |
|
523 |
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, |
|
524 |
QTouchEvent::TouchScreen, |
|
525 |
Qt::NoModifier, |
|
526 |
Qt::TouchPointMoved, |
|
527 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
528 |
res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); |
|
529 |
QVERIFY(res); |
|
530 |
// the scene accepts the event, since it found an item to send the event to |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
531 |
QVERIFY(!touchUpdateEvent.isAccepted()); |
0 | 532 |
QVERIFY(child.seenTouchUpdate); |
533 |
QVERIFY(!root.seenTouchUpdate); |
|
534 |
||
535 |
// send the touch end, same thing should happen as with touch update |
|
536 |
touchPoint.setState(Qt::TouchPointReleased); |
|
537 |
QTouchEvent touchEndEvent(QEvent::TouchEnd, |
|
538 |
QTouchEvent::TouchScreen, |
|
539 |
Qt::NoModifier, |
|
540 |
Qt::TouchPointReleased, |
|
541 |
(QList<QTouchEvent::TouchPoint>() << touchPoint)); |
|
542 |
res = QApplication::sendEvent(view.viewport(), &touchEndEvent); |
|
543 |
QVERIFY(res); |
|
544 |
// the scene accepts the event, since it found an item to send the event to |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
545 |
QVERIFY(!touchEndEvent.isAccepted()); |
0 | 546 |
QVERIFY(child.seenTouchEnd); |
547 |
QVERIFY(!root.seenTouchEnd); |
|
548 |
} |
|
549 |
} |
|
550 |
||
551 |
QPointF normalized(const QPointF &pos, const QRectF &rect) |
|
552 |
{ |
|
553 |
return QPointF(pos.x() / rect.width(), pos.y() / rect.height()); |
|
554 |
} |
|
555 |
||
556 |
void tst_QTouchEvent::basicRawEventTranslation() |
|
557 |
{ |
|
558 |
tst_QTouchEventWidget touchWidget; |
|
559 |
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
560 |
touchWidget.setGeometry(100, 100, 400, 300); |
|
561 |
||
562 |
QPointF pos = touchWidget.rect().center(); |
|
563 |
QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint()); |
|
564 |
QPointF delta(10, 10); |
|
565 |
QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
|
566 |
||
567 |
QTouchEvent::TouchPoint rawTouchPoint; |
|
568 |
rawTouchPoint.setId(0); |
|
569 |
||
570 |
// this should be translated to a TouchBegin |
|
571 |
rawTouchPoint.setState(Qt::TouchPointPressed); |
|
572 |
rawTouchPoint.setScreenPos(screenPos); |
|
573 |
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); |
|
574 |
qt_translateRawTouchEvent(&touchWidget, |
|
575 |
QTouchEvent::TouchScreen, |
|
576 |
QList<QTouchEvent::TouchPoint>() << rawTouchPoint); |
|
577 |
QVERIFY(touchWidget.seenTouchBegin); |
|
578 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
579 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
580 |
QCOMPARE(touchWidget.touchBeginPoints.count(), 1); |
|
581 |
QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); |
|
582 |
QCOMPARE(touchBeginPoint.id(), rawTouchPoint.id()); |
|
583 |
QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state()); |
|
584 |
QCOMPARE(touchBeginPoint.pos(), pos); |
|
585 |
QCOMPARE(touchBeginPoint.startPos(), pos); |
|
586 |
QCOMPARE(touchBeginPoint.lastPos(), pos); |
|
587 |
QCOMPARE(touchBeginPoint.scenePos(), rawTouchPoint.screenPos()); |
|
588 |
QCOMPARE(touchBeginPoint.startScenePos(), rawTouchPoint.screenPos()); |
|
589 |
QCOMPARE(touchBeginPoint.lastScenePos(), rawTouchPoint.screenPos()); |
|
590 |
QCOMPARE(touchBeginPoint.screenPos(), rawTouchPoint.screenPos()); |
|
591 |
QCOMPARE(touchBeginPoint.startScreenPos(), rawTouchPoint.screenPos()); |
|
592 |
QCOMPARE(touchBeginPoint.lastScreenPos(), rawTouchPoint.screenPos()); |
|
593 |
QCOMPARE(touchBeginPoint.normalizedPos(), rawTouchPoint.normalizedPos()); |
|
594 |
QCOMPARE(touchBeginPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
595 |
QCOMPARE(touchBeginPoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
596 |
QCOMPARE(touchBeginPoint.rect(), QRectF(pos, QSizeF(0, 0))); |
|
597 |
QCOMPARE(touchBeginPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); |
|
598 |
QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect()); |
|
599 |
QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); |
|
600 |
||
601 |
// moving the point should translate to TouchUpdate |
|
602 |
rawTouchPoint.setState(Qt::TouchPointMoved); |
|
603 |
rawTouchPoint.setScreenPos(screenPos + delta); |
|
604 |
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); |
|
605 |
qt_translateRawTouchEvent(&touchWidget, |
|
606 |
QTouchEvent::TouchScreen, |
|
607 |
QList<QTouchEvent::TouchPoint>() << rawTouchPoint); |
|
608 |
QVERIFY(touchWidget.seenTouchBegin); |
|
609 |
QVERIFY(touchWidget.seenTouchUpdate); |
|
610 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
611 |
QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); |
|
612 |
QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); |
|
613 |
QCOMPARE(touchUpdatePoint.id(), rawTouchPoint.id()); |
|
614 |
QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state()); |
|
615 |
QCOMPARE(touchUpdatePoint.pos(), pos + delta); |
|
616 |
QCOMPARE(touchUpdatePoint.startPos(), pos); |
|
617 |
QCOMPARE(touchUpdatePoint.lastPos(), pos); |
|
618 |
QCOMPARE(touchUpdatePoint.scenePos(), rawTouchPoint.screenPos()); |
|
619 |
QCOMPARE(touchUpdatePoint.startScenePos(), screenPos); |
|
620 |
QCOMPARE(touchUpdatePoint.lastScenePos(), screenPos); |
|
621 |
QCOMPARE(touchUpdatePoint.screenPos(), rawTouchPoint.screenPos()); |
|
622 |
QCOMPARE(touchUpdatePoint.startScreenPos(), screenPos); |
|
623 |
QCOMPARE(touchUpdatePoint.lastScreenPos(), screenPos); |
|
624 |
QCOMPARE(touchUpdatePoint.normalizedPos(), rawTouchPoint.normalizedPos()); |
|
625 |
QCOMPARE(touchUpdatePoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
626 |
QCOMPARE(touchUpdatePoint.lastNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
627 |
QCOMPARE(touchUpdatePoint.rect(), QRectF(pos + delta, QSizeF(0, 0))); |
|
628 |
QCOMPARE(touchUpdatePoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); |
|
629 |
QCOMPARE(touchUpdatePoint.sceneRect(), touchUpdatePoint.screenRect()); |
|
630 |
QCOMPARE(touchUpdatePoint.pressure(), qreal(1.)); |
|
631 |
||
632 |
// releasing the point translates to TouchEnd |
|
633 |
rawTouchPoint.setState(Qt::TouchPointReleased); |
|
634 |
rawTouchPoint.setScreenPos(screenPos + delta + delta); |
|
635 |
rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); |
|
636 |
qt_translateRawTouchEvent(&touchWidget, |
|
637 |
QTouchEvent::TouchScreen, |
|
638 |
QList<QTouchEvent::TouchPoint>() << rawTouchPoint); |
|
639 |
QVERIFY(touchWidget.seenTouchBegin); |
|
640 |
QVERIFY(touchWidget.seenTouchUpdate); |
|
641 |
QVERIFY(touchWidget.seenTouchEnd); |
|
642 |
QCOMPARE(touchWidget.touchEndPoints.count(), 1); |
|
643 |
QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); |
|
644 |
QCOMPARE(touchEndPoint.id(), rawTouchPoint.id()); |
|
645 |
QCOMPARE(touchEndPoint.state(), rawTouchPoint.state()); |
|
646 |
QCOMPARE(touchEndPoint.pos(), pos + delta + delta); |
|
647 |
QCOMPARE(touchEndPoint.startPos(), pos); |
|
648 |
QCOMPARE(touchEndPoint.lastPos(), pos + delta); |
|
649 |
QCOMPARE(touchEndPoint.scenePos(), rawTouchPoint.screenPos()); |
|
650 |
QCOMPARE(touchEndPoint.startScenePos(), screenPos); |
|
651 |
QCOMPARE(touchEndPoint.lastScenePos(), screenPos + delta); |
|
652 |
QCOMPARE(touchEndPoint.screenPos(), rawTouchPoint.screenPos()); |
|
653 |
QCOMPARE(touchEndPoint.startScreenPos(), screenPos); |
|
654 |
QCOMPARE(touchEndPoint.lastScreenPos(), screenPos + delta); |
|
655 |
QCOMPARE(touchEndPoint.normalizedPos(), rawTouchPoint.normalizedPos()); |
|
656 |
QCOMPARE(touchEndPoint.startNormalizedPos(), touchBeginPoint.normalizedPos()); |
|
657 |
QCOMPARE(touchEndPoint.lastNormalizedPos(), touchUpdatePoint.normalizedPos()); |
|
658 |
QCOMPARE(touchEndPoint.rect(), QRectF(pos + delta + delta, QSizeF(0, 0))); |
|
659 |
QCOMPARE(touchEndPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0))); |
|
660 |
QCOMPARE(touchEndPoint.sceneRect(), touchEndPoint.screenRect()); |
|
661 |
QCOMPARE(touchEndPoint.pressure(), qreal(0.)); |
|
662 |
} |
|
663 |
||
664 |
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() |
|
665 |
{ |
|
666 |
tst_QTouchEventWidget touchWidget; |
|
667 |
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
668 |
touchWidget.setGeometry(100, 100, 400, 300); |
|
669 |
||
670 |
tst_QTouchEventWidget leftWidget; |
|
671 |
leftWidget.setParent(&touchWidget); |
|
672 |
leftWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
673 |
leftWidget.setGeometry(0, 100, 100, 100); |
|
674 |
leftWidget.show(); |
|
675 |
||
676 |
tst_QTouchEventWidget rightWidget; |
|
677 |
rightWidget.setParent(&touchWidget); |
|
678 |
rightWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
679 |
rightWidget.setGeometry(300, 100, 100, 100); |
|
680 |
rightWidget.show(); |
|
681 |
||
682 |
QPointF leftPos = leftWidget.rect().center(); |
|
683 |
QPointF rightPos = rightWidget.rect().center(); |
|
684 |
QPointF centerPos = touchWidget.rect().center(); |
|
685 |
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint()); |
|
686 |
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint()); |
|
687 |
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint()); |
|
688 |
QPointF delta(10, 10); |
|
689 |
QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
|
690 |
||
691 |
QList<QTouchEvent::TouchPoint> rawTouchPoints; |
|
692 |
rawTouchPoints.append(QTouchEvent::TouchPoint(0)); |
|
693 |
rawTouchPoints.append(QTouchEvent::TouchPoint(1)); |
|
694 |
||
695 |
// generate TouchBegins on both leftWidget and rightWidget |
|
696 |
rawTouchPoints[0].setState(Qt::TouchPointPressed); |
|
697 |
rawTouchPoints[0].setScreenPos(leftScreenPos); |
|
698 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
699 |
rawTouchPoints[1].setState(Qt::TouchPointPressed); |
|
700 |
rawTouchPoints[1].setScreenPos(rightScreenPos); |
|
701 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
702 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
|
703 |
QVERIFY(!touchWidget.seenTouchBegin); |
|
704 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
705 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
706 |
QVERIFY(leftWidget.seenTouchBegin); |
|
707 |
QVERIFY(!leftWidget.seenTouchUpdate); |
|
708 |
QVERIFY(!leftWidget.seenTouchEnd); |
|
709 |
QVERIFY(rightWidget.seenTouchBegin); |
|
710 |
QVERIFY(!rightWidget.seenTouchUpdate); |
|
711 |
QVERIFY(!rightWidget.seenTouchEnd); |
|
712 |
QCOMPARE(leftWidget.touchBeginPoints.count(), 1); |
|
713 |
QCOMPARE(rightWidget.touchBeginPoints.count(), 1); |
|
714 |
{ |
|
715 |
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first(); |
|
716 |
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
717 |
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
718 |
QCOMPARE(leftTouchPoint.pos(), leftPos); |
|
719 |
QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
720 |
QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
721 |
QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); |
|
722 |
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
723 |
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
724 |
QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); |
|
725 |
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
726 |
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
727 |
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
728 |
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
729 |
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
730 |
QCOMPARE(leftTouchPoint.rect(), QRectF(leftPos, QSizeF(0, 0))); |
|
731 |
QCOMPARE(leftTouchPoint.sceneRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
732 |
QCOMPARE(leftTouchPoint.screenRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
733 |
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
734 |
||
735 |
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first(); |
|
736 |
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
737 |
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
738 |
QCOMPARE(rightTouchPoint.pos(), rightPos); |
|
739 |
QCOMPARE(rightTouchPoint.startPos(), rightPos); |
|
740 |
QCOMPARE(rightTouchPoint.lastPos(), rightPos); |
|
741 |
QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); |
|
742 |
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
743 |
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
744 |
QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); |
|
745 |
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
746 |
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
747 |
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
748 |
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
749 |
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
750 |
QCOMPARE(rightTouchPoint.rect(), QRectF(rightPos, QSizeF(0, 0))); |
|
751 |
QCOMPARE(rightTouchPoint.sceneRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
752 |
QCOMPARE(rightTouchPoint.screenRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
753 |
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
754 |
} |
|
755 |
||
756 |
// generate TouchUpdates on both leftWidget and rightWidget |
|
757 |
rawTouchPoints[0].setState(Qt::TouchPointMoved); |
|
758 |
rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
759 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
760 |
rawTouchPoints[1].setState(Qt::TouchPointMoved); |
|
761 |
rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
762 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
763 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
|
764 |
QVERIFY(!touchWidget.seenTouchBegin); |
|
765 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
766 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
767 |
QVERIFY(leftWidget.seenTouchBegin); |
|
768 |
QVERIFY(leftWidget.seenTouchUpdate); |
|
769 |
QVERIFY(!leftWidget.seenTouchEnd); |
|
770 |
QVERIFY(rightWidget.seenTouchBegin); |
|
771 |
QVERIFY(rightWidget.seenTouchUpdate); |
|
772 |
QVERIFY(!rightWidget.seenTouchEnd); |
|
773 |
QCOMPARE(leftWidget.touchUpdatePoints.count(), 1); |
|
774 |
QCOMPARE(rightWidget.touchUpdatePoints.count(), 1); |
|
775 |
{ |
|
776 |
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.first(); |
|
777 |
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
778 |
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
779 |
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
780 |
QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
781 |
QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
782 |
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
783 |
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
784 |
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
785 |
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
786 |
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
787 |
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
788 |
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
789 |
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
790 |
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
791 |
QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
792 |
QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
793 |
QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
794 |
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
795 |
||
796 |
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first(); |
|
797 |
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
798 |
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
799 |
QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); |
|
800 |
QCOMPARE(rightTouchPoint.startPos(), rightPos); |
|
801 |
QCOMPARE(rightTouchPoint.lastPos(), rightPos); |
|
802 |
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
803 |
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
804 |
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
805 |
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
806 |
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
807 |
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
808 |
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
809 |
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
810 |
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
811 |
QCOMPARE(rightTouchPoint.rect(), QRectF(rightWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
812 |
QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
813 |
QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
814 |
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
815 |
} |
|
816 |
||
817 |
// generate TouchEnds on both leftWidget and rightWidget |
|
818 |
rawTouchPoints[0].setState(Qt::TouchPointReleased); |
|
819 |
rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
820 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
821 |
rawTouchPoints[1].setState(Qt::TouchPointReleased); |
|
822 |
rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
823 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
824 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
|
825 |
QVERIFY(!touchWidget.seenTouchBegin); |
|
826 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
827 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
828 |
QVERIFY(leftWidget.seenTouchBegin); |
|
829 |
QVERIFY(leftWidget.seenTouchUpdate); |
|
830 |
QVERIFY(leftWidget.seenTouchEnd); |
|
831 |
QVERIFY(rightWidget.seenTouchBegin); |
|
832 |
QVERIFY(rightWidget.seenTouchUpdate); |
|
833 |
QVERIFY(rightWidget.seenTouchEnd); |
|
834 |
QCOMPARE(leftWidget.touchEndPoints.count(), 1); |
|
835 |
QCOMPARE(rightWidget.touchEndPoints.count(), 1); |
|
836 |
{ |
|
837 |
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.first(); |
|
838 |
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
839 |
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
840 |
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
841 |
QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
842 |
QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.pos()); |
|
843 |
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
844 |
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
845 |
QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePos()); |
|
846 |
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
847 |
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
848 |
QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.screenPos()); |
|
849 |
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
850 |
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
851 |
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
852 |
QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
853 |
QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
854 |
QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
855 |
QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); |
|
856 |
||
857 |
QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first(); |
|
858 |
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
859 |
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
860 |
QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); |
|
861 |
QCOMPARE(rightTouchPoint.startPos(), rightPos); |
|
862 |
QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.pos()); |
|
863 |
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
864 |
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
865 |
QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePos()); |
|
866 |
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
867 |
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
868 |
QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.screenPos()); |
|
869 |
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
870 |
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
871 |
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
872 |
QCOMPARE(rightTouchPoint.rect(), QRectF(rightWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
873 |
QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
874 |
QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
875 |
QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); |
|
876 |
} |
|
877 |
} |
|
878 |
||
879 |
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() |
|
880 |
{ |
|
881 |
tst_QTouchEventWidget touchWidget; |
|
882 |
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
883 |
touchWidget.setGeometry(100, 100, 400, 300); |
|
884 |
||
885 |
tst_QTouchEventWidget leftWidget; |
|
886 |
leftWidget.setParent(&touchWidget); |
|
887 |
leftWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
888 |
leftWidget.setGeometry(0, 100, 100, 100); |
|
889 |
leftWidget.show(); |
|
890 |
||
891 |
tst_QTouchEventWidget rightWidget; |
|
892 |
rightWidget.setParent(&touchWidget); |
|
893 |
rightWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
|
894 |
rightWidget.setGeometry(300, 100, 100, 100); |
|
895 |
rightWidget.show(); |
|
896 |
||
897 |
QPointF leftPos = leftWidget.rect().center(); |
|
898 |
QPointF rightPos = rightWidget.rect().center(); |
|
899 |
QPointF centerPos = touchWidget.rect().center(); |
|
900 |
QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint()); |
|
901 |
QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint()); |
|
902 |
QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint()); |
|
903 |
QPointF delta(10, 10); |
|
904 |
QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
|
905 |
||
906 |
QList<QTouchEvent::TouchPoint> rawTouchPoints; |
|
907 |
rawTouchPoints.append(QTouchEvent::TouchPoint(0)); |
|
908 |
rawTouchPoints.append(QTouchEvent::TouchPoint(1)); |
|
909 |
||
910 |
// generate TouchBegin on leftWidget only |
|
911 |
rawTouchPoints[0].setState(Qt::TouchPointPressed); |
|
912 |
rawTouchPoints[0].setScreenPos(leftScreenPos); |
|
913 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
914 |
rawTouchPoints[1].setState(Qt::TouchPointPressed); |
|
915 |
rawTouchPoints[1].setScreenPos(rightScreenPos); |
|
916 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
917 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints); |
|
918 |
QVERIFY(!touchWidget.seenTouchBegin); |
|
919 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
920 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
921 |
QVERIFY(leftWidget.seenTouchBegin); |
|
922 |
QVERIFY(!leftWidget.seenTouchUpdate); |
|
923 |
QVERIFY(!leftWidget.seenTouchEnd); |
|
924 |
QVERIFY(!rightWidget.seenTouchBegin); |
|
925 |
QVERIFY(!rightWidget.seenTouchUpdate); |
|
926 |
QVERIFY(!rightWidget.seenTouchEnd); |
|
927 |
QCOMPARE(leftWidget.touchBeginPoints.count(), 2); |
|
928 |
QCOMPARE(rightWidget.touchBeginPoints.count(), 0); |
|
929 |
{ |
|
930 |
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0); |
|
931 |
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
932 |
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
933 |
QCOMPARE(leftTouchPoint.pos(), leftPos); |
|
934 |
QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
935 |
QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
936 |
QCOMPARE(leftTouchPoint.scenePos(), leftScreenPos); |
|
937 |
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
938 |
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
939 |
QCOMPARE(leftTouchPoint.screenPos(), leftScreenPos); |
|
940 |
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
941 |
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
942 |
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
943 |
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
944 |
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
945 |
QCOMPARE(leftTouchPoint.rect(), QRectF(leftPos, QSizeF(0, 0))); |
|
946 |
QCOMPARE(leftTouchPoint.sceneRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
947 |
QCOMPARE(leftTouchPoint.screenRect(), QRectF(leftScreenPos, QSizeF(0, 0))); |
|
948 |
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
949 |
||
950 |
QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchBeginPoints.at(1); |
|
951 |
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
952 |
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
953 |
QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
954 |
QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
955 |
QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
956 |
QCOMPARE(rightTouchPoint.scenePos(), rightScreenPos); |
|
957 |
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
958 |
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
959 |
QCOMPARE(rightTouchPoint.screenPos(), rightScreenPos); |
|
960 |
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
961 |
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
962 |
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
963 |
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
964 |
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
965 |
QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()), QSizeF(0, 0))); |
|
966 |
QCOMPARE(rightTouchPoint.sceneRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
967 |
QCOMPARE(rightTouchPoint.screenRect(), QRectF(rightScreenPos, QSizeF(0, 0))); |
|
968 |
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
969 |
} |
|
970 |
||
971 |
// generate TouchUpdate on leftWidget |
|
972 |
rawTouchPoints[0].setState(Qt::TouchPointMoved); |
|
973 |
rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
974 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
975 |
rawTouchPoints[1].setState(Qt::TouchPointMoved); |
|
976 |
rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
977 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
978 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints); |
|
979 |
QVERIFY(!touchWidget.seenTouchBegin); |
|
980 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
981 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
982 |
QVERIFY(leftWidget.seenTouchBegin); |
|
983 |
QVERIFY(leftWidget.seenTouchUpdate); |
|
984 |
QVERIFY(!leftWidget.seenTouchEnd); |
|
985 |
QVERIFY(!rightWidget.seenTouchBegin); |
|
986 |
QVERIFY(!rightWidget.seenTouchUpdate); |
|
987 |
QVERIFY(!rightWidget.seenTouchEnd); |
|
988 |
QCOMPARE(leftWidget.touchUpdatePoints.count(), 2); |
|
989 |
QCOMPARE(rightWidget.touchUpdatePoints.count(), 0); |
|
990 |
{ |
|
991 |
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0); |
|
992 |
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
993 |
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
994 |
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
995 |
QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
996 |
QCOMPARE(leftTouchPoint.lastPos(), leftPos); |
|
997 |
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
998 |
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
999 |
QCOMPARE(leftTouchPoint.lastScenePos(), leftScreenPos); |
|
1000 |
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
1001 |
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
1002 |
QCOMPARE(leftTouchPoint.lastScreenPos(), leftScreenPos); |
|
1003 |
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1004 |
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1005 |
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1006 |
QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
1007 |
QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1008 |
QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1009 |
QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); |
|
1010 |
||
1011 |
QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchUpdatePoints.at(1); |
|
1012 |
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
1013 |
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
1014 |
QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
1015 |
QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
1016 |
QCOMPARE(rightTouchPoint.lastPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
1017 |
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
1018 |
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
1019 |
QCOMPARE(rightTouchPoint.lastScenePos(), rightScreenPos); |
|
1020 |
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
1021 |
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
1022 |
QCOMPARE(rightTouchPoint.lastScreenPos(), rightScreenPos); |
|
1023 |
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1024 |
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1025 |
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1026 |
QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
1027 |
QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1028 |
QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1029 |
QCOMPARE(rightTouchPoint.pressure(), qreal(1.)); |
|
1030 |
} |
|
1031 |
||
1032 |
// generate TouchEnd on leftWidget |
|
1033 |
rawTouchPoints[0].setState(Qt::TouchPointReleased); |
|
1034 |
rawTouchPoints[0].setScreenPos(centerScreenPos); |
|
1035 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
|
1036 |
rawTouchPoints[1].setState(Qt::TouchPointReleased); |
|
1037 |
rawTouchPoints[1].setScreenPos(centerScreenPos); |
|
1038 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
|
1039 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchPad, rawTouchPoints); |
|
1040 |
QVERIFY(!touchWidget.seenTouchBegin); |
|
1041 |
QVERIFY(!touchWidget.seenTouchUpdate); |
|
1042 |
QVERIFY(!touchWidget.seenTouchEnd); |
|
1043 |
QVERIFY(leftWidget.seenTouchBegin); |
|
1044 |
QVERIFY(leftWidget.seenTouchUpdate); |
|
1045 |
QVERIFY(leftWidget.seenTouchEnd); |
|
1046 |
QVERIFY(!rightWidget.seenTouchBegin); |
|
1047 |
QVERIFY(!rightWidget.seenTouchUpdate); |
|
1048 |
QVERIFY(!rightWidget.seenTouchEnd); |
|
1049 |
QCOMPARE(leftWidget.touchEndPoints.count(), 2); |
|
1050 |
QCOMPARE(rightWidget.touchEndPoints.count(), 0); |
|
1051 |
{ |
|
1052 |
QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.at(0); |
|
1053 |
QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); |
|
1054 |
QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); |
|
1055 |
QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
1056 |
QCOMPARE(leftTouchPoint.startPos(), leftPos); |
|
1057 |
QCOMPARE(leftTouchPoint.lastPos(), leftTouchPoint.pos()); |
|
1058 |
QCOMPARE(leftTouchPoint.scenePos(), centerScreenPos); |
|
1059 |
QCOMPARE(leftTouchPoint.startScenePos(), leftScreenPos); |
|
1060 |
QCOMPARE(leftTouchPoint.lastScenePos(), leftTouchPoint.scenePos()); |
|
1061 |
QCOMPARE(leftTouchPoint.screenPos(), centerScreenPos); |
|
1062 |
QCOMPARE(leftTouchPoint.startScreenPos(), leftScreenPos); |
|
1063 |
QCOMPARE(leftTouchPoint.lastScreenPos(), leftTouchPoint.screenPos()); |
|
1064 |
QCOMPARE(leftTouchPoint.normalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1065 |
QCOMPARE(leftTouchPoint.startNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1066 |
QCOMPARE(leftTouchPoint.lastNormalizedPos(), rawTouchPoints[0].normalizedPos()); |
|
1067 |
QCOMPARE(leftTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
1068 |
QCOMPARE(leftTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1069 |
QCOMPARE(leftTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1070 |
QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); |
|
1071 |
||
1072 |
QTouchEvent::TouchPoint rightTouchPoint = leftWidget.touchEndPoints.at(1); |
|
1073 |
QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); |
|
1074 |
QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); |
|
1075 |
QCOMPARE(rightTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); |
|
1076 |
QCOMPARE(rightTouchPoint.startPos(), QPointF(leftWidget.mapFromGlobal(rightScreenPos.toPoint()))); |
|
1077 |
QCOMPARE(rightTouchPoint.lastPos(), rightTouchPoint.pos()); |
|
1078 |
QCOMPARE(rightTouchPoint.scenePos(), centerScreenPos); |
|
1079 |
QCOMPARE(rightTouchPoint.startScenePos(), rightScreenPos); |
|
1080 |
QCOMPARE(rightTouchPoint.lastScenePos(), rightTouchPoint.scenePos()); |
|
1081 |
QCOMPARE(rightTouchPoint.screenPos(), centerScreenPos); |
|
1082 |
QCOMPARE(rightTouchPoint.startScreenPos(), rightScreenPos); |
|
1083 |
QCOMPARE(rightTouchPoint.lastScreenPos(), rightTouchPoint.screenPos()); |
|
1084 |
QCOMPARE(rightTouchPoint.normalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1085 |
QCOMPARE(rightTouchPoint.startNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1086 |
QCOMPARE(rightTouchPoint.lastNormalizedPos(), rawTouchPoints[1].normalizedPos()); |
|
1087 |
QCOMPARE(rightTouchPoint.rect(), QRectF(leftWidget.mapFromParent(centerPos.toPoint()), QSizeF(0, 0))); |
|
1088 |
QCOMPARE(rightTouchPoint.sceneRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1089 |
QCOMPARE(rightTouchPoint.screenRect(), QRectF(centerScreenPos, QSizeF(0, 0))); |
|
1090 |
QCOMPARE(rightTouchPoint.pressure(), qreal(0.)); |
|
1091 |
} |
|
1092 |
} |
|
1093 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1094 |
void tst_QTouchEvent::deleteInEventHandler() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1095 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1096 |
// QWidget |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1097 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1098 |
QWidget window; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1099 |
tst_QTouchEventWidget *child1, *child2, *child3; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1100 |
child1 = new tst_QTouchEventWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1101 |
child2 = new tst_QTouchEventWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1102 |
child3 = new tst_QTouchEventWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1103 |
child1->setParent(&window); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1104 |
child2->setParent(&window); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1105 |
child3->setParent(&window); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1106 |
child1->setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1107 |
child2->setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1108 |
child3->setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1109 |
child1->deleteInTouchBegin = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1110 |
child2->deleteInTouchUpdate = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1111 |
child3->deleteInTouchEnd = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1112 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1113 |
QList<QTouchEvent::TouchPoint> touchPoints; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1114 |
touchPoints.append(QTouchEvent::TouchPoint(0)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1115 |
QTouchEvent touchBeginEvent(QEvent::TouchBegin, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1116 |
QTouchEvent::TouchScreen, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1117 |
Qt::NoModifier, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1118 |
Qt::TouchPointPressed, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1119 |
touchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1120 |
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1121 |
QTouchEvent::TouchScreen, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1122 |
Qt::NoModifier, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1123 |
Qt::TouchPointStationary, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1124 |
touchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1125 |
QTouchEvent touchEndEvent(QEvent::TouchEnd, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1126 |
QTouchEvent::TouchScreen, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1127 |
Qt::NoModifier, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1128 |
Qt::TouchPointReleased, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1129 |
touchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1130 |
QWeakPointer<QWidget> p; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1131 |
bool res; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1132 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1133 |
touchBeginEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1134 |
p = child1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1135 |
res = QApplication::sendEvent(child1, &touchBeginEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1136 |
// event is handled, but widget should be deleted |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1137 |
QVERIFY(res && touchBeginEvent.isAccepted() && p.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1138 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
touchBeginEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1140 |
p = child2; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1141 |
res = QApplication::sendEvent(child2, &touchBeginEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1142 |
QVERIFY(res && touchBeginEvent.isAccepted() && !p.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1143 |
touchUpdateEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1144 |
res = QApplication::sendEvent(child2, &touchUpdateEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1145 |
QVERIFY(res && touchUpdateEvent.isAccepted() && p.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1146 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1147 |
touchBeginEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1148 |
p = child3; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1149 |
res = QApplication::sendEvent(child3, &touchBeginEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1150 |
QVERIFY(res && touchBeginEvent.isAccepted() && !p.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1151 |
touchUpdateEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1152 |
res = QApplication::sendEvent(child3, &touchUpdateEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1153 |
QVERIFY(res && touchUpdateEvent.isAccepted() && !p.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1154 |
touchEndEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1155 |
res = QApplication::sendEvent(child3, &touchEndEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1156 |
QVERIFY(res && touchEndEvent.isAccepted() && p.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1157 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1158 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1159 |
// QGraphicsView |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1160 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1161 |
QGraphicsScene scene; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1162 |
QGraphicsView view(&scene); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1163 |
tst_QTouchEventGraphicsItem *root, *child1, *child2, *child3; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1164 |
root = new tst_QTouchEventGraphicsItem; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1165 |
child1 = new tst_QTouchEventGraphicsItem; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1166 |
child2 = new tst_QTouchEventGraphicsItem; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1167 |
child3 = new tst_QTouchEventGraphicsItem; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1168 |
child1->setParentItem(root); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
child2->setParentItem(root); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1170 |
child3->setParentItem(root); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1171 |
child1->setZValue(1.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1172 |
child2->setZValue(0.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1173 |
child3->setZValue(-1.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1174 |
child1->setAcceptTouchEvents(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1175 |
child2->setAcceptTouchEvents(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1176 |
child3->setAcceptTouchEvents(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1177 |
child1->deleteInTouchBegin = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1178 |
child2->deleteInTouchUpdate = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1179 |
child3->deleteInTouchEnd = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1180 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1181 |
scene.addItem(root); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1182 |
view.resize(200, 200); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1183 |
view.fitInView(scene.sceneRect()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1184 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1185 |
QTouchEvent::TouchPoint touchPoint(0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1186 |
touchPoint.setState(Qt::TouchPointPressed); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1187 |
touchPoint.setPos(view.mapFromScene(child1->mapToScene(child1->boundingRect().center()))); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1188 |
touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1189 |
touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1190 |
QList<QTouchEvent::TouchPoint> touchPoints; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1191 |
touchPoints.append(touchPoint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1192 |
QTouchEvent touchBeginEvent(QEvent::TouchBegin, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1193 |
QTouchEvent::TouchScreen, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1194 |
Qt::NoModifier, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1195 |
Qt::TouchPointPressed, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1196 |
touchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1197 |
touchPoints[0].setState(Qt::TouchPointMoved); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1198 |
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1199 |
QTouchEvent::TouchScreen, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1200 |
Qt::NoModifier, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1201 |
Qt::TouchPointMoved, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1202 |
touchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1203 |
touchPoints[0].setState(Qt::TouchPointReleased); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1204 |
QTouchEvent touchEndEvent(QEvent::TouchEnd, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1205 |
QTouchEvent::TouchScreen, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1206 |
Qt::NoModifier, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1207 |
Qt::TouchPointReleased, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1208 |
touchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1209 |
bool res; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1210 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1211 |
child1->weakpointer = &child1; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1212 |
touchBeginEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1213 |
res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1214 |
QVERIFY(res && touchBeginEvent.isAccepted() && !child1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1215 |
touchUpdateEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1216 |
res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1217 |
QVERIFY(res && touchUpdateEvent.isAccepted() && !child1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1218 |
touchEndEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1219 |
res = QApplication::sendEvent(view.viewport(), &touchEndEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1220 |
QVERIFY(res && touchUpdateEvent.isAccepted() && !child1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1221 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1222 |
child2->weakpointer = &child2; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1223 |
touchBeginEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1224 |
res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1225 |
QVERIFY(res && touchBeginEvent.isAccepted() && child2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1226 |
touchUpdateEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1227 |
res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1228 |
QVERIFY(res && !touchUpdateEvent.isAccepted() && !child2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1229 |
touchEndEvent.ignore(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1230 |
res = QApplication::sendEvent(view.viewport(), &touchEndEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1231 |
QVERIFY(res && !touchUpdateEvent.isAccepted() && !child2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1232 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1233 |
child3->weakpointer = &child3; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1234 |
res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1235 |
QVERIFY(res && touchBeginEvent.isAccepted() && child3); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1236 |
res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1237 |
QVERIFY(res && !touchUpdateEvent.isAccepted() && child3); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1238 |
res = QApplication::sendEvent(view.viewport(), &touchEndEvent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1239 |
QVERIFY(res && !touchEndEvent.isAccepted() && !child3); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1240 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1241 |
delete root; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1242 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1243 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1244 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1245 |
void tst_QTouchEvent::deleteInRawEventTranslation() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1246 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1247 |
tst_QTouchEventWidget touchWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1248 |
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1249 |
touchWidget.setGeometry(100, 100, 300, 300); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1250 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1251 |
tst_QTouchEventWidget *leftWidget = new tst_QTouchEventWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1252 |
leftWidget->setParent(&touchWidget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1253 |
leftWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1254 |
leftWidget->setGeometry(0, 100, 100, 100); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1255 |
leftWidget->deleteInTouchBegin = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1256 |
leftWidget->show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1257 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1258 |
tst_QTouchEventWidget *centerWidget = new tst_QTouchEventWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1259 |
centerWidget->setParent(&touchWidget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1260 |
centerWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1261 |
centerWidget->setGeometry(100, 100, 100, 100); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1262 |
centerWidget->deleteInTouchUpdate = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1263 |
centerWidget->show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1264 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1265 |
tst_QTouchEventWidget *rightWidget = new tst_QTouchEventWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1266 |
rightWidget->setParent(&touchWidget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1267 |
rightWidget->setAttribute(Qt::WA_AcceptTouchEvents); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1268 |
rightWidget->setGeometry(200, 100, 100, 100); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1269 |
rightWidget->deleteInTouchEnd = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1270 |
rightWidget->show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1271 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1272 |
QPointF leftPos = leftWidget->rect().center(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1273 |
QPointF centerPos = centerWidget->rect().center(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1274 |
QPointF rightPos = rightWidget->rect().center(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1275 |
QPointF leftScreenPos = leftWidget->mapToGlobal(leftPos.toPoint()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1276 |
QPointF centerScreenPos = centerWidget->mapToGlobal(centerPos.toPoint()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1277 |
QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1278 |
QRectF screenGeometry = qApp->desktop()->screenGeometry(&touchWidget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1279 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1280 |
QWeakPointer<QWidget> pl = leftWidget, pc = centerWidget, pr = rightWidget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1281 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1282 |
QList<QTouchEvent::TouchPoint> rawTouchPoints; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1283 |
rawTouchPoints.append(QTouchEvent::TouchPoint(0)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1284 |
rawTouchPoints.append(QTouchEvent::TouchPoint(1)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1285 |
rawTouchPoints.append(QTouchEvent::TouchPoint(2)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1286 |
rawTouchPoints[0].setState(Qt::TouchPointPressed); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1287 |
rawTouchPoints[0].setScreenPos(leftScreenPos); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1288 |
rawTouchPoints[0].setNormalizedPos(normalized(rawTouchPoints[0].pos(), screenGeometry)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1289 |
rawTouchPoints[1].setState(Qt::TouchPointPressed); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1290 |
rawTouchPoints[1].setScreenPos(centerScreenPos); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1291 |
rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1292 |
rawTouchPoints[2].setState(Qt::TouchPointPressed); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1293 |
rawTouchPoints[2].setScreenPos(rightScreenPos); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1294 |
rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1295 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1296 |
// generate begin events on all widgets, the left widget should die |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1297 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1298 |
QVERIFY(pl.isNull() && !pc.isNull() && !pr.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1299 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1300 |
// generate update events on all widget, the center widget should die |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1301 |
rawTouchPoints[0].setState(Qt::TouchPointMoved); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1302 |
rawTouchPoints[1].setState(Qt::TouchPointMoved); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1303 |
rawTouchPoints[2].setState(Qt::TouchPointMoved); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1304 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1305 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1306 |
// generate end events on all widget, the right widget should die |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1307 |
rawTouchPoints[0].setState(Qt::TouchPointReleased); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1308 |
rawTouchPoints[1].setState(Qt::TouchPointReleased); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1309 |
rawTouchPoints[2].setState(Qt::TouchPointReleased); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1310 |
qt_translateRawTouchEvent(&touchWidget, QTouchEvent::TouchScreen, rawTouchPoints); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1311 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1312 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1313 |
void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin() |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1314 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1315 |
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1316 |
rect->setAcceptTouchEvents(true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1317 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1318 |
QGraphicsRectItem *mainRect = new QGraphicsRectItem(0, 0, 100, 100, rect); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1319 |
mainRect->setBrush(Qt::lightGray); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1320 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1321 |
QGraphicsRectItem *button = new QGraphicsRectItem(-20, -20, 40, 40, mainRect); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1322 |
button->setPos(50, 50); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1323 |
button->setBrush(Qt::darkGreen); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1324 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1325 |
QGraphicsView view; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1326 |
QGraphicsScene scene; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1327 |
scene.addItem(rect); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1328 |
scene.setSceneRect(0,0,100,100); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1329 |
view.setScene(&scene); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1330 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1331 |
view.show(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1332 |
QTest::qWaitForWindowShown(&view); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1333 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1334 |
QPoint centerPos = view.mapFromScene(rect->boundingRect().center()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1335 |
// Touch the button |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1336 |
QTest::touchEvent(view.viewport()).press(0, centerPos); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1337 |
QTest::touchEvent(view.viewport()).release(0, centerPos); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1338 |
// Touch outside of the button |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1339 |
QTest::touchEvent(view.viewport()).press(0, view.mapFromScene(QPoint(10, 10))); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1340 |
QTest::touchEvent(view.viewport()).release(0, view.mapFromScene(QPoint(10, 10))); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1341 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1342 |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1343 |
void tst_QTouchEvent::touchBeginWithGraphicsWidget() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1344 |
{ |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1345 |
QGraphicsScene scene; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1346 |
QGraphicsView view(&scene); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1347 |
tst_QTouchEventGraphicsItem *root; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1348 |
root = new tst_QTouchEventGraphicsItem; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1349 |
root->setAcceptTouchEvents(true); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1350 |
scene.addItem(root); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1351 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1352 |
QGraphicsWidget *glassWidget = new QGraphicsWidget; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1353 |
glassWidget->setMinimumSize(100, 100); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1354 |
scene.addItem(glassWidget); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1355 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1356 |
view.resize(200, 200); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1357 |
view.show(); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1358 |
QTest::qWaitForWindowShown(&view); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1359 |
view.fitInView(scene.sceneRect()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1360 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1361 |
QTest::touchEvent() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1362 |
.press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1363 |
QTest::touchEvent() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1364 |
.stationary(0) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1365 |
.press(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1366 |
QTest::touchEvent() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1367 |
.release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1368 |
.release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1369 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1370 |
QCOMPARE(root->touchBeginCounter, 1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1371 |
QCOMPARE(root->touchUpdateCounter, 1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1372 |
QCOMPARE(root->touchEndCounter, 1); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1373 |
QCOMPARE(root->touchUpdatePoints.size(), 2); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1374 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1375 |
root->reset(); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1376 |
glassWidget->setWindowFlags(Qt::Window); // make the glassWidget a panel |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1377 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1378 |
QTest::touchEvent() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1379 |
.press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1380 |
QTest::touchEvent() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1381 |
.stationary(0) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1382 |
.press(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1383 |
QTest::touchEvent() |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1384 |
.release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()) |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1385 |
.release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport()); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1386 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1387 |
QCOMPARE(root->touchBeginCounter, 0); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1388 |
QCOMPARE(root->touchUpdateCounter, 0); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1389 |
QCOMPARE(root->touchEndCounter, 0); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1390 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1391 |
|
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1392 |
delete root; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1393 |
delete glassWidget; |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1394 |
} |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1395 |
|
0 | 1396 |
QTEST_MAIN(tst_QTouchEvent) |
1397 |
||
1398 |
#include "tst_qtouchevent.moc" |