@@ -95,25 +95,19 @@ Item {
95 signalName: "movementStarted"
95 signalName: "movementStarted"
99− id: contentEndReachedSpy
101− signalName: "contentEndReached"
104 UT.UnityTestCase {
98 UT.UnityTestCase {
105 name: "DashContent"
99 name: "DashContent"
106 when: scopesModel.loaded
100 when: scopesModel.loaded
108 function init() {
102 function init() {
109 scopesModel.clear();
103 scopesModel.clear();
104+ scopeLoadedSpy.clear();
110 scopesModel.load();
105 scopesModel.load();
106+ tryCompare(scopeLoadedSpy, "count", 4);
113 function cleanup() {
109 function cleanup() {
114− scopeLoadedSpy.clear();
115 movementStartedSpy.clear();
110 movementStartedSpy.clear();
116− contentEndReachedSpy.clear();
117 clear_scope_status();
111 clear_scope_status();
118 dashContent.visible = true;
112 dashContent.visible = true;
@@ -122,17 +116,18 @@ Item {
122 scopesModel.clear();
116 scopesModel.clear();
123 // wait for dash to empty scopes.
117 // wait for dash to empty scopes.
124 tryCompare(dashContentList, "count", 0);
118 tryCompare(dashContentList, "count", 0);
125− // this is the default state for empty model
126− dashContentList.currentIndex = -1;
129 function test_current_index() {
121 function test_current_index() {
130 var dashContentList = findChild(dashContent, "dashContentList");
122 var dashContentList = findChild(dashContent, "dashContentList");
131 verify(dashContentList != undefined)
123 verify(dashContentList != undefined)
125+ scopesModel.clear();
133 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
126 compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
134− compare(dashContentList.currentIndex, -1, "DashContent's currentIndex should be -1 while there have been no items in the model");
127+ tryCompare(dashContentList, "currentIndex", -1);
129+ scopeLoadedSpy.clear();
136 tryCompare(scopeLoadedSpy, "count", 4);
131 tryCompare(scopeLoadedSpy, "count", 4);
138 verify(dashContentList.currentIndex >= 0);
133 verify(dashContentList.currentIndex >= 0);
@@ -142,10 +137,13 @@ Item {
142 var dashContentList = findChild(dashContent, "dashContentList");
137 var dashContentList = findChild(dashContent, "dashContentList");
143 verify(dashContentList != undefined)
138 verify(dashContentList != undefined)
140+ scopesModel.clear();
145− compare(dashContentList.count, 0, "DashContent should have 0 items when it starts");
141+ compare(dashContentList.count, 0, "DashContent should have 0 items after clearing");
146 // pretend we're running after a model reset
142 // pretend we're running after a model reset
147 dashContentList.currentIndex = 27;
143 dashContentList.currentIndex = 27;
145+ scopeLoadedSpy.clear();
149 tryCompare(scopeLoadedSpy, "count", 4);
147 tryCompare(scopeLoadedSpy, "count", 4);
151 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
149 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
@@ -157,8 +155,6 @@ Item {
157 var dashContentList = findChild(dashContent, "dashContentList");
155 var dashContentList = findChild(dashContent, "dashContentList");
158 verify(dashContentList != undefined)
156 verify(dashContentList != undefined)
160− tryCompare(scopeLoadedSpy, "count", 4);
162 dashContentList.movementStarted();
158 dashContentList.movementStarted();
164 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
160 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
@@ -171,8 +167,6 @@ Item {
171 function test_positioned_at_beginning_signal() {
167 function test_positioned_at_beginning_signal() {
172 dashContent.setCurrentScopeAtIndex(3, true, false);
168 dashContent.setCurrentScopeAtIndex(3, true, false);
174− tryCompare(scopeLoadedSpy, "count", 4);
176 dashContent.positionedAtBeginning();
170 dashContent.positionedAtBeginning();
177 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
171 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
178 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
172 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
@@ -180,30 +174,17 @@ Item {
180 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
174 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
183− function test_scope_loaded() {
184− tryCompare(scopeLoadedSpy, "count", 4);
187− function test_content_end_reached() {
188− var dashContentList = findChild(dashContent, "dashContentList");
189− verify(dashContentList != undefined);
191− tryCompare(scopeLoadedSpy, "count", 4);
192− dashContent.setCurrentScopeAtIndex(0, true, false);
193− dashContentList.currentItem.item.endReached();
195− compare(contentEndReachedSpy.count, 1);
198 // This tests that setting the current scope index will end up at the correct index even if
177 // This tests that setting the current scope index will end up at the correct index even if
199 // the scopes are loaded asynchrounsly.
178 // the scopes are loaded asynchrounsly.
200 function test_set_current_scope_index_async() {
179 function test_set_current_scope_index_async() {
180+ scopesModel.clear();
201 verify(scopesModel.loaded == false);
181 verify(scopesModel.loaded == false);
203− // next index is 1 if current is -1, otherwise it's current + 1
183+ tryCompare(dashContent, "currentIndex", -1);
204− var next_index = ((dashContent.currentIndex == -1 ? 0 : dashContent.currentIndex) + 1) % 5
184+ var next_index = 1
206 dashContent.setCurrentScopeAtIndex(next_index, true, false);
186 dashContent.setCurrentScopeAtIndex(next_index, true, false);
207 tryCompare(dashContent, "currentIndex", next_index);
188 tryCompare(dashContent, "currentIndex", next_index);
208 verify(scopesModel.loaded == true);
189 verify(scopesModel.loaded == true);
@@ -252,8 +233,6 @@ Item {
252 function test_is_active(data) {
233 function test_is_active(data) {
253 var dashContentList = findChild(dashContent, "dashContentList");
234 var dashContentList = findChild(dashContent, "dashContentList");
255− tryCompare(scopeLoadedSpy, "count", 4);
257 dashContent.setCurrentScopeAtIndex(data.select, true, false);
236 dashContent.setCurrentScopeAtIndex(data.select, true, false);
258 dashContent.visible = data.visible;
237 dashContent.visible = data.visible;