summaryrefslogtreecommitdiff
path: root/tests/auto/declarative/qdeclarativeproperty
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-12-06 16:43:57 +0100
committerOlivier Goffart <olivier.goffart@nokia.com>2010-12-06 16:43:57 +0100
commit9888fa259875d82bf08a28cac134fe6f71f371f0 (patch)
treea58a6ab673888d5c352d2cfe98b22fb1c11c40e9 /tests/auto/declarative/qdeclarativeproperty
parenta70ccc4aaad74dbf28569c78479d4668781bb0fe (diff)
parent9327490ad51b737211c26cae53a095a8485e2dad (diff)
downloadqt4-tools-9888fa259875d82bf08a28cac134fe6f71f371f0.tar.gz
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: configure qmake/generators/win32/msbuild_objectmodel.cpp src/gui/image/qpnghandler.cpp src/network/access/qnetworkaccessdatabackend.cpp src/opengl/qgl_x11egl.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp
Diffstat (limited to 'tests/auto/declarative/qdeclarativeproperty')
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml19
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp69
2 files changed, 88 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml b/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml
new file mode 100644
index 0000000000..a253a58da9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml
@@ -0,0 +1,19 @@
+import QtQuick 1.0
+
+Item {
+ id: root
+
+ property real test: 9
+ property real test2: 3
+
+ property real realProperty: test * test + test
+ property alias aliasProperty: root.realProperty
+
+ states: State {
+ name: "switch"
+ PropertyChanges {
+ target: root
+ aliasProperty: 32 * test2
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
index 0ca0e03b8e..3cc71bb3ea 100644
--- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
+++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
@@ -132,6 +132,7 @@ private slots:
// Bugs
void crashOnValueProperty();
+ void aliasPropertyBindings();
void copy();
private:
@@ -1308,6 +1309,74 @@ void tst_qdeclarativeproperty::crashOnValueProperty()
QCOMPARE(p.read(), QVariant(20));
}
+// QTBUG-13719
+void tst_qdeclarativeproperty::aliasPropertyBindings()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyBindings.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("realProperty").toReal(), 90.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 90.);
+
+ object->setProperty("test", 10);
+
+ QCOMPARE(object->property("realProperty").toReal(), 110.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 110.);
+
+ QDeclarativeProperty realProperty(object, QLatin1String("realProperty"));
+ QDeclarativeProperty aliasProperty(object, QLatin1String("aliasProperty"));
+
+ // Check there is a binding on these two properties
+ QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
+
+ // Check that its the same binding on these two properties
+ QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
+ QDeclarativePropertyPrivate::binding(aliasProperty));
+
+ // Change the binding
+ object->setProperty("state", QString("switch"));
+
+ QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
+ QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
+ QDeclarativePropertyPrivate::binding(aliasProperty));
+
+ QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 96.);
+
+ // Check the old binding really has not effect any more
+ object->setProperty("test", 4);
+
+ QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 96.);
+
+ object->setProperty("test2", 9);
+
+ QCOMPARE(object->property("realProperty").toReal(), 288.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 288.);
+
+ // Revert
+ object->setProperty("state", QString(""));
+
+ QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
+ QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
+ QDeclarativePropertyPrivate::binding(aliasProperty));
+
+ QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 20.);
+
+ object->setProperty("test2", 3);
+
+ QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 20.);
+
+ delete object;
+}
+
void tst_qdeclarativeproperty::copy()
{
PropertyObject object;