on xenial help sign in
Remove a few signals more and rework tests
afd3cd7Albert Astals
qml/Dash/GenericScopeView.qml−4
@@ -33,7 +33,6 @@ FocusScope {
33 property OpenEffect openEffect: null
33 property OpenEffect openEffect: null
34 property Item previewListView: null
34 property Item previewListView: null
35
35
36− signal endReached
37 signal movementStarted
36 signal movementStarted
38 signal positionedAtBeginning
37 signal positionedAtBeginning
39
38
@@ -118,9 +117,6 @@ FocusScope {
118 model: scopeView.categories
117 model: scopeView.categories
119 forceNoClip: previewListView.onScreen
118 forceNoClip: previewListView.onScreen
120
119
121− onAtYEndChanged: if (atYEnd) endReached()
122− onMovingChanged: if (moving && atYEnd) endReached()
123−
124 property string expandedCategoryId: ""
120 property string expandedCategoryId: ""
125 signal correctExpandedCategory();
121 signal correctExpandedCategory();
126
122
tests/qmltests/Dash/qml/FakeScopeView.qml−5
@@ -25,11 +25,6 @@ GenericScopeView {
25 property alias backColor : back.color
25 property alias backColor : back.color
26 property var categoryView: null
26 property var categoryView: null
27
27
28− onEndReached: {
29− if (scope != undefined && shell != undefined && shell.scopeStatus != undefined) {
30− shell.scopeStatus[scope.id].endReached++;
31− }
32− }
33 onMovementStarted: {
28 onMovementStarted: {
34 if (shell != undefined && shell.scopeStatus != undefined) {
29 if (shell != undefined && shell.scopeStatus != undefined) {
35 shell.scopeStatus[scope.id].movementStarted++;
30 shell.scopeStatus[scope.id].movementStarted++;
tests/qmltests/Dash/tst_DashContent.qml+14−17
@@ -111,11 +111,12 @@ Item {
111
111
112 function init() {
112 function init() {
113 scopesModel.clear();
113 scopesModel.clear();
114+ scopeLoadedSpy.clear();
114 scopesModel.load();
115 scopesModel.load();
116+ tryCompare(scopeLoadedSpy, "count", 5);
115 }
117 }
116
118
117 function cleanup() {
119 function cleanup() {
118− scopeLoadedSpy.clear();
119 movementStartedSpy.clear();
120 movementStartedSpy.clear();
120 clear_scope_status();
121 clear_scope_status();
121 dashContent.visible = true;
122 dashContent.visible = true;
@@ -125,17 +126,18 @@ Item {
125 scopesModel.clear();
126 scopesModel.clear();
126 // wait for dash to empty scopes.
127 // wait for dash to empty scopes.
127 tryCompare(dashContentList, "count", 0);
128 tryCompare(dashContentList, "count", 0);
128− // this is the default state for empty model
129− dashContentList.currentIndex = -1;
130 }
129 }
131
130
132 function test_current_index() {
131 function test_current_index() {
133 var dashContentList = findChild(dashContent, "dashContentList");
132 var dashContentList = findChild(dashContent, "dashContentList");
134 verify(dashContentList != undefined)
133 verify(dashContentList != undefined)
135
134
135+ scopesModel.clear();
136 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
136 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
137− compare(dashContentList.currentIndex, -1, "DashContent's currentIndex should be -1 while there have been no items in the model");
137+ tryCompare(dashContentList, "currentIndex", -1);
138
138
139+ scopeLoadedSpy.clear();
140+ scopesModel.load();
139 tryCompare(scopeLoadedSpy, "count", 5);
141 tryCompare(scopeLoadedSpy, "count", 5);
140
142
141 verify(dashContentList.currentIndex >= 0);
143 verify(dashContentList.currentIndex >= 0);
@@ -145,10 +147,13 @@ Item {
145 var dashContentList = findChild(dashContent, "dashContentList");
147 var dashContentList = findChild(dashContent, "dashContentList");
146 verify(dashContentList != undefined)
148 verify(dashContentList != undefined)
147
149
150+ scopesModel.clear();
148− compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
151+ compare(dashContentList.count, 0, "DashContent should have 0 items after clearing");
149 // pretend we're running after a model reset
152 // pretend we're running after a model reset
150 dashContentList.currentIndex = 27;
153 dashContentList.currentIndex = 27;
151
154
155+ scopeLoadedSpy.clear();
156+ scopesModel.load();
152 tryCompare(scopeLoadedSpy, "count", 5);
157 tryCompare(scopeLoadedSpy, "count", 5);
153
158
154 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
159 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
@@ -160,8 +165,6 @@ Item {
160 var dashContentList = findChild(dashContent, "dashContentList");
165 var dashContentList = findChild(dashContent, "dashContentList");
161 verify(dashContentList != undefined)
166 verify(dashContentList != undefined)
162
167
163− tryCompare(scopeLoadedSpy, "count", 5);
164−
165 dashContentList.movementStarted();
168 dashContentList.movementStarted();
166
169
167 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
170 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
@@ -175,8 +178,6 @@ Item {
175 function test_positioned_at_beginning_signal() {
178 function test_positioned_at_beginning_signal() {
176 dashContent.setCurrentScopeAtIndex(3, true, false);
179 dashContent.setCurrentScopeAtIndex(3, true, false);
177
180
178− tryCompare(scopeLoadedSpy, "count", 5);
179−
180 dashContent.positionedAtBeginning();
181 dashContent.positionedAtBeginning();
181 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
182 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
182 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
183 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
@@ -185,19 +186,17 @@ Item {
185 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
186 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
186 }
187 }
187
188
188− function test_scope_loaded() {
189− tryCompare(scopeLoadedSpy, "count", 5);
190− }
191−
192 // This tests that setting the current scope index will end up at the correct index even if
189 // This tests that setting the current scope index will end up at the correct index even if
193 // the scopes are loaded asynchrounsly.
190 // the scopes are loaded asynchrounsly.
194 function test_set_current_scope_index_async() {
191 function test_set_current_scope_index_async() {
192+ scopesModel.clear();
195 verify(scopesModel.loaded == false);
193 verify(scopesModel.loaded == false);
196
194
197− // next index is 1 if current is -1, otherwise it's current + 1
195+ tryCompare(dashContent, "currentIndex", -1);
198− var next_index = ((dashContent.currentIndex == -1 ? 0 : dashContent.currentIndex) + 1) % 5
196+ var next_index = 1
199
197
200 dashContent.setCurrentScopeAtIndex(next_index, true, false);
198 dashContent.setCurrentScopeAtIndex(next_index, true, false);
199+ scopesModel.load();
201 tryCompare(dashContent, "currentIndex", next_index);
200 tryCompare(dashContent, "currentIndex", next_index);
202 verify(scopesModel.loaded == true);
201 verify(scopesModel.loaded == true);
203
202
@@ -247,8 +246,6 @@ Item {
247 function test_is_active(data) {
246 function test_is_active(data) {
248 var dashContentList = findChild(dashContent, "dashContentList");
247 var dashContentList = findChild(dashContent, "dashContentList");
249
248
250− tryCompare(scopeLoadedSpy, "count", 5);
251−
252 dashContent.setCurrentScopeAtIndex(data.select, true, false);
249 dashContent.setCurrentScopeAtIndex(data.select, true, false);
253 dashContent.visible = data.visible;
250 dashContent.visible = data.visible;
254
251