~saviq/unity8/fix-frequent-app-ids

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/tst_DashPreview.qml

  • Committer: Tarmac
  • Author(s): Ying-Chun Liu, Michael Zanetti, Diego Sarmentero, Michał Sawicz
  • Date: 2013-10-07 15:01:21 UTC
  • mfrom: (361.5.35 previews)
  • Revision ID: tarmac-20131007150121-ytiepzjfgljk0rbf
update previews to match design. Fixes: https://bugs.launchpad.net/bugs/1224555.

Approved by PS Jenkins bot, Michał Sawicz, Ying-Chun Liu, Michal Hruby.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    DashPreview {
32
32
        id: preview
33
33
        anchors.fill: parent
34
 
        title: "Testing rocks, debugging sucks!"
35
 
 
36
 
        buttons: Row {
 
34
 
 
35
        previewImages: Rectangle {
 
36
            width: parent.width
 
37
            height: units.gu(20)
 
38
            color: "honeydew"
 
39
            Label {
 
40
                anchors.centerIn: parent
 
41
                text: "Preview images"
 
42
            }
 
43
        }
 
44
 
 
45
        header: Rectangle {
 
46
            width: parent.width
 
47
            height: units.gu(10)
 
48
            color: "papayawhip"
 
49
            Label {
 
50
                anchors.centerIn: parent
 
51
                text: "Caption label"
 
52
            }
 
53
        }
 
54
 
 
55
        actions: Row {
37
56
            width: parent.width
38
57
            height: units.gu(5)
39
58
            Rectangle {
40
59
                width: parent.width / 3
41
60
                height: parent.height
42
61
                color: "blue"
 
62
                Label {
 
63
                    anchors.centerIn: parent
 
64
                    text: "Button 1"
 
65
                }
43
66
                MouseArea {
44
67
                    id: buttonMouseArea
45
68
                    objectName: "buttonMouseArea"
51
74
                width: parent.width / 3
52
75
                height: parent.height
53
76
                color: "green"
 
77
                Label {
 
78
                    anchors.centerIn: parent
 
79
                    text: "Button 2"
 
80
                }
 
81
 
54
82
            }
55
83
        }
56
84
 
57
 
        header: Label { text: "Caption label" }
58
 
 
59
 
        body: Column {
 
85
        description: Column {
60
86
            id: testContent
61
87
            objectName: "testContent"
62
88
            width: parent.width
65
91
                width: parent.width
66
92
                height: parent.height / 3
67
93
                color: "green"
 
94
                Label {
 
95
                    anchors.centerIn: parent
 
96
                    text: "Description part 1"
 
97
                }
68
98
            }
69
99
            Rectangle {
70
100
                width: parent.width
71
101
                height: parent.height / 3
72
102
                color: "red"
 
103
                Label {
 
104
                    anchors.centerIn: parent
 
105
                    text: "Description part 2"
 
106
                }
73
107
            }
74
108
            Rectangle {
75
109
                width: parent.width
76
110
                height: parent.height / 3
77
111
                color: "blue"
 
112
                Label {
 
113
                    anchors.centerIn: parent
 
114
                    text: "Description part 3"
 
115
                }
 
116
            }
 
117
        }
 
118
 
 
119
        ratings: Rectangle {
 
120
            objectName: "ratings"
 
121
            width: parent.width
 
122
            height: units.gu(20)
 
123
            Label {
 
124
                anchors.centerIn: parent
 
125
                text: "Ratings"
78
126
            }
79
127
        }
80
128
    }
95
143
        name: "DashPreview"
96
144
        when: windowShown
97
145
 
98
 
        function test_close() {
99
 
            var title = findChild(preview, "titleLabel")
100
 
            mouseClick(title, 1, 1)
101
 
            compare(closeSpy.count, 1, "Close signal not emitted")
102
 
        }
103
 
 
104
146
        function test_columns_data() {
105
147
            return [
106
148
                {tag: "1 columns", width: units.gu(5), height: units.gu(10), columns: 1},
107
 
                {tag: "2 columns", width: units.gu(50), height: units.gu(10), columns: 2}
 
149
                {tag: "3 columns", width: units.gu(50), height: units.gu(10), columns: 3}
108
150
            ]
109
151
        }
110
152
 
111
153
        function test_columns(data) {
112
154
            var leftCol = findChild(preview, "leftColumn")
 
155
            var centerCol = findChild(preview, "centerColumn")
113
156
            var rightCol = findChild(preview, "rightColumn")
114
157
 
115
158
            root.width = data.width
116
159
            root.height = data.height
117
160
 
118
 
            // there are 2 columns in DashPreview. On portrait form factors
119
 
            // only the left one is used and the right one should be empty.
120
 
            // to find out if the content is in the correct column, we get a
 
161
            // there are 3 columns in DashPreview. On portrait form factors
 
162
            // only the left one is used and the center and right ones should be empty.
 
163
            // To find out if the content is in the correct column, we get a
121
164
            // reference to the column objects and search only the subtree
122
165
            // to see if the content is in the correct column.
123
 
            // 1 colum  -> content should be in leftColumn
124
 
            // 2 colums -> content should be in rightColumn
 
166
            // 1 colum  -> all content should be in leftColumn
 
167
            // 3 colums -> content should be in centerColumn, rating in rightColumn
125
168
 
126
169
            switch(data.columns) {
127
170
            case 1:
128
171
                var testContent = findChild(leftCol, "testContent")
129
172
                compare(testContent.objectName, "testContent")
 
173
                testContent = findChild(leftCol, "ratings")
 
174
                compare(testContent.objectName, "ratings")
130
175
                break
131
 
            case 2:
132
 
                var testContent = findChild(rightCol, "testContent")
 
176
            case 3:
 
177
                var testContent = findChild(centerCol, "testContent")
133
178
                compare(testContent.objectName, "testContent")
 
179
                testContent = findChild(rightCol, "ratings")
 
180
                compare(testContent.objectName, "ratings")
134
181
                break
135
182
            }
136
183