aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2013-04-12 11:52:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-23 12:53:48 +0200
commit7167ebd3012147b41a447a6b0bbecc64b6017bd4 (patch)
treec90308a2e5e3cf24c0750ce82e8bf8cac4ed433e /tests/auto
parent5f7ba49e2501286670e19ee8ba7d48b169fa3330 (diff)
Expose nextItemInFocusChain in QQuickItem
Convenient for other use cases related with tab focus chain. Autotest is included. Change-Id: I1ba6317e20edacc2b672bc5b78e3fcd29ac80bdc Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index f2d25e81ed..3ec77ce950 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -70,6 +70,8 @@ private slots:
void activeFocusOnTab4();
void activeFocusOnTab5();
+ void nextItemInFocusChain();
+
void keys();
void keysProcessingOrder();
void keysim();
@@ -664,6 +666,79 @@ void tst_QQuickItem::activeFocusOnTab5()
delete window;
}
+void tst_QQuickItem::nextItemInFocusChain()
+{
+ QQuickView *window = new QQuickView(0);
+ window->setBaseSize(QSize(800,600));
+
+ window->setSource(testFileUrl("activeFocusOnTab.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(QGuiApplication::focusWindow() == window);
+
+ QQuickItem *button11 = findItem<QQuickItem>(window->rootObject(), "button11");
+ QVERIFY(button11);
+ QQuickItem *button12 = findItem<QQuickItem>(window->rootObject(), "button12");
+ QVERIFY(button12);
+
+ QQuickItem *sub2 = findItem<QQuickItem>(window->rootObject(), "sub2");
+ QVERIFY(sub2);
+ QQuickItem *button21 = findItem<QQuickItem>(window->rootObject(), "button21");
+ QVERIFY(button21);
+ QQuickItem *button22 = findItem<QQuickItem>(window->rootObject(), "button22");
+ QVERIFY(button22);
+
+ QQuickItem *edit = findItem<QQuickItem>(window->rootObject(), "edit");
+ QVERIFY(edit);
+
+ QQuickItem *next, *prev;
+
+ next = button11->nextItemInFocusChain(true);
+ QVERIFY(next);
+ QCOMPARE(next, button12);
+ prev = button11->nextItemInFocusChain(false);
+ QVERIFY(prev);
+ QCOMPARE(prev, edit);
+
+ next = button12->nextItemInFocusChain();
+ QVERIFY(next);
+ QCOMPARE(next, sub2);
+ prev = button12->nextItemInFocusChain(false);
+ QVERIFY(prev);
+ QCOMPARE(prev, button11);
+
+ next = sub2->nextItemInFocusChain(true);
+ QVERIFY(next);
+ QCOMPARE(next, button21);
+ prev = sub2->nextItemInFocusChain(false);
+ QVERIFY(prev);
+ QCOMPARE(prev, button12);
+
+ next = button21->nextItemInFocusChain();
+ QVERIFY(next);
+ QCOMPARE(next, button22);
+ prev = button21->nextItemInFocusChain(false);
+ QVERIFY(prev);
+ QCOMPARE(prev, sub2);
+
+ next = button22->nextItemInFocusChain(true);
+ QVERIFY(next);
+ QCOMPARE(next, edit);
+ prev = button22->nextItemInFocusChain(false);
+ QVERIFY(prev);
+ QCOMPARE(prev, button21);
+
+ next = edit->nextItemInFocusChain();
+ QVERIFY(next);
+ QCOMPARE(next, button11);
+ prev = edit->nextItemInFocusChain(false);
+ QVERIFY(prev);
+ QCOMPARE(prev, button22);
+
+ delete window;
+}
+
void tst_QQuickItem::keys()
{
QQuickView *window = new QQuickView(0);