diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-03-04 08:25:20 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2010-03-04 08:25:20 (GMT) |
commit | cb66d13b62507391982047a0f8e74b84053562e3 (patch) | |
tree | 75d6d01c7b5747e91ac6a36c41ccca7a9e23dffe /tests/auto | |
parent | d29e837e34e3f683cfdea2d5e8f8241d4f26bafa (diff) | |
parent | 83cbbd6c4c9ff2f00651c31af0d52845b2e98390 (diff) | |
download | Qt-cb66d13b62507391982047a0f8e74b84053562e3.zip Qt-cb66d13b62507391982047a0f8e74b84053562e3.tar.gz Qt-cb66d13b62507391982047a0f8e74b84053562e3.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto')
9 files changed, 119 insertions, 8 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml new file mode 100644 index 0000000..4b5464d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml @@ -0,0 +1,9 @@ +import Qt 4.6 +import Qt.test 1.0 + +QtObject { + property int value: 9 + property int value2 + + MyQmlObject.onMySignal: value2 = value +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml new file mode 100644 index 0000000..d65b6e7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + id: a + property int b: 9 + + property int test + property string test2 + + // Should resolve to signal arguments, not to other elements in the file + onArgumentSignal: { test = a; test2 = b; } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 8fbd071..a283e3f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -60,10 +60,21 @@ class MyQmlAttachedObject : public QObject { Q_OBJECT Q_PROPERTY(int value READ value CONSTANT) + Q_PROPERTY(int value2 READ value2 WRITE setValue2) public: - MyQmlAttachedObject(QObject *parent) : QObject(parent) {} + MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {} int value() const { return 19; } + int value2() const { return m_value2; } + void setValue2(int v) { m_value2 = v; } + + void emitMySignal() { emit mySignal(); } + +signals: + void mySignal(); + +private: + int m_value2; }; class MyQmlObject : public QObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 75ee7ce..b5649cb 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -123,6 +123,7 @@ private slots: void multiEngineObject(); void deletedObject(); void scriptScope(); + void attachedPropertyScope(); void bug1(); @@ -739,6 +740,23 @@ void tst_qdeclarativeecmascript::scope() QCOMPARE(object->property("test2").toBool(), true); QCOMPARE(object->property("test3").toBool(), true); } + + // Signal argument scope + { + QDeclarativeComponent component(&engine, TEST_FILE("scope.4.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + QCOMPARE(object->property("test2").toString(), QString()); + + emit object->argumentSignal(13, "Argument Scope", 9); + + QCOMPARE(object->property("test").toInt(), 13); + QCOMPARE(object->property("test2").toString(), QString("Argument Scope")); + + delete object; + } } /* @@ -1693,6 +1711,26 @@ void tst_qdeclarativeecmascript::scriptScope() } } +void tst_qdeclarativeecmascript::attachedPropertyScope() +{ + QDeclarativeComponent component(&engine, TEST_FILE("attachedPropertyScope.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + MyQmlAttachedObject *attached = + qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object)); + QVERIFY(attached != 0); + + QCOMPARE(object->property("value2").toInt(), 0); + + attached->emitMySignal(); + + QCOMPARE(object->property("value2").toInt(), 9); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" 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() diff --git a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml index aecb3c3..b46ec34 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml @@ -3,8 +3,6 @@ import Test 1.0 as Namespace import Qt 4.6 QtObject { - property int value2: 8 MyQmlObject.value: 10 Namespace.MyQmlObject.value2: 13 - MyQmlObject.onValueChanged: value2 = MyQmlObject.value } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index a339a6d..3ce15cb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -718,11 +718,6 @@ void tst_qdeclarativelanguage::attachedProperties() QVERIFY(attached != 0); QCOMPARE(attached->property("value"), QVariant(10)); QCOMPARE(attached->property("value2"), QVariant(13)); - - QEXPECT_FAIL("", "QTBUG-8677", Abort); - attached->setProperty("value", QVariant(12)); - int val = object->property("value2").toInt(); - QCOMPARE(val, 12); } // Tests non-static object properties |