aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorValery Volgutov <valery.volgutov@lge.com>2020-04-20 20:42:56 +0300
committerValery Volgutov <valery.volgutov@lge.com>2021-03-14 12:12:24 +0300
commit057972edc90da80252764e1b3abb71e1e6ab0191 (patch)
tree7f67eaafe618954a1fa33a037bf47399a2fa708d /tests/auto/quick
parentdadd6ea6864990fa0143a177500ab07296dfa46e (diff)
Fix QQuickKeyNavigationAttached issue
When Repeater used for Item creation, we have following issue: When Repeater create new item and this item tried to use keyboard.left or keyboard.right to other Repeater's item - these items don't create yet, and we have issue with navigation keys. Set rightSet to true if right really changed. When object call KeboardNavigation::setRight with null item. rightSet field = true, but right field did not changed (null). After that navigation keys works incorrect. The same for other cases. Task-number: QTBUG-83356 Change-Id: I9ea6d6a7d13ff989aac3d9e2d22467b48080de13 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml37
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp19
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml
new file mode 100644
index 0000000000..12ce10e139
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/data/keynavigationtest_repeater.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+
+Grid {
+ property var textModel: ["1", "2", "3", "4", "5"]
+ columns: 5
+ width: 50*textModel.length
+
+ Repeater {
+ id: repeater
+ model: textModel.length
+ Rectangle {
+ width: 50
+ height: 50
+ color: focus ? "red" : "lightgrey"
+ focus: index == 2
+ Text {
+ id: t
+ text: textModel[index]
+ }
+ KeyNavigation.left: repeater.itemAt(index - 1)
+ KeyNavigation.right: repeater.itemAt(index + 1)
+ }
+ }
+
+ function verify() {
+ for (var i = 0; i < repeater.count; i++) {
+ var item = repeater.itemAt(i);
+ var prev = repeater.itemAt(i - 1);
+ var next = repeater.itemAt(i + 1);
+ if (item.KeyNavigation.left != prev || item.KeyNavigation.right != next)
+ return false;
+ }
+
+ return true;
+ }
+}
+
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 399535cfa6..db473d1ea1 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -89,6 +89,7 @@ private slots:
void keyNavigation_implicitDestroy();
void keyNavigation_focusReason();
void keyNavigation_loop();
+ void keyNavigation_repeater();
void layoutMirroring();
void layoutMirroringWindow();
void layoutMirroringIllegalParent();
@@ -2273,6 +2274,24 @@ void tst_QQuickItem::keyNavigation_loop()
delete window;
}
+void tst_QQuickItem::keyNavigation_repeater()
+{
+ // QTBUG-83356
+ QQuickView *window = new QQuickView(nullptr);
+ window->setBaseSize(QSize(240,320));
+
+ window->setSource(testFileUrl("keynavigationtest_repeater.qml"));
+ window->show();
+ window->requestActivate();
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ delete window;
+}
+
void tst_QQuickItem::smooth()
{
QQmlComponent component(&engine);