summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-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
12 files changed, 388 insertions, 0 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"