@@ -39,6 +39,10 @@ Item {
3939 id: scopes
4040 }
4141
42+ SignalSpy {
43+ id: spy
44+ }
45+
4246 property Item applicationManager: Item {
4347 signal sideStageFocusedApplicationChanged()
4448 signal mainStageFocusedApplicationChanged()
@@ -59,7 +63,14 @@ Item {
5963 genericScopeView.scope = scopes.getScope(1)
6064 shell.width = units.gu(120)
6165 genericScopeView.categoryView.positionAtBeginning();
62− tryCompare(genericScopeView.categoryView, "contentY", 0)
66+ waitForRendering(genericScopeView.categoryView);
67+ }
68+
69+ function cleanup() {
70+ genericScopeView.scope = null;
71+ spy.clear();
72+ spy.target = null;
73+ spy.signalName = "";
6374 }
6475
6576 function test_isActive() {
@@ -104,90 +115,146 @@ Item {
104115 tryCompare(genericScopeView.scope, "searchQuery", "test")
105116 }
106117
107− function test_filter_expand_collapse() {
108− // wait for the item to be there
109− waitForRendering(genericScopeView);
118+ function test_expand_collapse() {
110119 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != null; }, true);
111120
112− var header = findChild(genericScopeView, "dashSectionHeader0")
113121 var category = findChild(genericScopeView, "dashCategory0")
122+ var seeAll = findChild(category, "seeAll")
114123
115− waitForRendering(header);
124+ waitForRendering(seeAll);
116125 verify(category.expandable);
117− verify(category.filtered);
126+ verify(!category.expanded);
118127
119128 var initialHeight = category.height;
120− var middleHeight;
121− mouseClick(header, header.width / 2, header.height / 2);
122− tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
123− tryCompare(category, "filtered", false);
124− tryCompareFunction(function() { return category.height > middleHeight; }, true);
129+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
130+ verify(category.expanded);
131+ tryCompareFunction(function() { return category.height > initialHeight; }, true);
125132
126− mouseClick(header, header.width / 2, header.height / 2);
127− verify(category.expandable);
128− tryCompare(category, "filtered", true);
133+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
134+ verify(!category.expanded);
129135 }
130136
131− function test_filter_expand_expand_collapse() {
137+ function test_expand_expand_collapse() {
132138 // wait for the item to be there
133139 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != null; }, true);
134140
135141 var categoryListView = findChild(genericScopeView, "categoryListView");
136142 categoryListView.contentY = categoryListView.height;
137143
138− var header2 = findChild(genericScopeView, "dashSectionHeader2")
139144 var category2 = findChild(genericScopeView, "dashCategory2")
140− var category2FilterGrid = category2.children[1].children[2];
141− verify(UT.Util.isInstanceOf(category2FilterGrid, "CardFilterGrid"));
145+ var seeAll2 = findChild(category2, "seeAll")
142146
143− waitForRendering(header2);
147+ waitForRendering(seeAll2);
144148 verify(category2.expandable);
145− verify(category2.filtered);
149+ verify(!category2.expanded);
146150
147− mouseClick(header2, header2.width / 2, header2.height / 2);
148− tryCompare(category2, "filtered", false);
149− tryCompare(category2FilterGrid, "filtered", false);
151+ mouseClick(seeAll2, seeAll2.width / 2, seeAll2.height / 2);
152+ tryCompare(category2, "expanded", true);
150153
151154 categoryListView.positionAtBeginning();
152155
153− var header0 = findChild(genericScopeView, "dashSectionHeader0")
154156 var category0 = findChild(genericScopeView, "dashCategory0")
155− mouseClick(header0, header0.width / 2, header0.height / 2);
156− tryCompare(category0, "filtered", false);
157− tryCompare(category2, "filtered", true);
158− tryCompare(category2FilterGrid, "filtered", true);
159− mouseClick(header0, header0.width / 2, header0.height / 2);
160− tryCompare(category0, "filtered", true);
161− tryCompare(category2, "filtered", true);
157+ var seeAll0 = findChild(category0, "seeAll")
158+ mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
159+ tryCompare(category0, "expanded", true);
160+ tryCompare(category2, "expanded", false);
161+ mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
162+ tryCompare(category0, "expanded", false);
163+ tryCompare(category2, "expanded", false);
164+ }
165+
166+ function test_headerLink() {
167+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader1") != null; }, true);
168+ var header = findChild(genericScopeView, "dashSectionHeader1");
169+
170+ spy.target = genericScopeView.scope;
171+ spy.signalName = "performQuery";
172+
173+ mouseClick(header, header.width / 2, header.height / 2);
174+
175+ spy.wait();
176+ compare(spy.signalArguments[0][0], genericScopeView.scope.categories.data(1, Categories.RoleHeaderLink));
177+ }
178+
179+ function test_headerLink_disable_expansion() {
180+ var categoryListView = findChild(genericScopeView, "categoryListView");
181+ waitForRendering(categoryListView);
182+
183+ categoryListView.contentY = categoryListView.height * 2;
184+
185+ // wait for the item to be there
186+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader4") != null; }, true);
187+
188+ var categoryView = findChild(genericScopeView, "dashCategory4");
189+ verify(categoryView, "Can't find the category view.");
190+
191+ var seeAll = findChild(categoryView, "seeAll");
192+ verify(seeAll, "Can't find the seeAll element");
193+
194+ compare(seeAll.height, 0, "SeeAll should be 0-height.");
195+
196+ openPreview(4, 0);
197+
198+ compare(testCase.previewListView.count, 12, "There should only be 12 items in preview.");
162199 }
163200
164201 function test_narrow_delegate_ranges_expand() {
165− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
202+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
166203 var category = findChild(genericScopeView, "dashCategory0")
167− tryCompare(category, "filtered", true);
204+ tryCompare(category, "expanded", false);
168205
169206 shell.width = units.gu(20)
170207 var categoryListView = findChild(genericScopeView, "categoryListView");
171208 categoryListView.contentY = units.gu(20);
172− var header0 = findChild(genericScopeView, "dashSectionHeader0")
173− mouseClick(header0, header0.width / 2, header0.height / 2);
174− tryCompare(category, "filtered", false);
209+ var seeAll = findChild(category, "seeAll")
210+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
211+ tryCompare(category, "expanded", true);
175212 tryCompareFunction(function() { return category.item.height == genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd; }, true);
176− mouseClick(header0, header0.width / 2, header0.height / 2);
177− tryCompare(category, "filtered", true);
213+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
214+ tryCompare(category, "expanded", false);
215+ }
216+
217+ function test_forced_category_expansion() {
218+ tryCompareFunction(function() {
219+ mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,
220+ genericScopeView.width/2, genericScopeView.y)
221+ return findChild(genericScopeView, "dashCategory19") !== null;
222+ }, true);
223+ var category = findChild(genericScopeView, "dashCategory19")
224+ compare(category.expandable, false, "Category with collapsed-rows: 0 should not be expandable");
225+
226+ var grid = findChild(category, "19");
227+ verify(grid, "Could not find the category renderer.");
228+
229+ compare(grid.height, grid.expandedHeight, "Category with collapsed-rows: 0 should always be expanded.");
230+ }
231+
232+ function test_single_category_expansion() {
233+ genericScopeView.scope = scopes.getScope(4);
234+
235+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
236+ var category = findChild(genericScopeView, "dashCategory0")
237+ compare(category.expandable, false, "Only category should not be expandable.");
238+
239+ var grid = findChild(category, "0");
240+ verify(grid, "Could not find the category renderer.");
241+
242+ compare(grid.height, grid.expandedHeight, "Only category should always be expanded");
178243 }
179244
180− function openPreview() {
245+ function openPreview(category, delegate) {
246+ if (category === undefined) category = 0;
247+ if (delegate === undefined) delegate = 0;
181248 tryCompareFunction(function() {
182− var filterGrid = findChild(genericScopeView, "0");
183− if (filterGrid != null) {
184− var tile = findChild(filterGrid, "delegate0");
249+ var cardGrid = findChild(genericScopeView, category);
250+ if (cardGrid != null) {
251+ var tile = findChild(cardGrid, "delegate"+delegate);
185252 return tile != null;
186253 }
187254 return false;
188255 },
189256 true);
190− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
257+ var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);
191258 mouseClick(tile, tile.width / 2, tile.height / 2);
192259 tryCompare(testCase.previewListView, "open", true);
193260 tryCompare(testCase.previewListView, "x", 0);
@@ -257,7 +324,7 @@ Item {
257324 closePreview();
258325 }
259326
260− function test_haeder_logo() {
327+ function test_header_logo() {
261328 genericScopeView.scope = scopes.getScope(3);
262329
263330 var image = findChild(genericScopeView, "titleImage");