aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-11-08 11:51:02 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-11-08 18:07:49 +0000
commit87253cb04612a3f97c779c0111c0e635e6c910ab (patch)
treed4bba512666d51a6567946fe2073c0111ae7f85b
parent54f15f5df5cf545bf4d675ccbafecd482b4a2b0b (diff)
stabilize and optimize tst_QQuickListView::QTBUG_34576_velocityZero
- don't use QTRY_VERIFY or QTRY_COMPARE if there's nothing to wait for, because it will always wait a short time and add needless delay to the test - QVERIFY(QSignalSpy::wait())'s should perhaps not be done in sequence, in case the second signal already happened while we were waiting for the first. QTRY_VERIFY(QSignalSpy::count() > 0) should be more reliable in such a case, as long as we are sure the count started at zero before the behavior which was supposed to make the signal be emitted. - 1000ms is probably not long enough to wait for ListView velocity change on a slow CI system. - according to the comment "verify that currentIndexChanged is triggered" we need another spy for that signal. Change-Id: I99d93a849b674ce6c81acbe91639f03933025117 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index c08d5d31b4..f06a118976 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -8658,9 +8658,9 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
QVERIFY(QTest::qWaitForWindowExposed(window));
QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
+ QVERIFY(listview);
QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
+ QVERIFY(contentItem);
QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
QSignalSpy horizontalVelocitySpy(listview, SIGNAL(horizontalVelocityChanged()));
@@ -8672,20 +8672,21 @@ void tst_QQuickListView::QTBUG_34576_velocityZero()
window->rootObject()->setProperty("horizontalVelocityZeroCount", QVariant(0));
listview->setCurrentIndex(2);
QTRY_COMPARE(window->rootObject()->property("current").toInt(), 2);
- QTRY_COMPARE(horizontalVelocitySpy.count(), 0);
- QTRY_COMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0);
+ QCOMPARE(horizontalVelocitySpy.count(), 0);
+ QCOMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0);
+
+ QSignalSpy currentIndexChangedSpy(listview, SIGNAL(currentIndexChanged()));
// click button which increases currentIndex
QTest::mousePress(window, Qt::LeftButton, 0, QPoint(295,215));
QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(295,215));
// verify that currentIndexChanged is triggered
- QVERIFY(horizontalVelocitySpy.wait());
+ QTRY_VERIFY(currentIndexChangedSpy.count() > 0);
- // set currentIndex to item out of view to cause listview scroll
+ // since we have set currentIndex to an item out of view, the listview will scroll
QTRY_COMPARE(window->rootObject()->property("current").toInt(), 3);
- QTRY_COMPARE(horizontalVelocitySpy.count() > 0, true);
- QVERIFY(horizontalVelocitySpy.wait(1000));
+ QTRY_VERIFY(horizontalVelocitySpy.count() > 0);
// velocity should be always > 0.0
QTRY_COMPARE(window->rootObject()->property("horizontalVelocityZeroCount").toInt(), 0);