on xenial help sign in
Make sure that unfavoriting a scope gives us the next one
7f0ef25Albert Astals Cid
tests/mocks/Unity/fake_scopes.cpp+3
@@ -260,6 +260,9 @@ void Scopes::addScope(Scope* scope)
260 beginInsertRows(QModelIndex(), index, index);
260 beginInsertRows(QModelIndex(), index, index);
261 m_scopes.append(scope);
261 m_scopes.append(scope);
262 endInsertRows();
262 endInsertRows();
263+ connect(scope, &Scope::favoriteChanged, [this, scope]{
264+ setFavorite(scope->id(), scope->favorite());
265+ });
263 }
266 }
264 m_allScopes.append(scope);
267 m_allScopes.append(scope);
265}
268}
tests/qmltests/Dash/tst_DashContent.qml+13
@@ -599,5 +599,18 @@ Item {
599 expectFail("", "There has to be new cards after releasing the list is not moving anymore");
599 expectFail("", "There has to be new cards after releasing the list is not moving anymore");
600 verify(compareArrays(buttons3, buttons));
600 verify(compareArrays(buttons3, buttons));
601 }
601 }
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+ }
602 }
615 }
603}
616}
tests/qmltests/Dash/tst_GenericScopeView.qml+5
@@ -70,6 +70,11 @@ Item {
70 property Item header: findChild(genericScopeView, "scopePageHeader")
70 property Item header: findChild(genericScopeView, "scopePageHeader")
71
71
72 function init() {
72 function init() {
73+ // Start from a clean scopes situation every test
74+ scopes.clear();
75+ scopes.load();
76+ tryCompare(scopes, "loaded", true);
77+
73 genericScopeView.scope = scopes.getScope(2);
78 genericScopeView.scope = scopes.getScope(2);
74 shell.width = units.gu(120);
79 shell.width = units.gu(120);
75 genericScopeView.categoryView.positionAtBeginning();
80 genericScopeView.categoryView.positionAtBeginning();