summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtableview
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-09-08 08:45:57 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-09-08 08:49:39 (GMT)
commitfa889cf4b80868249c70715275069eb150b597cc (patch)
treeab98dc0979d7c2874902e7f2a9812843104e1c49 /tests/auto/qtableview
parentdeff8fcf0ed060b949c3ec0fa0ec4bd81c253825 (diff)
downloadQt-fa889cf4b80868249c70715275069eb150b597cc.zip
Qt-fa889cf4b80868249c70715275069eb150b597cc.tar.gz
Qt-fa889cf4b80868249c70715275069eb150b597cc.tar.bz2
Try to make test more robust.
By using QTRY_{COMPARE,VERIFY} instead of waiting an arbitrary amount of time waiting for the window manager to do his job. Also use QApplication::setActiveWindow which seems to be more robust then QWidget::activateWindow
Diffstat (limited to 'tests/auto/qtableview')
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp25
1 files changed, 14 insertions, 11 deletions
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;
}