summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2010-03-04 08:17:24 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2010-03-04 08:17:24 (GMT)
commita65e37f0fd48158403296d5ca9ffa0f0feae2940 (patch)
tree8612fdb60fdaf707c90cbca60aeafd19251f7b2d
parent15f0fb150b924b890a8285fda8f10134f76d263c (diff)
downloadQt-a65e37f0fd48158403296d5ca9ffa0f0feae2940.zip
Qt-a65e37f0fd48158403296d5ca9ffa0f0feae2940.tar.gz
Qt-a65e37f0fd48158403296d5ca9ffa0f0feae2940.tar.bz2
Add autotests for tab and backtab in Keys and KeyNavigation.
-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 36dcf1f..dbcba16 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -176,6 +176,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);
@@ -240,6 +260,24 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
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());
}
void tst_QDeclarativeItem::smooth()