summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-22 01:18:24 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-22 01:18:24 (GMT)
commit7c56bb7beda9d64737f0446f3a661c2ce146c741 (patch)
treea8d0e30b876d0c35ce1ee88e7592ae4236d45291
parent01498eb9a44f3b15e517e81b309087fbbf1b93bf (diff)
downloadQt-7c56bb7beda9d64737f0446f3a661c2ce146c741.zip
Qt-7c56bb7beda9d64737f0446f3a661c2ce146c741.tar.gz
Qt-7c56bb7beda9d64737f0446f3a661c2ce146c741.tar.bz2
Remove use of direct event posting. Use QTest::keyClick() for keys.
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
index 00127e5..2520d4a 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
+++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
@@ -645,45 +645,29 @@ void tst_QmlGraphicsGridView::currentIndex()
QCOMPARE(gridview->viewportY(), 0.0);
// Test keys
+ qApp->setActiveWindow(canvas);
canvas->show();
canvas->setFocus();
qApp->processEvents();
- QEvent wa(QEvent::WindowActivate);
- QApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QApplication::sendEvent(canvas, &fe);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Down);
QCOMPARE(gridview->currentIndex(), 3);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Up);
QCOMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QmlGraphicsGridView::TopToBottom);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Right);
QCOMPARE(gridview->currentIndex(), 5);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Left);
QCOMPARE(gridview->currentIndex(), 0);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Down);
QCOMPARE(gridview->currentIndex(), 1);
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
+ QTest::keyClick(canvas, Qt::Key_Up);
QCOMPARE(gridview->currentIndex(), 0);