on xenial help sign in
Refactor Ubuntu.Gesture tests to share common logic
6a3ca33Daniel d'Andrada
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+18−19
@@ -1,33 +1,31 @@
1−########## tst_DirectionalDragArea
2−
3include_directories(
1include_directories(
4 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
2 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
5 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_CURRENT_BINARY_DIR}
6 )
4 )
7
5
8−set(testCommand
9− LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
10− ${CMAKE_CURRENT_BINARY_DIR}/DirectionalDragAreaTestExec
11− -o ${CMAKE_BINARY_DIR}/DirectionalDragAreaTest.xml,xunitxml
12− -o -,txt)
13−
14−add_custom_target(testDirectionalDragArea ${testCommand})
15−add_dependencies(qmluitests testDirectionalDragArea)
16−add_dependencies(testDirectionalDragArea DirectionalDragAreaTestExec UbutunGesturesTestQmlFiles)
17−
18−add_executable(DirectionalDragAreaTestExec tst_DirectionalDragArea.cpp)
19−qt5_use_modules(DirectionalDragAreaTestExec Test Core Qml Gui Quick)
20−target_link_libraries(DirectionalDragAreaTestExec UbuntuGestureQml)
21−
22−add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
23−
24file(GLOB qmlFiles *.qml)
6file(GLOB qmlFiles *.qml)
25add_custom_target(UbuntuGesturesTestQmlFiles ALL
7add_custom_target(UbuntuGesturesTestQmlFiles ALL
26 COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
8 COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
27 DEPENDS ${qmlFiles}
9 DEPENDS ${qmlFiles}
28)
10)
29
11
30−########## other tests
12+add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
13+
14+macro(add_gesture_ui_test CLASSNAME)
15+ set(testCommand
16+ LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
17+ ${CMAKE_CURRENT_BINARY_DIR}/${CLASSNAME}TestExec
18+ -o ${CMAKE_BINARY_DIR}/${CLASSNAME}Test.xml,xunitxml
19+ -o -,txt)
20+
21+ add_custom_target(test${CLASSNAME} ${testCommand})
22+ add_dependencies(qmluitests test${CLASSNAME})
23+ add_dependencies(test${CLASSNAME} ${CLASSNAME}TestExec UbuntuGesturesTestQmlFiles)
24+
25+ add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp)
26+ qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
27+ target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
28+endmacro(add_gesture_ui_test)
31
29
32macro(add_gesture_test CLASSNAME)
30macro(add_gesture_test CLASSNAME)
33 set(testCommand
31 set(testCommand
@@ -43,5 +41,6 @@ macro(add_gesture_test CLASSNAME)
43 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
41 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
44endmacro(add_gesture_test)
42endmacro(add_gesture_test)
45
43
44+add_gesture_ui_test(DirectionalDragArea)
46add_gesture_test(Damper)
45add_gesture_test(Damper)
47add_gesture_test(AxisVelocityCalculator)
46add_gesture_test(AxisVelocityCalculator)
tests/plugins/Ubuntu/Gestures/GestureTest.cppnew file+44
@@ -0,0 +1,44 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "GestureTest.h"
18+
19+#include <qpa/qwindowsysteminterface.h>
20+#include <QQmlEngine>
21+#include <QQuickView>
22+
23+void GestureTest::initTestCase()
24+{
25+ if (!m_device) {
26+ m_device = new QTouchDevice;
27+ m_device->setType(QTouchDevice::TouchScreen);
28+ QWindowSystemInterface::registerTouchDevice(m_device);
29+ }
30+}
31+
32+void GestureTest::init()
33+{
34+ m_view = new QQuickView(0);
35+ m_view->setResizeMode(QQuickView::SizeRootObjectToView);
36+ m_view->resize(600, 600);
37+ m_view->engine()->addImportPath(QLatin1String(UBUNTU_GESTURES_PLUGIN_DIR));
38+}
39+
40+void GestureTest::cleanup()
41+{
42+ delete m_view;
43+ m_view = nullptr;
44+}
tests/plugins/Ubuntu/Gestures/GestureTest.hnew file+44
@@ -0,0 +1,44 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef GESTURETEST_H
18+#endif // GESTURETEST_H
19+
20+#include <QObject>
21+
22+class QQuickView;
23+class QTouchDevice;
24+
25+/*
26+ The common stuff among tests come here
27+ */
28+class GestureTest : public QObject
29+{
30+ Q_OBJECT
31+public:
32+ GestureTest() : QObject(), m_device(nullptr), m_view(nullptr) {}
33+
34+protected Q_SLOTS:
35+ void initTestCase(); // will be called before the first test function is executed
36+ virtual void init(); // called right before each and every test function is executed
37+ virtual void cleanup(); // called right after each and every test function is executed
38+
39+protected:
40+ QTouchDevice *m_device;
41+ QQuickView *m_view;
42+};
43+
44+#define GESTURETEST_H
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+66−98
@@ -16,13 +16,14 @@
16
16
17#include <QtTest/QtTest>
17#include <QtTest/QtTest>
18#include <QtCore/QObject>
18#include <QtCore/QObject>
19−#include <qpa/qwindowsysteminterface.h>
20#include <QtQuick/QQuickView>
19#include <QtQuick/QQuickView>
21#include <QtQml/QQmlEngine>
20#include <QtQml/QQmlEngine>
22#include <QPointer>
21#include <QPointer>
23
22
24#include <DirectionalDragArea.h>
23#include <DirectionalDragArea.h>
25
24
25+#include "GestureTest.h"
26+
26using namespace UbuntuGestures;
27using namespace UbuntuGestures;
27
28
28class FakeTimer : public AbstractTimer
29class FakeTimer : public AbstractTimer
@@ -61,15 +62,11 @@ public:
61 qint64 m_msecsSinceReference;
62 qint64 m_msecsSinceReference;
62};
63};
63
64
64−class tst_DirectionalDragArea: public QObject
65+class tst_DirectionalDragArea: public GestureTest
65{
66{
66 Q_OBJECT
67 Q_OBJECT
67public:
68public:
68− tst_DirectionalDragArea() : device(0) { }
69private Q_SLOTS:
69private Q_SLOTS:
70− void initTestCase(); // will be called before the first test function is executed
71− void cleanupTestCase(); // will be called after the last test function was executed.
72−
73 void init(); // called right before each and every test function is executed
70 void init(); // called right before each and every test function is executed
74 void cleanup(); // called right after each and every test function is executed
71 void cleanup(); // called right after each and every test function is executed
75
72
@@ -87,36 +84,18 @@ private Q_SLOTS:
87 void ignoreOldFinger();
84 void ignoreOldFinger();
88
85
89private:
86private:
90− QQuickView *createView();
91 void passTime(qint64 timeSpan);
87 void passTime(qint64 timeSpan);
92− QQuickView *view;
93− QTouchDevice *device;
94 FakeTimer *fakeTimer;
88 FakeTimer *fakeTimer;
95 QSharedPointer<FakeTimeSource> fakeTimeSource;
89 QSharedPointer<FakeTimeSource> fakeTimeSource;
96};
90};
97
91
98−void tst_DirectionalDragArea::initTestCase()
99−{
100− if (!device) {
101− device = new QTouchDevice;
102− device->setType(QTouchDevice::TouchScreen);
103− QWindowSystemInterface::registerTouchDevice(device);
104− }
105−
106− view = 0;
107−}
108−
109−void tst_DirectionalDragArea::cleanupTestCase()
110−{
111−}
112−
113void tst_DirectionalDragArea::init()
92void tst_DirectionalDragArea::init()
114{
93{
115− view = createView();
94+ GestureTest::init();
116− view->setSource(QUrl::fromLocalFile("edgeDragExample.qml"));
95+ m_view->setSource(QUrl::fromLocalFile("edgeDragExample.qml"));
117− view->show();
96+ m_view->show();
118− QVERIFY(QTest::qWaitForWindowExposed(view));
97+ QVERIFY(QTest::qWaitForWindowExposed(m_view));
119− QVERIFY(view->rootObject() != 0);
98+ QVERIFY(m_view->rootObject() != 0);
120 qApp->processEvents();
99 qApp->processEvents();
121
100
122 fakeTimeSource.reset(new FakeTimeSource);
101 fakeTimeSource.reset(new FakeTimeSource);
@@ -125,23 +104,12 @@ void tst_DirectionalDragArea::init()
125
104
126void tst_DirectionalDragArea::cleanup()
105void tst_DirectionalDragArea::cleanup()
127{
106{
128− delete view;
129− view = 0;
130−
131 delete fakeTimer;
107 delete fakeTimer;
132 fakeTimer = 0;
108 fakeTimer = 0;
133
109
134 fakeTimeSource.reset();
110 fakeTimeSource.reset();
135−}
136−
137−QQuickView *tst_DirectionalDragArea::createView()
138−{
139− QQuickView *window = new QQuickView(0);
140− window->setResizeMode(QQuickView::SizeRootObjectToView);
141− window->resize(600, 600);
142− window->engine()->addImportPath(QLatin1String(UBUNTU_GESTURES_PLUGIN_DIR));
143
111
144− return window;
112+ GestureTest::cleanup();
145}
113}
146
114
147void tst_DirectionalDragArea::passTime(qint64 timeSpan)
115void tst_DirectionalDragArea::passTime(qint64 timeSpan)
@@ -217,14 +185,14 @@ void tst_DirectionalDragArea::edgeDrag()
217 QFETCH(bool, expectGestureRecognition);
185 QFETCH(bool, expectGestureRecognition);
218
186
219 DirectionalDragArea *edgeDragArea =
187 DirectionalDragArea *edgeDragArea =
220− view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
188+ m_view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
221 QVERIFY(edgeDragArea != 0);
189 QVERIFY(edgeDragArea != 0);
222 edgeDragArea->setRecognitionTimer(fakeTimer);
190 edgeDragArea->setRecognitionTimer(fakeTimer);
223 edgeDragArea->setTimeSource(fakeTimeSource);
191 edgeDragArea->setTimeSource(fakeTimeSource);
224
192
225 QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
193 QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
226
194
227− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
195+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
228 QPointF touchPoint = initialTouchPos;
196 QPointF touchPoint = initialTouchPos;
229
197
230 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*dragDistanceFactor;
198 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*dragDistanceFactor;
@@ -235,7 +203,7 @@ void tst_DirectionalDragArea::edgeDrag()
235 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
203 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
236 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
204 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
237
205
238− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
206+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
239
207
240 QCOMPARE(draggingSpy.count(), 1);
208 QCOMPARE(draggingSpy.count(), 1);
241 QCOMPARE(edgeDragArea->dragging(), true);
209 QCOMPARE(edgeDragArea->dragging(), true);
@@ -245,13 +213,13 @@ void tst_DirectionalDragArea::edgeDrag()
245 // in order to make it easier to leave it by dragging at an angle
213 // in order to make it easier to leave it by dragging at an angle
246 // slightly bigger than the widening angle
214 // slightly bigger than the widening angle
247 touchPoint += createTouchDeviation(edgeDragArea);
215 touchPoint += createTouchDeviation(edgeDragArea);
248− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
216+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
249 }
217 }
250
218
251 for (int i = 0; i < totalMovementSteps; ++i) {
219 for (int i = 0; i < totalMovementSteps; ++i) {
252 touchPoint += touchMovement;
220 touchPoint += touchMovement;
253 passTime(movementTimeStepMs);
221 passTime(movementTimeStepMs);
254− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
222+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
255 }
223 }
256
224
257 if (expectGestureRecognition)
225 if (expectGestureRecognition)
@@ -262,7 +230,7 @@ void tst_DirectionalDragArea::edgeDrag()
262 QCOMPARE(draggingSpy.count(), 2);
230 QCOMPARE(draggingSpy.count(), 2);
263 }
231 }
264
232
265− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
233+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
266
234
267 QCOMPARE(draggingSpy.count(), 2);
235 QCOMPARE(draggingSpy.count(), 2);
268 QCOMPARE(edgeDragArea->dragging(), false);
236 QCOMPARE(edgeDragArea->dragging(), false);
@@ -326,12 +294,12 @@ void tst_DirectionalDragArea::edgeDrag_data()
326void tst_DirectionalDragArea::dragWithShortDirectionChange()
294void tst_DirectionalDragArea::dragWithShortDirectionChange()
327{
295{
328 DirectionalDragArea *edgeDragArea =
296 DirectionalDragArea *edgeDragArea =
329− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
297+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
330 QVERIFY(edgeDragArea != 0);
298 QVERIFY(edgeDragArea != 0);
331 edgeDragArea->setRecognitionTimer(fakeTimer);
299 edgeDragArea->setRecognitionTimer(fakeTimer);
332 edgeDragArea->setTimeSource(fakeTimeSource);
300 edgeDragArea->setTimeSource(fakeTimeSource);
333
301
334− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
302+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
335 QPointF touchPoint = initialTouchPos;
303 QPointF touchPoint = initialTouchPos;
336
304
337 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0;
305 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0;
@@ -341,32 +309,32 @@ void tst_DirectionalDragArea::dragWithShortDirectionChange()
341 int touchStepTimeMs = (touchStepDistance / (edgeDragArea->minSpeed() * 5.0f)) * 1000.0f;
309 int touchStepTimeMs = (touchStepDistance / (edgeDragArea->minSpeed() * 5.0f)) * 1000.0f;
342 QPointF touchMovement = dragDirectionVector * touchStepDistance;
310 QPointF touchMovement = dragDirectionVector * touchStepDistance;
343
311
344− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
312+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
345
313
346 // Move a bit in the proper direction
314 // Move a bit in the proper direction
347 for (int i=0; i < 3; ++i) {
315 for (int i=0; i < 3; ++i) {
348 touchPoint += touchMovement;
316 touchPoint += touchMovement;
349 passTime(touchStepTimeMs);
317 passTime(touchStepTimeMs);
350− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
318+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
351 }
319 }
352
320
353 // Then a sudden and small movement to the opposite direction
321 // Then a sudden and small movement to the opposite direction
354 touchPoint -= touchMovement*0.2;
322 touchPoint -= touchMovement*0.2;
355 passTime(touchStepTimeMs*0.2);
323 passTime(touchStepTimeMs*0.2);
356− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
324+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
357
325
358 // And then resume movment in the correct direction until it crosses the distance and time
326 // And then resume movment in the correct direction until it crosses the distance and time
359 // thresholds.
327 // thresholds.
360 do {
328 do {
361 touchPoint += touchMovement;
329 touchPoint += touchMovement;
362 passTime(touchStepTimeMs);
330 passTime(touchStepTimeMs);
363− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
331+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
364 } while ((touchPoint - initialTouchPos).manhattanLength() < desiredDragDistance
332 } while ((touchPoint - initialTouchPos).manhattanLength() < desiredDragDistance
365 || fakeTimeSource->m_msecsSinceReference < (edgeDragArea->compositionTime() * 1.5f));
333 || fakeTimeSource->m_msecsSinceReference < (edgeDragArea->compositionTime() * 1.5f));
366
334
367 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
335 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
368
336
369− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
337+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
370}
338}
371
339
372/*
340/*
@@ -380,7 +348,7 @@ void tst_DirectionalDragArea::minSpeed()
380 QFETCH(int, expectedStatusAfterSpeedCheck);
348 QFETCH(int, expectedStatusAfterSpeedCheck);
381
349
382 DirectionalDragArea *edgeDragArea =
350 DirectionalDragArea *edgeDragArea =
383− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
351+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
384 QVERIFY(edgeDragArea != 0);
352 QVERIFY(edgeDragArea != 0);
385 edgeDragArea->setRecognitionTimer(fakeTimer);
353 edgeDragArea->setRecognitionTimer(fakeTimer);
386 edgeDragArea->setTimeSource(fakeTimeSource);
354 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -391,7 +359,7 @@ void tst_DirectionalDragArea::minSpeed()
391
359
392 edgeDragArea->setMinSpeed(minSpeed);
360 edgeDragArea->setMinSpeed(minSpeed);
393
361
394− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
362+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
395 QPointF touchPoint = initialTouchPos;
363 QPointF touchPoint = initialTouchPos;
396
364
397 QPointF dragDirectionVector(1.0, 0.0);
365 QPointF dragDirectionVector(1.0, 0.0);
@@ -399,13 +367,13 @@ void tst_DirectionalDragArea::minSpeed()
399 qreal distanceStep = (speed / 1000.0f) * timeStepMsecs;
367 qreal distanceStep = (speed / 1000.0f) * timeStepMsecs;
400 QPointF touchMovement = dragDirectionVector * distanceStep;
368 QPointF touchMovement = dragDirectionVector * distanceStep;
401
369
402− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
370+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
403
371
404 // Move for a while to ensure our speed check is performed a couple of times
372 // Move for a while to ensure our speed check is performed a couple of times
405 for (int i=0; i < 20; ++i) {
373 for (int i=0; i < 20; ++i) {
406 touchPoint += touchMovement;
374 touchPoint += touchMovement;
407 passTime(timeStepMsecs);
375 passTime(timeStepMsecs);
408− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
376+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
409 }
377 }
410
378
411 QCOMPARE((int)edgeDragArea->status(), expectedStatusAfterSpeedCheck);
379 QCOMPARE((int)edgeDragArea->status(), expectedStatusAfterSpeedCheck);
@@ -429,7 +397,7 @@ void tst_DirectionalDragArea::minSpeed_data()
429void tst_DirectionalDragArea::recognitionTimerUsage()
397void tst_DirectionalDragArea::recognitionTimerUsage()
430{
398{
431 DirectionalDragArea *edgeDragArea =
399 DirectionalDragArea *edgeDragArea =
432− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
400+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
433 QVERIFY(edgeDragArea != 0);
401 QVERIFY(edgeDragArea != 0);
434 edgeDragArea->setRecognitionTimer(fakeTimer);
402 edgeDragArea->setRecognitionTimer(fakeTimer);
435 edgeDragArea->setTimeSource(fakeTimeSource);
403 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -439,7 +407,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
439
407
440 int timeStepMs = 5; // some arbitrary small value.
408 int timeStepMs = 5; // some arbitrary small value.
441
409
442− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
410+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
443 QPointF touchPoint = initialTouchPos;
411 QPointF touchPoint = initialTouchPos;
444
412
445 QPointF dragDirectionVector(1.0, 0.0);
413 QPointF dragDirectionVector(1.0, 0.0);
@@ -448,7 +416,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
448 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
416 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
449 QVERIFY(!fakeTimer->isRunning());
417 QVERIFY(!fakeTimer->isRunning());
450
418
451− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
419+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
452
420
453 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
421 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
454 QVERIFY(fakeTimer->isRunning());
422 QVERIFY(fakeTimer->isRunning());
@@ -461,7 +429,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
461
429
462 touchPoint += touchMovement;
430 touchPoint += touchMovement;
463 passTime(timeStepMs);
431 passTime(timeStepMs);
464− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
432+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
465 }
433 }
466
434
467 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
435 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
@@ -475,7 +443,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
475void tst_DirectionalDragArea::maxSilenceTime()
443void tst_DirectionalDragArea::maxSilenceTime()
476{
444{
477 DirectionalDragArea *edgeDragArea =
445 DirectionalDragArea *edgeDragArea =
478− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
446+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
479 QVERIFY(edgeDragArea != 0);
447 QVERIFY(edgeDragArea != 0);
480 edgeDragArea->setRecognitionTimer(fakeTimer);
448 edgeDragArea->setRecognitionTimer(fakeTimer);
481 edgeDragArea->setTimeSource(fakeTimeSource);
449 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -483,10 +451,10 @@ void tst_DirectionalDragArea::maxSilenceTime()
483 // Make sure this property is not disabled
451 // Make sure this property is not disabled
484 edgeDragArea->setMaxSilenceTime(100);
452 edgeDragArea->setMaxSilenceTime(100);
485
453
486− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
454+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
487 QPointF touchPoint = initialTouchPos;
455 QPointF touchPoint = initialTouchPos;
488
456
489− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
457+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
490
458
491 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
459 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
492 QVERIFY(fakeTimer->isRunning());
460 QVERIFY(fakeTimer->isRunning());
@@ -506,20 +474,20 @@ void tst_DirectionalDragArea::maxSilenceTime()
506void tst_DirectionalDragArea::sceneXAndX()
474void tst_DirectionalDragArea::sceneXAndX()
507{
475{
508 DirectionalDragArea *edgeDragArea =
476 DirectionalDragArea *edgeDragArea =
509− view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
477+ m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
510 QVERIFY(edgeDragArea != 0);
478 QVERIFY(edgeDragArea != 0);
511 edgeDragArea->setRecognitionTimer(fakeTimer);
479 edgeDragArea->setRecognitionTimer(fakeTimer);
512 edgeDragArea->setTimeSource(fakeTimeSource);
480 edgeDragArea->setTimeSource(fakeTimeSource);
513
481
514− QPointF touchScenePos(view->width() - (edgeDragArea->width()/2.0f), view->height()/2.0f);
482+ QPointF touchScenePos(m_view->width() - (edgeDragArea->width()/2.0f), m_view->height()/2.0f);
515
483
516− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
484+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
517
485
518 QSignalSpy touchXSpy(edgeDragArea, SIGNAL(touchXChanged(qreal)));
486 QSignalSpy touchXSpy(edgeDragArea, SIGNAL(touchXChanged(qreal)));
519 QSignalSpy touchSceneXSpy(edgeDragArea, SIGNAL(touchSceneXChanged(qreal)));
487 QSignalSpy touchSceneXSpy(edgeDragArea, SIGNAL(touchSceneXChanged(qreal)));
520
488
521− touchScenePos.rx() = view->width() / 2;
489+ touchScenePos.rx() = m_view->width() / 2;
522− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
490+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
523
491
524 QCOMPARE(touchXSpy.count(), 1);
492 QCOMPARE(touchXSpy.count(), 1);
525 QCOMPARE(touchSceneXSpy.count(), 1);
493 QCOMPARE(touchSceneXSpy.count(), 1);
@@ -534,20 +502,20 @@ void tst_DirectionalDragArea::sceneXAndX()
534void tst_DirectionalDragArea::sceneYAndY()
502void tst_DirectionalDragArea::sceneYAndY()
535{
503{
536 DirectionalDragArea *edgeDragArea =
504 DirectionalDragArea *edgeDragArea =
537− view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
505+ m_view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
538 QVERIFY(edgeDragArea != 0);
506 QVERIFY(edgeDragArea != 0);
539 edgeDragArea->setRecognitionTimer(fakeTimer);
507 edgeDragArea->setRecognitionTimer(fakeTimer);
540 edgeDragArea->setTimeSource(fakeTimeSource);
508 edgeDragArea->setTimeSource(fakeTimeSource);
541
509
542− QPointF touchScenePos(view->width()/2.0f, view->height() - (edgeDragArea->height()/2.0f));
510+ QPointF touchScenePos(m_view->width()/2.0f, m_view->height() - (edgeDragArea->height()/2.0f));
543
511
544− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
512+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
545
513
546 QSignalSpy touchYSpy(edgeDragArea, SIGNAL(touchYChanged(qreal)));
514 QSignalSpy touchYSpy(edgeDragArea, SIGNAL(touchYChanged(qreal)));
547 QSignalSpy touchSceneYSpy(edgeDragArea, SIGNAL(touchSceneYChanged(qreal)));
515 QSignalSpy touchSceneYSpy(edgeDragArea, SIGNAL(touchSceneYChanged(qreal)));
548
516
549− touchScenePos.ry() = view->height() / 2;
517+ touchScenePos.ry() = m_view->height() / 2;
550− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
518+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
551
519
552 QCOMPARE(touchYSpy.count(), 1);
520 QCOMPARE(touchYSpy.count(), 1);
553 QCOMPARE(touchSceneYSpy.count(), 1);
521 QCOMPARE(touchSceneYSpy.count(), 1);
@@ -564,27 +532,27 @@ void tst_DirectionalDragArea::sceneYAndY()
564void tst_DirectionalDragArea::twoFingerTap()
532void tst_DirectionalDragArea::twoFingerTap()
565{
533{
566 DirectionalDragArea *edgeDragArea =
534 DirectionalDragArea *edgeDragArea =
567− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
535+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
568 QVERIFY(edgeDragArea != 0);
536 QVERIFY(edgeDragArea != 0);
569 edgeDragArea->setRecognitionTimer(fakeTimer);
537 edgeDragArea->setRecognitionTimer(fakeTimer);
570 edgeDragArea->setTimeSource(fakeTimeSource);
538 edgeDragArea->setTimeSource(fakeTimeSource);
571
539
572 // Make touches evenly spaced along the edgeDragArea
540 // Make touches evenly spaced along the edgeDragArea
573− QPoint touchAPos(edgeDragArea->width()/2.0f, view->height()*0.33f);
541+ QPoint touchAPos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
574− QPoint touchBPos(edgeDragArea->width()/2.0f, view->height()*0.66f);
542+ QPoint touchBPos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
575
543
576 qint64 timeStepMsecs = 5; // some arbitrary, small value
544 qint64 timeStepMsecs = 5; // some arbitrary, small value
577
545
578 // Perform the first two-finger tap
546 // Perform the first two-finger tap
579 // NB: using move() instead of stationary() becasue in the latter you cannot provide
547 // NB: using move() instead of stationary() becasue in the latter you cannot provide
580 // the touch position and therefore it's left with some garbage numbers.
548 // the touch position and therefore it's left with some garbage numbers.
581− QTest::touchEvent(view, device)
549+ QTest::touchEvent(m_view, m_device)
582 .press(0, touchAPos);
550 .press(0, touchAPos);
583
551
584 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
552 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
585
553
586 passTime(timeStepMsecs);
554 passTime(timeStepMsecs);
587− QTest::touchEvent(view, device)
555+ QTest::touchEvent(m_view, m_device)
588 .move(0, touchAPos)
556 .move(0, touchAPos)
589 .press(1, touchBPos);
557 .press(1, touchBPos);
590
558
@@ -593,14 +561,14 @@ void tst_DirectionalDragArea::twoFingerTap()
593 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
561 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
594
562
595 passTime(timeStepMsecs);
563 passTime(timeStepMsecs);
596− QTest::touchEvent(view, device)
564+ QTest::touchEvent(m_view, m_device)
597 .release(0, touchAPos)
565 .release(0, touchAPos)
598 .move(1, touchBPos);
566 .move(1, touchBPos);
599
567
600 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
568 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
601
569
602 passTime(timeStepMsecs);
570 passTime(timeStepMsecs);
603− QTest::touchEvent(view, device)
571+ QTest::touchEvent(m_view, m_device)
604 .release(1, touchBPos);
572 .release(1, touchBPos);
605
573
606 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
574 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -608,27 +576,27 @@ void tst_DirectionalDragArea::twoFingerTap()
608 // Perform the second two-finger tap
576 // Perform the second two-finger tap
609
577
610 passTime(timeStepMsecs);
578 passTime(timeStepMsecs);
611− QTest::touchEvent(view, device)
579+ QTest::touchEvent(m_view, m_device)
612 .press(0, touchAPos);
580 .press(0, touchAPos);
613
581
614 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
582 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
615
583
616 passTime(timeStepMsecs);
584 passTime(timeStepMsecs);
617− QTest::touchEvent(view, device)
585+ QTest::touchEvent(m_view, m_device)
618 .move(0, touchAPos)
586 .move(0, touchAPos)
619 .press(1, touchBPos);
587 .press(1, touchBPos);
620
588
621 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
589 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
622
590
623 passTime(timeStepMsecs);
591 passTime(timeStepMsecs);
624− QTest::touchEvent(view, device)
592+ QTest::touchEvent(m_view, m_device)
625 .release(0, touchAPos)
593 .release(0, touchAPos)
626 .move(1, touchBPos);
594 .move(1, touchBPos);
627
595
628 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
596 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
629
597
630 passTime(timeStepMsecs);
598 passTime(timeStepMsecs);
631− QTest::touchEvent(view, device)
599+ QTest::touchEvent(m_view, m_device)
632 .release(1, touchBPos);
600 .release(1, touchBPos);
633
601
634 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
602 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -642,7 +610,7 @@ void tst_DirectionalDragArea::twoFingerTap()
642 */
610 */
643void tst_DirectionalDragArea::movingDDA()
611void tst_DirectionalDragArea::movingDDA()
644{
612{
645− QQuickItem *rightwardsLauncher = view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
613+ QQuickItem *rightwardsLauncher = m_view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
646 Q_ASSERT(rightwardsLauncher != 0);
614 Q_ASSERT(rightwardsLauncher != 0);
647
615
648 DirectionalDragArea *edgeDragArea =
616 DirectionalDragArea *edgeDragArea =
@@ -651,7 +619,7 @@ void tst_DirectionalDragArea::movingDDA()
651 edgeDragArea->setRecognitionTimer(fakeTimer);
619 edgeDragArea->setRecognitionTimer(fakeTimer);
652 edgeDragArea->setTimeSource(fakeTimeSource);
620 edgeDragArea->setTimeSource(fakeTimeSource);
653
621
654− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
622+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
655 QPointF touchPoint = initialTouchPos;
623 QPointF touchPoint = initialTouchPos;
656
624
657 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
625 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
@@ -662,7 +630,7 @@ void tst_DirectionalDragArea::movingDDA()
662 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
630 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
663 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
631 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
664
632
665− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
633+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
666
634
667 // Move it far ahead along the direction of the gesture
635 // Move it far ahead along the direction of the gesture
668 // rightwardsLauncher is a parent of our DirectionalDragArea. So moving it will move our DDA
636 // rightwardsLauncher is a parent of our DirectionalDragArea. So moving it will move our DDA
@@ -671,12 +639,12 @@ void tst_DirectionalDragArea::movingDDA()
671 for (int i = 0; i < totalMovementSteps; ++i) {
639 for (int i = 0; i < totalMovementSteps; ++i) {
672 touchPoint += touchMovement;
640 touchPoint += touchMovement;
673 passTime(movementTimeStepMs);
641 passTime(movementTimeStepMs);
674− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
642+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
675 }
643 }
676
644
677 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
645 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
678
646
679− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
647+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
680}
648}
681
649
682/*
650/*
@@ -686,16 +654,16 @@ void tst_DirectionalDragArea::movingDDA()
686void tst_DirectionalDragArea::ignoreOldFinger()
654void tst_DirectionalDragArea::ignoreOldFinger()
687{
655{
688 DirectionalDragArea *edgeDragArea =
656 DirectionalDragArea *edgeDragArea =
689− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
657+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
690 Q_ASSERT(edgeDragArea != 0);
658 Q_ASSERT(edgeDragArea != 0);
691 edgeDragArea->setRecognitionTimer(fakeTimer);
659 edgeDragArea->setRecognitionTimer(fakeTimer);
692 edgeDragArea->setTimeSource(fakeTimeSource);
660 edgeDragArea->setTimeSource(fakeTimeSource);
693
661
694 // Make touches evenly spaced along the edgeDragArea
662 // Make touches evenly spaced along the edgeDragArea
695− QPoint touch0Pos(edgeDragArea->width()/2.0f, view->height()*0.33f);
663+ QPoint touch0Pos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
696− QPoint touch1Pos(edgeDragArea->width()/2.0f, view->height()*0.66f);
664+ QPoint touch1Pos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
697
665
698− QTest::touchEvent(view, device).press(0, touch0Pos);
666+ QTest::touchEvent(m_view, m_device).press(0, touch0Pos);
699
667
700 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
668 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
701
669
@@ -712,7 +680,7 @@ void tst_DirectionalDragArea::ignoreOldFinger()
712 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
680 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
713 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
681 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
714
682
715− QTest::touchEvent(view, device)
683+ QTest::touchEvent(m_view, m_device)
716 .move(0, touch0Pos)
684 .move(0, touch0Pos)
717 .press(1, touch1Pos);
685 .press(1, touch1Pos);
718
686
@@ -721,14 +689,14 @@ void tst_DirectionalDragArea::ignoreOldFinger()
721 for (int i = 0; i < totalMovementSteps; ++i) {
689 for (int i = 0; i < totalMovementSteps; ++i) {
722 touch1Pos += touchMovement.toPoint();
690 touch1Pos += touchMovement.toPoint();
723 passTime(movementTimeStepMs);
691 passTime(movementTimeStepMs);
724− QTest::touchEvent(view, device)
692+ QTest::touchEvent(m_view, m_device)
725 .move(0, touch0Pos)
693 .move(0, touch0Pos)
726 .move(1, touch1Pos);
694 .move(1, touch1Pos);
727 }
695 }
728
696
729 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
697 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
730
698
731− QTest::touchEvent(view, device)
699+ QTest::touchEvent(m_view, m_device)
732 .move(0, touch0Pos)
700 .move(0, touch0Pos)
733 .release(1, touch1Pos);
701 .release(1, touch1Pos);
734
702