on xenial help sign in
Fix clicking on the manage dash list after having moved the current scope

Comes with a test for that and for a other manage dash scope move situation And removes unused code from the test Approved by: Michael Zanetti

commitf16743d899b22c1f90652ff3e4eaa51781519556 authorAlbert Astals <albert.astals@canonical.com> dateMon 15 Dec 2014, 22:42 (12 years ago) parent112b015de74135
2 files changed+87−14
qml/Dash/Dash.qml+1 tests/qmltests/Dash/tst_Dash.qml+86−14
qml/Dash/Dash.qml+1
@@ -75,6 +75,7 @@ Showable {
7575 return
7676 }
7777
78+ dashContent.workaroundRestoreIndex = -1;
7879 dashContent.setCurrentScopeAtIndex(scopeIndex, animate, reset)
7980 }
8081
tests/qmltests/Dash/tst_Dash.qml+86−14
@@ -70,19 +70,6 @@ Item {
7070 waitForRendering(findChild(dash, "scopeLoader0").item);
7171 }
7272
73− function get_scope_data() {
74− return [
75− { tag: "MockScope1", visualIndex: 0 },
76− { tag: "MockScope2", visualIndex: -1 },
77− { tag: "clickscope", visualIndex: 1 },
78− { tag: "MockScope5", visualIndex: 2 },
79− ]
80− }
81−
82− function test_show_scope_on_load_data() {
83− return get_scope_data()
84− }
85−
8673 function test_manage_dash_clickscope_unfavoritable() {
8774 // Show the manage dash
8875 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
@@ -330,7 +317,7 @@ Item {
330317 spy.target = scopesList.scope;
331318 spy.signalName = "performQuery";
332319
333− // Do a search
320+ // Click on the store
334321 var scopesListPageHeader = findChild(scopesList, "pageHeader");
335322 var searchButton = findChild(scopesListPageHeader, "store_header_button");
336323 mouseClick(searchButton, 0, 0);
@@ -339,5 +326,90 @@ Item {
339326 compare(spy.signalArguments[0][0], "scope://com.canonical.scopes.clickstore");
340327 tryCompare(bottomEdgeController, "progress", 0);
341328 }
329+
330+ function test_manage_dash_move_current() {
331+ var dashContentList = findChild(dash, "dashContentList");
332+ compare(dashContentList.currentIndex, 0);
333+ compare(dashContentList.currentItem.scopeId, "MockScope1");
334+
335+ // Show the manage dash
336+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
337+ var bottomEdgeController = findInvisibleChild(dash, "bottomEdgeController");
338+ tryCompare(bottomEdgeController, "progress", 1);
339+
340+ // Make sure stuff is loaded
341+ var favScopesListCategory = findChild(dash, "scopesListCategoryfavorites");
342+ var favScopesListCategoryList = findChild(favScopesListCategory, "scopesListCategoryInnerList");
343+ tryCompare(favScopesListCategoryList, "currentIndex", 0);
344+
345+ // Enter edit mode
346+ var scopesList = findChild(dash, "scopesList");
347+ var clickScope = findChild(favScopesListCategoryList, "delegateclickscope");
348+ mousePress(clickScope, 0, 0);
349+ tryCompare(scopesList, "state", "edit");
350+ mouseRelease(clickScope, 0, 0);
351+
352+ var starArea = findChild(clickScope, "starArea");
353+ touchFlick(starArea, 0, 0, 0, -units.gu(10));
354+
355+ // Exit edit mode and go back
356+ var scopesList = findChild(dash, "scopesList");
357+ var scopesListPageHeader = findChild(scopesList, "pageHeader");
358+ var backButton = findChild(findChild(scopesListPageHeader, "innerPageHeader"), "backButton");
359+ mouseClick(backButton, 0, 0);
360+ mouseClick(backButton, 0, 0);
361+ tryCompare(bottomEdgeController, "progress", 0);
362+
363+ tryCompare(dashContentList, "currentIndex", 0);
364+ compare(dashContentList.currentItem.scopeId, "clickscope");
365+
366+ // Move to second scope
367+ touchFlick(dash, dash.width / 2, units.gu(2), dash.width / 5, units.gu(2));
368+ tryCompare(dashContentList, "currentIndex", 1);
369+ compare(dashContentList.currentItem.scopeId, "MockScope1");
370+ }
371+
372+ function test_manage_dash_move_current_click_other() {
373+ var dashContentList = findChild(dash, "dashContentList");
374+ compare(dashContentList.currentIndex, 0);
375+ compare(dashContentList.currentItem.scopeId, "MockScope1");
376+
377+ // Show the manage dash
378+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
379+ var bottomEdgeController = findInvisibleChild(dash, "bottomEdgeController");
380+ tryCompare(bottomEdgeController, "progress", 1);
381+
382+ // Make sure stuff is loaded
383+ var favScopesListCategory = findChild(dash, "scopesListCategoryfavorites");
384+ var favScopesListCategoryList = findChild(favScopesListCategory, "scopesListCategoryInnerList");
385+ tryCompare(favScopesListCategoryList, "currentIndex", 0);
386+
387+ // Enter edit mode
388+ var scopesList = findChild(dash, "scopesList");
389+ var clickScope = findChild(favScopesListCategoryList, "delegateclickscope");
390+ mousePress(clickScope, 0, 0);
391+ tryCompare(scopesList, "state", "edit");
392+ mouseRelease(clickScope, 0, 0);
393+
394+ var starArea = findChild(clickScope, "starArea");
395+ touchFlick(starArea, 0, 0, 0, -units.gu(10));
396+
397+ // wait for the animation to settle
398+ tryCompare(clickScope, "height", units.gu(6));
399+
400+ // Exit edit mode
401+ var scopesList = findChild(dash, "scopesList");
402+ var scopesListPageHeader = findChild(scopesList, "pageHeader");
403+ var backButton = findChild(findChild(scopesListPageHeader, "innerPageHeader"), "backButton");
404+ mouseClick(backButton, 0, 0);
405+
406+ // Click on third scope
407+ var mockScope5 = findChild(favScopesListCategoryList, "delegateMockScope5");
408+ waitForRendering(mockScope5)
409+ mouseClick(mockScope5, 0, 0);
410+ tryCompare(bottomEdgeController, "progress", 0);
411+ tryCompare(dashContentList, "currentIndex", 2);
412+ compare(dashContentList.currentItem.scopeId, "MockScope5");
413+ }
342414 }
343415}