Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Speed up view flick tests.
Change-Id: I98b0a45b5afd0150bfacef2c1c1e814f70ae042f
Reviewed-by: Bea Lam <bea.lam@nokia.com>
  • Loading branch information
Martin Jones authored and Qt by Nokia committed Mar 13, 2012
1 parent c53f609 commit 648c80c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tests/auto/quick/qquickgridview/data/snapOneRow.qml
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion tests/auto/quick/qquickgridview/data/snapToRow.qml
Expand Up @@ -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
}

Expand Down
35 changes: 17 additions & 18 deletions tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/quick/qquicklistview/data/snapToItem.qml
Expand Up @@ -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
}

Expand Down
14 changes: 6 additions & 8 deletions tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 648c80c

Please sign in to comment.