Speed up view flick tests.
authorMartin Jones <martin.jones@nokia.com>
Tue, 13 Mar 2012 00:32:48 +0000 (10:32 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Mar 2012 02:24:54 +0000 (03:24 +0100)
Change-Id: I98b0a45b5afd0150bfacef2c1c1e814f70ae042f
Reviewed-by: Bea Lam <bea.lam@nokia.com>
tests/auto/quick/qquickgridview/data/snapOneRow.qml
tests/auto/quick/qquickgridview/data/snapToRow.qml
tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
tests/auto/quick/qquicklistview/data/snapToItem.qml
tests/auto/quick/qquicklistview/tst_qquicklistview.cpp

index 3d32d75..597c5ef 100644 (file)
@@ -37,7 +37,7 @@ Rectangle {
         flow: GridView.TopToBottom
         highlightRangeMode: GridView.StrictlyEnforceRange
         highlight: Rectangle { width: 120; height: 120; color: "yellow" }
-        model: 10
+        model: 8
         delegate: myDelegate
     }
 
index f079a04..e3963b0 100644 (file)
@@ -37,7 +37,7 @@ Rectangle {
         flow: GridView.TopToBottom
         highlightRangeMode: GridView.StrictlyEnforceRange
         highlight: Rectangle { width: 80; height: 80; color: "yellow" }
-        model: 54
+        model: 39
         delegate: myDelegate
     }
 
index fe534e4..7d00491 100644 (file)
@@ -694,8 +694,7 @@ void tst_QQuickGridView::removed()
     QTRY_VERIFY(gridview->currentItem() != oldCurrent);
 
     gridview->setContentY(0);
-    // let transitions settle.
-    QTest::qWait(300);
+    QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
 
     // Confirm items positioned correctly
     itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -969,7 +968,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible()
     QTRY_COMPARE(gridview->currentIndex(), 24);
     QTRY_COMPARE(gridview->contentY(), 220.0);
 
-    QTest::qWait(100);  // wait for refill to complete
+    QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
     QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0));  // 0 shouldn't be visible
 
     if (doAdd) {
@@ -3574,22 +3573,22 @@ void tst_QQuickGridView::snapToRow_data()
     QTest::addColumn<qreal>("startExtent");
 
     QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
-        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 800.0 << 0.0;
 
     QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
-        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 800.0 << 0.0;
 
     QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
-        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
+        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -800.0 - 240.0 << -240.0;
 
     QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 940.0 << -20.0;
 
     QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 940.0 << -20.0;
 
     QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
+        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -800.0 - 240.0 - 140.0 << -220.0;
 }
 
 void tst_QQuickGridView::snapToRow()
@@ -3669,22 +3668,22 @@ void tst_QQuickGridView::snapOneRow_data()
     QTest::addColumn<qreal>("startExtent");
 
     QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
-        << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
+        << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 240.0 << 0.0;
 
     QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
-        << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
+        << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0;
 
     QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
-        << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0;
+        << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -240.0 - 240.0 << -240.0;
 
     QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
+        << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 340.0 << -20.0;
 
     QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
+        << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0;
 
     QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0;
+        << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0;
 }
 
 void tst_QQuickGridView::snapOneRow()
@@ -3739,8 +3738,8 @@ void tst_QQuickGridView::snapOneRow()
            : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
 
     if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
-        QCOMPARE(gridview->currentIndex(), 8);
-        QCOMPARE(currentIndexSpy.count(), 4);
+        QCOMPARE(gridview->currentIndex(), 6);
+        QCOMPARE(currentIndexSpy.count(), 3);
     }
 
     if (flow == QQuickGridView::LeftToRight)
@@ -3763,7 +3762,7 @@ void tst_QQuickGridView::snapOneRow()
 
     if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
         QCOMPARE(gridview->currentIndex(), 0);
-        QCOMPARE(currentIndexSpy.count(), 8);
+        QCOMPARE(currentIndexSpy.count(), 6);
     }
 
     delete canvas;
index 6f20107..91d31ad 100644 (file)
@@ -37,7 +37,7 @@ Rectangle {
         layoutDirection: Qt.RightToLeft
         highlightRangeMode: ListView.StrictlyEnforceRange
         highlight: Rectangle { width: 80; height: 80; color: "yellow" }
-        model: 18
+        model: 10
         delegate: myDelegate
     }
 
index 1584bc3..1a49418 100644 (file)
@@ -827,7 +827,6 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
     listview->setContentY(20); // That's the top now
     // let transitions settle.
     QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-    QTest::qWait(300);
 
     // Confirm items positioned correctly
     itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
@@ -858,7 +857,6 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
 
     listview->setContentY(80);
     QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-    QTest::qWait(300);
 
     // remove all visible items
     model.removeItems(1, 18);
@@ -4251,22 +4249,22 @@ void tst_QQuickListView::snapToItem_data()
     QTest::addColumn<qreal>("startExtent");
 
     QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
-        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 560.0 << 0.0;
 
     QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
-        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 560.0 << 0.0;
 
     QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
-        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
+        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -560.0 - 240.0 << -240.0;
 
     QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+        << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 700.0 << -20.0;
 
     QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+        << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 700.0 << -20.0;
 
     QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
-        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
+        << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -560.0 - 240.0 - 140.0 << -220.0;
 }
 
 void tst_QQuickListView::snapToItem()