@@ -111,11 +111,12 @@ Item {
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);
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;
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+ 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);
139+ scopeLoadedSpy.clear();
139 tryCompare(scopeLoadedSpy, "count", 5);
141 tryCompare(scopeLoadedSpy, "count", 5);
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)
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;
155+ scopeLoadedSpy.clear();
152 tryCompare(scopeLoadedSpy, "count", 5);
157 tryCompare(scopeLoadedSpy, "count", 5);
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)
163− tryCompare(scopeLoadedSpy, "count", 5);
165 dashContentList.movementStarted();
168 dashContentList.movementStarted();
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);
178− tryCompare(scopeLoadedSpy, "count", 5);
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.");
188− function test_scope_loaded() {
189− tryCompare(scopeLoadedSpy, "count", 5);
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);
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
200 dashContent.setCurrentScopeAtIndex(next_index, true, false);
198 dashContent.setCurrentScopeAtIndex(next_index, true, false);
201 tryCompare(dashContent, "currentIndex", next_index);
200 tryCompare(dashContent, "currentIndex", next_index);
202 verify(scopesModel.loaded == true);
201 verify(scopesModel.loaded == true);
@@ -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");
250− tryCompare(scopeLoadedSpy, "count", 5);
252 dashContent.setCurrentScopeAtIndex(data.select, true, false);
249 dashContent.setCurrentScopeAtIndex(data.select, true, false);
253 dashContent.visible = data.visible;
250 dashContent.visible = data.visible;