@@ -20,8 +20,6 @@ import "../../../qml/Dash"
20import Ubuntu.Components 0.1
20import Ubuntu.Components 0.1
21import Unity.Test 0.1 as UT
21import Unity.Test 0.1 as UT
23−// TODO We don't have any tests for the overlay scope functionality.
27 width: units.gu(40)
25 width: units.gu(40)
@@ -61,9 +59,9 @@ Item {
61 function get_scope_data() {
59 function get_scope_data() {
63 { tag: "MockScope1", visualIndex: 0 },
61 { tag: "MockScope1", visualIndex: 0 },
64− { tag: "MockScope2", visualIndex: 1 },
62+ { tag: "MockScope2", visualIndex: -1 },
65− { tag: "clickscope", visualIndex: 2 },
63+ { tag: "clickscope", visualIndex: 1 },
66− { tag: "MockScope5", visualIndex: 3 },
64+ { tag: "MockScope5", visualIndex: 2 },
@@ -79,10 +77,234 @@ Item {
79 tryCompare(dashContentList, "count", 0);
77 tryCompare(dashContentList, "count", 0);
80 scopes.load();
78 scopes.load();
81 tryCompare(scopes, "loaded", true);
79 tryCompare(scopes, "loaded", true);
82− tryCompare(dashContentList, "count", 5);
80+ tryCompare(dashContentList, "count", 6);
84 verify(dashContentList != undefined);
82 verify(dashContentList != undefined);
83+ if (data.visualIndex == -1) {
84+ tryCompare(dashContentList, "currentIndex", 0);
85+ expectFail(data.tag, "non favorite scopes should not be visble in the scopes model");
86+ compare(dashContentList.currentItem.scopeId, data.tag); // this should fail
85− tryCompare(dashContentList, "currentIndex", data.visualIndex);
88+ tryCompare(dashContentList, "currentIndex", data.visualIndex);
89+ compare(dashContentList.currentItem.scopeId, data.tag);
93+ function test_dash_overview_show_select_same_favorite() {
94+ // Wait for stuff to be loaded
95+ tryCompare(scopes, "loaded", true);
96+ var dashContentList = findChild(dash, "dashContentList");
97+ tryCompare(dashContentList, "count", 6);
98+ var mockScope1Loader = findChild(dash, "MockScope1 loader");
99+ tryCompareFunction(function() { return mockScope1Loader.item != null; }, true);
101+ // Show the overview
102+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, dash.height - units.gu(18));
103+ var overviewController = findInvisibleChild(dash, "overviewController");
104+ tryCompare(overviewController, "progress", 1);
106+ // Make sure tab is where it should
107+ var scopesOverview = findChild(dash, "scopesOverview");
108+ compare(scopesOverview.currentTab, 0);
110+ // Make sure stuff is loaded
111+ var scopesOverviewFavoritesRepeater = findChild(dash, "scopesOverviewFavoritesRepeater");
112+ tryCompare(scopesOverviewFavoritesRepeater, "count", 6);
113+ tryCompareFunction(function() { return scopesOverviewFavoritesRepeater.itemAt(0).item != null; }, true);
114+ waitForRendering(scopesOverviewFavoritesRepeater.itemAt(0).item);
116+ // Click in first item
117+ mouseClick(scopesOverviewFavoritesRepeater.itemAt(0).item, 0, 0);
119+ // Make sure animation went back
120+ tryCompare(overviewController, "progress", 0);
121+ compare(dashContentList.currentIndex, 0);
124+ function test_dash_overview_show_select_different_favorite() {
125+ // Wait for stuff to be loaded
126+ tryCompare(scopes, "loaded", true);
127+ var dashContentList = findChild(dash, "dashContentList");
128+ tryCompare(dashContentList, "count", 6);
129+ var mockScope1Loader = findChild(dash, "MockScope1 loader");
130+ tryCompareFunction(function() { return mockScope1Loader.item != null; }, true);
132+ // Show the overview
133+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, dash.height - units.gu(18));
134+ var overviewController = findInvisibleChild(dash, "overviewController");
135+ tryCompare(overviewController, "progress", 1);
137+ // Make sure tab is where it should
138+ var scopesOverview = findChild(dash, "scopesOverview");
139+ compare(scopesOverview.currentTab, 0);
141+ // Make sure stuff is loaded
142+ var scopesOverviewFavoritesRepeater = findChild(dash, "scopesOverviewFavoritesRepeater");
143+ tryCompare(scopesOverviewFavoritesRepeater, "count", 6);
144+ tryCompareFunction(function() { return scopesOverviewFavoritesRepeater.itemAt(0).item != null; }, true);
145+ waitForRendering(scopesOverviewFavoritesRepeater.itemAt(1).item);
147+ // Click in first item
148+ mouseClick(scopesOverviewFavoritesRepeater.itemAt(1).item, 0, 0);
150+ // Make sure animation went back
151+ tryCompare(overviewController, "progress", 0);
152+ compare(dashContentList.currentIndex, 1);
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);
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);
168+ // Make sure tab is where it should
169+ var scopesOverview = findChild(dash, "scopesOverview");
170+ compare(scopesOverview.currentTab, 0);
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);
178+ // Click on the all tab
179+ var scopesOverviewAllTabButton = findChild(dash, "scopesOverviewAllTabButton");
180+ mouseClick(scopesOverviewAllTabButton, 0, 0);
182+ // Wait for all tab to be enabled (animation finish)
183+ var scopesOverviewAllView = findChild(dash, "scopesOverviewRepeaterChild1");
184+ tryCompare(scopesOverviewAllView, "enabled", true);
186+ // Click on a temp scope
187+ var tempScopeCard = findChild(scopesOverviewAllView, "delegate1");
188+ mouseClick(tempScopeCard, 0, 0);
190+ // Check the bottom edge (overview) is disabled from temp scope
191+ var overviewDragHandle = findChild(dash, "overviewDragHandle");
192+ compare(overviewDragHandle.enabled, false);
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);
200+ var scopesOverviewTempScopeItemHeader = findChild(scopesOverviewTempScopeItem, "scopePageHeader");
201+ var backButton = findChild(findChild(scopesOverviewTempScopeItemHeader, "innerPageHeader"), "backButton");
202+ mouseClick(backButton, 0, 0);
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);
210+ var scopesOverviewDoneButton = findChild(scopesOverview, "scopesOverviewDoneButton");
211+ mouseClick(scopesOverviewDoneButton, 0, 0);
213+ // Check the dash overview is gone
214+ tryCompare(overviewController, "progress", 0);
216+ // Original list is still on 0
217+ compare(dashContentList.currentIndex, 0);
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);
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);
233+ // Click on card that opens temp scope
234+ var categoryListView = findChild(dashContentList.currentItem, "categoryListView");
235+ var dashCategory2 = findChild(categoryListView, "dashCategory2");
236+ tryCompareFunction(function() {
237+ var d = findChild(dashCategory2, "delegate2");
239+ categoryListView.contentY += 100;
242+ var card2 = findChild(dashCategory2, "delegate2");
243+ waitForRendering(card2);
244+ mouseClick(card2, card2.width / 2, card2.height / 2);
246+ // Wait for temp scope to be there
247+ var dashTempScopeItem = findChild(dash, "dashTempScopeItem");
248+ tryCompare(dashTempScopeItem, "x", 0);
250+ // Show the overview
251+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, dash.height - units.gu(18));
252+ var overviewController = findInvisibleChild(dash, "overviewController");
253+ tryCompare(overviewController, "progress", 1);
255+ // Make sure tab is where it should
256+ var scopesOverview = findChild(dash, "scopesOverview");
257+ compare(scopesOverview.currentTab, 1);
260+ var scopesOverviewPageHeader = findChild(scopesOverview, "scopesOverviewPageHeader");
261+ var searchButton = findChild(scopesOverviewPageHeader, "search_header_button");
262+ mouseClick(searchButton, 0, 0);
267+ // Check results grid is there and the other lists are not
268+ var searchResultsViewer = findChild(scopesOverview, "searchResultsViewer");
269+ var scopesOverviewRepeater = findChild(dash, "scopesOverviewRepeater");
270+ tryCompare(searchResultsViewer, "opacity", 1);
271+ tryCompare(scopesOverviewRepeater, "count", 0);
273+ // Click on a temp scope in the search
274+ var dashCategorysearchA = findChild(searchResultsViewer, "dashCategorysearchA");
275+ var cardTempScope = findChild(dashCategorysearchA, "delegate2");
276+ waitForRendering(cardTempScope);
277+ mouseClick(cardTempScope, cardTempScope.width / 2, cardTempScope.height / 2);
279+ // Check the bottom edge (overview) is disabled from temp scope
280+ var overviewDragHandle = findChild(dash, "overviewDragHandle");
281+ compare(overviewDragHandle.enabled, false);
283+ // Check temp scope is there
284+ var scopesOverviewTempScopeItem = findChild(dash, "scopesOverviewTempScopeItem");
285+ tryCompareFunction( function() { return scopesOverviewTempScopeItem.scope != null; }, true);
286+ tryCompare(scopesOverviewTempScopeItem, "enabled", true);
289+ var scopesOverviewTempScopeItemHeader = findChild(scopesOverviewTempScopeItem, "scopePageHeader");
290+ var backButton = findChild(findChild(scopesOverviewTempScopeItemHeader, "innerPageHeader"), "backButton");
291+ mouseClick(backButton, 0, 0);
293+ // Check temp scope is gone
294+ var scopesOverviewTempScopeItem = findChild(dash, "scopesOverviewTempScopeItem");
295+ tryCompareFunction( function() { return scopesOverviewTempScopeItem.scope == null; }, true);
296+ tryCompare(scopesOverviewTempScopeItem, "enabled", false);
298+ // Press on a favorite
299+ var dashCategorysearchB = findChild(searchResultsViewer, "dashCategorysearchB");
300+ var cardFavSearch = findChild(dashCategorysearchB, "delegate3");
301+ mouseClick(cardFavSearch, 0, 0);
303+ // Check the dash overview is gone
304+ tryCompare(overviewController, "progress", 0);
306+ // Original list went to the favorite
307+ compare(dashContentList.currentIndex, 0);
88 function test_setCurrentScope() {
310 function test_setCurrentScope() {