diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-23 19:03:01 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-23 20:22:15 (GMT) |
commit | f6b942b88ed2519b73c540120fde73390716173f (patch) | |
tree | 378c5b425afd0466efa224e725cbcaea2a4ba26a /tests/auto | |
parent | 5c5a6b387319095a2c2a589bb1e1d67b51854fc1 (diff) | |
download | Qt-f6b942b88ed2519b73c540120fde73390716173f.zip Qt-f6b942b88ed2519b73c540120fde73390716173f.tar.gz Qt-f6b942b88ed2519b73c540120fde73390716173f.tar.bz2 |
Stabilize more tests
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/q3table/tst_q3table.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qstackedlayout/tst_qstackedlayout.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 177 |
3 files changed, 95 insertions, 89 deletions
diff --git a/tests/auto/q3table/tst_q3table.cpp b/tests/auto/q3table/tst_q3table.cpp index ca65852..f911dd4 100644 --- a/tests/auto/q3table/tst_q3table.cpp +++ b/tests/auto/q3table/tst_q3table.cpp @@ -51,6 +51,8 @@ #include <q3table.h> #include <qlayout.h> +#include "../../shared/util.h" + #define WAITS 1 #ifdef WAITS #endif @@ -499,6 +501,8 @@ void tst_Q3Table::pageUpDownNavigation() void tst_Q3Table::simpleKeyboardNavigation() { + QApplication::setActiveWindow(testWidget); + QTRY_COMPARE(QApplication::activeWindow(), testWidget); QWidget *w; // Test for task #24726 diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp index cdf84811..51f6c03 100644 --- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp @@ -353,8 +353,9 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent() stackLayout->setCurrentIndex(0); testWidget->show(); - QTest::qWait(25); QApplication::setActiveWindow(testWidget); + QTest::qWaitForWindowShown(testWidget); + QApplication::processEvents(); edit1->setFocus(); edit1->activateWindow(); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index d34d3c5..2e66da2 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -2304,8 +2304,8 @@ void tst_QWidget::showMinimizedKeepsFocus() QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0)); window.showMinimized(); - QTest::qWait(100); - QVERIFY(window.isMinimized()); + QTest::qWait(30); + QTRY_VERIFY(window.isMinimized()); #ifdef Q_WS_QWS QEXPECT_FAIL("", "QWS does not implement showMinimized()", Continue); #endif @@ -2935,7 +2935,7 @@ void tst_QWidget::stackUnder() if (expectedPaintEvents == 1 && child->numPaintEvents == 2) QEXPECT_FAIL(0, "Mac and Windows issues double repaints for Z-Order change", Continue); #endif - QCOMPARE(child->numPaintEvents, expectedPaintEvents); + QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents); QCOMPARE(child->numZOrderChangeEvents, 0); child->reset(); } @@ -3158,13 +3158,14 @@ void tst_QWidget::saveRestoreGeometry() widget.resize(size); QTest::qWait(20); QTRY_COMPARE(widget.size(), size); - QTest::qWait(100); + QTest::qWait(200); savedGeometry = widget.saveGeometry(); geom = widget.geometry(); widget.setWindowState(widget.windowState() | Qt::WindowMaximized); QTest::qWait(20); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); QTRY_VERIFY(widget.geometry() != geom); + QTest::qWait(100); QVERIFY(widget.restoreGeometry(savedGeometry)); QTest::qWait(20); QTRY_COMPARE(widget.geometry(), geom); @@ -3175,13 +3176,13 @@ void tst_QWidget::saveRestoreGeometry() widget.setWindowState(widget.windowState() | Qt::WindowMaximized); QTest::qWait(20); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); - QTest::qWait(100); + QTest::qWait(200); geom = widget.geometry(); savedGeometry = widget.saveGeometry(); widget.setWindowState(widget.windowState() ^ Qt::WindowMaximized); QTest::qWait(20); QTRY_VERIFY(!(widget.windowState() & Qt::WindowMaximized)); - QTest::qWait(20); + QTest::qWait(200); QVERIFY(widget.restoreGeometry(savedGeometry)); QTest::qWait(20); QTRY_VERIFY((widget.windowState() & Qt::WindowMaximized)); @@ -3245,8 +3246,8 @@ void tst_QWidget::restoreVersion1Geometry() QTest::qWait(100); if (expectedWindowState == Qt::WindowNoState) { - QCOMPARE(widget.pos(), expectedPosition); - QCOMPARE(widget.size(), expectedSize); + QTRY_COMPARE(widget.pos(), expectedPosition); + QTRY_COMPARE(widget.size(), expectedSize); } widget.showNormal(); @@ -5277,14 +5278,19 @@ public: const QRegion r = QRegion(region); \ for (int i = 0; i < r.rects().size(); ++i) { \ const QRect rect = r.rects().at(i); \ - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + for (int t = 0; t < 5; t++) { \ + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ rect.left(), rect.top(), \ rect.width(), rect.height()); \ - QCOMPARE(pixmap.size(), rect.size()); \ - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ - expectedPixmap.fill(color); \ - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ - QCOMPARE(pixmap, expectedPixmap); \ + QCOMPARE(pixmap.size(), rect.size()); \ + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.fill(color); \ + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + { QTest::qWait(200); continue; } \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(pixmap, expectedPixmap); \ + break; \ + } \ } \ } @@ -5324,8 +5330,8 @@ void tst_QWidget::moveChild() #ifdef QT_MAC_USE_COCOA QEXPECT_FAIL(0, "Cocoa compositor paints the entire content view, even when opaque", Continue); #endif - QCOMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); - QCOMPARE(child.r, QRegion(child.rect())); + QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); + QTRY_COMPARE(child.r, QRegion(child.rect())); VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), @@ -5340,7 +5346,7 @@ void tst_QWidget::moveChild() QPoint pos = child.pos() + offset; child.move(pos); QTest::qWait(100); - QCOMPARE(pos, child.pos()); + QTRY_COMPARE(pos, child.pos()); QCOMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); #if !defined(Q_WS_MAC) @@ -7388,8 +7394,8 @@ void tst_QWidget::repaintWhenChildDeleted() #endif w.show(); QTest::qWaitForWindowShown(&w); - QTest::qWait(30); - QCOMPARE(w.r, QRegion(w.rect())); + QTest::qWait(10); + QTRY_COMPARE(w.r, QRegion(w.rect())); w.r = QRegion(); { @@ -7397,13 +7403,13 @@ void tst_QWidget::repaintWhenChildDeleted() ColorWidget child(&w, Qt::blue); child.setGeometry(10, 10, 10, 10); child.show(); - QTest::qWait(100); - QCOMPARE(child.r, QRegion(child.rect())); + QTest::qWait(10); + QTRY_COMPARE(child.r, QRegion(child.rect())); w.r = QRegion(); } - QTest::qWait(100); - QCOMPARE(w.r, QRegion(10, 10, 10, 10)); + QTest::qWait(10); + QTRY_COMPARE(w.r, QRegion(10, 10, 10, 10)); } // task 175114 @@ -8070,10 +8076,8 @@ void tst_QWidget::resizeInPaintEvent() QWidget window; UpdateWidget widget(&window); window.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&window); -#endif - QTest::qWait(100); + QTest::qWaitForWindowShown(&window); + QTRY_VERIFY(widget.numPaintEvents > 0); widget.reset(); QCOMPARE(widget.numPaintEvents, 0); @@ -8085,9 +8089,9 @@ void tst_QWidget::resizeInPaintEvent() QCOMPARE(widget.numPaintEvents, 1); widget.numPaintEvents = 0; - QTest::qWait(100); + QTest::qWait(10); // Make sure the resize triggers another update. - QCOMPARE(widget.numPaintEvents, 1); + QTRY_COMPARE(widget.numPaintEvents, 1); } #endif @@ -8597,8 +8601,7 @@ void tst_QWidget::setClearAndResizeMask() topLevel.resize(150, 150); topLevel.show(); QTest::qWaitForWindowShown(&topLevel); - QTest::qWait(40); - + QTRY_VERIFY(topLevel.numPaintEvents > 0); topLevel.reset(); // Mask top-level widget @@ -8615,20 +8618,20 @@ void tst_QWidget::setClearAndResizeMask() // Clear top-level mask topLevel.clearMask(); QCOMPARE(topLevel.mask(), QRegion()); - QTest::qWait(100); + QTest::qWait(10); QRegion outsideOldMask(topLevel.rect()); outsideOldMask -= topLevelMask; #if defined(Q_WS_WIN) || defined(Q_WS_X11) // We don't control what's happening on other platforms. // and ensure that the top-level gets an update for the area outside the old mask. QTRY_VERIFY(topLevel.numPaintEvents > 0); - QCOMPARE(topLevel.paintedRegion, outsideOldMask); + QTRY_COMPARE(topLevel.paintedRegion, outsideOldMask); #endif UpdateWidget child(&topLevel); child.setAutoFillBackground(true); // NB! Opaque child. child.resize(100, 100); child.show(); - QTest::qWait(50); + QTest::qWait(10); child.reset(); topLevel.reset(); @@ -8656,10 +8659,10 @@ void tst_QWidget::setClearAndResizeMask() // Clear child widget mask child.clearMask(); - QCOMPARE(child.mask(), QRegion()); - QTest::qWait(50); + QTRY_COMPARE(child.mask(), QRegion()); + QTest::qWait(10); // and ensure that that the child widget gets an update for the area outside the old mask. - QCOMPARE(child.numPaintEvents, 1); + QTRY_COMPARE(child.numPaintEvents, 1); outsideOldMask = child.rect(); #ifndef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. @@ -8674,10 +8677,10 @@ void tst_QWidget::setClearAndResizeMask() // Mask child widget with a mask that is bigger than the rect child.setMask(QRegion(0, 0, 1000, 1000)); - QTest::qWait(50); + QTest::qWait(10); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. - QCOMPARE(child.numPaintEvents, 1); + QTRY_COMPARE(child.numPaintEvents, 1); #else // and ensure that we don't get any updates at all. QCOMPARE(child.numPaintEvents, 0); @@ -8686,10 +8689,10 @@ void tst_QWidget::setClearAndResizeMask() // ...and the same applies when clearing the mask. child.clearMask(); - QTest::qWait(50); + QTest::qWait(10); #ifdef Q_WS_MAC // Mac always issues a full update when calling setMask, and we cannot force it to not do so. - QVERIFY(child.numPaintEvents > 0); + QTRY_VERIFY(child.numPaintEvents > 0); #else QCOMPARE(child.numPaintEvents, 0); #endif @@ -8752,10 +8755,9 @@ void tst_QWidget::maskedUpdate() grandChild.setMask(grandChildMask); topLevel.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&topLevel); -#endif - QTest::qWait(200); + QTest::qWaitForWindowShown(&topLevel); + QTRY_VERIFY(topLevel.numPaintEvents > 0); + #define RESET_WIDGETS \ topLevel.reset(); \ @@ -8773,29 +8775,29 @@ void tst_QWidget::maskedUpdate() // TopLevel update. RESET_WIDGETS; topLevel.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, topLevelMask); - QCOMPARE(child.paintedRegion, childMask); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, topLevelMask); + QTRY_COMPARE(child.paintedRegion, childMask); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); // Child update. RESET_WIDGETS; child.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, childMask.translated(child.pos())); - QCOMPARE(child.paintedRegion, childMask); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, childMask.translated(child.pos())); + QTRY_COMPARE(child.paintedRegion, childMask); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); // GrandChild update. RESET_WIDGETS; grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, grandChildMask.translated(grandChild.mapTo(&topLevel, QPoint()))); - QCOMPARE(child.paintedRegion, grandChildMask.translated(grandChild.pos())); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, grandChildMask.translated(grandChild.mapTo(&topLevel, QPoint()))); + QTRY_COMPARE(child.paintedRegion, grandChildMask.translated(grandChild.pos())); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); topLevel.setAttribute(Qt::WA_OpaquePaintEvent); child.setAttribute(Qt::WA_OpaquePaintEvent); @@ -8807,41 +8809,41 @@ void tst_QWidget::maskedUpdate() // TopLevel update. RESET_WIDGETS; topLevel.update(); - QTest::qWait(100); + QTest::qWait(10); QRegion expectedTopLevelUpdate = topLevelMask; expectedTopLevelUpdate -= childMask.translated(child.pos()); // Subtract opaque children. - QCOMPARE(topLevel.paintedRegion, expectedTopLevelUpdate); - QCOMPARE(child.paintedRegion, QRegion()); - QCOMPARE(grandChild.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, expectedTopLevelUpdate); + QTRY_COMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(grandChild.paintedRegion, QRegion()); // Child update. RESET_WIDGETS; child.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); QRegion expectedChildUpdate = childMask; expectedChildUpdate -= grandChildMask.translated(grandChild.pos()); // Subtract oapque children. - QCOMPARE(child.paintedRegion, expectedChildUpdate); - QCOMPARE(grandChild.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, expectedChildUpdate); + QTRY_COMPARE(grandChild.paintedRegion, QRegion()); // GrandChild update. RESET_WIDGETS; grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); - QCOMPARE(grandChild.paintedRegion, grandChildMask); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(grandChild.paintedRegion, grandChildMask); // GrandChild update. CLEAR_MASK(grandChild); grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); QRegion expectedGrandChildUpdate = grandChild.rect(); // Clip with parent's mask. expectedGrandChildUpdate &= childMask.translated(-grandChild.pos()); @@ -8850,36 +8852,36 @@ void tst_QWidget::maskedUpdate() // GrandChild update. CLEAR_MASK(child); grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); expectedGrandChildUpdate = grandChild.rect(); // Clip with parent's mask. expectedGrandChildUpdate &= topLevelMask.translated(-grandChild.mapTo(&topLevel, QPoint())); - QCOMPARE(grandChild.paintedRegion, expectedGrandChildUpdate); + QTRY_COMPARE(grandChild.paintedRegion, expectedGrandChildUpdate); // Child update. RESET_WIDGETS; child.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); expectedChildUpdate = child.rect(); // Clip with parent's mask. expectedChildUpdate &= topLevelMask.translated(-child.pos()); expectedChildUpdate -= grandChild.geometry(); // Subtract opaque children. - QCOMPARE(child.paintedRegion, expectedChildUpdate); - QCOMPARE(grandChild.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, expectedChildUpdate); + QTRY_COMPARE(grandChild.paintedRegion, QRegion()); // GrandChild update. CLEAR_MASK(topLevel); grandChild.update(); - QTest::qWait(100); + QTest::qWait(10); - QCOMPARE(topLevel.paintedRegion, QRegion()); - QCOMPARE(child.paintedRegion, QRegion()); - QCOMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update. + QTRY_COMPARE(topLevel.paintedRegion, QRegion()); + QTRY_COMPARE(child.paintedRegion, QRegion()); + QTRY_COMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update. } #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) @@ -9164,16 +9166,15 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() main.show(); QTest::qWaitForWindowShown(&main); - QTest::qWait(10); + QTest::qWait(50); QCursor::setPos(main.pos()); //get the cursor out of the picture QTest::qWait(50); - QPixmap pixmap = QPixmap::grabWindow(main.winId()); QPixmap correct(main.size()); correct.fill(Qt::green); QRect center(100, 100, 200, 200); // to avoid the decorations - QCOMPARE(pixmap.toImage().copy(center), correct.toImage().copy(center)); + QTRY_COMPARE(QPixmap::grabWindow(main.winId()).toImage().copy(center), correct.toImage().copy(center)); } void tst_QWidget::inputFocus_task257832() @@ -9232,7 +9233,7 @@ void tst_QWidget::activateWindow() mainwindow->setCentralWidget(label); mainwindow->setVisible(true); mainwindow->activateWindow(); - QTest::qWaitForWindowShown(&mainWindow); + QTest::qWaitForWindowShown(mainwindow); qApp->processEvents(); QTRY_VERIFY(mainwindow->isActiveWindow()); |