diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qabstractbutton/tst_qabstractbutton.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qbuttongroup/tst_qbuttongroup.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qcompleter/tst_qcompleter.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qfocusevent/tst_qfocusevent.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qgridlayout/tst_qgridlayout.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qgroupbox/tst_qgroupbox.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qitemdelegate/tst_qitemdelegate.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp | 42 | ||||
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qpushbutton/tst_qpushbutton.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qspinbox/tst_qspinbox.cpp | 20 | ||||
-rw-r--r-- | tests/auto/qstackedlayout/tst_qstackedlayout.cpp | 13 | ||||
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qtextbrowser/tst_qtextbrowser.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qtreeview/tst_qtreeview.cpp | 5 |
16 files changed, 130 insertions, 84 deletions
diff --git a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp index de2d9f4..7ee52ad 100644 --- a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp @@ -550,6 +550,7 @@ void tst_QAbstractButton::setShortcut() { QKeySequence seq( Qt::Key_A ); testWidget->setShortcut( seq ); + QApplication::setActiveWindow(testWidget); // must be active to get shortcuts for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) { @@ -557,8 +558,8 @@ void tst_QAbstractButton::setShortcut() QApplication::instance()->processEvents(); QTest::qWait(100); } - QVERIFY(testWidget->isActiveWindow()); - + QVERIFY(testWidget->isActiveWindow()); + QTest::keyClick( testWidget, 'A' ); QTest::qWait(300); // Animate click takes time QCOMPARE(click_count, (uint)1); diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp index f49568d..82969b9 100644 --- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp @@ -100,7 +100,7 @@ private slots: #if QT_VERSION >= 0x040600 void autoIncrementId(); #endif - + void task209485_removeFromGroupInEventHandler_data(); void task209485_removeFromGroupInEventHandler(); }; @@ -333,12 +333,12 @@ void tst_QButtonGroup::testSignals() QCOMPARE(clickedSpy.count(), 1); QCOMPARE(clickedIdSpy.count(), 1); - - int expectedId = -1; + + int expectedId = -1; #if QT_VERSION >= 0x040600 expectedId = -2; #endif - + QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId); QCOMPARE(pressedSpy.count(), 1); QCOMPARE(pressedIdSpy.count(), 1); diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 928d826..7eefb26 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -1025,6 +1025,7 @@ void tst_QCompleter::multipleWidgets() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&window); #endif + QApplication::setActiveWindow(&window); QTest::qWait(50); QTRY_VERIFY(qApp->focusWidget() == comboBox); comboBox->lineEdit()->setText("it"); @@ -1058,6 +1059,7 @@ void tst_QCompleter::focusIn() window.show(); QTest::qWait(100); window.activateWindow(); + QApplication::setActiveWindow(&window); QTest::qWait(100); QTRY_COMPARE(qApp->activeWindow(), &window); @@ -1322,8 +1324,10 @@ void tst_QCompleter::task253125_lineEditCompletion() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&edit); #endif + QTest::qWait(10); + QApplication::setActiveWindow(&edit); + QTRY_COMPARE(QApplication::activeWindow(), &edit); - QTest::qWait(100); QTest::keyClick(&edit, 'i'); QCOMPARE(edit.completer()->currentCompletion(), QString("iota")); QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); @@ -1358,7 +1362,9 @@ void tst_QCompleter::task247560_keyboardNavigation() qt_x11_wait_for_window_manager(&edit); #endif - QTest::qWait(100); + QTest::qWait(10); + QApplication::setActiveWindow(&edit); + QTRY_COMPARE(QApplication::activeWindow(), &edit); QTest::keyClick(&edit, 'r'); QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 6162be0..aa3ccb7 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -52,6 +52,9 @@ #include <qlineedit.h> #include <qdebug.h> + +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h @@ -772,8 +775,8 @@ void tst_QDoubleSpinBox::editingFinished() layout->addWidget(box2); testFocusWidget->show(); - QTest::qWait(100); - QVERIFY(box->isActiveWindow()); + QTest::qWait(10); + QTRY_VERIFY(box->isActiveWindow()); box->setFocus(); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp index 662f115..5ad78de 100644 --- a/tests/auto/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp @@ -56,6 +56,8 @@ #include <qlineedit.h> #include <QBoxLayout> +#include "../../shared/util.h" + QT_FORWARD_DECLARE_CLASS(QWidget) //TESTED_CLASS= @@ -168,6 +170,7 @@ void tst_QFocusEvent::initWidget() { // On X11 we have to ensure the event was processed before doing any checking, on Windows // this is processed straight away. + QApplication::setActiveWindow(childFocusWidgetOne); for (int i = 0; i < 1000; ++i) { if (childFocusWidgetOne->isActiveWindow() && childFocusWidgetOne->hasFocus()) @@ -243,9 +246,9 @@ void tst_QFocusEvent::checkReason_BackTab() // Now test the backtab key QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab ); - QTest::qWait(2000); + QTest::qWait(200); - QVERIFY(childFocusWidgetOne->focusOutEventRecieved); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved); QVERIFY(childFocusWidgetTwo->focusInEventRecieved); QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); QVERIFY(childFocusWidgetTwo->focusInEventGotFocus); @@ -265,9 +268,9 @@ void tst_QFocusEvent::checkReason_Popup() Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget ); popupMenu->insertItem( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(500); + QTest::qWait(50); - QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); QVERIFY( childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); @@ -290,11 +293,11 @@ void tst_QFocusEvent::checkReason_Popup() QMenu* popupMenu = new QMenu( testFocusWidget ); popupMenu->addMenu( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(500); + QTest::qWait(50); - QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); - QVERIFY( childFocusWidgetOne->hasFocus() ); + QTRY_VERIFY( childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); QVERIFY( childFocusWidgetOne->focusOutEventRecieved ); QVERIFY( !childFocusWidgetTwo->focusInEventRecieved ); @@ -368,13 +371,13 @@ void tst_QFocusEvent::checkReason_focusWidget() QLineEdit edit1; QLineEdit edit2; - QVBoxLayout outerLayout; + QVBoxLayout outerLayout; outerLayout.addWidget(&frame1); outerLayout.addWidget(&frame2); window1.setLayout(&outerLayout); - - QVBoxLayout leftLayout; - QVBoxLayout rightLayout; + + QVBoxLayout leftLayout; + QVBoxLayout rightLayout; leftLayout.addWidget(&edit1); rightLayout.addWidget(&edit2); frame1.setLayout(&leftLayout); diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp index 13d79b1..590bafa 100644 --- a/tests/auto/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp @@ -51,6 +51,8 @@ #include <QtGui/QWindowsStyle> #include <QStyleFactory> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h @@ -788,8 +790,8 @@ void tst_QGridLayout::minMaxSize_data() QTest::addColumn<QSize>("fixedSize"); //input and expected output QTest::addColumn<SizeInfoList>("sizeinfos"); - - QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1 + + QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1 << int(QSizePolicy::Minimum) << QSize(152, 50) << (SizeInfoList() << SizeInfo(QRect(10, 10, 43, 30), QSize( 75, 75), QSize(0,0)) << SizeInfo(QRect(10 + 45, 10, 43, 30), QSize(75, 75), QSize( 0, 0)) @@ -917,13 +919,14 @@ void tst_QGridLayout::minMaxSize() #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(m_toplevel); // wait for the show #endif + QTest::qWait(20); m_toplevel->adjustSize(); - QTest::qWait(200); // wait for the implicit adjustSize + QTest::qWait(20); // wait for the implicit adjustSize // If the following fails we might have to wait longer. // If that does not help there is likely a problem with the implicit adjustSize in show() if (!fixedSize.isValid()) { // Note that this can fail if the desktop has large fonts on windows. - QCOMPARE(m_toplevel->size(), m_toplevel->sizeHint()); + QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint()); } // We are relying on the order here... for (int pi = 0; pi < sizehinters.count(); ++pi) { diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp index 94b70e6..7346700 100644 --- a/tests/auto/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp @@ -49,6 +49,8 @@ #include "qgroupbox.h" +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -81,7 +83,7 @@ private slots: void toggledVsClicked(); void childrenAreDisabled(); void propagateFocus(); - + private: bool checked; qint64 timeStamp; @@ -467,7 +469,7 @@ void tst_QGroupBox::propagateFocus() box.show(); box.setFocus(); QTest::qWait(250); - QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); + QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); } QTEST_MAIN(tst_QGroupBox) diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 1ef77c0..9871da3 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -63,6 +63,8 @@ #include <QPlainTextEdit> #include <QDialog> +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint) //TESTED_CLASS= @@ -862,6 +864,8 @@ void tst_QItemDelegate::decoration() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&table); #endif + QApplication::setActiveWindow(&table); + QTRY_COMPARE(QApplication::activeWindow(), &table); QVariant value; switch ((QVariant::Type)type) { @@ -1164,10 +1168,7 @@ void tst_QItemDelegate::task257859_finalizeEdit() QDialog dialog; QTimer::singleShot(100, &dialog, SLOT(close())); dialog.exec(); - - QTest::qWait(100); - - QVERIFY(!editor); + QTRY_VERIFY(!editor); } diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp index 78ba46b..4d5160b 100644 --- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp @@ -63,6 +63,9 @@ #include <QMacStyle> #endif +#include "../../shared/util.h" + + QT_BEGIN_NAMESPACE #if defined(Q_WS_X11) extern void qt_x11_wait_for_window_manager(QWidget *w); @@ -1004,15 +1007,16 @@ void tst_QMdiSubWindow::setSystemMenu() qt_x11_wait_for_window_manager(&mainWindow); #endif - QVERIFY(subWindow->isVisible()); - QPoint globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft()); + QTRY_VERIFY(subWindow->isVisible()); + QPoint globalPopupPos; // Show system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), + (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) ); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1034,9 +1038,9 @@ void tst_QMdiSubWindow::setSystemMenu() // Show the new system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1048,12 +1052,12 @@ void tst_QMdiSubWindow::setSystemMenu() QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget(); QVERIFY(menuLabel); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); - globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), + (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())))); systemMenu->hide(); - QVERIFY(!qApp->activePopupWidget()); + QTRY_VERIFY(!qApp->activePopupWidget()); subWindow->showNormal(); #endif @@ -1064,11 +1068,11 @@ void tst_QMdiSubWindow::setSystemMenu() subWindow->showSystemMenu(); QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top()) globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1081,10 +1085,10 @@ void tst_QMdiSubWindow::setSystemMenu() QVERIFY(menuLabel); subWindow->showSystemMenu(); QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height())); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); #endif delete systemMenu; @@ -1902,7 +1906,7 @@ void tst_QMdiSubWindow::task_182852() mainWindow.show(); mainWindow.menuBar()->setVisible(true); qApp->setActiveWindow(&mainWindow); - + QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]"); mainWindow.setWindowTitle(originalWindowTitle); @@ -1917,7 +1921,7 @@ void tst_QMdiSubWindow::task_182852() window->showMaximized(); qApp->processEvents(); QVERIFY(window->isMaximized()); - + QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]") .arg(originalWindowTitle, window->widget()->windowTitle())); diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index ab8dd48..4a4231a 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -55,6 +55,9 @@ #include <qmenu.h> #include <qstyle.h> #include <qdebug.h> + +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -437,15 +440,16 @@ void tst_QMenu::overrideMenuAction() m->addAction(aQuit); w.show(); - QTest::qWait(200); + w.setFocus(); + QTRY_VERIFY(w.hasFocus()); //test of the action inside the menu QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier); - QCOMPARE(activated, aQuit); + QTRY_COMPARE(activated, aQuit); //test if the menu still pops out QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier); - QVERIFY(m->isVisible()); + QTRY_VERIFY(m->isVisible()); delete aFileMenu; @@ -703,12 +707,12 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() }; QMenu sub; - + if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) { //the style prevents the menus from getting columns QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle); } - + sub.addAction("Sub-Item1"); QAction *subAction = sub.addAction("Sub-Item2"); diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp index 5059578..2013258 100644 --- a/tests/auto/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp @@ -54,6 +54,8 @@ #include <QStyleFactory> #include <QTabWidget> +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QPushButton*) //TESTED_CLASS= @@ -413,6 +415,7 @@ void tst_QPushButton::setAccel() // The shortcut will not be activated unless the button is in a active // window and has focus + QApplication::setActiveWindow(testWidget); testWidget->setFocus(); for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) { testWidget->activateWindow(); @@ -421,8 +424,8 @@ void tst_QPushButton::setAccel() } QVERIFY(testWidget->isActiveWindow()); QTest::keyClick( testWidget, 'A', Qt::AltModifier ); - QTest::qWait( 500 ); - QVERIFY( click_count == 1 ); + QTest::qWait( 50 ); + QTRY_VERIFY( click_count == 1 ); QVERIFY( press_count == 1 ); QVERIFY( release_count == 1 ); QVERIFY( toggle_count == 0 ); @@ -430,6 +433,7 @@ void tst_QPushButton::setAccel() // wait 200 ms because setAccel uses animateClick. // if we don't wait this may screw up a next test. QTest::qWait(200); + QTRY_VERIFY( !testWidget->isDown() ); } void tst_QPushButton::animateClick() diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 73d25a2..f4d70d1 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -140,7 +140,7 @@ private slots: void removeAll(); void startWithDash(); void undoRedo(); - + void specialValue(); void textFromValue(); @@ -750,11 +750,13 @@ void tst_QSpinBox::editingFinished() QSpinBox *box2 = new QSpinBox(testFocusWidget); layout->addWidget(box2); + testFocusWidget->show(); + QApplication::setActiveWindow(testFocusWidget); box->activateWindow(); - QTest::qWait(1000);//qApp->processEvents(); + QTest::qWait(100);//qApp->processEvents(); box->setFocus(); - QTRY_VERIFY(qApp->focusWidget() == box); + QTRY_COMPARE(qApp->focusWidget(), box); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); @@ -910,7 +912,7 @@ void tst_QSpinBox::undoRedo() void tst_QSpinBox::specialValue() { QString specialText="foo"; - + QWidget topWidget; QVBoxLayout layout(&topWidget); SpinBox spin(&topWidget); @@ -937,7 +939,7 @@ void tst_QSpinBox::specialValue() QCOMPARE(spin.text(), QString("0")); QTest::keyClick(&spin, Qt::Key_Return); QCOMPARE(spin.text(), specialText); - + spin.setValue(50); QTest::keyClick(&spin, Qt::Key_Return); QTest::keyClick(&spin, '0'); @@ -987,17 +989,17 @@ void tst_QSpinBox::sizeHint() QVERIFY(spinBox->sizeHintRequests > 0); // Suffix - spinBox->sizeHintRequests = 0; + spinBox->sizeHintRequests = 0; spinBox->setSuffix(QLatin1String("abcdefghij")); qApp->processEvents(); - QVERIFY(spinBox->sizeHintRequests > 0); + QVERIFY(spinBox->sizeHintRequests > 0); // Range - spinBox->sizeHintRequests = 0; + spinBox->sizeHintRequests = 0; spinBox->setRange(0, 1234567890); spinBox->setValue(spinBox->maximum()); qApp->processEvents(); - QVERIFY(spinBox->sizeHintRequests > 0); + QVERIFY(spinBox->sizeHintRequests > 0); } QTEST_MAIN(tst_QSpinBox) diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp index c6a30a5..481ee2c 100644 --- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp @@ -47,6 +47,8 @@ #include <qwidget.h> #include <QPushButton> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h @@ -149,7 +151,7 @@ void tst_QStackedLayout::testCase() QStackedLayout onStack(testWidget); QStackedLayout *testLayout = &onStack; testWidget->setLayout(testLayout); - + QSignalSpy spy(testLayout,SIGNAL(currentChanged(int))); // Nothing in layout @@ -350,12 +352,15 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent() stackLayout->setCurrentIndex(0); + testWidget->show(); + QTest::qWait(25); + QApplication::setActiveWindow(testWidget); + edit1->setFocus(); - QTest::qWait(250); edit1->activateWindow(); - QTest::qWait(100); + QTest::qWait(25); - QVERIFY(edit1->hasFocus()); + QTRY_VERIFY(edit1->hasFocus()); stackLayout->setCurrentIndex(1); QVERIFY(!edit1->hasFocus()); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 6fe2963..51d0e33 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2334,8 +2334,10 @@ void tst_QTableView::scrollTo() QtTestTableView view; view.show(); - view.resize(columnWidth * 2, rowHeight * 2); + QSize forcedSize(columnWidth * 2, rowHeight * 2); + view.resize(forcedSize); QTest::qWait(0); + QTRY_COMPARE(view.size(), forcedSize); view.setModel(&model); view.setSpan(row, column, rowSpan, columnSpan); @@ -2910,6 +2912,7 @@ void tst_QTableView::tabFocus() window.setFocus(); QTest::qWait(100); window.activateWindow(); + QApplication::setActiveWindow(&window); QTest::qWait(100); qApp->processEvents(); @@ -2926,43 +2929,43 @@ void tst_QTableView::tabFocus() for (int i = 0; i < 2; ++i) { // tab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(!window.hasFocus()); + QTRY_VERIFY(!window.hasFocus()); QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // tab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); } // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); QStandardItemModel *model = new QStandardItemModel; view->setModel(model); // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); model->insertRow(0, new QStandardItem("Hei")); model->insertRow(0, new QStandardItem("Hei")); @@ -2970,8 +2973,8 @@ void tst_QTableView::tabFocus() // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit doesn't work @@ -2984,14 +2987,14 @@ void tst_QTableView::tabFocus() // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(edit->hasFocus()); + QTRY_VERIFY(edit->hasFocus()); delete model; } diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp index 0311900..966e9c9 100644 --- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp @@ -49,6 +49,8 @@ #include <qtextbrowser.h> #include <qtextobject.h> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -64,9 +66,11 @@ public: #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(this); #endif + QApplication::setActiveWindow(this); activateWindow(); setFocus(); - QTest::qWait(100); + QTest::qWait(50); + QTRY_VERIFY(hasFocus()); } virtual QVariant loadResource(int type, const QUrl &name); diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index fae4b26..f42d5f6 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3354,7 +3354,7 @@ void tst_QTreeView::task246536_scrollbarsNotWorking() o.count = 0; tree.verticalScrollBar()->setValue(50); QTest::qWait(100); - QVERIFY(o.count > 0); + QTRY_VERIFY(o.count > 0); } void tst_QTreeView::task250683_wrongSectionSize() @@ -3404,8 +3404,9 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden() QStandardItem sub1("sub1"), sub11("sub11"); root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11); - QTest::qWait(200); + QTest::qWait(20); //items in the 2nd column should have been painted + QTRY_VERIFY(!delegate.paintedIndexes.isEmpty()); QVERIFY(delegate.paintedIndexes.contains(sub00.index())); QVERIFY(delegate.paintedIndexes.contains(sub11.index())); } |