author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 3 | 41300fa6a67c |
child 7 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
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 test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
#include "../../shared/util.h" |
|
45 |
||
46 |
#include <qevent.h> |
|
47 |
#include <qwidget.h> |
|
48 |
#include <qlayout.h> |
|
49 |
#include <qgesture.h> |
|
50 |
#include <qgesturerecognizer.h> |
|
51 |
#include <qgraphicsitem.h> |
|
52 |
#include <qgraphicsview.h> |
|
53 |
||
54 |
#include <qdebug.h> |
|
55 |
||
56 |
//TESTED_CLASS= |
|
57 |
//TESTED_FILES= |
|
58 |
||
59 |
static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) |
|
60 |
{ |
|
61 |
return view->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); |
|
62 |
} |
|
63 |
||
64 |
class CustomGesture : public QGesture |
|
65 |
{ |
|
66 |
Q_OBJECT |
|
67 |
public: |
|
68 |
static Qt::GestureType GestureType; |
|
69 |
||
70 |
CustomGesture(QObject *parent = 0) |
|
71 |
: QGesture(parent), serial(0) |
|
72 |
{ |
|
73 |
} |
|
74 |
||
75 |
int serial; |
|
76 |
||
77 |
static const int SerialMaybeThreshold; |
|
78 |
static const int SerialStartedThreshold; |
|
79 |
static const int SerialFinishedThreshold; |
|
80 |
}; |
|
81 |
Qt::GestureType CustomGesture::GestureType = Qt::CustomGesture; |
|
82 |
const int CustomGesture::SerialMaybeThreshold = 1; |
|
83 |
const int CustomGesture::SerialStartedThreshold = 3; |
|
84 |
const int CustomGesture::SerialFinishedThreshold = 6; |
|
85 |
||
86 |
class CustomEvent : public QEvent |
|
87 |
{ |
|
88 |
public: |
|
89 |
static int EventType; |
|
90 |
||
91 |
CustomEvent(int serial_ = 0) |
|
92 |
: QEvent(QEvent::Type(CustomEvent::EventType)), |
|
93 |
serial(serial_), hasHotSpot(false) |
|
94 |
{ |
|
95 |
} |
|
96 |
||
97 |
int serial; |
|
98 |
QPointF hotSpot; |
|
99 |
bool hasHotSpot; |
|
100 |
}; |
|
101 |
int CustomEvent::EventType = 0; |
|
102 |
||
103 |
class CustomGestureRecognizer : public QGestureRecognizer |
|
104 |
{ |
|
105 |
public: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
static bool ConsumeEvents; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
|
0 | 108 |
CustomGestureRecognizer() |
109 |
{ |
|
110 |
if (!CustomEvent::EventType) |
|
111 |
CustomEvent::EventType = QEvent::registerEventType(); |
|
112 |
} |
|
113 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
QGesture* create(QObject *) |
0 | 115 |
{ |
116 |
return new CustomGesture; |
|
117 |
} |
|
118 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event) |
0 | 120 |
{ |
121 |
if (event->type() == CustomEvent::EventType) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
QGestureRecognizer::Result result = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
if (CustomGestureRecognizer::ConsumeEvents) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
result |= QGestureRecognizer::ConsumeEventHint; |
0 | 125 |
CustomGesture *g = static_cast<CustomGesture*>(state); |
126 |
CustomEvent *e = static_cast<CustomEvent*>(event); |
|
127 |
g->serial = e->serial; |
|
128 |
if (e->hasHotSpot) |
|
129 |
g->setHotSpot(e->hotSpot); |
|
130 |
if (g->serial >= CustomGesture::SerialFinishedThreshold) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
result |= QGestureRecognizer::FinishGesture; |
0 | 132 |
else if (g->serial >= CustomGesture::SerialStartedThreshold) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
result |= QGestureRecognizer::TriggerGesture; |
0 | 134 |
else if (g->serial >= CustomGesture::SerialMaybeThreshold) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
result |= QGestureRecognizer::MayBeGesture; |
0 | 136 |
else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
result = QGestureRecognizer::CancelGesture; |
0 | 138 |
return result; |
139 |
} |
|
140 |
return QGestureRecognizer::Ignore; |
|
141 |
} |
|
142 |
||
143 |
void reset(QGesture *state) |
|
144 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
CustomGesture *g = static_cast<CustomGesture *>(state); |
0 | 146 |
g->serial = 0; |
147 |
QGestureRecognizer::reset(state); |
|
148 |
} |
|
149 |
}; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
bool CustomGestureRecognizer::ConsumeEvents = false; |
0 | 151 |
|
152 |
// same as CustomGestureRecognizer but triggers early without the maybe state |
|
153 |
class CustomContinuousGestureRecognizer : public QGestureRecognizer |
|
154 |
{ |
|
155 |
public: |
|
156 |
CustomContinuousGestureRecognizer() |
|
157 |
{ |
|
158 |
if (!CustomEvent::EventType) |
|
159 |
CustomEvent::EventType = QEvent::registerEventType(); |
|
160 |
} |
|
161 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
QGesture* create(QObject *) |
0 | 163 |
{ |
164 |
return new CustomGesture; |
|
165 |
} |
|
166 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
QGestureRecognizer::Result recognize(QGesture *state, QObject*, QEvent *event) |
0 | 168 |
{ |
169 |
if (event->type() == CustomEvent::EventType) { |
|
170 |
QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
CustomGesture *g = static_cast<CustomGesture *>(state); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
CustomEvent *e = static_cast<CustomEvent *>(event); |
0 | 173 |
g->serial = e->serial; |
174 |
if (e->hasHotSpot) |
|
175 |
g->setHotSpot(e->hotSpot); |
|
176 |
if (g->serial >= CustomGesture::SerialFinishedThreshold) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
result |= QGestureRecognizer::FinishGesture; |
0 | 178 |
else if (g->serial >= CustomGesture::SerialMaybeThreshold) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
result |= QGestureRecognizer::TriggerGesture; |
0 | 180 |
else |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
result = QGestureRecognizer::CancelGesture; |
0 | 182 |
return result; |
183 |
} |
|
184 |
return QGestureRecognizer::Ignore; |
|
185 |
} |
|
186 |
||
187 |
void reset(QGesture *state) |
|
188 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
CustomGesture *g = static_cast<CustomGesture *>(state); |
0 | 190 |
g->serial = 0; |
191 |
QGestureRecognizer::reset(state); |
|
192 |
} |
|
193 |
}; |
|
194 |
||
195 |
class GestureWidget : public QWidget |
|
196 |
{ |
|
197 |
Q_OBJECT |
|
198 |
public: |
|
199 |
GestureWidget(const char *name = 0, QWidget *parent = 0) |
|
200 |
: QWidget(parent) |
|
201 |
{ |
|
202 |
if (name) |
|
203 |
setObjectName(QLatin1String(name)); |
|
204 |
reset(); |
|
205 |
acceptGestureOverride = false; |
|
206 |
} |
|
207 |
void reset() |
|
208 |
{ |
|
209 |
customEventsReceived = 0; |
|
210 |
gestureEventsReceived = 0; |
|
211 |
gestureOverrideEventsReceived = 0; |
|
212 |
events.clear(); |
|
213 |
overrideEvents.clear(); |
|
214 |
ignoredGestures.clear(); |
|
215 |
} |
|
216 |
||
217 |
int customEventsReceived; |
|
218 |
int gestureEventsReceived; |
|
219 |
int gestureOverrideEventsReceived; |
|
220 |
struct Events |
|
221 |
{ |
|
222 |
QList<Qt::GestureType> all; |
|
223 |
QList<Qt::GestureType> started; |
|
224 |
QList<Qt::GestureType> updated; |
|
225 |
QList<Qt::GestureType> finished; |
|
226 |
QList<Qt::GestureType> canceled; |
|
227 |
||
228 |
void clear() |
|
229 |
{ |
|
230 |
all.clear(); |
|
231 |
started.clear(); |
|
232 |
updated.clear(); |
|
233 |
finished.clear(); |
|
234 |
canceled.clear(); |
|
235 |
} |
|
236 |
} events, overrideEvents; |
|
237 |
||
238 |
bool acceptGestureOverride; |
|
239 |
QSet<Qt::GestureType> ignoredGestures; |
|
240 |
||
241 |
protected: |
|
242 |
bool event(QEvent *event) |
|
243 |
{ |
|
244 |
Events *eventsPtr = 0; |
|
245 |
if (event->type() == QEvent::Gesture) { |
|
246 |
QGestureEvent *e = static_cast<QGestureEvent*>(event); |
|
247 |
++gestureEventsReceived; |
|
248 |
eventsPtr = &events; |
|
249 |
foreach(Qt::GestureType type, ignoredGestures) |
|
250 |
e->ignore(e->gesture(type)); |
|
251 |
} else if (event->type() == QEvent::GestureOverride) { |
|
252 |
++gestureOverrideEventsReceived; |
|
253 |
eventsPtr = &overrideEvents; |
|
254 |
if (acceptGestureOverride) |
|
255 |
event->accept(); |
|
256 |
} |
|
257 |
if (eventsPtr) { |
|
258 |
QGestureEvent *e = static_cast<QGestureEvent*>(event); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
259 |
QList<QGesture*> gestures = e->gestures(); |
0 | 260 |
foreach(QGesture *g, gestures) { |
261 |
eventsPtr->all << g->gestureType(); |
|
262 |
switch(g->state()) { |
|
263 |
case Qt::GestureStarted: |
|
264 |
eventsPtr->started << g->gestureType(); |
|
265 |
break; |
|
266 |
case Qt::GestureUpdated: |
|
267 |
eventsPtr->updated << g->gestureType(); |
|
268 |
break; |
|
269 |
case Qt::GestureFinished: |
|
270 |
eventsPtr->finished << g->gestureType(); |
|
271 |
break; |
|
272 |
case Qt::GestureCanceled: |
|
273 |
eventsPtr->canceled << g->gestureType(); |
|
274 |
break; |
|
275 |
default: |
|
276 |
Q_ASSERT(false); |
|
277 |
} |
|
278 |
} |
|
279 |
} else if (event->type() == CustomEvent::EventType) { |
|
280 |
++customEventsReceived; |
|
281 |
} else { |
|
282 |
return QWidget::event(event); |
|
283 |
} |
|
284 |
return true; |
|
285 |
} |
|
286 |
}; |
|
287 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
// TODO rename to sendGestureSequence |
0 | 289 |
static void sendCustomGesture(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0) |
290 |
{ |
|
291 |
for (int i = CustomGesture::SerialMaybeThreshold; |
|
292 |
i <= CustomGesture::SerialFinishedThreshold; ++i) { |
|
293 |
event->serial = i; |
|
294 |
if (scene) |
|
295 |
scene->sendEvent(qobject_cast<QGraphicsObject *>(object), event); |
|
296 |
else |
|
297 |
QApplication::sendEvent(object, event); |
|
298 |
} |
|
299 |
} |
|
300 |
||
301 |
class tst_Gestures : public QObject |
|
302 |
{ |
|
303 |
Q_OBJECT |
|
304 |
||
305 |
public: |
|
306 |
tst_Gestures(); |
|
307 |
virtual ~tst_Gestures(); |
|
308 |
||
309 |
public slots: |
|
310 |
void initTestCase(); |
|
311 |
void cleanupTestCase(); |
|
312 |
void init(); |
|
313 |
void cleanup(); |
|
314 |
||
315 |
private slots: |
|
316 |
void customGesture(); |
|
317 |
void autoCancelingGestures(); |
|
318 |
void gestureOverChild(); |
|
319 |
void multipleWidgetOnlyGestureInTree(); |
|
320 |
void conflictingGestures(); |
|
321 |
void finishedWithoutStarted(); |
|
322 |
void unknownGesture(); |
|
323 |
void graphicsItemGesture(); |
|
324 |
void graphicsItemTreeGesture(); |
|
325 |
void explicitGraphicsObjectTarget(); |
|
326 |
void gestureOverChildGraphicsItem(); |
|
327 |
void twoGesturesOnDifferentLevel(); |
|
328 |
void multipleGesturesInTree(); |
|
329 |
void multipleGesturesInComplexTree(); |
|
330 |
void testMapToScene(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
331 |
void ungrabGesture(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
332 |
void consumeEventHint(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
void unregisterRecognizer(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
void autoCancelGestures(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
335 |
void autoCancelGestures2(); |
0 | 336 |
}; |
337 |
||
338 |
tst_Gestures::tst_Gestures() |
|
339 |
{ |
|
340 |
} |
|
341 |
||
342 |
tst_Gestures::~tst_Gestures() |
|
343 |
{ |
|
344 |
} |
|
345 |
||
346 |
void tst_Gestures::initTestCase() |
|
347 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
348 |
CustomGesture::GestureType = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
0 | 349 |
QVERIFY(CustomGesture::GestureType != Qt::GestureType(0)); |
350 |
QVERIFY(CustomGesture::GestureType != Qt::CustomGesture); |
|
351 |
} |
|
352 |
||
353 |
void tst_Gestures::cleanupTestCase() |
|
354 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
355 |
QGestureRecognizer::unregisterRecognizer(CustomGesture::GestureType); |
0 | 356 |
} |
357 |
||
358 |
void tst_Gestures::init() |
|
359 |
{ |
|
360 |
} |
|
361 |
||
362 |
void tst_Gestures::cleanup() |
|
363 |
{ |
|
364 |
} |
|
365 |
||
366 |
void tst_Gestures::customGesture() |
|
367 |
{ |
|
368 |
GestureWidget widget; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 370 |
CustomEvent event; |
371 |
sendCustomGesture(&event, &widget); |
|
372 |
||
373 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
374 |
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
|
375 |
QCOMPARE(widget.customEventsReceived, TotalCustomEventsCount); |
|
376 |
QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount); |
|
377 |
QCOMPARE(widget.gestureOverrideEventsReceived, 0); |
|
378 |
QCOMPARE(widget.events.all.size(), TotalGestureEventsCount); |
|
379 |
for(int i = 0; i < widget.events.all.size(); ++i) |
|
380 |
QCOMPARE(widget.events.all.at(i), CustomGesture::GestureType); |
|
381 |
QCOMPARE(widget.events.started.size(), 1); |
|
382 |
QCOMPARE(widget.events.updated.size(), TotalGestureEventsCount - 2); |
|
383 |
QCOMPARE(widget.events.finished.size(), 1); |
|
384 |
QCOMPARE(widget.events.canceled.size(), 0); |
|
385 |
} |
|
386 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
void tst_Gestures::consumeEventHint() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
388 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
389 |
GestureWidget widget; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
390 |
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
391 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
392 |
CustomGestureRecognizer::ConsumeEvents = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
CustomEvent event; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
394 |
sendCustomGesture(&event, &widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
395 |
CustomGestureRecognizer::ConsumeEvents = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
396 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
397 |
QCOMPARE(widget.customEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
399 |
|
0 | 400 |
void tst_Gestures::autoCancelingGestures() |
401 |
{ |
|
402 |
GestureWidget widget; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
403 |
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 404 |
// send partial gesture. The gesture will be in the "maybe" state, but will |
405 |
// never get enough events to fire, so Qt will have to kill it. |
|
406 |
CustomEvent ev; |
|
407 |
for (int i = CustomGesture::SerialMaybeThreshold; |
|
408 |
i < CustomGesture::SerialStartedThreshold; ++i) { |
|
409 |
ev.serial = i; |
|
410 |
QApplication::sendEvent(&widget, &ev); |
|
411 |
} |
|
412 |
// wait long enough so the gesture manager will cancel the gesture |
|
413 |
QTest::qWait(5000); |
|
414 |
QCOMPARE(widget.customEventsReceived, CustomGesture::SerialStartedThreshold - CustomGesture::SerialMaybeThreshold); |
|
415 |
QCOMPARE(widget.gestureEventsReceived, 0); |
|
416 |
QCOMPARE(widget.gestureOverrideEventsReceived, 0); |
|
417 |
QCOMPARE(widget.events.all.size(), 0); |
|
418 |
} |
|
419 |
||
420 |
void tst_Gestures::gestureOverChild() |
|
421 |
{ |
|
422 |
GestureWidget widget("widget"); |
|
423 |
QVBoxLayout *l = new QVBoxLayout(&widget); |
|
424 |
GestureWidget *child = new GestureWidget("child"); |
|
425 |
l->addWidget(child); |
|
426 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
427 |
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 428 |
|
429 |
CustomEvent event; |
|
430 |
sendCustomGesture(&event, child); |
|
431 |
||
432 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
433 |
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
|
434 |
||
435 |
QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); |
|
436 |
QCOMPARE(widget.customEventsReceived, 0); |
|
437 |
QCOMPARE(child->gestureEventsReceived, 0); |
|
438 |
QCOMPARE(child->gestureOverrideEventsReceived, 0); |
|
439 |
QCOMPARE(widget.gestureEventsReceived, 0); |
|
440 |
QCOMPARE(widget.gestureOverrideEventsReceived, 0); |
|
441 |
||
442 |
// enable gestures over the children |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
443 |
widget.grabGesture(CustomGesture::GestureType); |
0 | 444 |
|
445 |
widget.reset(); |
|
446 |
child->reset(); |
|
447 |
||
448 |
sendCustomGesture(&event, child); |
|
449 |
||
450 |
QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); |
|
451 |
QCOMPARE(widget.customEventsReceived, 0); |
|
452 |
||
453 |
QCOMPARE(child->gestureEventsReceived, 0); |
|
454 |
QCOMPARE(child->gestureOverrideEventsReceived, 0); |
|
455 |
QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount); |
|
456 |
QCOMPARE(widget.gestureOverrideEventsReceived, 0); |
|
457 |
for(int i = 0; i < widget.events.all.size(); ++i) |
|
458 |
QCOMPARE(widget.events.all.at(i), CustomGesture::GestureType); |
|
459 |
QCOMPARE(widget.events.started.size(), 1); |
|
460 |
QCOMPARE(widget.events.updated.size(), TotalGestureEventsCount - 2); |
|
461 |
QCOMPARE(widget.events.finished.size(), 1); |
|
462 |
QCOMPARE(widget.events.canceled.size(), 0); |
|
463 |
} |
|
464 |
||
465 |
void tst_Gestures::multipleWidgetOnlyGestureInTree() |
|
466 |
{ |
|
467 |
GestureWidget parent("parent"); |
|
468 |
QVBoxLayout *l = new QVBoxLayout(&parent); |
|
469 |
GestureWidget *child = new GestureWidget("child"); |
|
470 |
l->addWidget(child); |
|
471 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
472 |
parent.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
child->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 474 |
|
475 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
476 |
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
|
477 |
||
478 |
// sending events to the child and making sure there is no conflict |
|
479 |
CustomEvent event; |
|
480 |
sendCustomGesture(&event, child); |
|
481 |
||
482 |
QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); |
|
483 |
QCOMPARE(parent.customEventsReceived, 0); |
|
484 |
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); |
|
485 |
QCOMPARE(child->gestureOverrideEventsReceived, 0); |
|
486 |
QCOMPARE(parent.gestureEventsReceived, 0); |
|
487 |
QCOMPARE(parent.gestureOverrideEventsReceived, 0); |
|
488 |
||
489 |
parent.reset(); |
|
490 |
child->reset(); |
|
491 |
||
492 |
// same for the parent widget |
|
493 |
sendCustomGesture(&event, &parent); |
|
494 |
||
495 |
QCOMPARE(child->customEventsReceived, 0); |
|
496 |
QCOMPARE(parent.customEventsReceived, TotalCustomEventsCount); |
|
497 |
QCOMPARE(child->gestureEventsReceived, 0); |
|
498 |
QCOMPARE(child->gestureOverrideEventsReceived, 0); |
|
499 |
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); |
|
500 |
QCOMPARE(parent.gestureOverrideEventsReceived, 0); |
|
501 |
} |
|
502 |
||
503 |
void tst_Gestures::conflictingGestures() |
|
504 |
{ |
|
505 |
GestureWidget parent("parent"); |
|
506 |
QVBoxLayout *l = new QVBoxLayout(&parent); |
|
507 |
GestureWidget *child = new GestureWidget("child"); |
|
508 |
l->addWidget(child); |
|
509 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
parent.grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
511 |
child->grabGesture(CustomGesture::GestureType); |
0 | 512 |
|
513 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
514 |
||
515 |
// child accepts the override, parent will not receive anything |
|
516 |
parent.acceptGestureOverride = false; |
|
517 |
child->acceptGestureOverride = true; |
|
518 |
||
519 |
// sending events to the child and making sure there is no conflict |
|
520 |
CustomEvent event; |
|
521 |
sendCustomGesture(&event, child); |
|
522 |
||
523 |
QCOMPARE(child->gestureOverrideEventsReceived, 1); |
|
524 |
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); |
|
525 |
QCOMPARE(parent.gestureOverrideEventsReceived, 0); |
|
526 |
QCOMPARE(parent.gestureEventsReceived, 0); |
|
527 |
||
528 |
parent.reset(); |
|
529 |
child->reset(); |
|
530 |
||
531 |
// parent accepts the override |
|
532 |
parent.acceptGestureOverride = true; |
|
533 |
child->acceptGestureOverride = false; |
|
534 |
||
535 |
// sending events to the child and making sure there is no conflict |
|
536 |
sendCustomGesture(&event, child); |
|
537 |
||
538 |
QCOMPARE(child->gestureOverrideEventsReceived, 1); |
|
539 |
QCOMPARE(child->gestureEventsReceived, 0); |
|
540 |
QCOMPARE(parent.gestureOverrideEventsReceived, 1); |
|
541 |
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); |
|
542 |
||
543 |
parent.reset(); |
|
544 |
child->reset(); |
|
545 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
546 |
// nobody accepts the override, we will send normal events to the closest |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
547 |
// context (i.e. to the child widget) and it will be propagated and |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
548 |
// accepted by the parent widget |
0 | 549 |
parent.acceptGestureOverride = false; |
550 |
child->acceptGestureOverride = false; |
|
551 |
child->ignoredGestures << CustomGesture::GestureType; |
|
552 |
||
553 |
// sending events to the child and making sure there is no conflict |
|
554 |
sendCustomGesture(&event, child); |
|
555 |
||
556 |
QCOMPARE(child->gestureOverrideEventsReceived, 1); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
QCOMPARE(child->gestureEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
QCOMPARE(parent.gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
560 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
561 |
parent.reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
562 |
child->reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
563 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
// nobody accepts the override, and nobody accepts the gesture event |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
parent.acceptGestureOverride = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
566 |
child->acceptGestureOverride = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
parent.ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
568 |
child->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
569 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
// sending events to the child and making sure there is no conflict |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
571 |
sendCustomGesture(&event, child); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
572 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
573 |
QCOMPARE(child->gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
575 |
QCOMPARE(parent.gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
QCOMPARE(parent.gestureEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
577 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
578 |
parent.reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
579 |
child->reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
580 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
// we set an attribute to make sure all gesture events are propagated |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
582 |
parent.grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
583 |
parent.acceptGestureOverride = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
584 |
child->acceptGestureOverride = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
585 |
parent.ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
586 |
child->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
587 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
588 |
// sending events to the child and making sure there is no conflict |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
589 |
sendCustomGesture(&event, child); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
590 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
591 |
QCOMPARE(child->gestureOverrideEventsReceived, 1); |
0 | 592 |
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); |
593 |
QCOMPARE(parent.gestureOverrideEventsReceived, 1); |
|
594 |
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); |
|
595 |
||
596 |
parent.reset(); |
|
597 |
child->reset(); |
|
598 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
599 |
Qt::GestureType ContinuousGesture = QGestureRecognizer::registerRecognizer(new CustomContinuousGestureRecognizer); |
0 | 600 |
static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
601 |
child->grabGesture(ContinuousGesture); |
|
602 |
// child accepts override. And it also receives another custom gesture. |
|
603 |
parent.acceptGestureOverride = false; |
|
604 |
child->acceptGestureOverride = true; |
|
605 |
sendCustomGesture(&event, child); |
|
606 |
||
607 |
QCOMPARE(child->gestureOverrideEventsReceived, 1); |
|
608 |
QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount); |
|
609 |
QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount); |
|
610 |
QCOMPARE(parent.gestureOverrideEventsReceived, 0); |
|
611 |
QCOMPARE(parent.gestureEventsReceived, 0); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
612 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
613 |
QGestureRecognizer::unregisterRecognizer(ContinuousGesture); |
0 | 614 |
} |
615 |
||
616 |
void tst_Gestures::finishedWithoutStarted() |
|
617 |
{ |
|
618 |
GestureWidget widget; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
619 |
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 620 |
|
621 |
// the gesture will claim it finished, but it was never started. |
|
622 |
CustomEvent ev; |
|
623 |
ev.serial = CustomGesture::SerialFinishedThreshold; |
|
624 |
QApplication::sendEvent(&widget, &ev); |
|
625 |
||
626 |
QCOMPARE(widget.customEventsReceived, 1); |
|
627 |
QCOMPARE(widget.gestureEventsReceived, 2); |
|
628 |
QCOMPARE(widget.gestureOverrideEventsReceived, 0); |
|
629 |
QCOMPARE(widget.events.all.size(), 2); |
|
630 |
QCOMPARE(widget.events.started.size(), 1); |
|
631 |
QCOMPARE(widget.events.updated.size(), 0); |
|
632 |
QCOMPARE(widget.events.finished.size(), 1); |
|
633 |
QCOMPARE(widget.events.canceled.size(), 0); |
|
634 |
} |
|
635 |
||
636 |
void tst_Gestures::unknownGesture() |
|
637 |
{ |
|
638 |
GestureWidget widget; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
639 |
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
640 |
widget.grabGesture(Qt::CustomGesture, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
641 |
widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::DontStartGestureOnChildren); |
0 | 642 |
|
643 |
CustomEvent event; |
|
644 |
sendCustomGesture(&event, &widget); |
|
645 |
||
646 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
647 |
||
648 |
QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount); |
|
649 |
} |
|
650 |
||
651 |
static const QColor InstanceColors[] = { |
|
652 |
Qt::blue, Qt::red, Qt::green, Qt::gray, Qt::yellow |
|
653 |
}; |
|
654 |
||
655 |
class GestureItem : public QGraphicsObject |
|
656 |
{ |
|
657 |
static int InstanceCount; |
|
658 |
||
659 |
public: |
|
660 |
GestureItem(const char *name = 0) |
|
661 |
{ |
|
662 |
instanceNumber = InstanceCount++; |
|
663 |
if (name) |
|
664 |
setObjectName(QLatin1String(name)); |
|
665 |
size = QRectF(0, 0, 100, 100); |
|
666 |
customEventsReceived = 0; |
|
667 |
gestureEventsReceived = 0; |
|
668 |
gestureOverrideEventsReceived = 0; |
|
669 |
events.clear(); |
|
670 |
overrideEvents.clear(); |
|
671 |
acceptGestureOverride = false; |
|
672 |
} |
|
673 |
~GestureItem() |
|
674 |
{ |
|
675 |
--InstanceCount; |
|
676 |
} |
|
677 |
||
678 |
int customEventsReceived; |
|
679 |
int gestureEventsReceived; |
|
680 |
int gestureOverrideEventsReceived; |
|
681 |
struct Events |
|
682 |
{ |
|
683 |
QList<Qt::GestureType> all; |
|
684 |
QList<Qt::GestureType> started; |
|
685 |
QList<Qt::GestureType> updated; |
|
686 |
QList<Qt::GestureType> finished; |
|
687 |
QList<Qt::GestureType> canceled; |
|
688 |
||
689 |
void clear() |
|
690 |
{ |
|
691 |
all.clear(); |
|
692 |
started.clear(); |
|
693 |
updated.clear(); |
|
694 |
finished.clear(); |
|
695 |
canceled.clear(); |
|
696 |
} |
|
697 |
} events, overrideEvents; |
|
698 |
||
699 |
bool acceptGestureOverride; |
|
700 |
QSet<Qt::GestureType> ignoredGestures; |
|
701 |
||
702 |
QRectF size; |
|
703 |
int instanceNumber; |
|
704 |
||
705 |
void reset() |
|
706 |
{ |
|
707 |
customEventsReceived = 0; |
|
708 |
gestureEventsReceived = 0; |
|
709 |
gestureOverrideEventsReceived = 0; |
|
710 |
events.clear(); |
|
711 |
overrideEvents.clear(); |
|
712 |
ignoredGestures.clear(); |
|
713 |
} |
|
714 |
||
715 |
protected: |
|
716 |
QRectF boundingRect() const |
|
717 |
{ |
|
718 |
return size; |
|
719 |
} |
|
720 |
void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) |
|
721 |
{ |
|
722 |
QColor color = InstanceColors[instanceNumber % (sizeof(InstanceColors)/sizeof(InstanceColors[0]))]; |
|
723 |
p->fillRect(boundingRect(), color); |
|
724 |
} |
|
725 |
||
726 |
bool event(QEvent *event) |
|
727 |
{ |
|
728 |
Events *eventsPtr = 0; |
|
729 |
if (event->type() == QEvent::Gesture) { |
|
730 |
++gestureEventsReceived; |
|
731 |
eventsPtr = &events; |
|
732 |
QGestureEvent *e = static_cast<QGestureEvent *>(event); |
|
733 |
foreach(Qt::GestureType type, ignoredGestures) |
|
734 |
e->ignore(e->gesture(type)); |
|
735 |
} else if (event->type() == QEvent::GestureOverride) { |
|
736 |
++gestureOverrideEventsReceived; |
|
737 |
eventsPtr = &overrideEvents; |
|
738 |
if (acceptGestureOverride) |
|
739 |
event->accept(); |
|
740 |
} |
|
741 |
if (eventsPtr) { |
|
742 |
QGestureEvent *e = static_cast<QGestureEvent*>(event); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
743 |
QList<QGesture*> gestures = e->gestures(); |
0 | 744 |
foreach(QGesture *g, gestures) { |
745 |
eventsPtr->all << g->gestureType(); |
|
746 |
switch(g->state()) { |
|
747 |
case Qt::GestureStarted: |
|
748 |
eventsPtr->started << g->gestureType(); |
|
749 |
break; |
|
750 |
case Qt::GestureUpdated: |
|
751 |
eventsPtr->updated << g->gestureType(); |
|
752 |
break; |
|
753 |
case Qt::GestureFinished: |
|
754 |
eventsPtr->finished << g->gestureType(); |
|
755 |
break; |
|
756 |
case Qt::GestureCanceled: |
|
757 |
eventsPtr->canceled << g->gestureType(); |
|
758 |
break; |
|
759 |
default: |
|
760 |
Q_ASSERT(false); |
|
761 |
} |
|
762 |
} |
|
763 |
} else if (event->type() == CustomEvent::EventType) { |
|
764 |
++customEventsReceived; |
|
765 |
} else { |
|
766 |
return QGraphicsObject::event(event); |
|
767 |
} |
|
768 |
return true; |
|
769 |
} |
|
770 |
}; |
|
771 |
int GestureItem::InstanceCount = 0; |
|
772 |
||
773 |
void tst_Gestures::graphicsItemGesture() |
|
774 |
{ |
|
775 |
QGraphicsScene scene; |
|
776 |
QGraphicsView view(&scene); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
777 |
view.setWindowFlags(Qt::X11BypassWindowManagerHint); |
0 | 778 |
|
779 |
GestureItem *item = new GestureItem("item"); |
|
780 |
scene.addItem(item); |
|
781 |
item->setPos(100, 100); |
|
782 |
||
783 |
view.show(); |
|
784 |
QTest::qWaitForWindowShown(&view); |
|
785 |
view.ensureVisible(scene.sceneRect()); |
|
786 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
787 |
view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 788 |
item->grabGesture(CustomGesture::GestureType); |
789 |
||
790 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
791 |
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
|
792 |
||
793 |
CustomEvent event; |
|
794 |
// gesture without hotspot should not be delivered to items in the view |
|
795 |
QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); |
|
796 |
QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); |
|
797 |
QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); |
|
798 |
QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); |
|
799 |
sendCustomGesture(&event, item, &scene); |
|
800 |
||
801 |
QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); |
|
802 |
QCOMPARE(item->gestureEventsReceived, 0); |
|
803 |
QCOMPARE(item->gestureOverrideEventsReceived, 0); |
|
804 |
||
805 |
item->reset(); |
|
806 |
||
807 |
// make sure the event is properly delivered if only the hotspot is set. |
|
808 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view); |
|
809 |
event.hasHotSpot = true; |
|
810 |
sendCustomGesture(&event, item, &scene); |
|
811 |
||
812 |
QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); |
|
813 |
QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); |
|
814 |
QCOMPARE(item->gestureOverrideEventsReceived, 0); |
|
815 |
QCOMPARE(item->events.all.size(), TotalGestureEventsCount); |
|
816 |
for(int i = 0; i < item->events.all.size(); ++i) |
|
817 |
QCOMPARE(item->events.all.at(i), CustomGesture::GestureType); |
|
818 |
QCOMPARE(item->events.started.size(), 1); |
|
819 |
QCOMPARE(item->events.updated.size(), TotalGestureEventsCount - 2); |
|
820 |
QCOMPARE(item->events.finished.size(), 1); |
|
821 |
QCOMPARE(item->events.canceled.size(), 0); |
|
822 |
||
823 |
item->reset(); |
|
824 |
||
825 |
// send gesture to the item which ignores it. |
|
826 |
item->ignoredGestures << CustomGesture::GestureType; |
|
827 |
||
828 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view); |
|
829 |
event.hasHotSpot = true; |
|
830 |
sendCustomGesture(&event, item, &scene); |
|
831 |
QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); |
|
832 |
QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); |
|
833 |
QCOMPARE(item->gestureOverrideEventsReceived, 0); |
|
834 |
} |
|
835 |
||
836 |
void tst_Gestures::graphicsItemTreeGesture() |
|
837 |
{ |
|
838 |
QGraphicsScene scene; |
|
839 |
QGraphicsView view(&scene); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
840 |
view.setWindowFlags(Qt::X11BypassWindowManagerHint); |
0 | 841 |
|
842 |
GestureItem *item1 = new GestureItem("item1"); |
|
843 |
item1->setPos(100, 100); |
|
844 |
item1->size = QRectF(0, 0, 350, 200); |
|
845 |
scene.addItem(item1); |
|
846 |
||
847 |
GestureItem *item1_child1 = new GestureItem("item1_child1"); |
|
848 |
item1_child1->setPos(50, 50); |
|
849 |
item1_child1->size = QRectF(0, 0, 100, 100); |
|
850 |
item1_child1->setParentItem(item1); |
|
851 |
||
852 |
GestureItem *item1_child2 = new GestureItem("item1_child2"); |
|
853 |
item1_child2->size = QRectF(0, 0, 100, 100); |
|
854 |
item1_child2->setPos(200, 50); |
|
855 |
item1_child2->setParentItem(item1); |
|
856 |
||
857 |
view.show(); |
|
858 |
QTest::qWaitForWindowShown(&view); |
|
859 |
view.ensureVisible(scene.sceneRect()); |
|
860 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
861 |
view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 862 |
item1->grabGesture(CustomGesture::GestureType); |
863 |
||
864 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
865 |
||
866 |
CustomEvent event; |
|
867 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item1_child1, &view); |
|
868 |
event.hasHotSpot = true; |
|
869 |
||
870 |
item1->ignoredGestures << CustomGesture::GestureType; |
|
871 |
sendCustomGesture(&event, item1_child1, &scene); |
|
872 |
QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0); |
|
873 |
QCOMPARE(item1_child1->gestureEventsReceived, 0); |
|
874 |
QCOMPARE(item1_child2->gestureEventsReceived, 0); |
|
875 |
QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0); |
|
876 |
QCOMPARE(item1->gestureOverrideEventsReceived, 0); |
|
877 |
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); |
|
878 |
||
879 |
item1->reset(); item1_child1->reset(); item1_child2->reset(); |
|
880 |
||
881 |
item1_child1->grabGesture(CustomGesture::GestureType); |
|
882 |
||
883 |
item1->ignoredGestures << CustomGesture::GestureType; |
|
884 |
item1_child1->ignoredGestures << CustomGesture::GestureType; |
|
885 |
sendCustomGesture(&event, item1_child1, &scene); |
|
886 |
QCOMPARE(item1_child1->gestureOverrideEventsReceived, 1); |
|
887 |
QCOMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount); |
|
888 |
QCOMPARE(item1_child2->gestureEventsReceived, 0); |
|
889 |
QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0); |
|
890 |
QCOMPARE(item1->gestureOverrideEventsReceived, 1); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
891 |
QCOMPARE(item1->gestureEventsReceived, 1); |
0 | 892 |
} |
893 |
||
894 |
void tst_Gestures::explicitGraphicsObjectTarget() |
|
895 |
{ |
|
896 |
QGraphicsScene scene; |
|
897 |
QGraphicsView view(&scene); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
898 |
view.setWindowFlags(Qt::X11BypassWindowManagerHint); |
0 | 899 |
|
900 |
GestureItem *item1 = new GestureItem("item1"); |
|
901 |
scene.addItem(item1); |
|
902 |
item1->setPos(100, 100); |
|
903 |
item1->setZValue(1); |
|
904 |
||
905 |
GestureItem *item2 = new GestureItem("item2"); |
|
906 |
scene.addItem(item2); |
|
907 |
item2->setPos(100, 100); |
|
908 |
item2->setZValue(5); |
|
909 |
||
910 |
GestureItem *item2_child1 = new GestureItem("item2_child1"); |
|
911 |
scene.addItem(item2_child1); |
|
912 |
item2_child1->setParentItem(item2); |
|
913 |
item2_child1->setPos(10, 10); |
|
914 |
||
915 |
view.show(); |
|
916 |
QTest::qWaitForWindowShown(&view); |
|
917 |
view.ensureVisible(scene.sceneRect()); |
|
918 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
919 |
view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
920 |
item1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
921 |
item2->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
922 |
item2_child1->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 923 |
|
924 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
925 |
||
926 |
// sending events to item1, but the hotSpot is set to item2 |
|
927 |
CustomEvent event; |
|
928 |
event.hotSpot = mapToGlobal(QPointF(15, 15), item2, &view); |
|
929 |
event.hasHotSpot = true; |
|
930 |
||
931 |
sendCustomGesture(&event, item1, &scene); |
|
932 |
||
933 |
QCOMPARE(item1->gestureEventsReceived, 0); |
|
934 |
QCOMPARE(item1->gestureOverrideEventsReceived, 1); |
|
935 |
QCOMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount); |
|
936 |
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 1); |
|
937 |
QCOMPARE(item2_child1->events.all.size(), TotalGestureEventsCount); |
|
938 |
for(int i = 0; i < item2_child1->events.all.size(); ++i) |
|
939 |
QCOMPARE(item2_child1->events.all.at(i), CustomGesture::GestureType); |
|
940 |
QCOMPARE(item2_child1->events.started.size(), 1); |
|
941 |
QCOMPARE(item2_child1->events.updated.size(), TotalGestureEventsCount - 2); |
|
942 |
QCOMPARE(item2_child1->events.finished.size(), 1); |
|
943 |
QCOMPARE(item2_child1->events.canceled.size(), 0); |
|
944 |
QCOMPARE(item2->gestureEventsReceived, 0); |
|
945 |
QCOMPARE(item2->gestureOverrideEventsReceived, 1); |
|
946 |
} |
|
947 |
||
948 |
void tst_Gestures::gestureOverChildGraphicsItem() |
|
949 |
{ |
|
950 |
QGraphicsScene scene; |
|
951 |
QGraphicsView view(&scene); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
952 |
view.setWindowFlags(Qt::X11BypassWindowManagerHint); |
0 | 953 |
|
954 |
GestureItem *item0 = new GestureItem("item0"); |
|
955 |
scene.addItem(item0); |
|
956 |
item0->setPos(0, 0); |
|
957 |
item0->grabGesture(CustomGesture::GestureType); |
|
958 |
item0->setZValue(1); |
|
959 |
||
960 |
GestureItem *item1 = new GestureItem("item1"); |
|
961 |
scene.addItem(item1); |
|
962 |
item1->setPos(100, 100); |
|
963 |
item1->setZValue(5); |
|
964 |
||
965 |
GestureItem *item2 = new GestureItem("item2"); |
|
966 |
scene.addItem(item2); |
|
967 |
item2->setPos(100, 100); |
|
968 |
item2->setZValue(10); |
|
969 |
||
970 |
GestureItem *item2_child1 = new GestureItem("item2_child1"); |
|
971 |
scene.addItem(item2_child1); |
|
972 |
item2_child1->setParentItem(item2); |
|
973 |
item2_child1->setPos(0, 0); |
|
974 |
||
975 |
view.show(); |
|
976 |
QTest::qWaitForWindowShown(&view); |
|
977 |
view.ensureVisible(scene.sceneRect()); |
|
978 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
979 |
view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
0 | 980 |
item1->grabGesture(CustomGesture::GestureType); |
981 |
||
982 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
983 |
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
|
984 |
||
985 |
CustomEvent event; |
|
986 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); |
|
987 |
event.hasHotSpot = true; |
|
988 |
sendCustomGesture(&event, item0, &scene); |
|
989 |
||
990 |
QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount); |
|
991 |
QCOMPARE(item2_child1->gestureEventsReceived, 0); |
|
992 |
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); |
|
993 |
QCOMPARE(item2->gestureEventsReceived, 0); |
|
994 |
QCOMPARE(item2->gestureOverrideEventsReceived, 0); |
|
995 |
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); |
|
996 |
QCOMPARE(item1->gestureOverrideEventsReceived, 0); |
|
997 |
||
998 |
item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); |
|
999 |
item2->grabGesture(CustomGesture::GestureType); |
|
1000 |
item2->ignoredGestures << CustomGesture::GestureType; |
|
1001 |
||
1002 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); |
|
1003 |
event.hasHotSpot = true; |
|
1004 |
sendCustomGesture(&event, item0, &scene); |
|
1005 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1006 |
QCOMPARE(item2_child1->gestureEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1008 |
QCOMPARE(item2->gestureEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1009 |
QCOMPARE(item2->gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1010 |
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1011 |
QCOMPARE(item1->gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1012 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1013 |
item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1014 |
item2->grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1015 |
item2->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1016 |
item1->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1017 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1018 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1019 |
event.hasHotSpot = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1020 |
sendCustomGesture(&event, item0, &scene); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1021 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1022 |
QCOMPARE(item2_child1->gestureEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1023 |
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1024 |
QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1025 |
QCOMPARE(item2->gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1026 |
QCOMPARE(item1->gestureEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1027 |
QCOMPARE(item1->gestureOverrideEventsReceived, 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1028 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1029 |
item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1030 |
item2->grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1031 |
item2->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1032 |
item1->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1033 |
item1->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1034 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1035 |
event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1036 |
event.hasHotSpot = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1037 |
sendCustomGesture(&event, item0, &scene); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1038 |
|
0 | 1039 |
QCOMPARE(item2_child1->gestureEventsReceived, 0); |
1040 |
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); |
|
1041 |
QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); |
|
1042 |
QCOMPARE(item2->gestureOverrideEventsReceived, 1); |
|
1043 |
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); |
|
1044 |
QCOMPARE(item1->gestureOverrideEventsReceived, 1); |
|
1045 |
} |
|
1046 |
||
1047 |
void tst_Gestures::twoGesturesOnDifferentLevel() |
|
1048 |
{ |
|
1049 |
GestureWidget parent("parent"); |
|
1050 |
QVBoxLayout *l = new QVBoxLayout(&parent); |
|
1051 |
GestureWidget *child = new GestureWidget("child"); |
|
1052 |
l->addWidget(child); |
|
1053 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1054 |
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
0 | 1055 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1056 |
parent.grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1057 |
child->grabGesture(SecondGesture); |
0 | 1058 |
|
1059 |
CustomEvent event; |
|
1060 |
// sending events that form a gesture to one widget, but they will be |
|
1061 |
// filtered by two different gesture recognizers and will generate two |
|
1062 |
// QGesture objects. Check that those gesture objects are delivered to |
|
1063 |
// different widgets properly. |
|
1064 |
sendCustomGesture(&event, child); |
|
1065 |
||
1066 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
1067 |
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; |
|
1068 |
||
1069 |
QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); |
|
1070 |
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); |
|
1071 |
QCOMPARE(child->gestureOverrideEventsReceived, 0); |
|
1072 |
QCOMPARE(child->events.all.size(), TotalGestureEventsCount); |
|
1073 |
for(int i = 0; i < child->events.all.size(); ++i) |
|
1074 |
QCOMPARE(child->events.all.at(i), SecondGesture); |
|
1075 |
||
1076 |
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); |
|
1077 |
QCOMPARE(parent.gestureOverrideEventsReceived, 0); |
|
1078 |
QCOMPARE(parent.events.all.size(), TotalGestureEventsCount); |
|
1079 |
for(int i = 0; i < child->events.all.size(); ++i) |
|
1080 |
QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1081 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1082 |
QGestureRecognizer::unregisterRecognizer(SecondGesture); |
0 | 1083 |
} |
1084 |
||
1085 |
void tst_Gestures::multipleGesturesInTree() |
|
1086 |
{ |
|
1087 |
GestureWidget a("A"); |
|
1088 |
GestureWidget *A = &a; |
|
1089 |
GestureWidget *B = new GestureWidget("B", A); |
|
1090 |
GestureWidget *C = new GestureWidget("C", B); |
|
1091 |
GestureWidget *D = new GestureWidget("D", C); |
|
1092 |
||
1093 |
Qt::GestureType FirstGesture = CustomGesture::GestureType; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1094 |
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1095 |
Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
0 | 1096 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1097 |
Qt::GestureFlags flags = Qt::ReceivePartialGestures; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1098 |
A->grabGesture(FirstGesture, flags); // A [1 3] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1099 |
A->grabGesture(ThirdGesture, flags); // | |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1100 |
B->grabGesture(SecondGesture, flags); // B [ 2 3] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1101 |
B->grabGesture(ThirdGesture, flags); // | |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1102 |
C->grabGesture(FirstGesture, flags); // C [1 2 3] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1103 |
C->grabGesture(SecondGesture, flags); // | |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1104 |
C->grabGesture(ThirdGesture, flags); // D [1 3] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1105 |
D->grabGesture(FirstGesture, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1106 |
D->grabGesture(ThirdGesture, flags); |
0 | 1107 |
|
1108 |
// make sure all widgets ignore events, so they get propagated. |
|
1109 |
A->ignoredGestures << FirstGesture << ThirdGesture; |
|
1110 |
B->ignoredGestures << SecondGesture << ThirdGesture; |
|
1111 |
C->ignoredGestures << FirstGesture << SecondGesture << ThirdGesture; |
|
1112 |
D->ignoredGestures << FirstGesture << ThirdGesture; |
|
1113 |
||
1114 |
CustomEvent event; |
|
1115 |
sendCustomGesture(&event, D); |
|
1116 |
||
1117 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
1118 |
||
1119 |
// gesture override events |
|
1120 |
QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1); |
|
1121 |
QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0); |
|
1122 |
QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1); |
|
1123 |
||
1124 |
QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1); |
|
1125 |
QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1); |
|
1126 |
QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1); |
|
1127 |
||
1128 |
QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0); |
|
1129 |
QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1); |
|
1130 |
QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1); |
|
1131 |
||
1132 |
QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1); |
|
1133 |
QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0); |
|
1134 |
QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1); |
|
1135 |
||
1136 |
// normal gesture events |
|
1137 |
QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount); |
|
1138 |
QCOMPARE(D->events.all.count(SecondGesture), 0); |
|
1139 |
QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1140 |
||
1141 |
QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount); |
|
1142 |
QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount); |
|
1143 |
QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1144 |
||
1145 |
QCOMPARE(B->events.all.count(FirstGesture), 0); |
|
1146 |
QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount); |
|
1147 |
QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1148 |
||
1149 |
QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount); |
|
1150 |
QCOMPARE(A->events.all.count(SecondGesture), 0); |
|
1151 |
QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1152 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1153 |
QGestureRecognizer::unregisterRecognizer(SecondGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1154 |
QGestureRecognizer::unregisterRecognizer(ThirdGesture); |
0 | 1155 |
} |
1156 |
||
1157 |
void tst_Gestures::multipleGesturesInComplexTree() |
|
1158 |
{ |
|
1159 |
GestureWidget a("A"); |
|
1160 |
GestureWidget *A = &a; |
|
1161 |
GestureWidget *B = new GestureWidget("B", A); |
|
1162 |
GestureWidget *C = new GestureWidget("C", B); |
|
1163 |
GestureWidget *D = new GestureWidget("D", C); |
|
1164 |
||
1165 |
Qt::GestureType FirstGesture = CustomGesture::GestureType; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1166 |
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1167 |
Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1168 |
Qt::GestureType FourthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
Qt::GestureType FifthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1170 |
Qt::GestureType SixthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1171 |
Qt::GestureType SeventhGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
0 | 1172 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1173 |
Qt::GestureFlags flags = Qt::ReceivePartialGestures; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1174 |
A->grabGesture(FirstGesture, flags); // A [1,3,4] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1175 |
A->grabGesture(ThirdGesture, flags); // | |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1176 |
A->grabGesture(FourthGesture, flags); // B [2,3,5] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1177 |
B->grabGesture(SecondGesture, flags); // | |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1178 |
B->grabGesture(ThirdGesture, flags); // C [1,2,3,6] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1179 |
B->grabGesture(FifthGesture, flags); // | |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1180 |
C->grabGesture(FirstGesture, flags); // D [1,3,7] |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1181 |
C->grabGesture(SecondGesture, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1182 |
C->grabGesture(ThirdGesture, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1183 |
C->grabGesture(SixthGesture, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1184 |
D->grabGesture(FirstGesture, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1185 |
D->grabGesture(ThirdGesture, flags); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1186 |
D->grabGesture(SeventhGesture, flags); |
0 | 1187 |
|
1188 |
// make sure all widgets ignore events, so they get propagated. |
|
1189 |
QSet<Qt::GestureType> allGestureTypes; |
|
1190 |
allGestureTypes << FirstGesture << SecondGesture << ThirdGesture |
|
1191 |
<< FourthGesture << FifthGesture << SixthGesture << SeventhGesture; |
|
1192 |
A->ignoredGestures = B->ignoredGestures = allGestureTypes; |
|
1193 |
C->ignoredGestures = D->ignoredGestures = allGestureTypes; |
|
1194 |
||
1195 |
CustomEvent event; |
|
1196 |
sendCustomGesture(&event, D); |
|
1197 |
||
1198 |
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; |
|
1199 |
||
1200 |
// gesture override events |
|
1201 |
QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1); |
|
1202 |
QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0); |
|
1203 |
QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1); |
|
1204 |
||
1205 |
QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1); |
|
1206 |
QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1); |
|
1207 |
QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1); |
|
1208 |
||
1209 |
QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0); |
|
1210 |
QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1); |
|
1211 |
QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1); |
|
1212 |
||
1213 |
QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1); |
|
1214 |
QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0); |
|
1215 |
QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1); |
|
1216 |
||
1217 |
// normal gesture events |
|
1218 |
QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount); |
|
1219 |
QCOMPARE(D->events.all.count(SecondGesture), 0); |
|
1220 |
QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1221 |
QCOMPARE(D->events.all.count(FourthGesture), 0); |
|
1222 |
QCOMPARE(D->events.all.count(FifthGesture), 0); |
|
1223 |
QCOMPARE(D->events.all.count(SixthGesture), 0); |
|
1224 |
QCOMPARE(D->events.all.count(SeventhGesture), TotalGestureEventsCount); |
|
1225 |
||
1226 |
QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount); |
|
1227 |
QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount); |
|
1228 |
QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1229 |
QCOMPARE(C->events.all.count(FourthGesture), 0); |
|
1230 |
QCOMPARE(C->events.all.count(FifthGesture), 0); |
|
1231 |
QCOMPARE(C->events.all.count(SixthGesture), TotalGestureEventsCount); |
|
1232 |
QCOMPARE(C->events.all.count(SeventhGesture), 0); |
|
1233 |
||
1234 |
QCOMPARE(B->events.all.count(FirstGesture), 0); |
|
1235 |
QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount); |
|
1236 |
QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1237 |
QCOMPARE(B->events.all.count(FourthGesture), 0); |
|
1238 |
QCOMPARE(B->events.all.count(FifthGesture), TotalGestureEventsCount); |
|
1239 |
QCOMPARE(B->events.all.count(SixthGesture), 0); |
|
1240 |
QCOMPARE(B->events.all.count(SeventhGesture), 0); |
|
1241 |
||
1242 |
QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount); |
|
1243 |
QCOMPARE(A->events.all.count(SecondGesture), 0); |
|
1244 |
QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); |
|
1245 |
QCOMPARE(A->events.all.count(FourthGesture), TotalGestureEventsCount); |
|
1246 |
QCOMPARE(A->events.all.count(FifthGesture), 0); |
|
1247 |
QCOMPARE(A->events.all.count(SixthGesture), 0); |
|
1248 |
QCOMPARE(A->events.all.count(SeventhGesture), 0); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1249 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1250 |
QGestureRecognizer::unregisterRecognizer(SecondGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1251 |
QGestureRecognizer::unregisterRecognizer(ThirdGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1252 |
QGestureRecognizer::unregisterRecognizer(FourthGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1253 |
QGestureRecognizer::unregisterRecognizer(FifthGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1254 |
QGestureRecognizer::unregisterRecognizer(SixthGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1255 |
QGestureRecognizer::unregisterRecognizer(SeventhGesture); |
0 | 1256 |
} |
1257 |
||
1258 |
void tst_Gestures::testMapToScene() |
|
1259 |
{ |
|
1260 |
QGesture gesture; |
|
1261 |
QList<QGesture*> list; |
|
1262 |
list << &gesture; |
|
1263 |
QGestureEvent event(list); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1264 |
QCOMPARE(event.mapToGraphicsScene(gesture.hotSpot()), QPointF()); // not set, can't do much |
0 | 1265 |
|
1266 |
QGraphicsScene scene; |
|
1267 |
QGraphicsView view(&scene); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1268 |
view.setWindowFlags(Qt::X11BypassWindowManagerHint); |
0 | 1269 |
|
1270 |
GestureItem *item0 = new GestureItem; |
|
1271 |
scene.addItem(item0); |
|
1272 |
item0->setPos(14, 16); |
|
1273 |
||
1274 |
view.show(); // need to show to give it a global coordinate |
|
1275 |
QTest::qWaitForWindowShown(&view); |
|
1276 |
view.ensureVisible(scene.sceneRect()); |
|
1277 |
||
1278 |
QPoint origin = view.mapToGlobal(QPoint()); |
|
1279 |
event.setWidget(view.viewport()); |
|
1280 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1281 |
QCOMPARE(event.mapToGraphicsScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1282 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1283 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1284 |
void tst_Gestures::ungrabGesture() // a method on QWidget |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1285 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1286 |
class MockGestureWidget : public GestureWidget { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1287 |
public: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1288 |
MockGestureWidget(const char *name = 0, QWidget *parent = 0) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1289 |
: GestureWidget(name, parent) { } |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1290 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1291 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1292 |
QSet<QGesture*> gestures; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1293 |
protected: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1294 |
bool event(QEvent *event) |
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 |
if (event->type() == QEvent::Gesture) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1297 |
QGestureEvent *gestureEvent = static_cast<QGestureEvent*>(event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1298 |
if (gestureEvent) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1299 |
foreach (QGesture *g, gestureEvent->gestures()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1300 |
gestures.insert(g); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1301 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1302 |
return GestureWidget::event(event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1303 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1304 |
}; |
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 |
MockGestureWidget parent("A"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1307 |
MockGestureWidget *a = &parent; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1308 |
MockGestureWidget *b = new MockGestureWidget("B", a); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1309 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1310 |
a->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1311 |
b->grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1312 |
b->ignoredGestures << CustomGesture::GestureType; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1313 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1314 |
CustomEvent event; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1315 |
// sending an event will cause the QGesture objects to be instantiated for the widgets |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1316 |
sendCustomGesture(&event, b); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1317 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1318 |
QCOMPARE(a->gestures.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1319 |
QPointer<QGesture> customGestureA; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1320 |
customGestureA = *(a->gestures.begin()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1321 |
QVERIFY(!customGestureA.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1322 |
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1323 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1324 |
QCOMPARE(b->gestures.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1325 |
QPointer<QGesture> customGestureB; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1326 |
customGestureB = *(b->gestures.begin()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1327 |
QVERIFY(!customGestureB.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1328 |
QVERIFY(customGestureA.data() == customGestureB.data()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1329 |
QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1330 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1331 |
a->gestures.clear(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1332 |
// sending an event will cause the QGesture objects to be instantiated for the widget |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1333 |
sendCustomGesture(&event, a); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1334 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1335 |
QCOMPARE(a->gestures.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1336 |
customGestureA = *(a->gestures.begin()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1337 |
QVERIFY(!customGestureA.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1338 |
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1339 |
QVERIFY(customGestureA.data() != customGestureB.data()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1340 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1341 |
a->ungrabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1342 |
QVERIFY(customGestureA.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1343 |
QVERIFY(!customGestureB.isNull()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1344 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1345 |
a->gestures.clear(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1346 |
a->reset(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1347 |
// send again to 'b' and make sure a never gets it. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1348 |
sendCustomGesture(&event, b); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1349 |
QCOMPARE(a->gestureEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1350 |
QCOMPARE(a->gestureOverrideEventsReceived, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1351 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1352 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1353 |
void tst_Gestures::unregisterRecognizer() // a method on QApplication |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1354 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1355 |
/* |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1356 |
The hardest usecase to get right is when we remove a recognizer while several |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1357 |
of the gestures it created are in active state and we immediately add a new recognizer |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1358 |
for the same type (thus replacing the old one). |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1359 |
The expected result is that all old gestures continue till they are finished/cancelled |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1360 |
and the new recognizer starts creating gestures immediately at registration. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1361 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1362 |
This implies that deleting of the recognizer happens only when there are no more gestures |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1363 |
that it created. (since gestures might have a pointer to the recognizer) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1364 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1365 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1366 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1367 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1368 |
void tst_Gestures::autoCancelGestures() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1369 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1370 |
class MockWidget : public GestureWidget { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1371 |
public: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1372 |
MockWidget(const char *name) : GestureWidget(name) { } |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1373 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1374 |
bool event(QEvent *event) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1375 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1376 |
if (event->type() == QEvent::Gesture) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1377 |
QGestureEvent *ge = static_cast<QGestureEvent*>(event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1378 |
Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here... |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1379 |
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1380 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1381 |
return GestureWidget::event(event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1382 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1383 |
}; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1384 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1385 |
const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1386 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1387 |
MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1388 |
parent.resize(300, 100); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1389 |
parent.setWindowFlags(Qt::X11BypassWindowManagerHint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1390 |
GestureWidget *child = new GestureWidget("child", &parent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1391 |
child->setGeometry(10, 10, 100, 80); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1392 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1393 |
parent.grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1394 |
child->grabGesture(secondGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1395 |
parent.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1396 |
QTest::qWaitForWindowShown(&parent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1397 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1398 |
/* |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1399 |
An event is send to both the child and the parent, when the child gets it a gesture is triggered |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1400 |
and send to the child. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1401 |
When the parent gets the event a new gesture is triggered and delivered to the parent. When the |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1402 |
parent gets it he accepts it and that causes the cancel policy to activate. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1403 |
The cause of that is the gesture for the child is cancelled and send to the child as such. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1404 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1405 |
CustomEvent event; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1406 |
event.serial = CustomGesture::SerialStartedThreshold; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1407 |
QApplication::sendEvent(child, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1408 |
QCOMPARE(child->events.all.count(), 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1409 |
QCOMPARE(child->events.started.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1410 |
QCOMPARE(child->events.canceled.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1411 |
QCOMPARE(parent.events.all.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1412 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1413 |
// clean up, make the parent gesture finish |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1414 |
event.serial = CustomGesture::SerialFinishedThreshold; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1415 |
QApplication::sendEvent(child, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1416 |
QCOMPARE(parent.events.all.count(), 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1418 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1419 |
void tst_Gestures::autoCancelGestures2() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1420 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1421 |
class MockItem : public GestureItem { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1422 |
public: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1423 |
MockItem(const char *name) : GestureItem(name) { } |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1424 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1425 |
bool event(QEvent *event) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1426 |
if (event->type() == QEvent::Gesture) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1427 |
QGestureEvent *ge = static_cast<QGestureEvent*>(event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1428 |
Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here... |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1429 |
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1430 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1431 |
return GestureItem::event(event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1432 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1433 |
}; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1434 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1435 |
const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1436 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1437 |
QGraphicsScene scene; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1438 |
QGraphicsView view(&scene); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1439 |
view.setWindowFlags(Qt::X11BypassWindowManagerHint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1440 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1441 |
MockItem *parent = new MockItem("parent"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1442 |
GestureItem *child = new GestureItem("child"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1443 |
child->setParentItem(parent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1444 |
parent->setPos(0, 0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1445 |
child->setPos(10, 10); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1446 |
scene.addItem(parent); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1447 |
view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1448 |
view.viewport()->grabGesture(secondGesture, Qt::DontStartGestureOnChildren); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1449 |
parent->grabGesture(CustomGesture::GestureType); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1450 |
child->grabGesture(secondGesture); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1451 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1452 |
view.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1453 |
QTest::qWaitForWindowShown(&view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1454 |
view.ensureVisible(scene.sceneRect()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1455 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1456 |
CustomEvent event; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1457 |
event.serial = CustomGesture::SerialStartedThreshold; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1458 |
event.hasHotSpot = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1459 |
event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1460 |
// qDebug() << event.hotSpot; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1461 |
scene.sendEvent(child, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1462 |
//QEventLoop().exec(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1463 |
QCOMPARE(parent->events.all.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1464 |
QCOMPARE(child->events.started.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1465 |
QCOMPARE(child->events.canceled.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1466 |
QCOMPARE(child->events.all.count(), 2); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1467 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1468 |
// clean up, make the parent gesture finish |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1469 |
event.serial = CustomGesture::SerialFinishedThreshold; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1470 |
scene.sendEvent(child, &event); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1471 |
QCOMPARE(parent->events.all.count(), 2); |
0 | 1472 |
} |
1473 |
||
1474 |
QTEST_MAIN(tst_Gestures) |
|
1475 |
#include "tst_gestures.moc" |