Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativeecmascript / data / aliasBindingsAssignCorrectly.qml
1 import QtQuick 1.0
2
3 Item {
4     id: root
5     
6     property bool test: false
7
8     property real testData: 9
9     property real testData2: 9
10
11     states: State {
12         name: "change"
13         PropertyChanges {
14             target: myType
15             realProperty: if (testData2 > 3) 9; else 11;
16         }
17     }
18
19     AliasBindingsAssignCorrectlyType {
20         id: myType
21
22         aliasProperty: if (testData > 3) 14; else 12;
23     }
24
25     Component.onCompleted: {
26         // Check original binding works
27         if (myType.aliasProperty != 14) return;
28
29         testData = 2;
30         if (myType.aliasProperty != 12) return;
31
32         // Change binding indirectly by modifying the "realProperty"
33         root.state = "change";
34         if (myType.aliasProperty != 9) return;
35
36         // Check the new binding works
37         testData2 = 1;
38         if (myType.aliasProperty != 11) return;
39
40         // Try and trigger the old binding (that should have been removed)
41         testData = 6;
42         if (myType.aliasProperty != 11) return;
43
44         // Restore the original binding
45         root.state = "";
46         if (myType.aliasProperty != 14) return;
47
48         // Test the restored binding works
49         testData = 0;
50         if (myType.aliasProperty != 12) return;
51
52         // Test the old binding isn't somehow hanging around and still in effect
53         testData2 = 13;
54         if (myType.aliasProperty != 12) return;
55
56         test = true;
57     }
58 }
59