on xenial help sign in
Cleanup DashContent

Remove unused signals and properties

commitf4d6fad91099503fd815102ab21bc4371e1479bb authorAlbert Astals <albert.astals@canonical.com> dateFri 28 Feb 2014, 10:46 (13 years ago) parentfc9312cafd3cd7
5 files changed+14−53
qml/Dash/Dash.qml−1 qml/Dash/DashContent.qml−8 qml/Dash/GenericScopeView.qml−4 tests/qmltests/Dash/qml/FakeScopeView.qml−5 tests/qmltests/Dash/tst_DashContent.qml+14−35
qml/Dash/Dash.qml−1
@@ -28,7 +28,6 @@ Showable {
2828
2929 property ListModel searchHistory: SearchHistoryModel {}
3030
31− property alias contentProgress: dashContent.contentProgress
3231 property string showScopeOnLoaded: "home.scope"
3332 property real contentScale: 1.0
3433
qml/Dash/DashContent.qml−8
@@ -24,7 +24,6 @@ Item {
2424
2525 property var model: null
2626 property var scopes: null
27− property real contentProgress: Math.max(0, Math.min(dashContentList.contentX / (dashContentList.contentWidth - dashContentList.width), units.dp(1)))
2827 property alias currentIndex: dashContentList.currentIndex
2928
3029 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
@@ -32,8 +31,6 @@ Item {
3231
3332 signal movementStarted()
3433 signal movementEnded()
35− signal contentFlickStarted()
36− signal contentEndReached()
3734 signal scopeLoaded(string scopeId)
3835 signal positionedAtBeginning()
3936
@@ -144,11 +141,6 @@ Item {
144141 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
145142 dashContent.scopeLoaded(item.scope.id)
146143 }
147− Connections {
148− target: item
149− ignoreUnknownSignals: true
150− onEndReached: contentEndReached()
151− }
152144
153145 Component.onDestruction: active = false
154146 }
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−35
@@ -105,25 +105,19 @@ Item {
105105 signalName: "movementStarted"
106106 }
107107
108− SignalSpy {
109− id: contentEndReachedSpy
110− target: dashContent
111− signalName: "contentEndReached"
112− }
113−
114108 UT.UnityTestCase {
115109 name: "DashContent"
116110 when: scopesModel.loaded
117111
118112 function init() {
119113 scopesModel.clear();
114+ scopeLoadedSpy.clear();
120115 scopesModel.load();
116+ tryCompare(scopeLoadedSpy, "count", 5);
121117 }
122118
123119 function cleanup() {
124− scopeLoadedSpy.clear();
125120 movementStartedSpy.clear();
126− contentEndReachedSpy.clear();
127121 clear_scope_status();
128122 dashContent.visible = true;
129123
@@ -132,17 +126,18 @@ Item {
132126 scopesModel.clear();
133127 // wait for dash to empty scopes.
134128 tryCompare(dashContentList, "count", 0);
135− // this is the default state for empty model
136− dashContentList.currentIndex = -1;
137129 }
138130
139131 function test_current_index() {
140132 var dashContentList = findChild(dashContent, "dashContentList");
141133 verify(dashContentList != undefined)
142134
135+ scopesModel.clear();
143136 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);
145138
139+ scopeLoadedSpy.clear();
140+ scopesModel.load();
146141 tryCompare(scopeLoadedSpy, "count", 5);
147142
148143 verify(dashContentList.currentIndex >= 0);
@@ -152,10 +147,13 @@ Item {
152147 var dashContentList = findChild(dashContent, "dashContentList");
153148 verify(dashContentList != undefined)
154149
155− 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");
156152 // pretend we're running after a model reset
157153 dashContentList.currentIndex = 27;
158154
155+ scopeLoadedSpy.clear();
156+ scopesModel.load();
159157 tryCompare(scopeLoadedSpy, "count", 5);
160158
161159 verify(dashContentList.currentIndex >= 0 && dashContentList.currentIndex < 5);
@@ -167,8 +165,6 @@ Item {
167165 var dashContentList = findChild(dashContent, "dashContentList");
168166 verify(dashContentList != undefined)
169167
170− tryCompare(scopeLoadedSpy, "count", 5);
171−
172168 dashContentList.movementStarted();
173169
174170 compare(movementStartedSpy.count, 1, "DashContent should have emitted movementStarted signal when content list did.");
@@ -182,8 +178,6 @@ Item {
182178 function test_positioned_at_beginning_signal() {
183179 dashContent.setCurrentScopeAtIndex(3, true, false);
184180
185− tryCompare(scopeLoadedSpy, "count", 5);
186−
187181 dashContent.positionedAtBeginning();
188182 compare(scopeStatus["MockScope1"].positionedAtBeginning, 1, "MockScope1 should have emitted positionedAtBeginning signal when DashContent did.");
189183 compare(scopeStatus["MockScope2"].positionedAtBeginning, 1, "MockScope2 should have emitted positionedAtBeginning signal when DashContent did.");
@@ -192,30 +186,17 @@ Item {
192186 compare(scopeStatus["MockScope5"].positionedAtBeginning, 1, "MockScope5 should have emitted positionedAtBeginning signal when DashContent did.");
193187 }
194188
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−
210189 // This tests that setting the current scope index will end up at the correct index even if
211190 // the scopes are loaded asynchrounsly.
212191 function test_set_current_scope_index_async() {
192+ scopesModel.clear();
213193 verify(scopesModel.loaded == false);
214194
215− // next index is 1 if current is -1, otherwise it's current + 1
216− var next_index = ((dashContent.currentIndex == -1 ? 0 : dashContent.currentIndex) + 1) % 5
195+ tryCompare(dashContent, "currentIndex", -1);
196+ var next_index = 1
217197
218198 dashContent.setCurrentScopeAtIndex(next_index, true, false);
199+ scopesModel.load();
219200 tryCompare(dashContent, "currentIndex", next_index);
220201 verify(scopesModel.loaded == true);
221202
@@ -265,8 +246,6 @@ Item {
265246 function test_is_active(data) {
266247 var dashContentList = findChild(dashContent, "dashContentList");
267248
268− tryCompare(scopeLoadedSpy, "count", 5);
269−
270249 dashContent.setCurrentScopeAtIndex(data.select, true, false);
271250 dashContent.visible = data.visible;
272251