aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickloader/data/TestComponent.qml
blob: 81ea07cb8872b81b29e31334d2e1b739bb6e610a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import QtQuick 2.0

Item {
    id: root
    objectName: "root"
    property int zero: 0
    property int one: 1

    Item {
        id: c1
        objectName: "c1"
        property int one: zero + parent.one

        Item {
            id: c1c1
            objectName: "c1c1"
            property bool two: c2c1c1.two
        }

        Item {
            id: c1c2
            objectName: "c1c2"
            property string three: "three"

            Rectangle {
                id: c1c2c3
                objectName: "c1c2c3"
                property alias othercolor: c2c1.color
                color: if (c2c1.color == Qt.rgba(0,0,1)) Qt.rgba(1,0,0); else Qt.rgba(0,1,0);
            }
        }
    }

    Item {
        id: c2
        objectName: "c2"
        property string two: "two"

        Rectangle {
            id: c2c1
            objectName: "c2c1"
            property string three: "2" + c1c2.three
            color: "blue"

            MouseArea {
                id: c2c1c1
                objectName: "c2c1c1"
                property bool two: false
                onClicked: two = !two
            }

            Item {
                id: c2c1c2
                objectName: "c2c1c2"
                property string three: "1" + parent.three
            }
        }
    }

    property alias c1one: c1.one
    property bool success: true
    Component.onCompleted: {
        // test state after initial bindings evaluation
        if (zero != 0) success = false;
        if (c1.one != 1) success = false;
        if (c1c1.two != false) success = false;
        if (c1c2.three != "three") success = false;
        if (c1c2c3.color != Qt.rgba(1,0,0)) success = false;
        if (c2.two != "two") success = false;
        if (c2c1.three != "2three") success = false;
        if (c2c1.color != Qt.rgba(0,0,1)) success = false;
        if (c2c1c1.two != false) success = false;
        if (c2c1c2.three != "12three") success = false;

        // now retrigger bindings evaluation
        root.zero = 5;
        if (c1.one != 6) success = false;
        root.one = 50;
        if (c1.one != 55) success = false;
        c2c1c1.two = true;
        if (c1c1.two != true) success = false;
        c1c2.three = "3";
        if (c2c1.three != "23") success = false;
        if (c2c1c2.three != "123") success = false;
        c2c1.color = Qt.rgba(1,0,0);
        if (c1c2c3.color != Qt.rgba(0,1,0)) success = false;
        if (c1c2c3.othercolor != Qt.rgba(1,0,0)) success = false;
    }
}