aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2012-03-12 18:48:05 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-15 10:14:37 +0100
commit67f589209dc856be3ac6261f51023125343812ce (patch)
tree2bff3a1e9510ff2a9ea707f0dfe93ceee77f5c74 /tests
parent1c7b0362b8a1d230e52b7ee5df2aa36a3217b79b (diff)
Don't assert if focus is already clear.
Already cleared focus should exit the function without terminating the runtime. Task-number: QTBUG-24714 Change-Id: Ia8c6be0d88e43d1f71112acc7bac3eb674f22de8 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickitem/data/multipleFocusClears.qml18
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp11
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem/data/multipleFocusClears.qml b/tests/auto/quick/qquickitem/data/multipleFocusClears.qml
new file mode 100644
index 0000000000..f68a8901ab
--- /dev/null
+++ b/tests/auto/quick/qquickitem/data/multipleFocusClears.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 200
+ height: 200
+
+ FocusScope {
+ id: focusScope
+ anchors.fill: parent
+
+ TextInput {
+ anchors.centerIn: parent
+ text: "Some text"
+ onActiveFocusChanged: if (!activeFocus) focusScope.focus = false
+ Component.onCompleted: forceActiveFocus()
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 7a589a48cd..9fdfa78559 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -138,6 +138,7 @@ private slots:
void scopedFocus();
void addedToCanvas();
void changeParent();
+ void multipleFocusClears();
void constructor();
void setParentItem();
@@ -675,6 +676,16 @@ void tst_qquickitem::changeParent()
}
+void tst_qquickitem::multipleFocusClears()
+{
+ //Multiple clears of focus inside a focus scope shouldn't crash. QTBUG-24714
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("multipleFocusClears.qml"));
+ view->show();
+ ensureFocus(view);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == view);
+}
+
void tst_qquickitem::constructor()
{
QQuickItem *root = new QQuickItem;