on xenial help sign in
Make sure that unfavoriting a scope gives us the next one

This is currently broken due to a regression in the Qt Quick ListView Approved by: Michael Zanetti

commit7f0ef25a9f66d37d3a0730d5d65219ef5b19decc authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 8 Dec 2015, 15:36 (11 years ago) parentcb4c07bac0d1bf
3 files changed+21
tests/mocks/Unity/fake_scopes.cpp+3 tests/qmltests/Dash/tst_DashContent.qml+13 tests/qmltests/Dash/tst_GenericScopeView.qml+5
tests/mocks/Unity/fake_scopes.cpp+3
@@ -260,6 +260,9 @@ void Scopes::addScope(Scope* scope)
260260 beginInsertRows(QModelIndex(), index, index);
261261 m_scopes.append(scope);
262262 endInsertRows();
263+ connect(scope, &Scope::favoriteChanged, [this, scope]{
264+ setFavorite(scope->id(), scope->favorite());
265+ });
263266 }
264267 m_allScopes.append(scope);
265268}
tests/qmltests/Dash/tst_DashContent.qml+13
@@ -599,5 +599,18 @@ Item {
599599 expectFail("", "There has to be new cards after releasing the list is not moving anymore");
600600 verify(compareArrays(buttons3, buttons));
601601 }
602+
603+ function test_unfavoriteScope()
604+ {
605+ var dashContentList = findChild(dashContent, "dashContentList");
606+ var header = findChild(dashContentList.currentItem, "scopePageHeader")
607+ var favoriteAction = findChild(header, "favorite_action_button");
608+ compare(dashContentList.currentIndex, 0);
609+ compare(dashContentList.indexAt(dashContentList.width * 1.5, 0), 1);
610+ var nextScopeId = dashContentList.itemAt(dashContentList.width * 1.5, 0).item.scope.id;
611+ mouseClick(favoriteAction);
612+ tryCompareFunction(function() { return dashContentList.currentItem.item.scope.id == nextScopeId; }, true);
613+ compare(dashContentList.currentIndex, 0);
614+ }
602615 }
603616}
tests/qmltests/Dash/tst_GenericScopeView.qml+5
@@ -70,6 +70,11 @@ Item {
7070 property Item header: findChild(genericScopeView, "scopePageHeader")
7171
7272 function init() {
73+ // Start from a clean scopes situation every test
74+ scopes.clear();
75+ scopes.load();
76+ tryCompare(scopes, "loaded", true);
77+
7378 genericScopeView.scope = scopes.getScope(2);
7479 shell.width = units.gu(120);
7580 genericScopeView.categoryView.positionAtBeginning();