summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-11-29 08:41:24 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-11-29 08:41:24 (GMT)
commit312604c85b1e6a6fc6de505bac86848936f81edd (patch)
tree40708cd6a968a54dcdbbbf7d0e98007f6cae1ab5 /tests
parentb604dc0b77a3a4b9001d682925006a3438e00cb7 (diff)
downloadQt-312604c85b1e6a6fc6de505bac86848936f81edd.zip
Qt-312604c85b1e6a6fc6de505bac86848936f81edd.tar.gz
Qt-312604c85b1e6a6fc6de505bac86848936f81edd.tar.bz2
Improve consistency in handling of aliases, bindings and value types
Task-number: QTBUG-13719
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml14
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml59
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml29
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml24
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml28
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml29
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml46
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp95
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml19
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp69
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml29
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml31
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml36
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml27
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml27
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp56
24 files changed, 706 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml
new file mode 100644
index 0000000..0eda67d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml
@@ -0,0 +1,9 @@
+import QtQuick 1.0
+
+QtObject {
+ id: root
+
+ property real realProperty
+ property alias aliasProperty: root.realProperty
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml
new file mode 100644
index 0000000..f539fb6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml
@@ -0,0 +1,14 @@
+import QtQuick 1.0
+import Qt.test 1.0
+
+MyTypeObject {
+ id: root
+
+ property int data: 7
+
+ property int targetProperty: root.data * 43 - root.data
+ property alias aliasProperty: root.targetProperty
+
+ pointProperty: Qt.point(data, data);
+ property alias pointAliasProperty: root.pointProperty
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml
new file mode 100644
index 0000000..a4b0527
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml
@@ -0,0 +1,9 @@
+import QtQuick 1.0
+
+QtObject {
+ id: root
+
+ property int testProperty
+ property alias aliasProperty: root.testProperty
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml
new file mode 100644
index 0000000..f0808c4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml
@@ -0,0 +1,59 @@
+import QtQuick 1.0
+
+Item {
+ id: root
+
+ property bool test: false
+
+ property real testData: 9
+ property real testData2: 9
+
+ states: State {
+ name: "change"
+ PropertyChanges {
+ target: myType
+ realProperty: if (testData2 > 3) 9; else 11;
+ }
+ }
+
+ AliasBindingsAssignCorrectlyType {
+ id: myType
+
+ aliasProperty: if (testData > 3) 14; else 12;
+ }
+
+ Component.onCompleted: {
+ // Check original binding works
+ if (myType.aliasProperty != 14) return;
+
+ testData = 2;
+ if (myType.aliasProperty != 12) return;
+
+ // Change binding indirectly by modifying the "realProperty"
+ root.state = "change";
+ if (myType.aliasProperty != 9) return;
+
+ // Check the new binding works
+ testData2 = 1;
+ if (myType.aliasProperty != 11) return;
+
+ // Try and trigger the old binding (that should have been removed)
+ testData = 6;
+ if (myType.aliasProperty != 11) return;
+
+ // Restore the original binding
+ root.state = "";
+ if (myType.aliasProperty != 14) return;
+
+ // Test the restored binding works
+ testData = 0;
+ if (myType.aliasProperty != 12) return;
+
+ // Test the old binding isn't somehow hanging around and still in effect
+ testData2 = 13;
+ if (myType.aliasProperty != 12) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml
new file mode 100644
index 0000000..4f07cbf
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml
@@ -0,0 +1,29 @@
+import QtQuick 1.0
+
+Item {
+ id: me
+ property bool test: false
+
+ property int value: 9
+
+ AliasBindingsOverrideTargetType {
+ id: aliasType
+ pointAliasProperty.x: me.value
+ }
+
+ Component.onCompleted: {
+ if (aliasType.pointAliasProperty.x != 9) return;
+
+ me.value = 11;
+ if (aliasType.pointAliasProperty.x != 11) return;
+
+ aliasType.data = 8;
+ if (aliasType.pointAliasProperty.x != 11) return;
+
+ me.value = 4;
+ if (aliasType.pointAliasProperty.x != 4) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml
new file mode 100644
index 0000000..937ae91
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+Item {
+ id: root
+ property bool test: false;
+
+ property int value1: 10
+ property int value2: 11
+
+ AliasBindingsOverrideTargetType3 {
+ id: obj
+
+ testProperty: root.value1 * 9
+ aliasProperty: root.value2 * 10
+ }
+
+ Component.onCompleted: {
+ if (obj.testProperty != 110) return;
+ if (obj.aliasProperty != 110) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml
new file mode 100644
index 0000000..a01dc5b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml
@@ -0,0 +1,28 @@
+import QtQuick 1.0
+
+Item {
+ id: me
+ property bool test: false
+
+ property int value: 9
+
+ AliasBindingsOverrideTargetType {
+ id: aliasType
+ aliasProperty: me.value
+ }
+
+ Component.onCompleted: {
+ if (aliasType.aliasProperty != 9) return;
+
+ me.value = 11;
+ if (aliasType.aliasProperty != 11) return;
+
+ aliasType.data = 8;
+ if (aliasType.aliasProperty != 11) return;
+
+ me.value = 4;
+ if (aliasType.aliasProperty != 4) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml
new file mode 100644
index 0000000..5bf9f6a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml
@@ -0,0 +1,29 @@
+import QtQuick 1.0
+
+Item {
+ id: me
+ property bool test: false
+
+ property int value: 9
+
+ AliasBindingsOverrideTargetType {
+ id: aliasType
+ }
+
+ Component.onCompleted: {
+ if (aliasType.aliasProperty != 294) return;
+
+ aliasType.data = 8;
+ if (aliasType.aliasProperty != 336) return;
+
+ aliasType.aliasProperty = 4;
+ if (aliasType.aliasProperty != 4) return;
+
+ aliasType.data = 7;
+ if (aliasType.aliasProperty != 4) return;
+
+ test = true;
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml
new file mode 100644
index 0000000..a23ad4a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.0
+
+Item {
+ id: me
+ property bool test: false
+
+ property int value: 9
+
+ AliasBindingsOverrideTargetType {
+ id: aliasType
+ pointAliasProperty.x: 9
+ }
+
+ Component.onCompleted: {
+ if (aliasType.pointAliasProperty.x != 9) return;
+
+ aliasType.data = 8;
+ if (aliasType.pointAliasProperty.x != 9) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml
new file mode 100644
index 0000000..ac20371
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.0
+
+Item {
+ id: me
+ property bool test: false
+
+ property int value: 9
+
+ AliasBindingsOverrideTargetType {
+ id: aliasType
+ aliasProperty: 11
+ }
+
+ Component.onCompleted: {
+ if (aliasType.aliasProperty != 11) return;
+
+ aliasType.data = 8;
+ if (aliasType.aliasProperty != 11) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml
new file mode 100644
index 0000000..035f037
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml
@@ -0,0 +1,46 @@
+import QtQuick 1.0
+
+QtObject {
+ id: root
+
+ property bool test: false
+
+ property real data: 9
+ property real binding: data
+
+ property alias aliasProperty: root.aliasBinding
+ property real aliasBinding: data
+
+ Component.onCompleted: {
+ // Non-aliased properties
+ if (binding != 9) return;
+
+ data = 11;
+ if (binding != 11) return;
+
+ binding = 6;
+ if (binding != 6) return;
+
+ data = 3;
+ if (binding != 6) return;
+
+
+ // Writing through an aliased property
+ if (aliasProperty != 3) return;
+ if (aliasBinding != 3) return;
+
+ data = 4;
+ if (aliasProperty != 4) return;
+ if (aliasBinding != 4) return;
+
+ aliasProperty = 19;
+ if (aliasProperty != 19) return;
+ if (aliasBinding != 19) return;
+
+ data = 5;
+ if (aliasProperty != 19) return;
+ if (aliasBinding != 19) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 652404c..8658217 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -164,6 +164,10 @@ private slots:
void in();
void sharedAttachedObject();
void objectName();
+ void writeRemovesBinding();
+ void aliasBindingsAssignCorrectly();
+ void aliasBindingsOverrideTarget();
+ void aliasWritesOverrideBindings();
void include();
@@ -2671,6 +2675,97 @@ void tst_qdeclarativeecmascript::objectName()
delete o;
}
+void tst_qdeclarativeecmascript::writeRemovesBinding()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("writeRemovesBinding.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+// Test bindings assigned to alias properties actually assign to the alias' target
+void tst_qdeclarativeecmascript::aliasBindingsAssignCorrectly()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsAssignCorrectly.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
+void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.3.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Test that writes to alias properties override bindings on the alias target (QTBUG-13719)
+void tst_qdeclarativeecmascript::aliasWritesOverrideBindings()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.3.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
index db1f191..4470d65 100644
--- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
+++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
@@ -458,6 +458,7 @@ void tst_qdeclarativeinstruction::dump()
i.type = QDeclarativeInstruction::FetchValueType;
i.fetchValue.property = 34;
i.fetchValue.type = 6;
+ i.fetchValue.bindingSkipList = 7;
data->bytecode << i;
}
@@ -538,7 +539,7 @@ void tst_qdeclarativeinstruction::dump()
<< "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
<< "-------------------------------------------------------------------------------"
<< "0\t\t0\tINIT\t\t\t0\t3\t-1\t-1"
- << "1\t\t1\tCREATE\t\t\t0\t\t\t\"Test\""
+ << "1\t\t1\tCREATE\t\t\t0\t-1\t\t\"Test\""
<< "2\t\t2\tSETID\t\t\t0\t\t\t\"testId\""
<< "3\t\t3\tSET_DEFAULT"
<< "4\t\t4\tCREATE_COMPONENT\t3"
@@ -578,7 +579,7 @@ void tst_qdeclarativeinstruction::dump()
<< "38\t\t40\tFETCH_ATTACHED\t\t23"
<< "39\t\t42\tFETCH_QLIST\t\t32"
<< "40\t\t43\tFETCH\t\t\t33"
- << "41\t\t44\tFETCH_VALUE\t\t34\t6"
+ << "41\t\t44\tFETCH_VALUE\t\t34\t6\t7"
<< "42\t\t45\tPOP"
<< "43\t\t46\tPOP_QLIST"
<< "44\t\t47\tPOP_VALUE\t\t35\t8"
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml b/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml
new file mode 100644
index 0000000..a253a58
--- /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 0ca0e03..3cc71bb 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;
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml
new file mode 100644
index 0000000..f625d08
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property bool boldProperty: false
+
+ font.bold: boldProperty
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml
new file mode 100644
index 0000000..0bdccce
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int dataProperty: 7
+
+ point: Qt.point(dataProperty, dataProperty)
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml
new file mode 100644
index 0000000..151c499
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ property int dataProperty: 7
+
+ point.x: dataProperty
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml
new file mode 100644
index 0000000..7012143
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml
@@ -0,0 +1,29 @@
+import Test 1.0
+import QtQuick 1.0
+
+BindingsSpliceCorrectlyType {
+ property bool test: false
+
+ property bool italicProperty: false
+
+ font.italic: italicProperty
+
+ Component.onCompleted: {
+ // Test initial state
+ if (font.italic != false) return;
+ if (font.bold != false) return;
+
+ // Test italic binding worked
+ italicProperty = true;
+
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ // Test bold binding worked
+ boldProperty = true;
+ if (font.italic != true) return;
+ if (font.bold != true) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml
new file mode 100644
index 0000000..69dbcab
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml
@@ -0,0 +1,31 @@
+import Test 1.0
+import QtQuick 1.0
+
+BindingsSpliceCorrectlyType {
+ property bool test: false
+
+ property bool italicProperty: false
+
+ font.italic: italicProperty
+ font.bold: false
+
+ Component.onCompleted: {
+ // Test initial state
+ if (font.italic != false) return;
+ if (font.bold != false) return;
+
+ // Test italic binding worked
+ italicProperty = true;
+
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ // Test bold binding was removed by constant write
+ boldProperty = true;
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml
new file mode 100644
index 0000000..669feb9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml
@@ -0,0 +1,36 @@
+import Test 1.0
+import QtQuick 1.0
+
+BindingsSpliceCorrectlyType {
+ property bool test: false
+
+ property bool italicProperty: false
+ property bool boldProperty2: false
+
+ font.italic: italicProperty
+ font.bold: boldProperty2
+
+ Component.onCompleted: {
+ // Test initial state
+ if (font.italic != false) return;
+ if (font.bold != false) return;
+
+ // Test italic binding worked
+ italicProperty = true;
+
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ // Test bold binding was overridden
+ boldProperty = true;
+ if (font.italic != true) return;
+ if (font.bold != false) return;
+
+ boldProperty2 = true;
+ if (font.italic != true) return;
+ if (font.bold != true) return;
+
+ test = true;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml
new file mode 100644
index 0000000..f28584f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml
@@ -0,0 +1,27 @@
+import Test 1.0
+import QtQuick 1.0
+
+BindingsSpliceCorrectlyType4 {
+ property bool test: false
+
+ property int dataProperty2: 8
+
+ point.x: dataProperty2
+
+ Component.onCompleted: {
+ if (point.x != 8) return;
+ if (point.y != 4) return;
+
+ dataProperty = 9;
+
+ if (point.x != 8) return;
+ if (point.y != 4) return;
+
+ dataProperty2 = 13;
+
+ if (point.x != 13) return;
+ if (point.y != 4) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml
new file mode 100644
index 0000000..1214c83
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml
@@ -0,0 +1,27 @@
+import Test 1.0
+import QtQuick 1.0
+
+BindingsSpliceCorrectlyType5 {
+ property bool test: false
+
+ property int dataProperty2: 8
+
+ point: Qt.point(dataProperty2, dataProperty2);
+
+ Component.onCompleted: {
+ if (point.x != 8) return;
+ if (point.y != 8) return;
+
+ dataProperty = 9;
+
+ if (point.x != 8) return;
+ if (point.y != 8) return;
+
+ dataProperty2 = 13;
+
+ if (point.x != 13) return;
+ if (point.y != 13) return;
+
+ test = true;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index a4819f3..c243a75 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -94,6 +94,7 @@ private slots:
void conflictingBindings();
void returnValues();
void varAssignment();
+ void bindingsSpliceCorrectly();
private:
QDeclarativeEngine engine;
@@ -942,6 +943,61 @@ void tst_qdeclarativevaluetypes::varAssignment()
delete object;
}
+// Test bindings splice together correctly
+void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+}
+
QTEST_MAIN(tst_qdeclarativevaluetypes)
#include "tst_qdeclarativevaluetypes.moc"