on xenial help sign in
More GestureTest and tst_DirectionalDragArea refactoring

- Move more stuff to GestureTest base class - add tryFoo make command - Let the qml file dictate the scene/window size, not the c++ code

commit1bd33d83dea9891c63f28b8d20bc943ac07ec2f5 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 22 Nov 2013, 09:28 (13 years ago) parent6a3ca33
5 files changed+22−11
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+3 tests/plugins/Ubuntu/Gestures/GestureTest.cpp+13−3 tests/plugins/Ubuntu/Gestures/GestureTest.h+3−1 tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+1−5 tests/plugins/Ubuntu/Gestures/edgeDragExample.qml → tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.qml+2−2
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+3
@@ -1,3 +1,5 @@
1+include(QmlTest)
2+
13include_directories(
24 ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
35 ${CMAKE_CURRENT_BINARY_DIR}
@@ -25,6 +27,7 @@ macro(add_gesture_ui_test CLASSNAME)
2527 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp)
2628 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
2729 target_link_libraries(${CLASSNAME}TestExec UbuntuGestureQml)
30+ add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
2831endmacro(add_gesture_ui_test)
2932
3033macro(add_gesture_test CLASSNAME)
tests/plugins/Ubuntu/Gestures/GestureTest.cpp+13−3
@@ -19,6 +19,12 @@
1919#include <qpa/qwindowsysteminterface.h>
2020#include <QQmlEngine>
2121#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+}
2228
2329void GestureTest::initTestCase()
2430{
@@ -31,10 +37,14 @@ void GestureTest::initTestCase()
3137
3238void GestureTest::init()
3339{
34− m_view = new QQuickView(0);
35− m_view->setResizeMode(QQuickView::SizeRootObjectToView);
36− m_view->resize(600, 600);
40+ m_view = new QQuickView;
41+ m_view->setResizeMode(QQuickView::SizeViewToRootObject);
3742 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();
3848}
3949
4050void GestureTest::cleanup()
tests/plugins/Ubuntu/Gestures/GestureTest.h+3−1
@@ -29,7 +29,8 @@ class GestureTest : public QObject
2929{
3030 Q_OBJECT
3131public:
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);
3334
3435protected Q_SLOTS:
3536 void initTestCase(); // will be called before the first test function is executed
@@ -39,6 +40,7 @@ protected Q_SLOTS:
3940protected:
4041 QTouchDevice *m_device;
4142 QQuickView *m_view;
43+ QString m_qmlFilename;
4244};
4345
4446#define GESTURETEST_H
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp+1−5
@@ -66,6 +66,7 @@ class tst_DirectionalDragArea: public GestureTest
6666{
6767 Q_OBJECT
6868public:
69+ tst_DirectionalDragArea() : GestureTest("tst_DirectionalDragArea.qml") {}
6970private Q_SLOTS:
7071 void init(); // called right before each and every test function is executed
7172 void cleanup(); // called right after each and every test function is executed
@@ -92,11 +93,6 @@ private:
9293void tst_DirectionalDragArea::init()
9394{
9495 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();
10096
10197 fakeTimeSource.reset(new FakeTimeSource);
10298 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
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 {