aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-08-23 13:35:00 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-26 10:21:56 +0200
commit6ba7d88df623df5bce85bfdae853fc49006e76f2 (patch)
tree64de42db0f026a55b684ea787999a2e8c95762d6
parentcf3537e99c75d3bb92b9d4ed6f4d437e316dcf01 (diff)
Stabilize tests using utilities from QQuickViewTestUtil.
Change QQuickViewTestUtil::createView() to center the window on the screen to avoid taskbar areas. Add routine to move the mouse away and use that in tests using QQuickViewTestUtil::flick() and other mouse interaction since the mouse cursor can interfere with it. Affected tests: qquickgridview, qquickpathview, qquickflickable, qquicklistview, qquickrepeater and qquickpositioners. Task-number: QTBUG-33017 Change-Id: I540c0efb54a231dcb44c8fd5ad9573a2d4d4b9df Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp51
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp2
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp6
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp5
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp28
-rw-r--r--tests/auto/quick/shared/viewtestutil.h3
6 files changed, 84 insertions, 11 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index dd9fa47d81..4392055dde 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -236,6 +236,10 @@ void tst_qquickflickable::rebound()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("rebound.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -375,6 +379,9 @@ void tst_qquickflickable::pressDelay()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("pressDelay.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -414,6 +421,9 @@ void tst_qquickflickable::nestedPressDelay()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("nestedPressDelay.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -636,6 +646,9 @@ void tst_qquickflickable::movingAndFlicking()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -796,6 +809,9 @@ void tst_qquickflickable::movingAndDragging()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -999,6 +1015,9 @@ void tst_qquickflickable::pressWhileFlicking()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -1077,6 +1096,9 @@ void tst_qquickflickable::flickVelocity()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -1177,6 +1199,9 @@ void tst_qquickflickable::cancelOnMouseGrab()
{
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("cancel.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
@@ -1212,6 +1237,9 @@ void tst_qquickflickable::clickAndDragWhenTransformed()
{
QScopedPointer<QQuickView> view(new QQuickView);
view->setSource(testFileUrl("transformedFlickable.qml"));
+ QTRY_COMPARE(view->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(view.data());
+ QQuickViewTestUtil::moveMouseAway(view.data());
view->show();
QVERIFY(QTest::qWaitForWindowExposed(view.data()));
QVERIFY(view->rootObject() != 0);
@@ -1260,8 +1288,11 @@ void tst_qquickflickable::flickTwiceUsingTouches()
touchDevice->setCapabilities(QTouchDevice::Position);
QWindowSystemInterface::registerTouchDevice(touchDevice);
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("longList.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(window->rootObject() != 0);
@@ -1269,20 +1300,18 @@ void tst_qquickflickable::flickTwiceUsingTouches()
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 0.0f);
- flickWithTouch(window, touchDevice, QPoint(100, 400), QPoint(100, 240));
+ flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240));
qreal contentYAfterFirstFlick = flickable->contentY();
qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick;
QVERIFY(contentYAfterFirstFlick > 50.0f);
- flickWithTouch(window, touchDevice, QPoint(100, 400), QPoint(100, 240));
+ flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240));
// In the original bug, that second flick would cause Flickable to halt immediately
qreal contentYAfterSecondFlick = flickable->contentY();
qDebug() << "contentYAfterSecondFlick " << contentYAfterSecondFlick;
QVERIFY(contentYAfterSecondFlick > (contentYAfterFirstFlick + 80.0f));
-
- delete window;
}
void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to)
@@ -1319,6 +1348,9 @@ void tst_qquickflickable::nestedStopAtBounds()
QQuickView view;
view.setSource(testFileUrl("nestedStopAtBounds.qml"));
+ QTRY_COMPARE(view.status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(&view);
+ QQuickViewTestUtil::moveMouseAway(&view);
view.show();
view.requestActivate();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@@ -1378,8 +1410,11 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
touchDevice->setCapabilities(QTouchDevice::Position);
QWindowSystemInterface::registerTouchDevice(touchDevice);
- QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("nestedmousearea.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
QVERIFY(window->rootObject() != 0);
@@ -1387,7 +1422,7 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 50.0f);
- flickWithTouch(window, touchDevice, QPoint(100, 300), QPoint(100, 200));
+ flickWithTouch(window.data(), touchDevice, QPoint(100, 300), QPoint(100, 200));
// flickable should not have moved
QCOMPARE(flickable->contentY(), 50.0);
@@ -1395,8 +1430,6 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
// draggable item should have moved up
QQuickItem *nested = window->rootObject()->findChild<QQuickItem*>("nested");
QVERIFY(nested->y() < 100.0);
-
- delete window;
}
QTEST_MAIN(tst_qquickflickable)
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index d0ffba9435..f1adb7858f 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -4253,6 +4253,7 @@ void tst_QQuickGridView::snapToRow()
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapToRow.qml"));
window->show();
qApp->processEvents();
@@ -4347,6 +4348,7 @@ void tst_QQuickGridView::snapOneRow()
QFETCH(qreal, startExtent);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapOneRow.qml"));
window->show();
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index cd8cc53b40..41f193cdb7 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -2127,6 +2127,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds()
QFETCH(int, cacheBuffer);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
QaimModel model;
for (int i = 0; i < 10; i++)
@@ -4819,6 +4820,7 @@ void tst_QQuickListView::marginsResize()
QQuickView *window = getView();
window->setSource(testFileUrl("margins2.qml"));
+ QQuickViewTestUtil::moveMouseAway(window);
window->show();
qApp->processEvents();
@@ -4954,6 +4956,7 @@ void tst_QQuickListView::snapToItem()
QFETCH(qreal, startExtent);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapToItem.qml"));
window->show();
@@ -5282,6 +5285,7 @@ void tst_QQuickListView::snapOneItem()
QFETCH(qreal, startExtent);
QQuickView *window = getView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("snapOneItem.qml"));
window->show();
@@ -6754,6 +6758,7 @@ void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QLi
void tst_QQuickListView::flickBeyondBounds()
{
QQuickView *window = createView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("flickBeyondBoundsBug.qml"));
window->show();
@@ -6889,6 +6894,7 @@ void tst_QQuickListView::delayedChanges_QTBUG_30555()
void tst_QQuickListView::outsideViewportChangeNotAffectingView()
{
QQuickView *window = createView();
+ QQuickViewTestUtil::moveMouseAway(window);
window->setSource(testFileUrl("outsideViewportChangeNotAffectingView.qml"));
QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index e4ad7b9c40..5ca081aa92 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -1444,6 +1444,7 @@ void tst_QQuickPathView::undefinedPath()
void tst_QQuickPathView::mouseDrag()
{
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
@@ -1736,6 +1737,7 @@ static inline bool hasFraction(qreal o)
void tst_QQuickPathView::cancelDrag()
{
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("dragpath.qml"));
window->show();
window->requestActivate();
@@ -1782,6 +1784,7 @@ void tst_QQuickPathView::maximumFlickVelocity()
{
QScopedPointer<QQuickView> window(createView());
window->setSource(testFileUrl("dragpath.qml"));
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
@@ -1827,6 +1830,7 @@ void tst_QQuickPathView::snapToItem()
QFETCH(bool, enforceRange);
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("panels.qml"));
QQuickPathView *pathview = window->rootObject()->findChild<QQuickPathView*>("view");
QVERIFY(pathview != 0);
@@ -1865,6 +1869,7 @@ void tst_QQuickPathView::snapOneItem()
QFETCH(bool, enforceRange);
QScopedPointer<QQuickView> window(createView());
+ QQuickViewTestUtil::moveMouseAway(window.data());
window->setSource(testFileUrl("panels.qml"));
window->show();
window->requestActivate();
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
index 29b82072c9..0e3964d52d 100644
--- a/tests/auto/quick/shared/viewtestutil.cpp
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -42,17 +42,41 @@
#include "viewtestutil.h"
#include <QtQuick/QQuickView>
+#include <QtQuick/QQuickView>
+#include <QtGui/QScreen>
#include <QtTest/QTest>
QQuickView *QQuickViewTestUtil::createView()
{
QQuickView *window = new QQuickView(0);
- window->setGeometry(0,0,240,320);
-
+ const QSize size(240, 320);
+ window->resize(size);
+ QQuickViewTestUtil::centerOnScreen(window, size);
return window;
}
+void QQuickViewTestUtil::centerOnScreen(QQuickView *window, const QSize &size)
+{
+ const QRect screenGeometry = window->screen()->availableGeometry();
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ window->setFramePosition(screenGeometry.center() - offset);
+}
+
+void QQuickViewTestUtil::centerOnScreen(QQuickView *window)
+{
+ QQuickViewTestUtil::centerOnScreen(window, window->size());
+}
+
+void QQuickViewTestUtil::moveMouseAway(QQuickView *window)
+{
+#ifndef QT_NO_CURSOR // Get the cursor out of the way.
+ QCursor::setPos(window->geometry().topRight() + QPoint(100, 100));
+#else
+ Q_UNUSED(window)
+#endif
+}
+
void QQuickViewTestUtil::flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration)
{
const int pointCount = 5;
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
index 67906114f6..5b0b10b69c 100644
--- a/tests/auto/quick/shared/viewtestutil.h
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -53,6 +53,9 @@ namespace QQuickViewTestUtil
QQuickView *createView();
void flick(QQuickView *window, const QPoint &from, const QPoint &to, int duration);
+ void centerOnScreen(QQuickView *window, const QSize &size);
+ void centerOnScreen(QQuickView *window);
+ void moveMouseAway(QQuickView *window);
QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);