summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeitem
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-05 03:51:10 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-05 03:51:10 (GMT)
commit48fd47f64f3f73e82016161d82cdf67908a9c653 (patch)
treee337d89e525d3a55d2b9aca8c19d2b3b43c65c50 /tests/auto/declarative/qdeclarativeitem
parenta7b46bda37a428ae2e5554aa8e58469c92b310a9 (diff)
parentc9b3309ae1d3a34790d71fdfd7dcaab79433f049 (diff)
downloadQt-48fd47f64f3f73e82016161d82cdf67908a9c653.zip
Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.gz
Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts: tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
Diffstat (limited to 'tests/auto/declarative/qdeclarativeitem')
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeitem/data/keys.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp38
3 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
index 9281a17..08da901 100644
--- a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml
@@ -11,6 +11,8 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.right: item2
KeyNavigation.down: item3
+ KeyNavigation.tab: item2
+ KeyNavigation.backtab: item4
}
Rectangle {
id: item2
@@ -19,6 +21,8 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.left: item1
KeyNavigation.down: item4
+ KeyNavigation.tab: item3
+ KeyNavigation.backtab: item1
}
Rectangle {
id: item3
@@ -27,6 +31,8 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.right: item4
KeyNavigation.up: item1
+ KeyNavigation.tab: item4
+ KeyNavigation.backtab: item2
}
Rectangle {
id: item4
@@ -35,5 +41,7 @@ Grid {
color: focus ? "red" : "lightgray"
KeyNavigation.left: item3
KeyNavigation.up: item2
+ KeyNavigation.tab: item1
+ KeyNavigation.backtab: item3
}
}
diff --git a/tests/auto/declarative/qdeclarativeitem/data/keys.qml b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
index f3c1f7b..7d34fc8 100644
--- a/tests/auto/declarative/qdeclarativeitem/data/keys.qml
+++ b/tests/auto/declarative/qdeclarativeitem/data/keys.qml
@@ -7,6 +7,8 @@ Item {
Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers)
Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers)
Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) }
+ Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers)
+ Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers)
Keys.forwardTo: [ item2 ]
Keys.enabled: enableKeyHanding
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index 5549a3e..bbcc86e 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -178,6 +178,26 @@ void tst_QDeclarativeItem::keys()
testObject->reset();
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mText, QLatin1String("Tab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mText, QLatin1String("Backtab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
@@ -243,6 +263,24 @@ void tst_QDeclarativeItem::keyNavigation()
QVERIFY(item);
QVERIFY(item->hasFocus());
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasFocus());
+
delete canvas;
}