summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-09 10:01:10 +0200
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-09 17:18:07 +0200
commit948038f077ea413ab7aa7634d1c9987ec7ab50f6 (patch)
tree4f1142819abe81fedad25e276b28900f1b16c157 /tests/auto/qgraphicsview
parentc44402453593cbdf2eafa66f6ee23d17aacf44fd (diff)
Only active QGraphicsScenes can have active input focus.
This change ensures that only active scenes can have active input focus items. If you try to set input focus on items that are in an inactive scene, these items will gain input focus only when the scene is activated. For scenes attached to a view, this change should only fix the bug that you could have a blinking line edit in a scene when the view is inactive, meaning you couldn't type into the line edit. For scenes that have no view, you now must activate the scene in order to give the items active input focus. This will affect those who use QGraphicsScene with custom key and focus handling. Reviewed-by: brad
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index bb0ea70f3e..0b731d53a5 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -1938,6 +1938,7 @@ void tst_QGraphicsView::wheelEvent()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
+ QTest::qWait(250);
// Send a wheel event with horizontal orientation.
{
@@ -2941,10 +2942,10 @@ void tst_QGraphicsView::task239729_noViewUpdate()
}
view->show();
- QTest::qWait(250);
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(view);
#endif
+ QTest::qWait(250);
EventSpy spy(view->viewport(), QEvent::Paint);
QCOMPARE(spy.count(), 0);
@@ -3418,7 +3419,7 @@ void tst_QGraphicsView::exposeRegion()
QRegion expectedExposeRegion = QRect(0, 0, 5, 5);
expectedExposeRegion += QRect(viewport->rect().bottomRight() - QPoint(5, 5), QSize(5, 5));
viewport->update(expectedExposeRegion);
- qApp->processEvents();
+ QTest::qWait(125);
// Make sure it triggers correct repaint on the view.
QCOMPARE(view.lastUpdateRegions.size(), 1);
@@ -3488,7 +3489,7 @@ void tst_QGraphicsView::update()
viewPrivate->processPendingUpdates();
QVERIFY(viewPrivate->dirtyRegion.isEmpty());
QVERIFY(viewPrivate->dirtyBoundingRect.isEmpty());
- QTest::qWait(50);
+ QTest::qWait(150);
if (!intersects) {
QVERIFY(view.lastUpdateRegions.isEmpty());
} else {
@@ -3504,6 +3505,11 @@ void tst_QGraphicsView::inputMethodSensitivity()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(300);
QGraphicsRectItem *item = new QGraphicsRectItem;
@@ -3571,11 +3577,12 @@ void tst_QGraphicsView::inputMethodSensitivity()
class InputContextTester : public QInputContext
{
+ Q_OBJECT
+public:
QString identifierName() { return QString(); }
bool isComposing() const { return false; }
QString language() { return QString(); }
void reset() { ++resets; }
-public:
int resets;
};
@@ -3583,10 +3590,17 @@ void tst_QGraphicsView::inputContextReset()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
InputContextTester inputContext;
view.setInputContext(&inputContext);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(300);
+
QGraphicsItem *item1 = new QGraphicsRectItem;
item1->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
@@ -3596,6 +3610,8 @@ void tst_QGraphicsView::inputContextReset()
inputContext.resets = 0;
scene.setFocusItem(item1);
+ QCOMPARE(scene.focusItem(), (QGraphicsItem *)item1);
+ QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
QCOMPARE(inputContext.resets, 0);
inputContext.resets = 0;