on xenial help sign in
Added test_tryOpenNullPreview qmltest
6472b0fMarcus Tomlinson
tests/mocks/Unity/fake_scope.cpp+12−4
@@ -28,7 +28,7 @@ Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
28{
28{
29}
29}
30
30
31−Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories)
31+Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories, bool returnNullPreview)
32 : unity::shell::scopes::ScopeInterface(parent)
32 : unity::shell::scopes::ScopeInterface(parent)
33 , m_id(id)
33 , m_id(id)
34 , m_name(name)
34 , m_name(name)
@@ -41,6 +41,7 @@ Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* pare
41 , m_categories(new Categories(categories, this))
41 , m_categories(new Categories(categories, this))
42 , m_openScope(nullptr)
42 , m_openScope(nullptr)
43 , m_settings(new SettingsModel(this))
43 , m_settings(new SettingsModel(this))
44+ , m_returnNullPreview(returnNullPreview)
44{
45{
45}
46}
46
47
@@ -175,9 +176,16 @@ PreviewStack* Scope::preview(QVariant const& result)
175{
176{
176 Q_UNUSED(result);
177 Q_UNUSED(result);
177
178
179+ if (m_returnNullPreview)
180+ {
181+ return nullptr;
182+ }
183+ else
184+ {
178− // This probably leaks, do we don't care
185+ // This probably leaks, do we don't care
179− // it's a test after all
186+ // it's a test after all
180− return new PreviewStack;
187+ return new PreviewStack;
188+ }
181}
189}
182
190
183void Scope::cancelActivation()
191void Scope::cancelActivation()
tests/mocks/Unity/fake_scope.h+3−1
@@ -32,7 +32,7 @@ class Scope : public unity::shell::scopes::ScopeInterface
32
32
33public:
33public:
34 Scope(Scopes* parent = 0);
34 Scope(Scopes* parent = 0);
35− Scope(QString const& id, QString const& name, bool favorite, Scopes* parent = 0, int categories = 20);
35+ Scope(QString const& id, QString const& name, bool favorite, Scopes* parent = 0, int categories = 20, bool returnNullPreview = false);
36
36
37 /* getters */
37 /* getters */
38 QString id() const override;
38 QString id() const override;
@@ -97,6 +97,8 @@ protected:
97 unity::shell::scopes::CategoriesInterface* m_categories;
97 unity::shell::scopes::CategoriesInterface* m_categories;
98 unity::shell::scopes::ScopeInterface* m_openScope;
98 unity::shell::scopes::ScopeInterface* m_openScope;
99 unity::shell::scopes::SettingsModelInterface* m_settings;
99 unity::shell::scopes::SettingsModelInterface* m_settings;
100+
101+ bool m_returnNullPreview;
100};
102};
101
103
102#endif // FAKE_SCOPE_H
104#endif // FAKE_SCOPE_H
tests/mocks/Unity/fake_scopes.cpp+1
@@ -59,6 +59,7 @@ void Scopes::updateScopes()
59 addScope(new Scope("MockScope7", "MS7", false, this));
59 addScope(new Scope("MockScope7", "MS7", false, this));
60 addScope(new Scope("MockScope8", "MS8", false, this));
60 addScope(new Scope("MockScope8", "MS8", false, this));
61 addScope(new Scope("MockScope9", "MS9", false, this));
61 addScope(new Scope("MockScope9", "MS9", false, this));
62+ addScope(new Scope("NullPreviewScope", "NPS", true, this, 1, true));
62 m_scopesOverview = new ScopesOverview(this);
63 m_scopesOverview = new ScopesOverview(this);
63
64
64 if (!m_loaded) {
65 if (!m_loaded) {
tests/qmltests/Dash/tst_GenericScopeView.qml+26
@@ -301,6 +301,32 @@ Item {
301 closePreview();
301 closePreview();
302 }
302 }
303
303
304+ function test_tryOpenNullPreview() {
305+ var originalScopeId = genericScopeView.scope.id;
306+ genericScopeView.scope = scopes.getScope("NullPreviewScope");
307+
308+ tryCompareFunction(function() {
309+ var cardGrid = findChild(genericScopeView, 0);
310+ if (cardGrid != null) {
311+ var tile = findChild(cardGrid, 0);
312+ return tile != null;
313+ }
314+ return false;
315+ },
316+ true);
317+ var tile = findChild(findChild(genericScopeView, 0), 0);
318+
319+ tryCompare(testCase.subPageLoader, "open", false);
320+ tryCompare(testCase.subPageLoader, "visible", false);
321+
322+ mouseClick(tile, tile.width / 2, tile.height / 2);
323+
324+ tryCompare(testCase.subPageLoader, "open", false);
325+ tryCompare(testCase.subPageLoader, "visible", false);
326+
327+ genericScopeView.scope = scopes.getScope(originalScopeId)
328+ }
329+
304 function test_showPreviewCarousel() {
330 function test_showPreviewCarousel() {
305 var category = scrollToCategory("dashCategory1");
331 var category = scrollToCategory("dashCategory1");
306
332