on xenial help sign in
Manage Dash: Make store button work even if you have no favorites
4a91402Albert Astals
qml/Dash/Dash.qml+1−1
@@ -167,7 +167,7 @@ Showable {
167 onStoreClicked: {
167 onStoreClicked: {
168 bottomEdgeController.enableAnimation = true;
168 bottomEdgeController.enableAnimation = true;
169 bottomEdgeController.progress = 0;
169 bottomEdgeController.progress = 0;
170− dashContent.currentScope.performQuery("scope://com.canonical.scopes.clickstore");
170+ scopesList.scope.performQuery("scope://com.canonical.scopes.clickstore");
171 }
171 }
172 onRequestFavorite: {
172 onRequestFavorite: {
173 scopes.setFavorite(scopeId, favorite);
173 scopes.setFavorite(scopeId, favorite);
tests/mocks/Unity/fake_scopes.cpp+12
@@ -88,6 +88,18 @@ void Scopes::clear()
88 }
88 }
89}
89}
90
90
91+void Scopes::clearFavorites()
92+{
93+ if (m_scopes.size() > 0) {
94+ beginRemoveRows(QModelIndex(), 0, m_scopes.count()-1);
95+ Q_FOREACH(Scope *scope, m_scopes) {
96+ m_scopesOverview->setFavorite(scope, false);
97+ }
98+ m_scopes.clear();
99+ endRemoveRows();
100+ }
101+}
102+
91void Scopes::load()
103void Scopes::load()
92{
104{
93 timer.start();
105 timer.start();
tests/mocks/Unity/fake_scopes.h+1
@@ -46,6 +46,7 @@ public:
46 Q_INVOKABLE void addScope(Scope* scope);
46 Q_INVOKABLE void addScope(Scope* scope);
47
47
48 Q_INVOKABLE void clear();
48 Q_INVOKABLE void clear();
49+ Q_INVOKABLE void clearFavorites();
49 Q_INVOKABLE void load();
50 Q_INVOKABLE void load();
50
51
51 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
52 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
tests/qmltests/Dash/tst_Dash.qml+29
@@ -38,6 +38,10 @@ Item {
38 anchors.fill: parent
38 anchors.fill: parent
39 }
39 }
40
40
41+ SignalSpy {
42+ id: spy
43+ }
44+
41 UT.UnityTestCase {
45 UT.UnityTestCase {
42 name: "Dash"
46 name: "Dash"
43 when: windowShown
47 when: windowShown
@@ -286,5 +290,30 @@ Item {
286 currentScope.setSearchInProgress(false);
290 currentScope.setSearchInProgress(false);
287 tryCompare(processingIndicator, "visible", false);
291 tryCompare(processingIndicator, "visible", false);
288 }
292 }
293+
294+ function test_manage_dash_store_no_favorites() {
295+ // Show the manage dash
296+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
297+ var bottomEdgeController = findInvisibleChild(dash, "bottomEdgeController");
298+ tryCompare(bottomEdgeController, "progress", 1);
299+
300+ // clear the favorite scopes
301+ scopes.clearFavorites();
302+ var dashContentList = findChild(dash, "dashContentList");
303+ tryCompare(dashContentList, "count", 0);
304+
305+ var scopesList = findChild(dash, "scopesList");
306+ spy.target = scopesList.scope;
307+ spy.signalName = "performQuery";
308+
309+ // Do a search
310+ var scopesListPageHeader = findChild(scopesList, "pageHeader");
311+ var searchButton = findChild(scopesListPageHeader, "store_header_button");
312+ mouseClick(searchButton, 0, 0);
313+
314+ spy.wait();
315+ compare(spy.signalArguments[0][0], "scope://com.canonical.scopes.clickstore");
316+ tryCompare(bottomEdgeController, "progress", 0);
317+ }
289 }
318 }
290}
319}