~zsombi/ubuntu-ui-toolkit/ima-enhancement

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_components/tst_pagestack.new_header.qml

Add UbuntuTestCase.waitForHeaderAnimation().

Approved by PS Jenkins bot, Christian Dywan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2012-2014 Canonical Ltd.
 
2
 * Copyright 2012-2015 Canonical Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU Lesser General Public License as published by
16
16
 
17
17
import QtQuick 2.2
18
18
import Ubuntu.Test 1.0
19
 
import Ubuntu.Components 1.1
 
19
import Ubuntu.Components 1.2
20
20
 
21
21
// pagestack tests for deprecated toolbar are in
22
22
// unit/tst_components/tst_pagestack_deprecated_toolbar.qml
28
28
    MainView {
29
29
        id: mainView
30
30
        anchors.fill: parent
31
 
        useDeprecatedToolbar: false
32
31
        PageStack {
33
32
            id: pageStack
34
33
            Page {
73
72
        when: windowShown
74
73
        id: testCase
75
74
 
76
 
        property var head_style
77
 
 
78
75
        function initTestCase() {
79
 
            testCase.head_style = findChild(mainView, "PageHeadStyle");
80
 
            wait_for_animation();
 
76
            waitForHeaderAnimation(mainView);
81
77
            compare(pageStack.currentPage, null, "is not set by default");
82
78
            compare(pageStack.__propagated, mainView.__propagated, "propagated property of pageStack equals mainView.__propagated")
83
79
            compare(mainView.__propagated.header.title, "", "empty title by default");
84
80
        }
85
81
 
86
 
        function wait_for_animation() {
87
 
            tryCompareFunction(function(){return testCase.head_style.animating}, false);
88
 
        }
89
 
 
90
82
        function test_depth() {
91
83
            compare(pageStack.depth, 0, "depth is 0 by default");
92
84
            pageStack.push(page1);
93
 
            wait_for_animation();
 
85
            waitForHeaderAnimation(mainView);
94
86
            compare(pageStack.depth, 1, "depth is correctly increased when pushing a page");
95
87
            pageStack.push(page2);
96
 
            wait_for_animation();
 
88
            waitForHeaderAnimation(mainView);
97
89
            compare(pageStack.depth, 2, "depth is correctly updated when pushing a page");
98
90
            pageStack.pop();
99
 
            wait_for_animation();
 
91
            waitForHeaderAnimation(mainView);
100
92
            compare(pageStack.depth, 1, "depth is correctly decreased when popping a page");
101
93
            pageStack.clear();
102
 
            wait_for_animation();
 
94
            waitForHeaderAnimation(mainView);
103
95
            compare(pageStack.depth, 0, "depth is after clearing");
104
96
        }
105
97
 
106
98
        function test_currentPage() {
107
99
            compare(pageStack.currentPage, null, "currentPage is null by default");
108
100
            pageStack.push(page1);
109
 
            wait_for_animation();
 
101
            waitForHeaderAnimation(mainView);
110
102
            compare(pageStack.currentPage, page1, "currentPage properly updated");
111
103
            pageStack.clear();
112
 
            wait_for_animation();
 
104
            waitForHeaderAnimation(mainView);
113
105
            compare(pageStack.currentPage, null, "currentPage properly reset");
114
106
        }
115
107
 
117
109
            compare(pageStack.depth, 0, "depth is 0 initially");
118
110
            pageStack.push(page1);
119
111
            pageStack.push(page2);
120
 
            wait_for_animation();
 
112
            waitForHeaderAnimation(mainView);
121
113
            compare(pageStack.currentPage, page2, "last pushed page is on top");
122
114
            pageStack.pop();
123
 
            wait_for_animation();
 
115
            waitForHeaderAnimation(mainView);
124
116
            compare(pageStack.currentPage, page1, "popping puts previously pushed page on top");
125
117
            pageStack.clear();
126
 
            wait_for_animation();
 
118
            waitForHeaderAnimation(mainView);
127
119
        }
128
120
 
129
121
        function test_active_bug1260116() {
130
122
            pageStack.push(page1);
131
 
            wait_for_animation();
 
123
            waitForHeaderAnimation(mainView);
132
124
 
133
125
            compare(page1.active, true, "Page is active after pushing");
134
126
            pageStack.push(page2);
135
 
            wait_for_animation();
 
127
            waitForHeaderAnimation(mainView);
136
128
 
137
129
            compare(page1.active, false, "Page no longer active after pushing a new page");
138
130
            compare(page2.active, true, "New page is active after pushing");
139
131
            pageStack.pop();
140
 
            wait_for_animation();
 
132
            waitForHeaderAnimation(mainView);
141
133
            compare(page1.active, true, "Page re-activated when on top of the stack");
142
134
            compare(page2.active, false, "Page no longer active after being popped");
143
135
            pageStack.clear();
144
 
            wait_for_animation();
 
136
            waitForHeaderAnimation(mainView);
145
137
 
146
138
            compare(pageInStack.active, false, "Page defined inside PageStack is not active by default");
147
139
            pageStack.push(pageInStack);
148
 
            wait_for_animation();
 
140
            waitForHeaderAnimation(mainView);
149
141
            compare(pageInStack.active, true, "Pushing a page on PageStack makes it active");
150
142
            pageStack.pop();
151
 
            wait_for_animation();
 
143
            waitForHeaderAnimation(mainView);
152
144
            compare(pageInStack.active, false, "Popping a page from PageStack makes it inactive");
153
145
            pageStack.clear();
154
 
            wait_for_animation();
 
146
            waitForHeaderAnimation(mainView);
155
147
        }
156
148
 
157
149
        function test_title_bug1143345_bug1317902() {
158
150
            pageStack.push(page1);
159
 
            wait_for_animation();
 
151
            waitForHeaderAnimation(mainView);
160
152
            compare(mainView.__propagated.header.title, "Title 1", "Header title is correctly set by page");
161
153
            page1.title = "New title";
162
154
            compare(mainView.__propagated.header.title, "New title", "Header title correctly updated by page");
163
155
            pageStack.push(page2);
164
 
            wait_for_animation();
 
156
            waitForHeaderAnimation(mainView);
165
157
            compare(mainView.__propagated.header.title, "Title 2", "Header title is correctly set by page");
166
158
            pageStack.clear();
167
159
            page1.title = "Title 1";
168
160
 
169
161
            pageStack.push(pageWithPage);
170
 
            wait_for_animation();
 
162
            waitForHeaderAnimation(mainView);
171
163
            compare(mainView.__propagated.header.title, pageWithPage.title, "Embedded page sets title of outer page");
172
164
            pageStack.clear();
173
 
            wait_for_animation();
 
165
            waitForHeaderAnimation(mainView);
174
166
        }
175
167
 
176
168
        function get_tabs_button() {
182
174
        function test_tabs_inside_stack_bug1187850() {
183
175
            compare(get_tabs_button(), null, "Without tabs there is no visible tabs button.");
184
176
            pageStack.push(tabs);
185
 
            wait_for_animation();
 
177
            waitForHeaderAnimation(mainView);
186
178
            compare(pageStack.currentPage, tabs, "Tabs can be pushed on a PageStack");
187
179
            compare(tabs.active, true, "Tabs on top of a PageStack are active");
188
180
            compare(get_tabs_button().visible, true, "Pushing tabs on pagestack enables the tabs button");
189
181
            pageStack.push(page1);
190
 
            wait_for_animation();
 
182
            waitForHeaderAnimation(mainView);
191
183
            compare(pageStack.currentPage, page1, "A page can be pushed on top of a Tabs");
192
184
            compare(tabs.active, false, "Tabs on a PageStack, but not on top, are inactive");
193
185
            compare(get_tabs_button(), null, "Contents of inactive Tabs is not applied to header");
194
186
            pageStack.pop();
195
 
            wait_for_animation();
 
187
            waitForHeaderAnimation(mainView);
196
188
            compare(tabs.active, true, "Tabs on top of PageStack is active");
197
189
            compare(get_tabs_button().visible, true, "Active Tabs controls header contents");
198
190
            pageStack.clear();
199
 
            wait_for_animation();
 
191
            waitForHeaderAnimation(mainView);
200
192
        }
201
193
 
202
194
        function test_pop_to_tabs_bug1316736() {
203
195
            pageStack.push(tabs);
204
 
            wait_for_animation();
 
196
            waitForHeaderAnimation(mainView);
205
197
            tabs.selectedTabIndex = 1;
206
198
            pageStack.push(page1);
207
 
            wait_for_animation();
 
199
            waitForHeaderAnimation(mainView);
208
200
            compare(tabs.active, false, "Tabs on a PageStack, but not on top, are inactive");
209
201
            pageStack.pop();
210
 
            wait_for_animation();
 
202
            waitForHeaderAnimation(mainView);
211
203
            compare(tabs.active, true, "Tabs on top of PageStack is active");
212
204
            compare(tabs.selectedTabIndex, 1, "Pushing and popping another page on top of Tabs does not change selectedTabsIndex");
213
205
            pageStack.clear();
214
 
            wait_for_animation();
 
206
            waitForHeaderAnimation(mainView);
215
207
        }
216
208
 
217
209
        function test_push_return_values() {
225
217
            compare(pushedPage.title, "Page from QML file",
226
218
                    "PageStack.push() returns Page created from QML file");
227
219
            pageStack.clear();
228
 
            wait_for_animation();
 
220
            waitForHeaderAnimation(mainView);
229
221
        }
230
222
    }
231
223
}