diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-11-10 00:11:30 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-11-10 00:11:30 (GMT) |
commit | 94886fcc184147420cdd205e5d5be073d768bfc8 (patch) | |
tree | e67245d043d4b4ff64c9e0f5af589bfde4a0281f /tests/auto/declarative | |
parent | 9b3a87a0f20023b59b3d59807aac69e53be277eb (diff) | |
download | Qt-94886fcc184147420cdd205e5d5be073d768bfc8.zip Qt-94886fcc184147420cdd205e5d5be073d768bfc8.tar.gz Qt-94886fcc184147420cdd205e5d5be073d768bfc8.tar.bz2 |
More Keys testing.
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qmlgraphicsitem/data/keys.qml | 3 | ||||
-rw-r--r-- | tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp | 31 |
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlgraphicsitem/data/keys.qml b/tests/auto/declarative/qmlgraphicsitem/data/keys.qml index 7c16559..f3c1f7b 100644 --- a/tests/auto/declarative/qmlgraphicsitem/data/keys.qml +++ b/tests/auto/declarative/qmlgraphicsitem/data/keys.qml @@ -5,7 +5,10 @@ Item { Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } 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.forwardTo: [ item2 ] + Keys.enabled: enableKeyHanding Item { id: item2 diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp index b4b3eaf..66ef982 100644 --- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp +++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp @@ -113,6 +113,8 @@ void tst_QmlGraphicsItem::keys() KeysTestObject *testObject = new KeysTestObject; canvas->rootContext()->setContextProperty("keysTestObject", testObject); + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + canvas->execute(); canvas->show(); qApp->processEvents(); @@ -150,6 +152,35 @@ void tst_QmlGraphicsItem::keys() QVERIFY(testObject->mModifiers == Qt::NoModifier); QVERIFY(key.isAccepted()); + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_0)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0)); + QCOMPARE(testObject->mText, QLatin1String("0")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_9)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9)); + QCOMPARE(testObject->mText, QLatin1String("9")); + 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); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(!key.isAccepted()); + delete canvas; delete testObject; } |