summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2018-04-04 12:57:51 +0300
committerKari Oikarinen <kari.oikarinen@qt.io>2018-04-24 05:01:57 +0000
commit15ada2b91798638c90630c332e4a8caef7660638 (patch)
treebac271959a1dc7050ae74ed1950bdfd476b4f723 /tests/auto
parentc579f49e2a80a55a4004ff8e5b2ee76bda146387 (diff)
tests/auto/widgets/kernel: Avoid unconditional qWait()s
Task-number: QTBUG-63992 Change-Id: Icb32b516002c3bb2841c8e7a29624e54cfcbbcac Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp2
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp8
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp3
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp1
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp2
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp17
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp10
7 files changed, 10 insertions, 33 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index c70ac0309f..5301dababc 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -288,7 +288,6 @@ void tst_QApplication::alert()
widget2.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
QVERIFY(QTest::qWaitForWindowExposed(&widget2));
- QTest::qWait(100);
app.alert(&widget, -1);
app.alert(&widget, 250);
widget2.activateWindow();
@@ -1711,6 +1710,7 @@ void tst_QApplication::focusOut()
le2->setStyleSheet("background: #fee");
le2->move(100, 100);
w.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QTest::qWait(2000);
le2->setFocus();
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 2f1a305710..8314dbedf5 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -226,15 +226,13 @@ void tst_QBoxLayout::setStyleShouldChangeSpacing()
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
- QCOMPARE(spacing, 6);
+ auto spacing = [&]() { return pb2->geometry().left() - pb1->geometry().right() - 1; };
+ QCOMPARE(spacing(), 6);
QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
style2->hspacing = 10;
window.setStyle(style2.data());
- QTest::qWait(100);
- spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
- QCOMPARE(spacing, 10);
+ QTRY_COMPARE(spacing(), 10);
}
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 1ccda25339..162da61584 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -164,7 +164,7 @@ private slots:
void tst_QFormLayout::cleanup()
{
- QVERIFY(QApplication::topLevelWidgets().isEmpty());
+ QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QFormLayout::rowCount()
@@ -1188,7 +1188,6 @@ void tst_QFormLayout::layoutAlone()
w.setWindowTitle(QTest::currentTestFunction());
w.show();
layout.activate();
- QTest::qWait(500);
}
void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 40a2319910..5e0327319b 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -1441,7 +1441,6 @@ void tst_QGridLayout::layoutSpacing()
QLayout *layout = widget->layout();
QVERIFY(layout);
- //QTest::qWait(2000);
for (int pi = 0; pi < expectedpositions.count(); ++pi) {
QLayoutItem *item = layout->itemAt(pi);
//qDebug() << item->widget()->pos();
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index ff35b0cdb1..b78287f84b 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -604,7 +604,7 @@ void tst_QShortcut::disabledItems()
{
clearAllShortcuts();
mainW->activateWindow();
- QTest::qWait(100);
+ QVERIFY(QTest::qWaitForWindowActive(mainW));
/* Testing Disabled Shortcuts
Qt::Key_M on slot1
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index 5be4846b3e..10712ea9ad 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -103,7 +103,7 @@ void tst_QStackedLayout::init()
// make sure the tests work with focus follows mouse
QCursor::setPos(testWidget->geometry().center());
testWidget->activateWindow();
- QTest::qWait(250);
+ QVERIFY(QTest::qWaitForWindowActive(testWidget));
}
void tst_QStackedLayout::cleanup()
@@ -251,24 +251,13 @@ void tst_QStackedLayout::removeWidget()
testLayout->addWidget(w2);
vbox->addLayout(testLayout);
top->setFocus();
- QTest::qWait(100);
top->activateWindow();
- QTest::qWait(100);
- int i =0;
- for (;;) {
- if (QApplication::focusWidget() == top)
- break;
- else if (i >= 5)
- QSKIP("Can't get focus");
- QTest::qWait(100);
- ++i;
- }
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(top));
+ QTRY_COMPARE(QApplication::focusWidget(), top);
// focus should stay at the 'top' widget
testLayout->removeWidget(w1);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(top));
+ QCOMPARE(QApplication::focusWidget(), top);
}
class LineEdit : public QLineEdit
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index a3e549aa50..c9c8e193b3 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -146,13 +146,7 @@ void tst_QWindowContainer::testExposeObscure()
container->hide();
- QElapsedTimer timer;
- timer.start();
- while (window->numberOfObscures == 0 && timer.elapsed() < 5000) {
- QTest::qWait(10);
- }
-
- QVERIFY(window->numberOfObscures > 0);
+ QTRY_VERIFY(window->numberOfObscures > 0);
}
@@ -345,11 +339,9 @@ void tst_QWindowContainer::testDockWidget()
QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
QCOMPARE(window->parent(), mainWindow.window()->windowHandle());
- QTest::qWait(1000);
dock->setFloating(true);
QTRY_VERIFY(window->parent() != mainWindow.window()->windowHandle());
- QTest::qWait(1000);
dock->setFloating(false);
QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle());
}