diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-02-09 12:38:18 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-02-09 12:38:18 (GMT) |
commit | 3b56735e8d90cb760bf56fc07fbd87e48ca08619 (patch) | |
tree | 73bd37d15bd0365a2a3fb149a5ef6aa215ce25b9 /tests/auto/qlistview | |
parent | 997490b36b28bca877409de97a506c969840bc43 (diff) | |
download | Qt-3b56735e8d90cb760bf56fc07fbd87e48ca08619.zip Qt-3b56735e8d90cb760bf56fc07fbd87e48ca08619.tar.gz Qt-3b56735e8d90cb760bf56fc07fbd87e48ca08619.tar.bz2 |
Speed up QListView test
(from 31s to 7s)
Diffstat (limited to 'tests/auto/qlistview')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 1e6d36a..2c31d8b 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -606,9 +606,8 @@ void tst_QListView::indexAt() view2.setWrapping(true); // We really want to make sure it is shown, because the layout won't be known until it is shown view2.show(); - for (int i = 0; i < 5 && !view2.m_shown; ++i) { - QTest::qWait(500); - } + QTest::qWaitForWindowShown(&view2); + QTRY_VERIFY(view2.m_shown); QVERIFY(view2.m_index.isValid()); QVERIFY(view2.m_index.row() != 0); @@ -760,7 +759,8 @@ void tst_QListView::hideFirstRow() view.setUniformItemSizes(true); view.setRowHidden(0,true); view.show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTest::qWait(10); } void tst_QListView::batchedMode() @@ -778,10 +778,9 @@ void tst_QListView::batchedMode() view.setBatchSize(2); view.resize(200,400); view.show(); + QTest::qWaitForWindowShown(&view); -#if !defined(Q_OS_WINCE) - QTest::qWait(100); -#else +#if defined(Q_OS_WINCE) QTest::qWait(2000); #endif QBitArray ba; @@ -1203,9 +1202,9 @@ void tst_QListView::scrollTo() //we click the item QPoint p = lv.visualRect(index).center(); QTest::mouseClick(lv.viewport(), Qt::LeftButton, Qt::NoModifier, p); - //let's wait 1 second because the scrolling is delayed - QTest::qWait(1000); - QCOMPARE(lv.visualRect(index).y(),0); + //let's wait because the scrolling is delayed + QTest::qWait(QApplication::doubleClickInterval() + 150); + QTRY_COMPARE(lv.visualRect(index).y(),0); //we scroll down. As the item is to tall for the view, it will disappear QTest::keyClick(lv.viewport(), Qt::Key_Down, Qt::NoModifier); @@ -1222,9 +1221,9 @@ void tst_QListView::scrollTo() //we click the item p = lv.visualRect(index).center(); QTest::mouseClick(lv.viewport(), Qt::LeftButton, Qt::NoModifier, p); - //let's wait 1 second because the scrolling is delayed - QTest::qWait(1000); - QCOMPARE(lv.visualRect(index).x(),0); + //let's wait because the scrolling is delayed + QTest::qWait(QApplication::doubleClickInterval() + 150); + QTRY_COMPARE(lv.visualRect(index).x(),0); //we scroll right. As the item is too wide for the view, it will disappear QTest::keyClick(lv.viewport(), Qt::Key_Right, Qt::NoModifier); @@ -1243,9 +1242,9 @@ void tst_QListView::scrollTo() //we click the item p = lv.visualRect(index).center(); QTest::mouseClick(lv.viewport(), Qt::LeftButton, Qt::NoModifier, p); - //let's wait 1 second because the scrolling is delayed - QTest::qWait(1000); - QCOMPARE(lv.visualRect(index).y(),0); + //let's wait because the scrolling is delayed + QTest::qWait(QApplication::doubleClickInterval() + 150); + QTRY_COMPARE(lv.visualRect(index).y(),0); //we scroll down. As the item is too tall for the view, it will partially disappear QTest::keyClick(lv.viewport(), Qt::Key_Down, Qt::NoModifier); @@ -1277,7 +1276,7 @@ void tst_QListView::scrollBarRanges() for (int h = 30; h <= 210; ++h) { lv.resize(250, h); - QTest::qWait(100); // wait for the layout to be done + QApplication::processEvents(); // wait for the layout to be done int visibleRowCount = lv.viewport()->size().height() / rowHeight; int invisibleRowCount = rowCount - visibleRowCount; QCOMPARE(lv.verticalScrollBar()->maximum(), invisibleRowCount); @@ -1366,7 +1365,7 @@ void tst_QListView::scrollBarAsNeeded() model.setStringList(list); QApplication::processEvents(); - QTest::qWait(100); + QTest::qWait(50); QStringList replacement; for (i = 0; i < itemCount; ++i) { @@ -1375,10 +1374,9 @@ void tst_QListView::scrollBarAsNeeded() model.setStringList(replacement); QApplication::processEvents(); - QTest::qWait(100); - QCOMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible); - QCOMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible); + QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible); + QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible); } } @@ -1433,10 +1431,9 @@ void tst_QListView::wordWrap() lv.setFixedSize(150, 150); lv.show(); QApplication::processEvents(); - QTest::qWait(100); - QCOMPARE(lv.horizontalScrollBar()->isVisible(), false); - QCOMPARE(lv.verticalScrollBar()->isVisible(), true); + QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), false); + QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), true); } #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -1557,7 +1554,8 @@ void tst_QListView::task248430_crashWith0SizedItem() QStringListModel model(QStringList() << QLatin1String("item1") << QString()); view.setModel(&model); view.show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTest::qWait(20); } void tst_QListView::task250446_scrollChanged() @@ -1569,21 +1567,21 @@ void tst_QListView::task250446_scrollChanged() QVERIFY(index.isValid()); view.setCurrentIndex(index); view.show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); const int scrollValue = view.verticalScrollBar()->maximum(); view.verticalScrollBar()->setValue(scrollValue); QCOMPARE(view.verticalScrollBar()->value(), scrollValue); QCOMPARE(view.currentIndex(), index); view.showMinimized(); - QTest::qWait(100); - QCOMPARE(view.verticalScrollBar()->value(), scrollValue); - QCOMPARE(view.currentIndex(), index); + QTest::qWait(50); + QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue); + QTRY_COMPARE(view.currentIndex(), index); view.showNormal(); - QTest::qWait(100); - QCOMPARE(view.verticalScrollBar()->value(), scrollValue); - QCOMPARE(view.currentIndex(), index); + QTest::qWait(50); + QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue); + QTRY_COMPARE(view.currentIndex(), index); } void tst_QListView::task196118_visualRegionForSelection() @@ -1699,7 +1697,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() view.setViewMode(QListView::IconMode); view.setModel(&model); view.show(); - QTest::qWait(30); + QTest::qWaitForWindowShown(&view); // Verfify that item sizes are non-uniform QVERIFY(view.sizeHintForIndex(model.index(0, 0)).height() > view.sizeHintForIndex(model.index(1, 0)).height()); @@ -1729,7 +1727,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() view.setViewMode(QListView::IconMode); view.setModel(&model); view.show(); - QTest::qWait(30); + QTest::qWaitForWindowShown(&view); // Verfify that item sizes are non-uniform QVERIFY(view.sizeHintForIndex(model.index(0, 0)).width() > view.sizeHintForIndex(model.index(1, 0)).width()); @@ -1789,7 +1787,6 @@ void tst_QListView::task262152_setModelColumnNavigate() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QTest::qWait(30); QTRY_COMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow()); QTest::keyClick(&view, Qt::Key_Down); QTest::qWait(30); |