on xenial help sign in
Add test
7b82497Albert Astals
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
@@ -262,5 +266,30 @@ Item {
262 currentScope.setSearchInProgress(false);
266 currentScope.setSearchInProgress(false);
263 tryCompare(processingIndicator, "visible", false);
267 tryCompare(processingIndicator, "visible", false);
264 }
268 }
269+
270+ function test_manage_dash_store_no_favorites() {
271+ // Show the manage dash
272+ touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
273+ var bottomEdgeController = findInvisibleChild(dash, "bottomEdgeController");
274+ tryCompare(bottomEdgeController, "progress", 1);
275+
276+ // clear the favorite scopes
277+ scopes.clearFavorites();
278+ var dashContentList = findChild(dash, "dashContentList");
279+ tryCompare(dashContentList, "count", 0);
280+
281+ var scopesList = findChild(dash, "scopesList");
282+ spy.target = scopesList.scope;
283+ spy.signalName = "performQuery";
284+
285+ // Do a search
286+ var scopesListPageHeader = findChild(scopesList, "pageHeader");
287+ var searchButton = findChild(scopesListPageHeader, "store_header_button");
288+ mouseClick(searchButton, 0, 0);
289+
290+ spy.wait();
291+ compare(spy.signalArguments[0][0], "scope://com.canonical.scopes.clickstore");
292+ tryCompare(bottomEdgeController, "progress", 0);
293+ }
265 }
294 }
266}
295}