on xenial help sign in
Add favorite testing.
a5d0304Michał Sawicz
tests/mocks/Unity/fake_scopes.h+1−1
@@ -56,7 +56,7 @@ public:
56 // This is used as part of implementation of the other C++ code, not API
56 // This is used as part of implementation of the other C++ code, not API
57 QList<Scope*> scopes() const;
57 QList<Scope*> scopes() const;
58 QList<Scope*> allScopes() const;
58 QList<Scope*> allScopes() const;
59− Scope* getScopeFromAll(const QString& scope_id) const;
59+ Q_INVOKABLE Scope* getScopeFromAll(const QString& scope_id) const;
60
60
61private Q_SLOTS:
61private Q_SLOTS:
62 void updateScopes();
62 void updateScopes();
tests/qmltests/Dash/tst_GenericScopeView.qml+28
@@ -415,6 +415,34 @@ Item {
415 verify(image, "Could not find the title image.");
415 verify(image, "Could not find the title image.");
416 compare(image.source, data.logo, "Title image has the wrong source");
416 compare(image.source, data.logo, "Title image has the wrong source");
417 }
417 }
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+ }
418 }
446 }
419 }
447 }
420}
448}