diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml | 14 | ||||
-rw-r--r-- | tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp | 26 |
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml new file mode 100644 index 0000000..6143164 --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/aliasPropertyAndBinding.qml @@ -0,0 +1,14 @@ +import Qt 4.6 +import Qt.test 1.0 + +MyQmlObject { + property alias c1: MyObject.c1 + property int c2: 3 + property int c3: c2 + objectProperty: Object { + id: MyObject + property int c1 + } +} + + diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 7e6d83b..113c12f 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -48,6 +48,7 @@ private slots: void valueTypeFunctions(); void constantsOverrideBindings(); void outerBindingOverridesInnerBinding(); + void aliasPropertyAndBinding(); void nonExistantAttachedObject(); private: @@ -451,6 +452,7 @@ void tst_qmlecmascript::constantsOverrideBindings() QCOMPARE(object->property("c2").toInt(), 10); } +#if 0 // From C++ { QmlComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml")); @@ -467,6 +469,7 @@ void tst_qmlecmascript::constantsOverrideBindings() QCOMPARE(object->property("c1").toInt(), 7); QCOMPARE(object->property("c2").toInt(), 13); } +#endif } /* @@ -475,7 +478,8 @@ the original binding to be disabled. */ void tst_qmlecmascript::outerBindingOverridesInnerBinding() { - QmlComponent component(&engine, TEST_FILE("outerBindingOverridesInnerBinding.qml")); + QmlComponent component(&engine, + TEST_FILE("outerBindingOverridesInnerBinding.qml")); MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); @@ -506,6 +510,26 @@ void tst_qmlecmascript::nonExistantAttachedObject() QVERIFY(object != 0); } +/* +Confirm bindings and alias properties can coexist. + +Tests for a regression where the binding would not reevaluate. +*/ +void tst_qmlecmascript::aliasPropertyAndBinding() +{ + QmlComponent component(&engine, TEST_FILE("aliasPropertyAndBinding.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("c2").toInt(), 3); + QCOMPARE(object->property("c3").toInt(), 3); + + object->setProperty("c2", QVariant(19)); + + QCOMPARE(object->property("c2").toInt(), 19); + QCOMPARE(object->property("c3").toInt(), 19); +} + QTEST_MAIN(tst_qmlecmascript) #include "tst_qmlecmascript.moc" |