diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-11 14:48:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-24 18:17:04 +0100 |
commit | 6933b7e8e6dc279a8eb34e1f4c60bc109dfb7d26 (patch) | |
tree | 79e41aa9c624708f8dfe52621a5c49f008bc51e4 /tests | |
parent | d4425318801c055127dba04792ebf4ef69643b6e (diff) |
Ungrab mouse when FocusAboutToChange instead of Leave
Commit 7b2e2117162594a2d0234bb02408f5b5a446488b
introduced a regression in mouse handling:
When moving the mouse out of the window it would cancel
all further mouse events. That is actually not wanted
(eg scroll bars).
Instead ungrab the mouse when the focus changes,
that means the mouse handling with popups works and the
scrollbar use case is also fixed.
All the tests related to this seem quite timing sensitive,
so try some more QTRY_VERIFY.
Remove the parallel_test so that more cpu time will actually
let the tests pass more reliably.
Change-Id: I90586b05f461d3762728a466d71bcb967e03d14b
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'tests')
4 files changed, 21 insertions, 18 deletions
diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro index 3ba752bf7d..95c703befe 100644 --- a/tests/auto/quick/qquickflickable/qquickflickable.pro +++ b/tests/auto/quick/qquickflickable/qquickflickable.pro @@ -9,6 +9,5 @@ include (../shared/util.pri) TESTDATA = data/* -CONFIG += parallel_test QT += core-private gui-private v8-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 662e86018c..784988b913 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -618,7 +618,7 @@ void tst_qquickflickable::movingAndFlicking() window->setSource(testFileUrl("flickable03.qml")); window->show(); window->requestActivate(); - QTest::qWaitForWindowActive(window); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); @@ -639,7 +639,7 @@ void tst_qquickflickable::movingAndFlicking() // do a flick that keeps the view within the bounds flick(window, flickFrom, flickToWithoutSnapBack, 200); - QVERIFY(flickable->isMoving()); + QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); QCOMPARE(flickable->isMovingVertically(), verticalEnabled); QVERIFY(flickable->isFlicking()); @@ -695,7 +695,7 @@ void tst_qquickflickable::movingAndFlicking() QTRY_VERIFY(!flickable->isMoving()); flick(window, flickFrom, flickToWithSnapBack, 200); - QVERIFY(flickable->isMoving()); + QTRY_VERIFY(flickable->isMoving()); QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled); QCOMPARE(flickable->isMovingVertically(), verticalEnabled); QVERIFY(flickable->isFlicking()); @@ -999,7 +999,7 @@ void tst_qquickflickable::pressWhileFlicking() // flicking == false, moving == true; flick(window, QPoint(20,190), QPoint(20, 50), 200); QVERIFY(flickable->verticalVelocity() > 0.0); - QVERIFY(flickable->isFlicking()); + QTRY_VERIFY(flickable->isFlicking()); QVERIFY(flickable->isFlickingVertically()); QVERIFY(!flickable->isFlickingHorizontally()); QVERIFY(flickable->isMoving()); @@ -1257,7 +1257,7 @@ void tst_qquickflickable::flickTwiceUsingTouches() window->setSource(testFileUrl("longList.qml")); window->show(); window->requestActivate(); - QTest::qWaitForWindowActive(window); + QVERIFY(QTest::qWaitForWindowActive(window)); QVERIFY(window->rootObject() != 0); QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject()); diff --git a/tests/auto/quick/qquickmousearea/qquickmousearea.pro b/tests/auto/quick/qquickmousearea/qquickmousearea.pro index 957b04a558..dd7b434898 100644 --- a/tests/auto/quick/qquickmousearea/qquickmousearea.pro +++ b/tests/auto/quick/qquickmousearea/qquickmousearea.pro @@ -10,7 +10,5 @@ include (../../shared/util.pri) TESTDATA = data/* -CONFIG += parallel_test - QT += core-private gui-private qml-private quick-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 9fd42373e2..ffe7b51537 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -248,7 +248,7 @@ void tst_QQuickMouseArea::dragging() window->setSource(testFileUrl("dragging.qml")); window->show(); window->requestActivate(); - QTest::qWait(20); + QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->rootObject() != 0); QQuickMouseArea *mouseRegion = window->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); @@ -274,19 +274,17 @@ void tst_QQuickMouseArea::dragging() // First move event triggers drag, second is acted upon. // This is due to possibility of higher stacked area taking precedence. - QTest::mouseMove(window, QPoint(111,111)); - QTest::qWait(50); - QTest::mouseMove(window, QPoint(122,122)); - QTest::qWait(50); + QTest::mouseMove(window, QPoint(111,111), 50); + QTest::mouseMove(window, QPoint(116,116), 50); + QTest::mouseMove(window, QPoint(122,122), 50); - QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); + QTRY_VERIFY(drag->active()); + QTRY_COMPARE(blackRect->x(), 72.0); QCOMPARE(blackRect->y(), 72.0); QTest::mouseRelease(window, button, 0, QPoint(122,122)); - QTest::qWait(50); - QVERIFY(!drag->active()); + QTRY_VERIFY(!drag->active()); QCOMPARE(blackRect->x(), 72.0); QCOMPARE(blackRect->y(), 72.0); @@ -477,20 +475,28 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() window->show(); window->requestActivate(); QVERIFY(window->rootObject() != 0); + QQuickMouseArea *mouseArea = qobject_cast<QQuickMouseArea*>(window->rootObject()->children().first()); + QVERIFY(mouseArea); QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(window, &pressEvent); + QVERIFY(mouseArea->pressedButtons() == Qt::LeftButton); QVERIFY(!window->rootObject()->property("clicked").toBool()); QVERIFY(!window->rootObject()->property("held").toBool()); + // timeout is 800 (in qquickmousearea.cpp) QTest::qWait(1000); + QCoreApplication::processEvents(); + + QVERIFY(!window->rootObject()->property("clicked").toBool()); + QVERIFY(window->rootObject()->property("held").toBool()); QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); QGuiApplication::sendEvent(window, &releaseEvent); + QTRY_VERIFY(window->rootObject()->property("held").toBool()); QVERIFY(!window->rootObject()->property("clicked").toBool()); - QVERIFY(window->rootObject()->property("held").toBool()); delete window; } |