summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-10-11 00:26:34 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-10-11 01:29:23 (GMT)
commite11ee40cefc981fbdcfb10816039d4efb080fb17 (patch)
treed20d1e42784154aa1bc370dbc69940cb5c17ddc7 /tests/auto/declarative
parentaa7fa8608939676ba56e130214b85f5d0c3745df (diff)
downloadQt-e11ee40cefc981fbdcfb10816039d4efb080fb17.zip
Qt-e11ee40cefc981fbdcfb10816039d4efb080fb17.tar.gz
Qt-e11ee40cefc981fbdcfb10816039d4efb080fb17.tar.bz2
Don't give focus to a FocusScope that has had focus explicitly cleared.
If focus was explicitly cleared on a non-visible FocusScope, and then it was made visible, it would incorrectly grab focus. Task-number: QTBUG-13380
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml24
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp26
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml b/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml
new file mode 100644
index 0000000..1784202
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+Rectangle {
+ width: 400; height: 400
+
+ property bool showRect: false
+ onShowRectChanged: if (showRect) rect.visible = true
+ property bool noFocus: !fs2.activeFocus
+
+ FocusScope {
+ id: fs1
+ focus: true
+ }
+ Rectangle {
+ id: rect
+ visible: false
+ FocusScope {
+ id: fs2
+ Rectangle {
+ focus: true
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
index ec8f048..4cafbd9 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
+++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
@@ -70,6 +70,7 @@ private slots:
void forceFocus();
void noParentFocus();
void signalEmission();
+ void qtBug13380();
};
/*
@@ -400,6 +401,31 @@ void tst_qdeclarativefocusscope::signalEmission()
delete view;
}
+void tst_qdeclarativefocusscope::qtBug13380()
+{
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtBug13380.qml"));
+
+ view->show();
+ QVERIFY(view->rootObject());
+ qApp->setActiveWindow(view);
+ qApp->processEvents();
+
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(view);
+#endif
+
+ QVERIFY(view->hasFocus());
+ QVERIFY(view->scene()->hasFocus());
+ QVERIFY(view->rootObject()->property("noFocus").toBool());
+
+ view->rootObject()->setProperty("showRect", true);
+ QVERIFY(view->rootObject()->property("noFocus").toBool());
+
+ delete view;
+}
+
QTEST_MAIN(tst_qdeclarativefocusscope)
#include "tst_qdeclarativefocusscope.moc"