on xenial help sign in
Refactor Ubuntu.Gesture tests to share common logic

Take the common part out of tst_DirectionalDragArea and put it into a separate base class, GestureTest, so that it can be shared with other, future, tests. In CMakeLists.txt, create a macro out of DirectionalDragArea build script to be used by future tests with similar requirements and structure. Also add the "m_" prefix to member variables.

commit6a3ca33a2bb401cb5aaaff22c661064487ac78a9 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 22 Nov 2013, 08:27 (13 years ago) parentd7a2fd9
4 files changed+172−117
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+18−19 tests/plugins/Ubuntu/Gestures/GestureTest.cpp+44 tests/plugins/Ubuntu/Gestures/GestureTest.h+44 tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+66−98
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+18−19
@@ -1,33 +1,31 @@
1−########## tst_DirectionalDragArea
2−
31include_directories(
42 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
53 ${CMAKE_CURRENT_BINARY_DIR}
64 )
75
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−
246file(GLOB qmlFiles *.qml)
257add_custom_target(UbuntuGesturesTestQmlFiles ALL
268 COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
279 DEPENDS ${qmlFiles}
2810)
2911
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)
3129
3230macro(add_gesture_test CLASSNAME)
3331 set(testCommand
@@ -43,5 +41,6 @@ macro(add_gesture_test CLASSNAME)
4341 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
4442endmacro(add_gesture_test)
4543
44+add_gesture_ui_test(DirectionalDragArea)
4645add_gesture_test(Damper)
4746add_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 @@
1616
1717#include <QtTest/QtTest>
1818#include <QtCore/QObject>
19−#include <qpa/qwindowsysteminterface.h>
2019#include <QtQuick/QQuickView>
2120#include <QtQml/QQmlEngine>
2221#include <QPointer>
2322
2423#include <DirectionalDragArea.h>
2524
25+#include "GestureTest.h"
26+
2627using namespace UbuntuGestures;
2728
2829class FakeTimer : public AbstractTimer
@@ -61,15 +62,11 @@ public:
6162 qint64 m_msecsSinceReference;
6263};
6364
64−class tst_DirectionalDragArea: public QObject
65+class tst_DirectionalDragArea: public GestureTest
6566{
6667 Q_OBJECT
6768public:
68− tst_DirectionalDragArea() : device(0) { }
6969private 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−
7370 void init(); // called right before each and every test function is executed
7471 void cleanup(); // called right after each and every test function is executed
7572
@@ -87,36 +84,18 @@ private Q_SLOTS:
8784 void ignoreOldFinger();
8885
8986private:
90− QQuickView *createView();
9187 void passTime(qint64 timeSpan);
92− QQuickView *view;
93− QTouchDevice *device;
9488 FakeTimer *fakeTimer;
9589 QSharedPointer<FakeTimeSource> fakeTimeSource;
9690};
9791
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−
11392void tst_DirectionalDragArea::init()
11493{
115− view = createView();
116− view->setSource(QUrl::fromLocalFile("edgeDragExample.qml"));
117− view->show();
118− QVERIFY(QTest::qWaitForWindowExposed(view));
119− QVERIFY(view->rootObject() != 0);
94+ GestureTest::init();
95+ m_view->setSource(QUrl::fromLocalFile("edgeDragExample.qml"));
96+ m_view->show();
97+ QVERIFY(QTest::qWaitForWindowExposed(m_view));
98+ QVERIFY(m_view->rootObject() != 0);
12099 qApp->processEvents();
121100
122101 fakeTimeSource.reset(new FakeTimeSource);
@@ -125,23 +104,12 @@ void tst_DirectionalDragArea::init()
125104
126105void tst_DirectionalDragArea::cleanup()
127106{
128− delete view;
129− view = 0;
130−
131107 delete fakeTimer;
132108 fakeTimer = 0;
133109
134110 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));
143111
144− return window;
112+ GestureTest::cleanup();
145113}
146114
147115void tst_DirectionalDragArea::passTime(qint64 timeSpan)
@@ -217,14 +185,14 @@ void tst_DirectionalDragArea::edgeDrag()
217185 QFETCH(bool, expectGestureRecognition);
218186
219187 DirectionalDragArea *edgeDragArea =
220− view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
188+ m_view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
221189 QVERIFY(edgeDragArea != 0);
222190 edgeDragArea->setRecognitionTimer(fakeTimer);
223191 edgeDragArea->setTimeSource(fakeTimeSource);
224192
225193 QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
226194
227− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
195+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
228196 QPointF touchPoint = initialTouchPos;
229197
230198 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*dragDistanceFactor;
@@ -235,7 +203,7 @@ void tst_DirectionalDragArea::edgeDrag()
235203 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
236204 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
237205
238− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
206+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
239207
240208 QCOMPARE(draggingSpy.count(), 1);
241209 QCOMPARE(edgeDragArea->dragging(), true);
@@ -245,13 +213,13 @@ void tst_DirectionalDragArea::edgeDrag()
245213 // in order to make it easier to leave it by dragging at an angle
246214 // slightly bigger than the widening angle
247215 touchPoint += createTouchDeviation(edgeDragArea);
248− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
216+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
249217 }
250218
251219 for (int i = 0; i < totalMovementSteps; ++i) {
252220 touchPoint += touchMovement;
253221 passTime(movementTimeStepMs);
254− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
222+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
255223 }
256224
257225 if (expectGestureRecognition)
@@ -262,7 +230,7 @@ void tst_DirectionalDragArea::edgeDrag()
262230 QCOMPARE(draggingSpy.count(), 2);
263231 }
264232
265− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
233+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
266234
267235 QCOMPARE(draggingSpy.count(), 2);
268236 QCOMPARE(edgeDragArea->dragging(), false);
@@ -326,12 +294,12 @@ void tst_DirectionalDragArea::edgeDrag_data()
326294void tst_DirectionalDragArea::dragWithShortDirectionChange()
327295{
328296 DirectionalDragArea *edgeDragArea =
329− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
297+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
330298 QVERIFY(edgeDragArea != 0);
331299 edgeDragArea->setRecognitionTimer(fakeTimer);
332300 edgeDragArea->setTimeSource(fakeTimeSource);
333301
334− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
302+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
335303 QPointF touchPoint = initialTouchPos;
336304
337305 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0;
@@ -341,32 +309,32 @@ void tst_DirectionalDragArea::dragWithShortDirectionChange()
341309 int touchStepTimeMs = (touchStepDistance / (edgeDragArea->minSpeed() * 5.0f)) * 1000.0f;
342310 QPointF touchMovement = dragDirectionVector * touchStepDistance;
343311
344− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
312+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
345313
346314 // Move a bit in the proper direction
347315 for (int i=0; i < 3; ++i) {
348316 touchPoint += touchMovement;
349317 passTime(touchStepTimeMs);
350− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
318+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
351319 }
352320
353321 // Then a sudden and small movement to the opposite direction
354322 touchPoint -= touchMovement*0.2;
355323 passTime(touchStepTimeMs*0.2);
356− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
324+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
357325
358326 // And then resume movment in the correct direction until it crosses the distance and time
359327 // thresholds.
360328 do {
361329 touchPoint += touchMovement;
362330 passTime(touchStepTimeMs);
363− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
331+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
364332 } while ((touchPoint - initialTouchPos).manhattanLength() < desiredDragDistance
365333 || fakeTimeSource->m_msecsSinceReference < (edgeDragArea->compositionTime() * 1.5f));
366334
367335 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
368336
369− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
337+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
370338}
371339
372340/*
@@ -380,7 +348,7 @@ void tst_DirectionalDragArea::minSpeed()
380348 QFETCH(int, expectedStatusAfterSpeedCheck);
381349
382350 DirectionalDragArea *edgeDragArea =
383− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
351+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
384352 QVERIFY(edgeDragArea != 0);
385353 edgeDragArea->setRecognitionTimer(fakeTimer);
386354 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -391,7 +359,7 @@ void tst_DirectionalDragArea::minSpeed()
391359
392360 edgeDragArea->setMinSpeed(minSpeed);
393361
394− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
362+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
395363 QPointF touchPoint = initialTouchPos;
396364
397365 QPointF dragDirectionVector(1.0, 0.0);
@@ -399,13 +367,13 @@ void tst_DirectionalDragArea::minSpeed()
399367 qreal distanceStep = (speed / 1000.0f) * timeStepMsecs;
400368 QPointF touchMovement = dragDirectionVector * distanceStep;
401369
402− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
370+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
403371
404372 // Move for a while to ensure our speed check is performed a couple of times
405373 for (int i=0; i < 20; ++i) {
406374 touchPoint += touchMovement;
407375 passTime(timeStepMsecs);
408− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
376+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
409377 }
410378
411379 QCOMPARE((int)edgeDragArea->status(), expectedStatusAfterSpeedCheck);
@@ -429,7 +397,7 @@ void tst_DirectionalDragArea::minSpeed_data()
429397void tst_DirectionalDragArea::recognitionTimerUsage()
430398{
431399 DirectionalDragArea *edgeDragArea =
432− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
400+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
433401 QVERIFY(edgeDragArea != 0);
434402 edgeDragArea->setRecognitionTimer(fakeTimer);
435403 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -439,7 +407,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
439407
440408 int timeStepMs = 5; // some arbitrary small value.
441409
442− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
410+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
443411 QPointF touchPoint = initialTouchPos;
444412
445413 QPointF dragDirectionVector(1.0, 0.0);
@@ -448,7 +416,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
448416 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
449417 QVERIFY(!fakeTimer->isRunning());
450418
451− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
419+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
452420
453421 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
454422 QVERIFY(fakeTimer->isRunning());
@@ -461,7 +429,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
461429
462430 touchPoint += touchMovement;
463431 passTime(timeStepMs);
464− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
432+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
465433 }
466434
467435 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
@@ -475,7 +443,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
475443void tst_DirectionalDragArea::maxSilenceTime()
476444{
477445 DirectionalDragArea *edgeDragArea =
478− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
446+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
479447 QVERIFY(edgeDragArea != 0);
480448 edgeDragArea->setRecognitionTimer(fakeTimer);
481449 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -483,10 +451,10 @@ void tst_DirectionalDragArea::maxSilenceTime()
483451 // Make sure this property is not disabled
484452 edgeDragArea->setMaxSilenceTime(100);
485453
486− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
454+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
487455 QPointF touchPoint = initialTouchPos;
488456
489− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
457+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
490458
491459 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
492460 QVERIFY(fakeTimer->isRunning());
@@ -506,20 +474,20 @@ void tst_DirectionalDragArea::maxSilenceTime()
506474void tst_DirectionalDragArea::sceneXAndX()
507475{
508476 DirectionalDragArea *edgeDragArea =
509− view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
477+ m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
510478 QVERIFY(edgeDragArea != 0);
511479 edgeDragArea->setRecognitionTimer(fakeTimer);
512480 edgeDragArea->setTimeSource(fakeTimeSource);
513481
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);
515483
516− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
484+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
517485
518486 QSignalSpy touchXSpy(edgeDragArea, SIGNAL(touchXChanged(qreal)));
519487 QSignalSpy touchSceneXSpy(edgeDragArea, SIGNAL(touchSceneXChanged(qreal)));
520488
521− touchScenePos.rx() = view->width() / 2;
522− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
489+ touchScenePos.rx() = m_view->width() / 2;
490+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
523491
524492 QCOMPARE(touchXSpy.count(), 1);
525493 QCOMPARE(touchSceneXSpy.count(), 1);
@@ -534,20 +502,20 @@ void tst_DirectionalDragArea::sceneXAndX()
534502void tst_DirectionalDragArea::sceneYAndY()
535503{
536504 DirectionalDragArea *edgeDragArea =
537− view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
505+ m_view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
538506 QVERIFY(edgeDragArea != 0);
539507 edgeDragArea->setRecognitionTimer(fakeTimer);
540508 edgeDragArea->setTimeSource(fakeTimeSource);
541509
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));
543511
544− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
512+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
545513
546514 QSignalSpy touchYSpy(edgeDragArea, SIGNAL(touchYChanged(qreal)));
547515 QSignalSpy touchSceneYSpy(edgeDragArea, SIGNAL(touchSceneYChanged(qreal)));
548516
549− touchScenePos.ry() = view->height() / 2;
550− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
517+ touchScenePos.ry() = m_view->height() / 2;
518+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
551519
552520 QCOMPARE(touchYSpy.count(), 1);
553521 QCOMPARE(touchSceneYSpy.count(), 1);
@@ -564,27 +532,27 @@ void tst_DirectionalDragArea::sceneYAndY()
564532void tst_DirectionalDragArea::twoFingerTap()
565533{
566534 DirectionalDragArea *edgeDragArea =
567− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
535+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
568536 QVERIFY(edgeDragArea != 0);
569537 edgeDragArea->setRecognitionTimer(fakeTimer);
570538 edgeDragArea->setTimeSource(fakeTimeSource);
571539
572540 // Make touches evenly spaced along the edgeDragArea
573− QPoint touchAPos(edgeDragArea->width()/2.0f, view->height()*0.33f);
574− QPoint touchBPos(edgeDragArea->width()/2.0f, view->height()*0.66f);
541+ QPoint touchAPos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
542+ QPoint touchBPos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
575543
576544 qint64 timeStepMsecs = 5; // some arbitrary, small value
577545
578546 // Perform the first two-finger tap
579547 // NB: using move() instead of stationary() becasue in the latter you cannot provide
580548 // the touch position and therefore it's left with some garbage numbers.
581− QTest::touchEvent(view, device)
549+ QTest::touchEvent(m_view, m_device)
582550 .press(0, touchAPos);
583551
584552 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
585553
586554 passTime(timeStepMsecs);
587− QTest::touchEvent(view, device)
555+ QTest::touchEvent(m_view, m_device)
588556 .move(0, touchAPos)
589557 .press(1, touchBPos);
590558
@@ -593,14 +561,14 @@ void tst_DirectionalDragArea::twoFingerTap()
593561 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
594562
595563 passTime(timeStepMsecs);
596− QTest::touchEvent(view, device)
564+ QTest::touchEvent(m_view, m_device)
597565 .release(0, touchAPos)
598566 .move(1, touchBPos);
599567
600568 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
601569
602570 passTime(timeStepMsecs);
603− QTest::touchEvent(view, device)
571+ QTest::touchEvent(m_view, m_device)
604572 .release(1, touchBPos);
605573
606574 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -608,27 +576,27 @@ void tst_DirectionalDragArea::twoFingerTap()
608576 // Perform the second two-finger tap
609577
610578 passTime(timeStepMsecs);
611− QTest::touchEvent(view, device)
579+ QTest::touchEvent(m_view, m_device)
612580 .press(0, touchAPos);
613581
614582 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
615583
616584 passTime(timeStepMsecs);
617− QTest::touchEvent(view, device)
585+ QTest::touchEvent(m_view, m_device)
618586 .move(0, touchAPos)
619587 .press(1, touchBPos);
620588
621589 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
622590
623591 passTime(timeStepMsecs);
624− QTest::touchEvent(view, device)
592+ QTest::touchEvent(m_view, m_device)
625593 .release(0, touchAPos)
626594 .move(1, touchBPos);
627595
628596 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
629597
630598 passTime(timeStepMsecs);
631− QTest::touchEvent(view, device)
599+ QTest::touchEvent(m_view, m_device)
632600 .release(1, touchBPos);
633601
634602 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -642,7 +610,7 @@ void tst_DirectionalDragArea::twoFingerTap()
642610 */
643611void tst_DirectionalDragArea::movingDDA()
644612{
645− QQuickItem *rightwardsLauncher = view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
613+ QQuickItem *rightwardsLauncher = m_view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
646614 Q_ASSERT(rightwardsLauncher != 0);
647615
648616 DirectionalDragArea *edgeDragArea =
@@ -651,7 +619,7 @@ void tst_DirectionalDragArea::movingDDA()
651619 edgeDragArea->setRecognitionTimer(fakeTimer);
652620 edgeDragArea->setTimeSource(fakeTimeSource);
653621
654− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
622+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
655623 QPointF touchPoint = initialTouchPos;
656624
657625 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
@@ -662,7 +630,7 @@ void tst_DirectionalDragArea::movingDDA()
662630 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
663631 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
664632
665− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
633+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
666634
667635 // Move it far ahead along the direction of the gesture
668636 // rightwardsLauncher is a parent of our DirectionalDragArea. So moving it will move our DDA
@@ -671,12 +639,12 @@ void tst_DirectionalDragArea::movingDDA()
671639 for (int i = 0; i < totalMovementSteps; ++i) {
672640 touchPoint += touchMovement;
673641 passTime(movementTimeStepMs);
674− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
642+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
675643 }
676644
677645 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
678646
679− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
647+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
680648}
681649
682650/*
@@ -686,16 +654,16 @@ void tst_DirectionalDragArea::movingDDA()
686654void tst_DirectionalDragArea::ignoreOldFinger()
687655{
688656 DirectionalDragArea *edgeDragArea =
689− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
657+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
690658 Q_ASSERT(edgeDragArea != 0);
691659 edgeDragArea->setRecognitionTimer(fakeTimer);
692660 edgeDragArea->setTimeSource(fakeTimeSource);
693661
694662 // Make touches evenly spaced along the edgeDragArea
695− QPoint touch0Pos(edgeDragArea->width()/2.0f, view->height()*0.33f);
696− QPoint touch1Pos(edgeDragArea->width()/2.0f, view->height()*0.66f);
663+ QPoint touch0Pos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
664+ QPoint touch1Pos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
697665
698− QTest::touchEvent(view, device).press(0, touch0Pos);
666+ QTest::touchEvent(m_view, m_device).press(0, touch0Pos);
699667
700668 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
701669
@@ -712,7 +680,7 @@ void tst_DirectionalDragArea::ignoreOldFinger()
712680 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
713681 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
714682
715− QTest::touchEvent(view, device)
683+ QTest::touchEvent(m_view, m_device)
716684 .move(0, touch0Pos)
717685 .press(1, touch1Pos);
718686
@@ -721,14 +689,14 @@ void tst_DirectionalDragArea::ignoreOldFinger()
721689 for (int i = 0; i < totalMovementSteps; ++i) {
722690 touch1Pos += touchMovement.toPoint();
723691 passTime(movementTimeStepMs);
724− QTest::touchEvent(view, device)
692+ QTest::touchEvent(m_view, m_device)
725693 .move(0, touch0Pos)
726694 .move(1, touch1Pos);
727695 }
728696
729697 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
730698
731− QTest::touchEvent(view, device)
699+ QTest::touchEvent(m_view, m_device)
732700 .move(0, touch0Pos)
733701 .release(1, touch1Pos);
734702