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. Approved by PS Jenkins bot, Michael Zanetti.

commit36f751dabd21b228beccf38b2c4667027b655c67 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 22 Nov 2013, 14:59 (13 years ago) parent2be9b562cef79a
5 files changed+187−116
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+20−18 tests/plugins/Ubuntu/Gestures/GestureTest.cpp+54 tests/plugins/Ubuntu/Gestures/GestureTest.h+46 tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+65−96 tests/plugins/Ubuntu/Gestures/edgeDragExample.qml → tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.qml+2−2
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+20−18
@@ -1,33 +1,34 @@
1−########## tst_DirectionalDragArea
1+include(QmlTest)
22
33include_directories(
44 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
55 ${CMAKE_CURRENT_BINARY_DIR}
66 )
77
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−
248file(GLOB qmlFiles *.qml)
259add_custom_target(UbuntuGesturesTestQmlFiles ALL
2610 COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
2711 DEPENDS ${qmlFiles}
2812)
2913
30−########## other tests
14+add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
15+
16+macro(add_gesture_ui_test CLASSNAME)
17+ set(testCommand
18+ LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
19+ ${CMAKE_CURRENT_BINARY_DIR}/${CLASSNAME}TestExec
20+ -o ${CMAKE_BINARY_DIR}/${CLASSNAME}Test.xml,xunitxml
21+ -o -,txt)
22+
23+ add_custom_target(test${CLASSNAME} ${testCommand})
24+ add_dependencies(qmluitests test${CLASSNAME})
25+ add_dependencies(test${CLASSNAME} ${CLASSNAME}TestExec UbuntuGesturesTestQmlFiles)
26+
27+ add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp)
28+ qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
29+ target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
30+ add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
31+endmacro(add_gesture_ui_test)
3132
3233macro(add_gesture_test CLASSNAME)
3334 set(testCommand
@@ -43,5 +44,6 @@ macro(add_gesture_test CLASSNAME)
4344 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
4445endmacro(add_gesture_test)
4546
47+add_gesture_ui_test(DirectionalDragArea)
4648add_gesture_test(Damper)
4749add_gesture_test(AxisVelocityCalculator)
tests/plugins/Ubuntu/Gestures/GestureTest.cppnew file+54
@@ -0,0 +1,54 @@
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+#include <QtTest>
23+
24+GestureTest::GestureTest(const QString &qmlFilename)
25+ : QObject(), m_device(nullptr), m_view(nullptr), m_qmlFilename(qmlFilename)
26+{
27+}
28+
29+void GestureTest::initTestCase()
30+{
31+ if (!m_device) {
32+ m_device = new QTouchDevice;
33+ m_device->setType(QTouchDevice::TouchScreen);
34+ QWindowSystemInterface::registerTouchDevice(m_device);
35+ }
36+}
37+
38+void GestureTest::init()
39+{
40+ m_view = new QQuickView;
41+ m_view->setResizeMode(QQuickView::SizeViewToRootObject);
42+ m_view->engine()->addImportPath(QStringLiteral(UBUNTU_GESTURES_PLUGIN_DIR));
43+ m_view->setSource(QUrl::fromLocalFile(m_qmlFilename));
44+ m_view->show();
45+ QVERIFY(QTest::qWaitForWindowExposed(m_view));
46+ QVERIFY(m_view->rootObject() != 0);
47+ qApp->processEvents();
48+}
49+
50+void GestureTest::cleanup()
51+{
52+ delete m_view;
53+ m_view = nullptr;
54+}
tests/plugins/Ubuntu/Gestures/GestureTest.hnew file+46
@@ -0,0 +1,46 @@
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+ // \param qmlFilename name of the qml file to be loaded by the QQuickView
33+ GestureTest(const QString &qmlFilename);
34+
35+protected Q_SLOTS:
36+ void initTestCase(); // will be called before the first test function is executed
37+ virtual void init(); // called right before each and every test function is executed
38+ virtual void cleanup(); // called right after each and every test function is executed
39+
40+protected:
41+ QTouchDevice *m_device;
42+ QQuickView *m_view;
43+ QString m_qmlFilename;
44+};
45+
46+#define GESTURETEST_H
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+65−96
@@ -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,12 @@ 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) { }
69+ tst_DirectionalDragArea();
6970private 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−
7371 void init(); // called right before each and every test function is executed
7472 void cleanup(); // called right after each and every test function is executed
7573
@@ -87,37 +85,19 @@ private Q_SLOTS:
8785 void ignoreOldFinger();
8886
8987private:
90− QQuickView *createView();
9188 void passTime(qint64 timeSpan);
92− QQuickView *view;
93− QTouchDevice *device;
9489 FakeTimer *fakeTimer;
9590 QSharedPointer<FakeTimeSource> fakeTimeSource;
9691};
9792
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()
93+tst_DirectionalDragArea::tst_DirectionalDragArea()
94+ : GestureTest(QStringLiteral("tst_DirectionalDragArea.qml"))
11095{
11196}
11297
11398void tst_DirectionalDragArea::init()
11499{
115− view = createView();
116− view->setSource(QUrl::fromLocalFile("edgeDragExample.qml"));
117− view->show();
118− QVERIFY(QTest::qWaitForWindowExposed(view));
119− QVERIFY(view->rootObject() != 0);
120− qApp->processEvents();
100+ GestureTest::init();
121101
122102 fakeTimeSource.reset(new FakeTimeSource);
123103 fakeTimer = new FakeTimer(fakeTimeSource);
@@ -125,23 +105,12 @@ void tst_DirectionalDragArea::init()
125105
126106void tst_DirectionalDragArea::cleanup()
127107{
128− delete view;
129− view = 0;
130−
131108 delete fakeTimer;
132109 fakeTimer = 0;
133110
134111 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));
143112
144− return window;
113+ GestureTest::cleanup();
145114}
146115
147116void tst_DirectionalDragArea::passTime(qint64 timeSpan)
@@ -217,14 +186,14 @@ void tst_DirectionalDragArea::edgeDrag()
217186 QFETCH(bool, expectGestureRecognition);
218187
219188 DirectionalDragArea *edgeDragArea =
220− view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
189+ m_view->rootObject()->findChild<DirectionalDragArea*>(dragAreaObjectName);
221190 QVERIFY(edgeDragArea != 0);
222191 edgeDragArea->setRecognitionTimer(fakeTimer);
223192 edgeDragArea->setTimeSource(fakeTimeSource);
224193
225194 QSignalSpy draggingSpy(edgeDragArea, SIGNAL(draggingChanged(bool)));
226195
227− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
196+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
228197 QPointF touchPoint = initialTouchPos;
229198
230199 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*dragDistanceFactor;
@@ -235,7 +204,7 @@ void tst_DirectionalDragArea::edgeDrag()
235204 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
236205 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
237206
238− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
207+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
239208
240209 QCOMPARE(draggingSpy.count(), 1);
241210 QCOMPARE(edgeDragArea->dragging(), true);
@@ -245,13 +214,13 @@ void tst_DirectionalDragArea::edgeDrag()
245214 // in order to make it easier to leave it by dragging at an angle
246215 // slightly bigger than the widening angle
247216 touchPoint += createTouchDeviation(edgeDragArea);
248− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
217+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
249218 }
250219
251220 for (int i = 0; i < totalMovementSteps; ++i) {
252221 touchPoint += touchMovement;
253222 passTime(movementTimeStepMs);
254− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
223+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
255224 }
256225
257226 if (expectGestureRecognition)
@@ -262,7 +231,7 @@ void tst_DirectionalDragArea::edgeDrag()
262231 QCOMPARE(draggingSpy.count(), 2);
263232 }
264233
265− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
234+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
266235
267236 QCOMPARE(draggingSpy.count(), 2);
268237 QCOMPARE(edgeDragArea->dragging(), false);
@@ -326,12 +295,12 @@ void tst_DirectionalDragArea::edgeDrag_data()
326295void tst_DirectionalDragArea::dragWithShortDirectionChange()
327296{
328297 DirectionalDragArea *edgeDragArea =
329− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
298+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
330299 QVERIFY(edgeDragArea != 0);
331300 edgeDragArea->setRecognitionTimer(fakeTimer);
332301 edgeDragArea->setTimeSource(fakeTimeSource);
333302
334− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
303+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
335304 QPointF touchPoint = initialTouchPos;
336305
337306 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0;
@@ -341,32 +310,32 @@ void tst_DirectionalDragArea::dragWithShortDirectionChange()
341310 int touchStepTimeMs = (touchStepDistance / (edgeDragArea->minSpeed() * 5.0f)) * 1000.0f;
342311 QPointF touchMovement = dragDirectionVector * touchStepDistance;
343312
344− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
313+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
345314
346315 // Move a bit in the proper direction
347316 for (int i=0; i < 3; ++i) {
348317 touchPoint += touchMovement;
349318 passTime(touchStepTimeMs);
350− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
319+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
351320 }
352321
353322 // Then a sudden and small movement to the opposite direction
354323 touchPoint -= touchMovement*0.2;
355324 passTime(touchStepTimeMs*0.2);
356− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
325+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
357326
358327 // And then resume movment in the correct direction until it crosses the distance and time
359328 // thresholds.
360329 do {
361330 touchPoint += touchMovement;
362331 passTime(touchStepTimeMs);
363− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
332+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
364333 } while ((touchPoint - initialTouchPos).manhattanLength() < desiredDragDistance
365334 || fakeTimeSource->m_msecsSinceReference < (edgeDragArea->compositionTime() * 1.5f));
366335
367336 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
368337
369− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
338+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
370339}
371340
372341/*
@@ -380,7 +349,7 @@ void tst_DirectionalDragArea::minSpeed()
380349 QFETCH(int, expectedStatusAfterSpeedCheck);
381350
382351 DirectionalDragArea *edgeDragArea =
383− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
352+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
384353 QVERIFY(edgeDragArea != 0);
385354 edgeDragArea->setRecognitionTimer(fakeTimer);
386355 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -391,7 +360,7 @@ void tst_DirectionalDragArea::minSpeed()
391360
392361 edgeDragArea->setMinSpeed(minSpeed);
393362
394− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
363+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
395364 QPointF touchPoint = initialTouchPos;
396365
397366 QPointF dragDirectionVector(1.0, 0.0);
@@ -399,13 +368,13 @@ void tst_DirectionalDragArea::minSpeed()
399368 qreal distanceStep = (speed / 1000.0f) * timeStepMsecs;
400369 QPointF touchMovement = dragDirectionVector * distanceStep;
401370
402− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
371+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
403372
404373 // Move for a while to ensure our speed check is performed a couple of times
405374 for (int i=0; i < 20; ++i) {
406375 touchPoint += touchMovement;
407376 passTime(timeStepMsecs);
408− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
377+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
409378 }
410379
411380 QCOMPARE((int)edgeDragArea->status(), expectedStatusAfterSpeedCheck);
@@ -429,7 +398,7 @@ void tst_DirectionalDragArea::minSpeed_data()
429398void tst_DirectionalDragArea::recognitionTimerUsage()
430399{
431400 DirectionalDragArea *edgeDragArea =
432− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
401+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
433402 QVERIFY(edgeDragArea != 0);
434403 edgeDragArea->setRecognitionTimer(fakeTimer);
435404 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -439,7 +408,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
439408
440409 int timeStepMs = 5; // some arbitrary small value.
441410
442− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
411+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
443412 QPointF touchPoint = initialTouchPos;
444413
445414 QPointF dragDirectionVector(1.0, 0.0);
@@ -448,7 +417,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
448417 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
449418 QVERIFY(!fakeTimer->isRunning());
450419
451− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
420+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
452421
453422 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
454423 QVERIFY(fakeTimer->isRunning());
@@ -461,7 +430,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
461430
462431 touchPoint += touchMovement;
463432 passTime(timeStepMs);
464− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
433+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
465434 }
466435
467436 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
@@ -475,7 +444,7 @@ void tst_DirectionalDragArea::recognitionTimerUsage()
475444void tst_DirectionalDragArea::maxSilenceTime()
476445{
477446 DirectionalDragArea *edgeDragArea =
478− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
447+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
479448 QVERIFY(edgeDragArea != 0);
480449 edgeDragArea->setRecognitionTimer(fakeTimer);
481450 edgeDragArea->setTimeSource(fakeTimeSource);
@@ -483,10 +452,10 @@ void tst_DirectionalDragArea::maxSilenceTime()
483452 // Make sure this property is not disabled
484453 edgeDragArea->setMaxSilenceTime(100);
485454
486− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
455+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
487456 QPointF touchPoint = initialTouchPos;
488457
489− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
458+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
490459
491460 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
492461 QVERIFY(fakeTimer->isRunning());
@@ -506,20 +475,20 @@ void tst_DirectionalDragArea::maxSilenceTime()
506475void tst_DirectionalDragArea::sceneXAndX()
507476{
508477 DirectionalDragArea *edgeDragArea =
509− view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
478+ m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
510479 QVERIFY(edgeDragArea != 0);
511480 edgeDragArea->setRecognitionTimer(fakeTimer);
512481 edgeDragArea->setTimeSource(fakeTimeSource);
513482
514− QPointF touchScenePos(view->width() - (edgeDragArea->width()/2.0f), view->height()/2.0f);
483+ QPointF touchScenePos(m_view->width() - (edgeDragArea->width()/2.0f), m_view->height()/2.0f);
515484
516− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
485+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
517486
518487 QSignalSpy touchXSpy(edgeDragArea, SIGNAL(touchXChanged(qreal)));
519488 QSignalSpy touchSceneXSpy(edgeDragArea, SIGNAL(touchSceneXChanged(qreal)));
520489
521− touchScenePos.rx() = view->width() / 2;
522− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
490+ touchScenePos.rx() = m_view->width() / 2;
491+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
523492
524493 QCOMPARE(touchXSpy.count(), 1);
525494 QCOMPARE(touchSceneXSpy.count(), 1);
@@ -534,20 +503,20 @@ void tst_DirectionalDragArea::sceneXAndX()
534503void tst_DirectionalDragArea::sceneYAndY()
535504{
536505 DirectionalDragArea *edgeDragArea =
537− view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
506+ m_view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
538507 QVERIFY(edgeDragArea != 0);
539508 edgeDragArea->setRecognitionTimer(fakeTimer);
540509 edgeDragArea->setTimeSource(fakeTimeSource);
541510
542− QPointF touchScenePos(view->width()/2.0f, view->height() - (edgeDragArea->height()/2.0f));
511+ QPointF touchScenePos(m_view->width()/2.0f, m_view->height() - (edgeDragArea->height()/2.0f));
543512
544− QTest::touchEvent(view, device).press(0, touchScenePos.toPoint());
513+ QTest::touchEvent(m_view, m_device).press(0, touchScenePos.toPoint());
545514
546515 QSignalSpy touchYSpy(edgeDragArea, SIGNAL(touchYChanged(qreal)));
547516 QSignalSpy touchSceneYSpy(edgeDragArea, SIGNAL(touchSceneYChanged(qreal)));
548517
549− touchScenePos.ry() = view->height() / 2;
550− QTest::touchEvent(view, device).move(0, touchScenePos.toPoint());
518+ touchScenePos.ry() = m_view->height() / 2;
519+ QTest::touchEvent(m_view, m_device).move(0, touchScenePos.toPoint());
551520
552521 QCOMPARE(touchYSpy.count(), 1);
553522 QCOMPARE(touchSceneYSpy.count(), 1);
@@ -564,27 +533,27 @@ void tst_DirectionalDragArea::sceneYAndY()
564533void tst_DirectionalDragArea::twoFingerTap()
565534{
566535 DirectionalDragArea *edgeDragArea =
567− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
536+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
568537 QVERIFY(edgeDragArea != 0);
569538 edgeDragArea->setRecognitionTimer(fakeTimer);
570539 edgeDragArea->setTimeSource(fakeTimeSource);
571540
572541 // 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);
542+ QPoint touchAPos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
543+ QPoint touchBPos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
575544
576545 qint64 timeStepMsecs = 5; // some arbitrary, small value
577546
578547 // Perform the first two-finger tap
579548 // NB: using move() instead of stationary() becasue in the latter you cannot provide
580549 // the touch position and therefore it's left with some garbage numbers.
581− QTest::touchEvent(view, device)
550+ QTest::touchEvent(m_view, m_device)
582551 .press(0, touchAPos);
583552
584553 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
585554
586555 passTime(timeStepMsecs);
587− QTest::touchEvent(view, device)
556+ QTest::touchEvent(m_view, m_device)
588557 .move(0, touchAPos)
589558 .press(1, touchBPos);
590559
@@ -593,14 +562,14 @@ void tst_DirectionalDragArea::twoFingerTap()
593562 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
594563
595564 passTime(timeStepMsecs);
596− QTest::touchEvent(view, device)
565+ QTest::touchEvent(m_view, m_device)
597566 .release(0, touchAPos)
598567 .move(1, touchBPos);
599568
600569 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
601570
602571 passTime(timeStepMsecs);
603− QTest::touchEvent(view, device)
572+ QTest::touchEvent(m_view, m_device)
604573 .release(1, touchBPos);
605574
606575 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -608,27 +577,27 @@ void tst_DirectionalDragArea::twoFingerTap()
608577 // Perform the second two-finger tap
609578
610579 passTime(timeStepMsecs);
611− QTest::touchEvent(view, device)
580+ QTest::touchEvent(m_view, m_device)
612581 .press(0, touchAPos);
613582
614583 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
615584
616585 passTime(timeStepMsecs);
617− QTest::touchEvent(view, device)
586+ QTest::touchEvent(m_view, m_device)
618587 .move(0, touchAPos)
619588 .press(1, touchBPos);
620589
621590 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
622591
623592 passTime(timeStepMsecs);
624− QTest::touchEvent(view, device)
593+ QTest::touchEvent(m_view, m_device)
625594 .release(0, touchAPos)
626595 .move(1, touchBPos);
627596
628597 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
629598
630599 passTime(timeStepMsecs);
631− QTest::touchEvent(view, device)
600+ QTest::touchEvent(m_view, m_device)
632601 .release(1, touchBPos);
633602
634603 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::WaitingForTouch);
@@ -642,7 +611,7 @@ void tst_DirectionalDragArea::twoFingerTap()
642611 */
643612void tst_DirectionalDragArea::movingDDA()
644613{
645− QQuickItem *rightwardsLauncher = view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
614+ QQuickItem *rightwardsLauncher = m_view->rootObject()->findChild<QQuickItem*>("rightwardsLauncher");
646615 Q_ASSERT(rightwardsLauncher != 0);
647616
648617 DirectionalDragArea *edgeDragArea =
@@ -651,7 +620,7 @@ void tst_DirectionalDragArea::movingDDA()
651620 edgeDragArea->setRecognitionTimer(fakeTimer);
652621 edgeDragArea->setTimeSource(fakeTimeSource);
653622
654− QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, view);
623+ QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea, m_view);
655624 QPointF touchPoint = initialTouchPos;
656625
657626 qreal desiredDragDistance = edgeDragArea->distanceThreshold()*2.0f;
@@ -662,7 +631,7 @@ void tst_DirectionalDragArea::movingDDA()
662631 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
663632 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
664633
665− QTest::touchEvent(view, device).press(0, touchPoint.toPoint());
634+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
666635
667636 // Move it far ahead along the direction of the gesture
668637 // rightwardsLauncher is a parent of our DirectionalDragArea. So moving it will move our DDA
@@ -671,12 +640,12 @@ void tst_DirectionalDragArea::movingDDA()
671640 for (int i = 0; i < totalMovementSteps; ++i) {
672641 touchPoint += touchMovement;
673642 passTime(movementTimeStepMs);
674− QTest::touchEvent(view, device).move(0, touchPoint.toPoint());
643+ QTest::touchEvent(m_view, m_device).move(0, touchPoint.toPoint());
675644 }
676645
677646 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
678647
679− QTest::touchEvent(view, device).release(0, touchPoint.toPoint());
648+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
680649}
681650
682651/*
@@ -686,16 +655,16 @@ void tst_DirectionalDragArea::movingDDA()
686655void tst_DirectionalDragArea::ignoreOldFinger()
687656{
688657 DirectionalDragArea *edgeDragArea =
689− view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
658+ m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
690659 Q_ASSERT(edgeDragArea != 0);
691660 edgeDragArea->setRecognitionTimer(fakeTimer);
692661 edgeDragArea->setTimeSource(fakeTimeSource);
693662
694663 // 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);
664+ QPoint touch0Pos(edgeDragArea->width()/2.0f, m_view->height()*0.33f);
665+ QPoint touch1Pos(edgeDragArea->width()/2.0f, m_view->height()*0.66f);
697666
698− QTest::touchEvent(view, device).press(0, touch0Pos);
667+ QTest::touchEvent(m_view, m_device).press(0, touch0Pos);
699668
700669 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Undecided);
701670
@@ -712,7 +681,7 @@ void tst_DirectionalDragArea::ignoreOldFinger()
712681 int totalMovementSteps = qCeil(desiredDragDistance / movementStepDistance);
713682 int movementTimeStepMs = (edgeDragArea->compositionTime() * 1.5f) / totalMovementSteps;
714683
715− QTest::touchEvent(view, device)
684+ QTest::touchEvent(m_view, m_device)
716685 .move(0, touch0Pos)
717686 .press(1, touch1Pos);
718687
@@ -721,14 +690,14 @@ void tst_DirectionalDragArea::ignoreOldFinger()
721690 for (int i = 0; i < totalMovementSteps; ++i) {
722691 touch1Pos += touchMovement.toPoint();
723692 passTime(movementTimeStepMs);
724− QTest::touchEvent(view, device)
693+ QTest::touchEvent(m_view, m_device)
725694 .move(0, touch0Pos)
726695 .move(1, touch1Pos);
727696 }
728697
729698 QCOMPARE((int)edgeDragArea->status(), (int)DirectionalDragArea::Recognized);
730699
731− QTest::touchEvent(view, device)
700+ QTest::touchEvent(m_view, m_device)
732701 .move(0, touch0Pos)
733702 .release(1, touch1Pos);
734703
tests/plugins/Ubuntu/Gestures/edgeDragExample.qml → tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.qmlrenamed+2−2
@@ -18,8 +18,8 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919
2020Rectangle {
21− //width: units.gu(40)
22− //height: units.gu(71)
21+ width: units.gu(40)
22+ height: units.gu(71)
2323 color: "white"
2424
2525 MouseArea {