on xenial help sign in
More GestureTest and tst_DirectionalDragArea refactoring
1bd33d8Daniel d'Andrada
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+3
@@ -1,3 +1,5 @@
1+include(QmlTest)
2+
1include_directories(
3include_directories(
2 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
4 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
3 ${CMAKE_CURRENT_BINARY_DIR}
5 ${CMAKE_CURRENT_BINARY_DIR}
@@ -25,6 +27,7 @@ macro(add_gesture_ui_test CLASSNAME)
25 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp)
27 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp)
26 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
28 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
27 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
29 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
30+ add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
28endmacro(add_gesture_ui_test)
31endmacro(add_gesture_ui_test)
29
32
30macro(add_gesture_test CLASSNAME)
33macro(add_gesture_test CLASSNAME)
tests/plugins/Ubuntu/Gestures/GestureTest.cpp+13−3
@@ -19,6 +19,12 @@
19#include <qpa/qwindowsysteminterface.h>
19#include <qpa/qwindowsysteminterface.h>
20#include <QQmlEngine>
20#include <QQmlEngine>
21#include <QQuickView>
21#include <QQuickView>
22+#include <QtTest>
23+
24+GestureTest::GestureTest(const char *qmlFile)
25+ : QObject(), m_device(nullptr), m_view(nullptr), m_qmlFilename(qmlFile)
26+{
27+}
22
28
23void GestureTest::initTestCase()
29void GestureTest::initTestCase()
24{
30{
@@ -31,10 +37,14 @@ void GestureTest::initTestCase()
31
37
32void GestureTest::init()
38void GestureTest::init()
33{
39{
34− m_view = new QQuickView(0);
40+ m_view = new QQuickView;
35− m_view->setResizeMode(QQuickView::SizeRootObjectToView);
41+ m_view->setResizeMode(QQuickView::SizeViewToRootObject);
36− m_view->resize(600, 600);
37 m_view->engine()->addImportPath(QLatin1String(UBUNTU_GESTURES_PLUGIN_DIR));
42 m_view->engine()->addImportPath(QLatin1String(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();
38}
48}
39
49
40void GestureTest::cleanup()
50void GestureTest::cleanup()
tests/plugins/Ubuntu/Gestures/GestureTest.h+3−1
@@ -29,7 +29,8 @@ class GestureTest : public QObject
29{
29{
30 Q_OBJECT
30 Q_OBJECT
31public:
31public:
32− GestureTest() : QObject(), m_device(nullptr), m_view(nullptr) {}
32+ // \param qmlFile name of the qml file to be loaded by the QQuickView
33+ GestureTest(const char *qmlFile);
33
34
34protected Q_SLOTS:
35protected Q_SLOTS:
35 void initTestCase(); // will be called before the first test function is executed
36 void initTestCase(); // will be called before the first test function is executed
@@ -39,6 +40,7 @@ protected Q_SLOTS:
39protected:
40protected:
40 QTouchDevice *m_device;
41 QTouchDevice *m_device;
41 QQuickView *m_view;
42 QQuickView *m_view;
43+ QString m_qmlFilename;
42};
44};
43
45
44#define GESTURETEST_H
46#define GESTURETEST_H
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+1−5
@@ -66,6 +66,7 @@ class tst_DirectionalDragArea: public GestureTest
66{
66{
67 Q_OBJECT
67 Q_OBJECT
68public:
68public:
69+ tst_DirectionalDragArea() : GestureTest("tst_DirectionalDragArea.qml") {}
69private Q_SLOTS:
70private Q_SLOTS:
70 void init(); // called right before each and every test function is executed
71 void init(); // called right before each and every test function is executed
71 void cleanup(); // called right after each and every test function is executed
72 void cleanup(); // called right after each and every test function is executed
@@ -92,11 +93,6 @@ private:
92void tst_DirectionalDragArea::init()
93void tst_DirectionalDragArea::init()
93{
94{
94 GestureTest::init();
95 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);
99− qApp->processEvents();
100
96
101 fakeTimeSource.reset(new FakeTimeSource);
97 fakeTimeSource.reset(new FakeTimeSource);
102 fakeTimer = new FakeTimer(fakeTimeSource);
98 fakeTimer = new FakeTimer(fakeTimeSource);
tests/plugins/Ubuntu/Gestures/edgeDragExample.qml → tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.qmlrenamed+2−2
@@ -18,8 +18,8 @@ import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19
19
20Rectangle {
20Rectangle {
21− //width: units.gu(40)
21+ width: units.gu(40)
22− //height: units.gu(71)
22+ height: units.gu(71)
23 color: "white"
23 color: "white"
24
24
25 MouseArea {
25 MouseArea {