on xenial help sign in
Tests for the scopes overview
commitf82ec3c35282c245e32cb9aebb1c873d2b7355de authorAlbert Astals <albert.astals@canonical.com> dateMon 21 Jul 2014, 13:10 (12 years ago) parent639bbcd
5 files changed+158−2
qml/Components/PageHeader.qml+1 qml/Dash/Dash.qml+2 qml/Dash/ScopesOverview.qml+6 qml/Dash/ScopesOverviewTab.qml+1 tests/qmltests/Dash/tst_Dash.qml+148−2
qml/Components/PageHeader.qml+1
@@ -242,6 +242,7 @@ Item {
242242
243243 actions: [
244244 Action {
245+ objectName: "search"
245246 iconName: "search"
246247 visible: root.searchEntryEnabled
247248 onTriggered: {
qml/Dash/Dash.qml+2
@@ -188,6 +188,7 @@ Showable {
188188
189189 GenericScopeView {
190190 id: scopeItem
191+ objectName: "dashTempScopeItem"
191192
192193 readonly property real targetOverviewScale: {
193194 if (scopesOverview.currentTab == 0) {
@@ -234,6 +235,7 @@ Showable {
234235
235236 EdgeDragArea {
236237 id: overviewDragHandle
238+ objectName: "overviewDragHandle"
237239 z: 1
238240 direction: Direction.Upwards
239241 enabled: !dashContent.previewShown && dashContent.currentScope && dashContent.currentScope.searchQuery == "" && (overviewController.progress == 0 || dragging)
qml/Dash/ScopesOverview.qml+6
@@ -154,6 +154,7 @@ Item {
154154
155155 PageHeader {
156156 id: pageHeader
157+ objectName: "scopesOverviewPageHeader"
157158
158159 readonly property real yDisplacement: pageHeader.height + tabBar.height + tabBar.anchors.margins
159160
@@ -190,10 +191,12 @@ Item {
190191
191192 Repeater {
192193 id: middleItems
194+ objectName: "scopesOverviewRepeater"
193195 property real overrideOpacity: -1
194196 model: scope && scope.searchQuery == "" ? scope.categories : null
195197 delegate: Loader {
196198 id: loader
199+ objectName: "scopesOverviewRepeaterChild" + index
197200
198201 height: {
199202 if (index == 0) {
@@ -297,6 +300,7 @@ Item {
297300
298301 GenericScopeView {
299302 id: searchResultsViewer
303+ objectName: "searchResultsViewer"
300304 anchors {
301305 top: pageHeader.bottom
302306 right: parent.right
@@ -346,6 +350,7 @@ Item {
346350 }
347351
348352 AbstractButton {
353+ objectName: "scopesOverviewDoneButton"
349354 width: Math.max(label.width + units.gu(2), units.gu(10))
350355 height: units.gu(4)
351356 anchors {
@@ -434,6 +439,7 @@ Item {
434439
435440 GenericScopeView {
436441 id: tempScopeItem
442+ objectName: "scopesOverviewTempScopeItem"
437443
438444 width: parent.width
439445 height: parent.height
qml/Dash/ScopesOverviewTab.qml+1
@@ -40,6 +40,7 @@ Item {
4040 }
4141 AbstractButton {
4242 id: tab2
43+ objectName: "scopesOverviewAllTabButton"
4344 x: width
4445 height: parent.height
4546 width: parent.width / 2
tests/qmltests/Dash/tst_Dash.qml+148−2
@@ -20,8 +20,6 @@ import "../../../qml/Dash"
2020import Ubuntu.Components 0.1
2121import Unity.Test 0.1 as UT
2222
23−// TODO We don't have any tests for the overlay scope functionality.
24−
2523Item {
2624 id: shell
2725 width: units.gu(40)
@@ -153,5 +151,153 @@ Item {
153151 tryCompare(overviewController, "progress", 0);
154152 compare(dashContentList.currentIndex, 1);
155153 }
154+
155+ function test_dash_overview_all_temp_scope_done_from_all() {
156+ // Wait for stuff to be loaded
157+ tryCompare(scopes, "loaded", true);
158+ var dashContentList = findChild(dash, "dashContentList");
159+ tryCompare(dashContentList, "count", 6);
160+ var mockScope1Loader = findChild(dash, "MockScope1 loader");
161+ tryCompareFunction(function() { return mockScope1Loader.item != null; }, true);
162+
163+ // Show the overview
164+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, dash.height - units.gu(18));
165+ var overviewController = findInvisibleChild(dash, "overviewController");
166+ tryCompare(overviewController, "progress", 1);
167+
168+ // Make sure tab is where it should
169+ var scopesOverview = findChild(dash, "scopesOverview");
170+ compare(scopesOverview.currentTab, 0);
171+
172+ // Make sure stuff is loaded
173+ var scopesOverviewFavoritesRepeater = findChild(dash, "scopesOverviewFavoritesRepeater");
174+ tryCompare(scopesOverviewFavoritesRepeater, "count", 6);
175+ tryCompareFunction(function() { return scopesOverviewFavoritesRepeater.itemAt(0).item != null; }, true);
176+ waitForRendering(scopesOverviewFavoritesRepeater.itemAt(1).item);
177+
178+ // Click on the all tab
179+ var scopesOverviewAllTabButton = findChild(dash, "scopesOverviewAllTabButton");
180+ mouseClick(scopesOverviewAllTabButton, 0, 0);
181+
182+ // Wait for all tab to be enabled (animation finish)
183+ var scopesOverviewAllView = findChild(dash, "scopesOverviewRepeaterChild1");
184+ tryCompare(scopesOverviewAllView, "enabled", true);
185+
186+ // Click on a temp scope
187+ var tempScopeCard = findChild(scopesOverviewAllView, "delegate1");
188+ mouseClick(tempScopeCard, 0, 0);
189+
190+ // Check the bottom edge (overview) is disabled from temp scope
191+ var overviewDragHandle = findChild(dash, "overviewDragHandle");
192+ compare(overviewDragHandle.enabled, false);
193+
194+ // Check temp scope is there
195+ var scopesOverviewTempScopeItem = findChild(dash, "scopesOverviewTempScopeItem");
196+ tryCompareFunction( function() { return scopesOverviewTempScopeItem.scope != null; }, true);
197+ tryCompare(scopesOverviewTempScopeItem, "enabled", true);
198+
199+ // Go back
200+ var scopesOverviewTempScopeItemHeader = findChild(scopesOverviewTempScopeItem, "scopePageHeader");
201+ var backButton = findChild(findChild(scopesOverviewTempScopeItemHeader, "innerPageHeader"), "backButton");
202+ mouseClick(backButton, 0, 0);
203+
204+ // Check temp scope is gone
205+ var scopesOverviewTempScopeItem = findChild(dash, "scopesOverviewTempScopeItem");
206+ tryCompareFunction( function() { return scopesOverviewTempScopeItem.scope == null; }, true);
207+ tryCompare(scopesOverviewTempScopeItem, "enabled", false);
208+
209+ // Press on done
210+ var scopesOverviewDoneButton = findChild(scopesOverview, "scopesOverviewDoneButton");
211+ mouseClick(scopesOverviewDoneButton, 0, 0);
212+
213+ // Check the dash overview is gone
214+ tryCompare(overviewController, "progress", 0);
215+
216+ // Original list is still on 0
217+ compare(dashContentList.currentIndex, 0);
218+ }
219+
220+ function test_temp_scope_dash_overview_all_search_temp_scope_favorite_from_all() {
221+ // Wait for stuff to be loaded
222+ tryCompare(scopes, "loaded", true);
223+ var dashContentList = findChild(dash, "dashContentList");
224+ tryCompare(dashContentList, "count", 6);
225+ var mockScope1Loader = findChild(dash, "MockScope1 loader");
226+ tryCompareFunction(function() { return mockScope1Loader.item != null; }, true);
227+
228+ // Swipe right to Apps scope
229+ touchFlick(dash, dash.width - 1, units.gu(1), dash.width - units.gu(10), units.gu(1));
230+ tryCompare(dashContentList, "contentX", dashContentList.width);
231+ tryCompare(dashContentList, "currentIndex", 1);
232+
233+ // Click on card that opens temp scope
234+ var dashCategory2 = findChild(dashContentList.currentItem, "dashCategory2");
235+ var card2 = findChild(dashCategory2, "delegate2");
236+ waitForRendering(card2);
237+ mouseClick(card2, 0, 0);
238+
239+ // Wait for temp scope to be there
240+ var dashTempScopeItem = findChild(dash, "dashTempScopeItem");
241+ tryCompare(dashTempScopeItem, "x", 0);
242+
243+ // Show the overview
244+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, dash.height - units.gu(18));
245+ var overviewController = findInvisibleChild(dash, "overviewController");
246+ tryCompare(overviewController, "progress", 1);
247+
248+ // Make sure tab is where it should
249+ var scopesOverview = findChild(dash, "scopesOverview");
250+ compare(scopesOverview.currentTab, 1);
251+
252+ // Do a search
253+ var scopesOverviewPageHeader = findChild(scopesOverview, "scopesOverviewPageHeader");
254+ var searchButton = findChild(scopesOverviewPageHeader, "search_header_button");
255+ mouseClick(searchButton, 0, 0);
256+
257+ // Type something
258+ keyClick(Qt.Key_H);
259+
260+ // Check results grid is there and the other lists are not
261+ var searchResultsViewer = findChild(scopesOverview, "searchResultsViewer");
262+ var scopesOverviewRepeater = findChild(dash, "scopesOverviewRepeater");
263+ tryCompare(searchResultsViewer, "opacity", 1);
264+ tryCompare(scopesOverviewRepeater, "count", 0);
265+
266+ // Click on a temp scope in the search
267+ var dashCategorysearchA = findChild(searchResultsViewer, "dashCategorysearchA");
268+ var cardTempScope = findChild(dashCategorysearchA, "delegate2");
269+ waitForRendering(cardTempScope);
270+ mouseClick(cardTempScope, cardTempScope.width / 2, cardTempScope.height / 2);
271+
272+ // Check the bottom edge (overview) is disabled from temp scope
273+ var overviewDragHandle = findChild(dash, "overviewDragHandle");
274+ compare(overviewDragHandle.enabled, false);
275+
276+ // Check temp scope is there
277+ var scopesOverviewTempScopeItem = findChild(dash, "scopesOverviewTempScopeItem");
278+ tryCompareFunction( function() { return scopesOverviewTempScopeItem.scope != null; }, true);
279+ tryCompare(scopesOverviewTempScopeItem, "enabled", true);
280+
281+ // Go back
282+ var scopesOverviewTempScopeItemHeader = findChild(scopesOverviewTempScopeItem, "scopePageHeader");
283+ var backButton = findChild(findChild(scopesOverviewTempScopeItemHeader, "innerPageHeader"), "backButton");
284+ mouseClick(backButton, 0, 0);
285+
286+ // Check temp scope is gone
287+ var scopesOverviewTempScopeItem = findChild(dash, "scopesOverviewTempScopeItem");
288+ tryCompareFunction( function() { return scopesOverviewTempScopeItem.scope == null; }, true);
289+ tryCompare(scopesOverviewTempScopeItem, "enabled", false);
290+
291+ // Press on a favorite
292+ var dashCategorysearchB = findChild(searchResultsViewer, "dashCategorysearchB");
293+ var cardFavSearch = findChild(dashCategorysearchB, "delegate3");
294+ mouseClick(cardFavSearch, 0, 0);
295+
296+ // Check the dash overview is gone
297+ tryCompare(overviewController, "progress", 0);
298+
299+ // Original list went to the favorite
300+ compare(dashContentList.currentIndex, 0);
301+ }
156302 }
157303}