@@ -105,25 +105,19 @@ Item {
105 signalName: "movementStarted"
105 signalName: "movementStarted"
109− id: contentEndReachedSpy
111− signalName: "contentEndReached"
114 UT.UnityTestCase {
108 UT.UnityTestCase {
115 name: "DashContent"
109 name: "DashContent"
116 when: scopesModel.loaded
110 when: scopesModel.loaded
118 function init() {
112 function init() {
119 scopesModel.clear();
113 scopesModel.clear();
114+ scopeLoadedSpy.clear();
120 scopesModel.load();
115 scopesModel.load();
116+ tryCompare(scopeLoadedSpy, "count", 5);
123 function cleanup() {
119 function cleanup() {
124− scopeLoadedSpy.clear();
125 movementStartedSpy.clear();
120 movementStartedSpy.clear();
126− contentEndReachedSpy.clear();
127 clear_scope_status();
121 clear_scope_status();
128 dashContent.visible = true;
122 dashContent.visible = true;
@@ -132,17 +126,18 @@ Item {
132 scopesModel.clear();
126 scopesModel.clear();
133 // wait for dash to empty scopes.
127 // wait for dash to empty scopes.
134 tryCompare(dashContentList, "count", 0);
128 tryCompare(dashContentList, "count", 0);
135− // this is the default state for empty model
136− dashContentList.currentIndex = -1;
139 function test_current_index() {
131 function test_current_index() {
140 var dashContentList = findChild(dashContent, "dashContentList");
132 var dashContentList = findChild(dashContent, "dashContentList");
141 verify(dashContentList != undefined)
133 verify(dashContentList != undefined)
135+ scopesModel.clear();
143 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");
144− 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();
146 tryCompare(scopeLoadedSpy, "count", 5);
141 tryCompare(scopeLoadedSpy, "count", 5);
148 verify(dashContentList.currentIndex >= 0);
143 verify(dashContentList.currentIndex >= 0);
@@ -152,10 +147,13 @@ Item {
152 var dashContentList = findChild(dashContent, "dashContentList");
147 var dashContentList = findChild(dashContent, "dashContentList");
153 verify(dashContentList != undefined)
148 verify(dashContentList != undefined)
150+ scopesModel.clear();
155− compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
151+ compare(dashContentList.count, 0, "DashContent should have 0 items after clearing");
156 // pretend we're running after a model reset
152 // pretend we're running after a model reset
157 dashContentList.currentIndex = 27;
153 dashContentList.currentIndex = 27;
155+ scopeLoadedSpy.clear();
159 tryCompare(scopeLoadedSpy, "count", 5);
157 tryCompare(scopeLoadedSpy, "count", 5);
161 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
159 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
@@ -167,8 +165,6 @@ Item {
167 var dashContentList = findChild(dashContent, "dashContentList");
165 var dashContentList = findChild(dashContent, "dashContentList");
168 verify(dashContentList != undefined)
166 verify(dashContentList != undefined)
170− tryCompare(scopeLoadedSpy, "count", 5);
172 dashContentList.movementStarted();
168 dashContentList.movementStarted();
174 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.");
@@ -182,8 +178,6 @@ Item {
182 function test_positioned_at_beginning_signal() {
178 function test_positioned_at_beginning_signal() {
183 dashContent.setCurrentScopeAtIndex(3, true, false);
179 dashContent.setCurrentScopeAtIndex(3, true, false);
185− tryCompare(scopeLoadedSpy, "count", 5);
187 dashContent.positionedAtBeginning();
181 dashContent.positionedAtBeginning();
188 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.");
189 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.");
@@ -192,30 +186,17 @@ Item {
192 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.");
195− function test_scope_loaded() {
196− tryCompare(scopeLoadedSpy, "count", 5);
199− function test_content_end_reached() {
200− var dashContentList = findChild(dashContent, "dashContentList");
201− verify(dashContentList != undefined);
203− tryCompare(scopeLoadedSpy, "count", 5);
204− dashContent.setCurrentScopeAtIndex(0, true, false);
205− dashContentList.currentItem.item.endReached();
207− compare(contentEndReachedSpy.count, 1);
210 // 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
211 // the scopes are loaded asynchrounsly.
190 // the scopes are loaded asynchrounsly.
212 function test_set_current_scope_index_async() {
191 function test_set_current_scope_index_async() {
192+ scopesModel.clear();
213 verify(scopesModel.loaded == false);
193 verify(scopesModel.loaded == false);
215− // next index is 1 if current is -1, otherwise it's current + 1
195+ tryCompare(dashContent, "currentIndex", -1);
216− var next_index = ((dashContent.currentIndex == -1 ? 0 : dashContent.currentIndex) + 1) % 5
196+ var next_index = 1
218 dashContent.setCurrentScopeAtIndex(next_index, true, false);
198 dashContent.setCurrentScopeAtIndex(next_index, true, false);
219 tryCompare(dashContent, "currentIndex", next_index);
200 tryCompare(dashContent, "currentIndex", next_index);
220 verify(scopesModel.loaded == true);
201 verify(scopesModel.loaded == true);
@@ -265,8 +246,6 @@ Item {
265 function test_is_active(data) {
246 function test_is_active(data) {
266 var dashContentList = findChild(dashContent, "dashContentList");
247 var dashContentList = findChild(dashContent, "dashContentList");
268− tryCompare(scopeLoadedSpy, "count", 5);
270 dashContent.setCurrentScopeAtIndex(data.select, true, false);
249 dashContent.setCurrentScopeAtIndex(data.select, true, false);
271 dashContent.visible = data.visible;
250 dashContent.visible = data.visible;