on xenial help sign in
Manage Dash: Make store button work even if you have no favorites

Fixes: #1400771 Approved by: Michael Zanetti

commit4a91402370f17eb73be23593b5fc0ef1ee1e416a authorAlbert Astals <albert.astals@canonical.com> dateThu 11 Dec 2014, 13:25 (12 years ago) parent3d183807b82497
4 files changed+43−1
qml/Dash/Dash.qml+1−1 tests/mocks/Unity/fake_scopes.cpp+12 tests/mocks/Unity/fake_scopes.h+1 tests/qmltests/Dash/tst_Dash.qml+29
qml/Dash/Dash.qml+1−1
@@ -167,7 +167,7 @@ Showable {
167167 onStoreClicked: {
168168 bottomEdgeController.enableAnimation = true;
169169 bottomEdgeController.progress = 0;
170− dashContent.currentScope.performQuery("scope://com.canonical.scopes.clickstore");
170+ scopesList.scope.performQuery("scope://com.canonical.scopes.clickstore");
171171 }
172172 onRequestFavorite: {
173173 scopes.setFavorite(scopeId, favorite);
tests/mocks/Unity/fake_scopes.cpp+12
@@ -88,6 +88,18 @@ void Scopes::clear()
8888 }
8989}
9090
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+
91103void Scopes::load()
92104{
93105 timer.start();
tests/mocks/Unity/fake_scopes.h+1
@@ -46,6 +46,7 @@ public:
4646 Q_INVOKABLE void addScope(Scope* scope);
4747
4848 Q_INVOKABLE void clear();
49+ Q_INVOKABLE void clearFavorites();
4950 Q_INVOKABLE void load();
5051
5152 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
tests/qmltests/Dash/tst_Dash.qml+29
@@ -38,6 +38,10 @@ Item {
3838 anchors.fill: parent
3939 }
4040
41+ SignalSpy {
42+ id: spy
43+ }
44+
4145 UT.UnityTestCase {
4246 name: "Dash"
4347 when: windowShown
@@ -286,5 +290,30 @@ Item {
286290 currentScope.setSearchInProgress(false);
287291 tryCompare(processingIndicator, "visible", false);
288292 }
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+ }
289318 }
290319}