on xenial help sign in
Cleanup DashContent
f4d6fadAlbert Astals
qml/Dash/Dash.qml−1
@@ -28,7 +28,6 @@ Showable {
28
28
29 property ListModel searchHistory: SearchHistoryModel {}
29 property ListModel searchHistory: SearchHistoryModel {}
30
30
31− property alias contentProgress: dashContent.contentProgress
32 property string showScopeOnLoaded: "home.scope"
31 property string showScopeOnLoaded: "home.scope"
33 property real contentScale: 1.0
32 property real contentScale: 1.0
34
33
qml/Dash/DashContent.qml−8
@@ -24,7 +24,6 @@ Item {
24
24
25 property var model: null
25 property var model: null
26 property var scopes: null
26 property var scopes: null
27− property real contentProgress: Math.max(0, Math.min(dashContentList.contentX / (dashContentList.contentWidth - dashContentList.width), units.dp(1)))
28 property alias currentIndex: dashContentList.currentIndex
27 property alias currentIndex: dashContentList.currentIndex
29
28
30 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
29 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
@@ -32,8 +31,6 @@ Item {
32
31
33 signal movementStarted()
32 signal movementStarted()
34 signal movementEnded()
33 signal movementEnded()
35− signal contentFlickStarted()
36− signal contentEndReached()
37 signal scopeLoaded(string scopeId)
34 signal scopeLoaded(string scopeId)
38 signal positionedAtBeginning()
35 signal positionedAtBeginning()
39
36
@@ -144,11 +141,6 @@ Item {
144 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
141 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
145 dashContent.scopeLoaded(item.scope.id)
142 dashContent.scopeLoaded(item.scope.id)
146 }
143 }
147− Connections {
148− target: item
149− ignoreUnknownSignals: true
150− onEndReached: contentEndReached()
151− }
152
144
153 Component.onDestruction: active = false
145 Component.onDestruction: active = false
154 }
146 }
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−35
@@ -105,25 +105,19 @@ Item {
105 signalName: "movementStarted"
105 signalName: "movementStarted"
106 }
106 }
107
107
108− SignalSpy {
109− id: contentEndReachedSpy
110− target: dashContent
111− signalName: "contentEndReached"
112− }
113−
114 UT.UnityTestCase {
108 UT.UnityTestCase {
115 name: "DashContent"
109 name: "DashContent"
116 when: scopesModel.loaded
110 when: scopesModel.loaded
117
111
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);
121 }
117 }
122
118
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;
129
123
@@ -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;
137 }
129 }
138
130
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)
142
134
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);
145
138
139+ scopeLoadedSpy.clear();
140+ scopesModel.load();
146 tryCompare(scopeLoadedSpy, "count", 5);
141 tryCompare(scopeLoadedSpy, "count", 5);
147
142
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)
154
149
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;
158
154
155+ scopeLoadedSpy.clear();
156+ scopesModel.load();
159 tryCompare(scopeLoadedSpy, "count", 5);
157 tryCompare(scopeLoadedSpy, "count", 5);
160
158
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)
169
167
170− tryCompare(scopeLoadedSpy, "count", 5);
171−
172 dashContentList.movementStarted();
168 dashContentList.movementStarted();
173
169
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);
184
180
185− tryCompare(scopeLoadedSpy, "count", 5);
186−
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.");
193 }
187 }
194
188
195− function test_scope_loaded() {
196− tryCompare(scopeLoadedSpy, "count", 5);
197− }
198−
199− function test_content_end_reached() {
200− var dashContentList = findChild(dashContent, "dashContentList");
201− verify(dashContentList != undefined);
202−
203− tryCompare(scopeLoadedSpy, "count", 5);
204− dashContent.setCurrentScopeAtIndex(0, true, false);
205− dashContentList.currentItem.item.endReached();
206−
207− compare(contentEndReachedSpy.count, 1);
208− }
209−
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);
214
194
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
217
197
218 dashContent.setCurrentScopeAtIndex(next_index, true, false);
198 dashContent.setCurrentScopeAtIndex(next_index, true, false);
199+ scopesModel.load();
219 tryCompare(dashContent, "currentIndex", next_index);
200 tryCompare(dashContent, "currentIndex", next_index);
220 verify(scopesModel.loaded == true);
201 verify(scopesModel.loaded == true);
221
202
@@ -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");
267
248
268− tryCompare(scopeLoadedSpy, "count", 5);
269−
270 dashContent.setCurrentScopeAtIndex(data.select, true, false);
249 dashContent.setCurrentScopeAtIndex(data.select, true, false);
271 dashContent.visible = data.visible;
250 dashContent.visible = data.visible;
272
251