on xenial help sign in
Add tests for auto and forced expansion.
7995171Michał Sawicz
tests/mocks/Unity/fake_categories.cpp+4−1
@@ -145,9 +145,12 @@ Categories::data(const QModelIndex& index, int role) const
145 } else {
145 } else {
146 map["category-layout"] = "carousel";
146 map["category-layout"] = "carousel";
147 map["card-size"] = "medium";
147 map["card-size"] = "medium";
148− map["collapsed-rows"] = 2;
149 map["overlay"] = true;
148 map["overlay"] = true;
150 }
149 }
150+ if (index.row() == 19) {
151+ map["category-layout"] = "grid";
152+ map["collapsed-rows"] = 0;
153+ }
151 map["card-size"] = "small";
154 map["card-size"] = "small";
152 return map;
155 return map;
153 }
156 }
tests/mocks/Unity/fake_scope.cpp+2−2
@@ -24,7 +24,7 @@ Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
24{
24{
25}
25}
26
26
27−Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
27+Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent, int categories)
28 : unity::shell::scopes::ScopeInterface(parent)
28 : unity::shell::scopes::ScopeInterface(parent)
29 , m_id(id)
29 , m_id(id)
30 , m_name(name)
30 , m_name(name)
@@ -33,7 +33,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
33 , m_isActive(false)
33 , m_isActive(false)
34 , m_currentDeparment("root")
34 , m_currentDeparment("root")
35 , m_previewRendererName("preview-generic")
35 , m_previewRendererName("preview-generic")
36− , m_categories(new Categories(20, this))
36+ , m_categories(new Categories(categories, this))
37{
37{
38}
38}
39
39
tests/mocks/Unity/fake_scope.h+1−1
@@ -30,7 +30,7 @@ class Scope : public unity::shell::scopes::ScopeInterface
30
30
31public:
31public:
32 Scope(QObject* parent = 0);
32 Scope(QObject* parent = 0);
33− Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);
33+ Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0, int categories = 20);
34
34
35 /* getters */
35 /* getters */
36 QString id() const override;
36 QString id() const override;
tests/mocks/Unity/fake_scopes.cpp+1
@@ -46,6 +46,7 @@ void Scopes::updateScopes()
46 addScope(new Scope("MockScope2", "Music", false, this));
46 addScope(new Scope("MockScope2", "Music", false, this));
47 addScope(new Scope("clickscope", "Apps", true, this));
47 addScope(new Scope("clickscope", "Apps", true, this));
48 addScope(new Scope("MockScope5", "Videos", true, this));
48 addScope(new Scope("MockScope5", "Videos", true, this));
49+ addScope(new Scope("SingleCategoryScope", "Single", true, this, 1));
49
50
50 if (!m_loaded) {
51 if (!m_loaded) {
51 m_loaded = true;
52 m_loaded = true;
tests/qmltests/Dash/tst_Dash.qml+1−1
@@ -86,7 +86,7 @@ Item {
86 tryCompare(dashContentList, "count", 0);
86 tryCompare(dashContentList, "count", 0);
87 scopes.load();
87 scopes.load();
88 tryCompare(scopes, "loaded", true);
88 tryCompare(scopes, "loaded", true);
89− tryCompare(dashContentList, "count", 3);
89+ tryCompare(dashContentList, "count", 4);
90
90
91 verify(dashContentList != undefined);
91 verify(dashContentList != undefined);
92 tryCompare(dashContentList, "currentIndex", data.visualIndex);
92 tryCompare(dashContentList, "currentIndex", data.visualIndex);
tests/qmltests/Dash/tst_DashContent.qml+4−4
@@ -115,10 +115,10 @@ Item {
115 }
115 }
116
116
117 function test_show_header_on_list_movement() {
117 function test_show_header_on_list_movement() {
118− var dashContentList = findChild(dashContent, "dashContentList");
118+ var scope = findChild(dashContent, "MockScope1 loader");
119− verify(dashContentList != undefined);
119+ verify(scope !== null);
120− var categoryListView = findChild(dashContentList, "categoryListView");
120+ var categoryListView = findChild(scope, "categoryListView");
121− verify(categoryListView != undefined);
121+ verify(categoryListView !== null);
122
122
123 waitForRendering(categoryListView);
123 waitForRendering(categoryListView);
124
124
tests/qmltests/Dash/tst_GenericScopeView.qml+29−2
@@ -60,7 +60,6 @@ Item {
60 shell.width = units.gu(120)
60 shell.width = units.gu(120)
61 genericScopeView.categoryView.positionAtBeginning();
61 genericScopeView.categoryView.positionAtBeginning();
62 waitForRendering(genericScopeView.categoryView);
62 waitForRendering(genericScopeView.categoryView);
63− tryCompare(genericScopeView.categoryView, "contentY", 0)
64 }
63 }
65
64
66 function test_isActive() {
65 function test_isActive() {
@@ -157,7 +156,7 @@ Item {
157 }
156 }
158
157
159 function test_narrow_delegate_ranges_expand() {
158 function test_narrow_delegate_ranges_expand() {
160− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
159+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
161 var category = findChild(genericScopeView, "dashCategory0")
160 var category = findChild(genericScopeView, "dashCategory0")
162 tryCompare(category, "expanded", false);
161 tryCompare(category, "expanded", false);
163
162
@@ -172,6 +171,34 @@ Item {
172 tryCompare(category, "expanded", false);
171 tryCompare(category, "expanded", false);
173 }
172 }
174
173
174+ function test_forced_category_expansion() {
175+ tryCompareFunction(function() {
176+ mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,
177+ genericScopeView.width/2, genericScopeView.y)
178+ return findChild(genericScopeView, "dashCategory19") !== null;
179+ }, true);
180+ var category = findChild(genericScopeView, "dashCategory19")
181+ compare(category.expandable, false, "Category with collapsed-rows: 0 should not be expandable");
182+
183+ var grid = findChild(category, "19");
184+ verify(grid, "Could not find the category renderer.");
185+
186+ compare(grid.height, grid.expandedHeight, "Category with collapsed-rows: 0 should always be expanded.");
187+ }
188+
189+ function test_single_category_expansion() {
190+ genericScopeView.scope = scopes.getScope(4);
191+
192+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
193+ var category = findChild(genericScopeView, "dashCategory0")
194+ compare(category.expandable, false, "Only category should not be expandable.");
195+
196+ var grid = findChild(category, "0");
197+ verify(grid, "Could not find the category renderer.");
198+
199+ compare(grid.height, grid.expandedHeight, "Only category should always be expanded");
200+ }
201+
175 function openPreview() {
202 function openPreview() {
176 tryCompareFunction(function() {
203 tryCompareFunction(function() {
177 var cardGrid = findChild(genericScopeView, "0");
204 var cardGrid = findChild(genericScopeView, "0");