@@ -39,6 +39,10 @@ Item {
39 id: scopes
39 id: scopes
42 property Item applicationManager: Item {
46 property Item applicationManager: Item {
43 signal sideStageFocusedApplicationChanged()
47 signal sideStageFocusedApplicationChanged()
44 signal mainStageFocusedApplicationChanged()
48 signal mainStageFocusedApplicationChanged()
@@ -54,12 +58,20 @@ Item {
54 when: scopes.loaded && windowShown
58 when: scopes.loaded && windowShown
56 property Item previewListView: findChild(genericScopeView, "previewListView")
60 property Item previewListView: findChild(genericScopeView, "previewListView")
61+ property Item header: findChild(genericScopeView, "scopePageHeader")
58 function init() {
63 function init() {
59 genericScopeView.scope = scopes.getScope(1)
64 genericScopeView.scope = scopes.getScope(1)
60 shell.width = units.gu(120)
65 shell.width = units.gu(120)
61 genericScopeView.categoryView.positionAtBeginning();
66 genericScopeView.categoryView.positionAtBeginning();
62− tryCompare(genericScopeView.categoryView, "contentY", 0)
67+ waitForRendering(genericScopeView.categoryView);
71+ genericScopeView.scope = null;
65 function test_isActive() {
77 function test_isActive() {
@@ -104,90 +116,146 @@ Item {
104 tryCompare(genericScopeView.scope, "searchQuery", "test")
116 tryCompare(genericScopeView.scope, "searchQuery", "test")
107− function test_filter_expand_collapse() {
119+ function test_expand_collapse() {
108− // wait for the item to be there
109− waitForRendering(genericScopeView);
110 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != null; }, true);
120 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != null; }, true);
112− var header = findChild(genericScopeView, "dashSectionHeader0")
113 var category = findChild(genericScopeView, "dashCategory0")
122 var category = findChild(genericScopeView, "dashCategory0")
123+ var seeAll = findChild(category, "seeAll")
115− waitForRendering(header);
125+ waitForRendering(seeAll);
116 verify(category.expandable);
126 verify(category.expandable);
117− verify(category.filtered);
127+ verify(!category.expanded);
119 var initialHeight = category.height;
129 var initialHeight = category.height;
121− mouseClick(header, header.width / 2, header.height / 2);
130+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
131+ verify(category.expanded);
122− tryCompareFunction(function() { middleHeight = category.height; return category.height > initialHeight; }, true);
132+ tryCompareFunction(function() { return category.height > initialHeight; }, true);
123− tryCompare(category, "filtered", false);
124− tryCompareFunction(function() { return category.height > middleHeight; }, true);
126− mouseClick(header, header.width / 2, header.height / 2);
134+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
127− verify(category.expandable);
135+ verify(!category.expanded);
128− tryCompare(category, "filtered", true);
131− function test_filter_expand_expand_collapse() {
138+ function test_expand_expand_collapse() {
132 // wait for the item to be there
139 // wait for the item to be there
133 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != null; }, true);
140 tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != null; }, true);
135 var categoryListView = findChild(genericScopeView, "categoryListView");
142 var categoryListView = findChild(genericScopeView, "categoryListView");
136 categoryListView.contentY = categoryListView.height;
143 categoryListView.contentY = categoryListView.height;
138− var header2 = findChild(genericScopeView, "dashSectionHeader2")
139 var category2 = findChild(genericScopeView, "dashCategory2")
145 var category2 = findChild(genericScopeView, "dashCategory2")
140− var category2FilterGrid = category2.children[1].children[2];
146+ var seeAll2 = findChild(category2, "seeAll")
141− verify(UT.Util.isInstanceOf(category2FilterGrid, "CardFilterGrid"));
143− waitForRendering(header2);
148+ waitForRendering(seeAll2);
144 verify(category2.expandable);
149 verify(category2.expandable);
145− verify(category2.filtered);
150+ verify(!category2.expanded);
147− mouseClick(header2, header2.width / 2, header2.height / 2);
152+ mouseClick(seeAll2, seeAll2.width / 2, seeAll2.height / 2);
148− tryCompare(category2, "filtered", false);
153+ tryCompare(category2, "expanded", true);
149− tryCompare(category2FilterGrid, "filtered", false);
151 categoryListView.positionAtBeginning();
155 categoryListView.positionAtBeginning();
153− var header0 = findChild(genericScopeView, "dashSectionHeader0")
154 var category0 = findChild(genericScopeView, "dashCategory0")
157 var category0 = findChild(genericScopeView, "dashCategory0")
158+ var seeAll0 = findChild(category0, "seeAll")
155− mouseClick(header0, header0.width / 2, header0.height / 2);
159+ mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
156− tryCompare(category0, "filtered", false);
160+ tryCompare(category0, "expanded", true);
157− tryCompare(category2, "filtered", true);
161+ tryCompare(category2, "expanded", false);
158− tryCompare(category2FilterGrid, "filtered", true);
162+ mouseClick(seeAll0, seeAll0.width / 2, seeAll0.height / 2);
163+ tryCompare(category0, "expanded", false);
164+ tryCompare(category2, "expanded", false);
167+ function test_headerLink() {
168+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader1") != null; }, true);
169+ var header = findChild(genericScopeView, "dashSectionHeader1");
171+ spy.target = genericScopeView.scope;
172+ spy.signalName = "performQuery";
159− mouseClick(header0, header0.width / 2, header0.height / 2);
174+ mouseClick(header, header.width / 2, header.height / 2);
160− tryCompare(category0, "filtered", true);
175+
161− tryCompare(category2, "filtered", true);
176+ spy.wait();
177+ compare(spy.signalArguments[0][0], genericScopeView.scope.categories.data(1, Categories.RoleHeaderLink));
180+ function test_headerLink_disable_expansion() {
181+ var categoryListView = findChild(genericScopeView, "categoryListView");
182+ waitForRendering(categoryListView);
184+ categoryListView.contentY = categoryListView.height * 2;
186+ // wait for the item to be there
187+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader4") != null; }, true);
189+ var categoryView = findChild(genericScopeView, "dashCategory4");
190+ verify(categoryView, "Can't find the category view.");
192+ var seeAll = findChild(categoryView, "seeAll");
193+ verify(seeAll, "Can't find the seeAll element");
195+ compare(seeAll.height, 0, "SeeAll should be 0-height.");
199+ compare(testCase.previewListView.count, 12, "There should only be 12 items in preview.");
164 function test_narrow_delegate_ranges_expand() {
202 function test_narrow_delegate_ranges_expand() {
165− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
203+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
166 var category = findChild(genericScopeView, "dashCategory0")
204 var category = findChild(genericScopeView, "dashCategory0")
167− tryCompare(category, "filtered", true);
205+ tryCompare(category, "expanded", false);
169 shell.width = units.gu(20)
207 shell.width = units.gu(20)
170 var categoryListView = findChild(genericScopeView, "categoryListView");
208 var categoryListView = findChild(genericScopeView, "categoryListView");
171 categoryListView.contentY = units.gu(20);
209 categoryListView.contentY = units.gu(20);
172− var header0 = findChild(genericScopeView, "dashSectionHeader0")
210+ var seeAll = findChild(category, "seeAll")
173− mouseClick(header0, header0.width / 2, header0.height / 2);
211+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
174− tryCompare(category, "filtered", false);
212+ tryCompare(category, "expanded", true);
175 tryCompareFunction(function() { return category.item.height == genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd; }, true);
213 tryCompareFunction(function() { return category.item.height == genericScopeView.height - category.item.displayMarginBeginning - category.item.displayMarginEnd; }, true);
176− mouseClick(header0, header0.width / 2, header0.height / 2);
214+ mouseClick(seeAll, seeAll.width / 2, seeAll.height / 2);
177− tryCompare(category, "filtered", true);
215+ tryCompare(category, "expanded", false);
218+ function test_forced_category_expansion() {
219+ tryCompareFunction(function() {
220+ mouseFlick(genericScopeView, genericScopeView.width/2, genericScopeView.height,
221+ genericScopeView.width/2, genericScopeView.y)
222+ return findChild(genericScopeView, "dashCategory19") !== null;
224+ var category = findChild(genericScopeView, "dashCategory19")
225+ compare(category.expandable, false, "Category with collapsed-rows: 0 should not be expandable");
227+ var grid = findChild(category, "19");
228+ verify(grid, "Could not find the category renderer.");
230+ compare(grid.height, grid.expandedHeight, "Category with collapsed-rows: 0 should always be expanded.");
233+ function test_single_category_expansion() {
234+ genericScopeView.scope = scopes.getScope(4);
236+ tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
237+ var category = findChild(genericScopeView, "dashCategory0")
238+ compare(category.expandable, false, "Only category should not be expandable.");
240+ var grid = findChild(category, "0");
241+ verify(grid, "Could not find the category renderer.");
243+ compare(grid.height, grid.expandedHeight, "Only category should always be expanded");
180− function openPreview() {
246+ function openPreview(category, delegate) {
247+ if (category === undefined) category = 0;
248+ if (delegate === undefined) delegate = 0;
181 tryCompareFunction(function() {
249 tryCompareFunction(function() {
182− var filterGrid = findChild(genericScopeView, "0");
250+ var cardGrid = findChild(genericScopeView, category);
183− if (filterGrid != null) {
251+ if (cardGrid != null) {
184− var tile = findChild(filterGrid, "delegate0");
252+ var tile = findChild(cardGrid, "delegate"+delegate);
185 return tile != null;
253 return tile != null;
187 return false;
255 return false;
190− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
258+ var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);
191 mouseClick(tile, tile.width / 2, tile.height / 2);
259 mouseClick(tile, tile.width / 2, tile.height / 2);
192 tryCompare(testCase.previewListView, "open", true);
260 tryCompare(testCase.previewListView, "open", true);
193 tryCompare(testCase.previewListView, "x", 0);
261 tryCompare(testCase.previewListView, "x", 0);
@@ -257,13 +325,33 @@ Item {
257 closePreview();
325 closePreview();
260− function test_haeder_logo() {
328+ function test_header_style_data() {
261− genericScopeView.scope = scopes.getScope(3);
329+ return [
330+ { tag: "Default", index: 0, foreground: "grey", background: "", logo: "" },
331+ { tag: "Foreground", index: 2, foreground: "yellow", background: "", logo: "" },
332+ { tag: "Logo+Background", index: 3, foreground: "grey", background: "gradient:///lightgrey/grey",
333+ logo: Qt.resolvedUrl("../Components/tst_PageHeader/logo-ubuntu-orange.svg") },
263− var image = findChild(genericScopeView, "titleImage");
337+ function test_header_style(data) {
338+ genericScopeView.scope = scopes.getScope(data.index);
339+ waitForRendering(genericScopeView);
340+ verify(header, "Could not find the header.");
342+ var innerHeader = findChild(header, "innerPageHeader");
264− verify(image, "Could not find the title image");
343+ verify(innerHeader, "Could not find the inner header");
265− compare(image.source, Qt.resolvedUrl("../Components/tst_PageHeader/logo-ubuntu-orange.svg"), "Title image has the wrong source");
344+ verify(Qt.colorEqual(innerHeader.textColor, data.foreground),
345+ "Foreground color not equal: %1 != %2".arg(innerHeader.textColor).arg(data.foreground));
347+ var background = findChild(header, "headerBackground");
348+ verify(background, "Could not find the background");
349+ compare(background.style, data.background);
351+ var image = findChild(genericScopeView, "titleImage");
352+ if (data.logo == "") expectFail(data.tag, "Title image should not exist.");
353+ verify(image, "Could not find the title image.");
354+ compare(image.source, data.logo, "Title image has the wrong source");