on xenial help sign in
Remove a few signals more and rework tests

Now when init() finishes we the scopes are loaded The tests that need the scopes not to be loaded can clear themselves as first thing

commitafd3cd7a41294d386bdb0bef03e2313f098d3ce6 authorAlbert Astals <albert.astals@canonical.com> dateMon 24 Feb 2014, 10:32 (13 years ago) parentb56f366
3 files changed+14−26
qml/Dash/GenericScopeView.qml−4 tests/qmltests/Dash/qml/FakeScopeView.qml−5 tests/qmltests/Dash/tst_DashContent.qml+14−17
qml/Dash/GenericScopeView.qml−4
@@ -33,7 +33,6 @@ FocusScope {
3333 property OpenEffect openEffect: null
3434 property Item previewListView: null
3535
36− signal endReached
3736 signal movementStarted
3837 signal positionedAtBeginning
3938
@@ -118,9 +117,6 @@ FocusScope {
118117 model: scopeView.categories
119118 forceNoClip: previewListView.onScreen
120119
121− onAtYEndChanged: if (atYEnd) endReached()
122− onMovingChanged: if (moving && atYEnd) endReached()
123−
124120 property string expandedCategoryId: ""
125121 signal correctExpandedCategory();
126122
tests/qmltests/Dash/qml/FakeScopeView.qml−5
@@ -25,11 +25,6 @@ GenericScopeView {
2525 property alias backColor : back.color
2626 property var categoryView: null
2727
28− onEndReached: {
29− if (scope != undefined && shell != undefined && shell.scopeStatus != undefined) {
30− shell.scopeStatus[scope.id].endReached++;
31− }
32− }
3328 onMovementStarted: {
3429 if (shell != undefined && shell.scopeStatus != undefined) {
3530 shell.scopeStatus[scope.id].movementStarted++;
tests/qmltests/Dash/tst_DashContent.qml+14−17
@@ -111,11 +111,12 @@ Item {
111111
112112 function init() {
113113 scopesModel.clear();
114+ scopeLoadedSpy.clear();
114115 scopesModel.load();
116+ tryCompare(scopeLoadedSpy, "count", 5);
115117 }
116118
117119 function cleanup() {
118− scopeLoadedSpy.clear();
119120 movementStartedSpy.clear();
120121 clear_scope_status();
121122 dashContent.visible = true;
@@ -125,17 +126,18 @@ Item {
125126 scopesModel.clear();
126127 // wait for dash to empty scopes.
127128 tryCompare(dashContentList, "count", 0);
128− // this is the default state for empty model
129− dashContentList.currentIndex = -1;
130129 }
131130
132131 function test_current_index() {
133132 var dashContentList = findChild(dashContent, "dashContentList");
134133 verify(dashContentList != undefined)
135134
135+ scopesModel.clear();
136136 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);
138138
139+ scopeLoadedSpy.clear();
140+ scopesModel.load();
139141 tryCompare(scopeLoadedSpy, "count", 5);
140142
141143 verify(dashContentList.currentIndex >= 0);
@@ -145,10 +147,13 @@ Item {
145147 var dashContentList = findChild(dashContent, "dashContentList");
146148 verify(dashContentList != undefined)
147149
148− compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
150+ scopesModel.clear();
151+ compare(dashContentList.count, 0, "DashContent should have 0 items after clearing");
149152 // pretend we're running after a model reset
150153 dashContentList.currentIndex = 27;
151154
155+ scopeLoadedSpy.clear();
156+ scopesModel.load();
152157 tryCompare(scopeLoadedSpy, "count", 5);
153158
154159 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
@@ -160,8 +165,6 @@ Item {
160165 var dashContentList = findChild(dashContent, "dashContentList");
161166 verify(dashContentList != undefined)
162167
163− tryCompare(scopeLoadedSpy, "count", 5);
164−
165168 dashContentList.movementStarted();
166169
167170 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
@@ -175,8 +178,6 @@ Item {
175178 function test_positioned_at_beginning_signal() {
176179 dashContent.setCurrentScopeAtIndex(3, true, false);
177180
178− tryCompare(scopeLoadedSpy, "count", 5);
179−
180181 dashContent.positionedAtBeginning();
181182 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
182183 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
@@ -185,19 +186,17 @@ Item {
185186 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
186187 }
187188
188− function test_scope_loaded() {
189− tryCompare(scopeLoadedSpy, "count", 5);
190− }
191−
192189 // This tests that setting the current scope index will end up at the correct index even if
193190 // the scopes are loaded asynchrounsly.
194191 function test_set_current_scope_index_async() {
192+ scopesModel.clear();
195193 verify(scopesModel.loaded == false);
196194
197− // next index is 1 if current is -1, otherwise it's current + 1
198− var next_index = ((dashContent.currentIndex == -1 ? 0 : dashContent.currentIndex) + 1) % 5
195+ tryCompare(dashContent, "currentIndex", -1);
196+ var next_index = 1
199197
200198 dashContent.setCurrentScopeAtIndex(next_index, true, false);
199+ scopesModel.load();
201200 tryCompare(dashContent, "currentIndex", next_index);
202201 verify(scopesModel.loaded == true);
203202
@@ -247,8 +246,6 @@ Item {
247246 function test_is_active(data) {
248247 var dashContentList = findChild(dashContent, "dashContentList");
249248
250− tryCompare(scopeLoadedSpy, "count", 5);
251−
252249 dashContent.setCurrentScopeAtIndex(data.select, true, false);
253250 dashContent.visible = data.visible;
254251