on xenial help sign in
Add tests for auto and forced expansion.
commit79951715d88de76329743d1f535bd780a9a11fe1 authorMichał Sawicz <michal.sawicz@canonical.com> dateFri 11 Jul 2014, 13:45 (12 years ago) parentc01d9ca
7 files changed+42−11
tests/mocks/Unity/fake_categories.cpp+4−1 tests/mocks/Unity/fake_scope.cpp+2−2 tests/mocks/Unity/fake_scope.h+1−1 tests/mocks/Unity/fake_scopes.cpp+1 tests/qmltests/Dash/tst_Dash.qml+1−1 tests/qmltests/Dash/tst_DashContent.qml+4−4 tests/qmltests/Dash/tst_GenericScopeView.qml+29−2
tests/mocks/Unity/fake_categories.cpp+4−1
@@ -145,9 +145,12 @@ Categories::data(const QModelIndex& index, int role) const
145145 } else {
146146 map["category-layout"] = "carousel";
147147 map["card-size"] = "medium";
148− map["collapsed-rows"] = 2;
149148 map["overlay"] = true;
150149 }
150+ if (index.row() == 19) {
151+ map["category-layout"] = "grid";
152+ map["collapsed-rows"] = 0;
153+ }
151154 map["card-size"] = "small";
152155 return map;
153156 }
tests/mocks/Unity/fake_scope.cpp+2−2
@@ -24,7 +24,7 @@ Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
2424{
2525}
2626
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)
2828 : unity::shell::scopes::ScopeInterface(parent)
2929 , m_id(id)
3030 , m_name(name)
@@ -33,7 +33,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
3333 , m_isActive(false)
3434 , m_currentDeparment("root")
3535 , m_previewRendererName("preview-generic")
36− , m_categories(new Categories(20, this))
36+ , m_categories(new Categories(categories, this))
3737{
3838}
3939
tests/mocks/Unity/fake_scope.h+1−1
@@ -30,7 +30,7 @@ class Scope : public unity::shell::scopes::ScopeInterface
3030
3131public:
3232 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);
3434
3535 /* getters */
3636 QString id() const override;
tests/mocks/Unity/fake_scopes.cpp+1
@@ -46,6 +46,7 @@ void Scopes::updateScopes()
4646 addScope(new Scope("MockScope2", "Music", false, this));
4747 addScope(new Scope("clickscope", "Apps", true, this));
4848 addScope(new Scope("MockScope5", "Videos", true, this));
49+ addScope(new Scope("SingleCategoryScope", "Single", true, this, 1));
4950
5051 if (!m_loaded) {
5152 m_loaded = true;
tests/qmltests/Dash/tst_Dash.qml+1−1
@@ -86,7 +86,7 @@ Item {
8686 tryCompare(dashContentList, "count", 0);
8787 scopes.load();
8888 tryCompare(scopes, "loaded", true);
89− tryCompare(dashContentList, "count", 3);
89+ tryCompare(dashContentList, "count", 4);
9090
9191 verify(dashContentList != undefined);
9292 tryCompare(dashContentList, "currentIndex", data.visualIndex);
tests/qmltests/Dash/tst_DashContent.qml+4−4
@@ -115,10 +115,10 @@ Item {
115115 }
116116
117117 function test_show_header_on_list_movement() {
118− var dashContentList = findChild(dashContent, "dashContentList");
119− verify(dashContentList != undefined);
120− var categoryListView = findChild(dashContentList, "categoryListView");
121− verify(categoryListView != undefined);
118+ var scope = findChild(dashContent, "MockScope1 loader");
119+ verify(scope !== null);
120+ var categoryListView = findChild(scope, "categoryListView");
121+ verify(categoryListView !== null);
122122
123123 waitForRendering(categoryListView);
124124
tests/qmltests/Dash/tst_GenericScopeView.qml+29−2
@@ -60,7 +60,6 @@ Item {
6060 shell.width = units.gu(120)
6161 genericScopeView.categoryView.positionAtBeginning();
6262 waitForRendering(genericScopeView.categoryView);
63− tryCompare(genericScopeView.categoryView, "contentY", 0)
6463 }
6564
6665 function test_isActive() {
@@ -157,7 +156,7 @@ Item {
157156 }
158157
159158 function test_narrow_delegate_ranges_expand() {
160− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
159+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
161160 var category = findChild(genericScopeView, "dashCategory0")
162161 tryCompare(category, "expanded", false);
163162
@@ -172,6 +171,34 @@ Item {
172171 tryCompare(category, "expanded", false);
173172 }
174173
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+
175202 function openPreview() {
176203 tryCompareFunction(function() {
177204 var cardGrid = findChild(genericScopeView, "0");