summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-16 14:54:38 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-17 10:25:47 (GMT)
commitc535df0f286826c5575ec00c7e4c3f811a73918b (patch)
tree50d853a85295176a9282a5bffb3184d703571f9a /tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
parentdb803b363785b6892cbf7809aabba1fb7d5fb934 (diff)
downloadQt-c535df0f286826c5575ec00c7e4c3f811a73918b.zip
Qt-c535df0f286826c5575ec00c7e4c3f811a73918b.tar.gz
Qt-c535df0f286826c5575ec00c7e4c3f811a73918b.tar.bz2
Fix tst_QGraphicsView::inputMethodSensitivity autotest
The problem was that the scene was not notified it lost the focus when it was disconnected from the view (with setScene) So when it got back the focus, nothing was updated because the scene thought it still had the focus. Reviewed-by: jasplin
Diffstat (limited to 'tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp62
1 files changed, 56 insertions, 6 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 9a561eb..a49c2c1 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3983,20 +3983,28 @@ void tst_QGraphicsScene::isActive()
QVERIFY(!scene1.isActive()); //it is hidden;
QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
view1->show();
QVERIFY(scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
view2->hide();
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
toplevel1.hide();
- QTest::qWait(12);
+ QTest::qWait(50);
QTRY_VERIFY(!scene1.isActive());
QTRY_VERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
toplevel1.show();
QApplication::setActiveWindow(&toplevel1);
@@ -4005,14 +4013,21 @@ void tst_QGraphicsScene::isActive()
QTRY_VERIFY(scene1.isActive());
QTRY_VERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
view2->show();
QVERIFY(scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
}
QVERIFY(!scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
{
QWidget toplevel2;
@@ -4025,6 +4040,8 @@ void tst_QGraphicsScene::isActive()
QVERIFY(!scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
toplevel2.show();
QApplication::setActiveWindow(&toplevel2);
@@ -4033,66 +4050,89 @@ void tst_QGraphicsScene::isActive()
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
view2->setScene(&scene2);
QVERIFY(scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
view1->setScene(&scene2);
QVERIFY(!scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
view1->hide();
QVERIFY(!scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
view1->setScene(&scene1);
QVERIFY(!scene1.isActive());
QVERIFY(scene2.isActive());
-
- view1->show();
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
view1->show();
QVERIFY(scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
view2->hide();
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
QGraphicsView topLevelView;
topLevelView.show();
QApplication::setActiveWindow(&topLevelView);
+ topLevelView.setFocus();
QTest::qWaitForWindowShown(&topLevelView);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&topLevelView));
QVERIFY(!scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
topLevelView.setScene(&scene1);
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
view2->show();
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
view1->hide();
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
QApplication::setActiveWindow(&toplevel2);
QTRY_COMPARE(QApplication::activeWindow(), &toplevel2);
QVERIFY(!scene1.isActive());
QVERIFY(scene2.isActive());
-
-
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
}
QVERIFY(!scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
{
QWidget toplevel3;
@@ -4104,6 +4144,9 @@ void tst_QGraphicsScene::isActive()
QVERIFY(!scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
+
toplevel3.show();
QApplication::setActiveWindow(&toplevel3);
@@ -4112,23 +4155,30 @@ void tst_QGraphicsScene::isActive()
QVERIFY(scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
layout->addWidget(view2);
QApplication::processEvents();
QVERIFY(scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
view1->setParent(0);
QVERIFY(!scene1.isActive());
QVERIFY(scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(scene2.hasFocus());
delete view1;
}
QVERIFY(!scene1.isActive());
QVERIFY(!scene2.isActive());
+ QVERIFY(!scene1.hasFocus());
+ QVERIFY(!scene2.hasFocus());
}
-
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"