on xenial help sign in
Add favorite testing.
commita5d030417925a0cc84bb01089be70c61428b0bb7 authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 25 Aug 2014, 16:13 (12 years ago) parent1811a8e
2 files changed+29−1
tests/mocks/Unity/fake_scopes.h+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml+28
tests/mocks/Unity/fake_scopes.h+1−1
@@ -56,7 +56,7 @@ public:
5656 // This is used as part of implementation of the other C++ code, not API
5757 QList<Scope*> scopes() const;
5858 QList<Scope*> allScopes() const;
59− Scope* getScopeFromAll(const QString& scope_id) const;
59+ Q_INVOKABLE Scope* getScopeFromAll(const QString& scope_id) const;
6060
6161private Q_SLOTS:
6262 void updateScopes();
tests/qmltests/Dash/tst_GenericScopeView.qml+28
@@ -415,6 +415,34 @@ Item {
415415 verify(image, "Could not find the title image.");
416416 compare(image.source, data.logo, "Title image has the wrong source");
417417 }
418+
419+ function test_favorite_data() {
420+ return [
421+ { tag: "People", id: "MockScope1", favorite: true },
422+ { tag: "Music", id: "MockScope2", favorite: false },
423+ { tag: "Apps", id: "clickscope", favorite: true },
424+ ];
425+ }
426+
427+ function test_favorite(data) {
428+ genericScopeView.scope = scopes.getScopeFromAll(data.id);
429+ waitForRendering(genericScopeView);
430+ verify(header, "Could not find the header.");
431+
432+ compare(genericScopeView.scope.favorite, data.favorite, "Unexpected initial favorite value");
433+
434+ var innerHeader = findChild(header, "innerPageHeader");
435+ verify(innerHeader, "Could not find the inner header");
436+
437+ expectFail("Apps", "Click scope should not have a favorite button");
438+ var favoriteAction = findChild(innerHeader, "favorite_header_button");
439+ verify(favoriteAction, "Could not find the favorite action.");
440+ mouseClick(favoriteAction, 0, 0);
441+
442+ tryCompare(genericScopeView.scope, "favorite", !data.favorite);
443+
444+ genericScopeView.scope = !genericScopeView.scope;
445+ }
418446 }
419447 }
420448}