diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2011-03-01 02:57:14 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2011-03-01 07:19:37 (GMT) |
commit | d5c72c6fb75357061c5f9e0d0d2efdaff9140741 (patch) | |
tree | 95a8801535c1a783b84f02f9306e879613ee4cd9 /tests/auto/declarative | |
parent | 2c7cab4172f1acc86fd49345a2847417e162f2c3 (diff) | |
download | Qt-d5c72c6fb75357061c5f9e0d0d2efdaff9140741.zip Qt-d5c72c6fb75357061c5f9e0d0d2efdaff9140741.tar.gz Qt-d5c72c6fb75357061c5f9e0d0d2efdaff9140741.tar.bz2 |
Reverse KeyNavigation left and right properties when the layout mirroring is enabled
Task-number: QTBUG-15882
Reviewed-by: Martin Jones
Change-Id: I4c9f0b48e089b30ced5e7fefa5d6e97b3155f3b2
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index f83207c..2d14e66 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -65,6 +65,7 @@ private slots: void keys(); void keysProcessingOrder(); void keyNavigation(); + void keyNavigation_RightToLeft(); void keyNavigation_skipNotVisible(); void layoutMirroring(); void layoutMirroringIllegalParent(); @@ -608,6 +609,59 @@ void tst_QDeclarativeItem::keyNavigation() delete canvas; } +void tst_QDeclarativeItem::keyNavigation_RightToLeft() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml")); + canvas->show(); + qApp->processEvents(); + + QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject()); + QVERIFY(rootItem); + QDeclarativeItemPrivate* rootItemPrivate = QDeclarativeItemPrivate::get(rootItem); + + rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true + rootItemPrivate->isMirrorImplicit = false; + rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true + rootItemPrivate->resolveLayoutMirror(); + + QEvent wa(QEvent::WindowActivate); + QApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QApplication::sendEvent(canvas, &fe); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + QVariant result; + QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", + Q_RETURN_ARG(QVariant, result))); + QVERIFY(result.toBool()); + + // right + QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // left + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete canvas; +} + void tst_QDeclarativeItem::keyNavigation_skipNotVisible() { QDeclarativeView *canvas = new QDeclarativeView(0); |