@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818import QtTest 1.0
19−import Unity 0.1
19+import Unity 0.2
2020import ".."
2121import "../../../qml/Dash"
2222import "../../../qml/Components"
@@ -26,7 +26,14 @@ import Unity.Test 0.1 as UT
2626Item {
2727 id: shell
2828 width: units.gu(120)
29− height: units.gu(80)
29+ height: units.gu(100)
30+
31+ // BEGIN To reduce warnings
32+ // TODO I think it we should pass down these variables
33+ // as needed instead of hoping they will be globally around
34+ property var greeter: null
35+ property var panel: null
36+ // BEGIN To reduce warnings
3037
3138 Scopes {
3239 id: scopes
@@ -42,17 +49,18 @@ Item {
4249 }
4350
4451 PageHeaderLabel {
45− id: pageHeader
52+ id: testPageHeader
4653 searchHistory: SearchHistoryModel {}
54+ text: genericScopeView.scope ? genericScopeView.scope.name : ""
55+ width: parent.width
4756 }
4857
4958 GenericScopeView {
5059 id: genericScopeView
5160 anchors.fill: parent
5261 previewListView: previewListView
53− openEffect: openEffect
54− pageHeader: pageHeader
55− tabBarHeight: pageHeader.implicitHeight
62+ pageHeader: testPageHeader
63+ tabBarHeight: testPageHeader.implicitHeight
5664
5765 UT.UnityTestCase {
5866 name: "GenericScopeView"
@@ -66,10 +74,10 @@ Item {
6674
6775 function test_isCurrent() {
6876 genericScopeView.isCurrent = true
69− pageHeader.searchQuery = "test"
77+ testPageHeader.searchQuery = "test"
7078 previewListView.open = true
7179 genericScopeView.isCurrent = false
72− tryCompare(pageHeader, "searchQuery", "")
80+ tryCompare(testPageHeader, "searchQuery", "")
7381 tryCompare(previewListView, "open", false);
7482 }
7583
@@ -87,181 +95,14 @@ Item {
8795
8896 function test_showDash() {
8997 previewListView.open = true;
90− tryCompare(openEffect, "live", true);
9198 scopes.get(2).showDash();
9299 tryCompare(previewListView, "open", false);
93− tryCompare(openEffect, "live", true);
94100 }
95101
96102 function test_hideDash() {
97103 previewListView.open = true;
98104 scopes.get(2).hideDash();
99105 tryCompare(previewListView, "open", false);
100− tryCompare(openEffect, "gap", 0);
101− }
102−
103− function openPreview(filterGridName, willOpen) {
104− if (filterGridName === undefined)
105− filterGridName = "0";
106− if (willOpen === undefined)
107− willOpen = true;
108− tryCompareFunction(function() {
109− var filterGrid = findChild(genericScopeView, filterGridName);
110− if (filterGrid != null) {
111− var tile = findChild(filterGrid, "delegate0");
112− return tile != null;
113− }
114− return false;
115− },
116− true);
117− var tile = findChild(findChild(genericScopeView, filterGridName), "delegate0");
118− mouseClick(tile, tile.width / 2, tile.height / 2);
119− tryCompare(previewListView, "open", willOpen);
120− tryCompare(openEffect, "gap", willOpen ? 1 : 0);
121− }
122−
123− function checkArrowPosition(index) {
124− tryCompareFunction(function() {
125− var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
126− return tile != null;
127− },
128− true);
129− var tile = findChild(findChild(genericScopeView, "0"), "delegate" + index);
130− var tileCenter = tile.x + tile.width/2;
131− var pointerArrow = findChild(previewListView, "pointerArrow");
132− var pointerArrowCenter = pointerArrow.x + pointerArrow.width/2;
133− compare(pointerArrowCenter, tileCenter, "Pointer did not move to tile");
134− }
135−
136− function closePreview() {
137− var closePreviewMouseArea = findChild(genericScopeView, "closePreviewMouseArea");
138− mouseClick(closePreviewMouseArea, closePreviewMouseArea.width / 2, closePreviewMouseArea.height / 2);
139−
140− tryCompare(previewListView, "open", false);
141− tryCompare(openEffect, "gap", 0);
142−
143− var categoryListView = findChild(genericScopeView, "categoryListView");
144− categoryListView.flick(0, units.gu(200));
145− tryCompare(categoryListView, "flicking", false);
146− }
147−
148− function test_previewOpenClose() {
149− tryCompare(previewListView, "open", false);
150− var categoryListView = findChild(genericScopeView, "categoryListView");
151− categoryListView.positionAtBeginning();
152−
153− openPreview();
154−
155− // check for it opening successfully
156− var currentPreviewItem = findChild(previewListView, "previewLoader0");
157− tryCompareFunction(function() {
158− var parts = currentPreviewItem.source.toString().split("/");
159− var name = parts[parts.length - 1];
160− return name == "DashPreviewPlaceholder.qml";
161− },
162− true);
163− tryCompareFunction(function() {
164− var parts = currentPreviewItem.source.toString().split("/");
165− var name = parts[parts.length - 1];
166− return name == "GenericPreview.qml";
167− },
168− true);
169− tryCompare(currentPreviewItem, "progress", 1);
170− tryCompare(previewListView, "open", true);
171−
172− closePreview();
173− tryCompare(previewListView, "open", false);
174− }
175−
176− function test_hiddenPreviewOpen() {
177− var categoryListView = findChild(genericScopeView, "categoryListView");
178− categoryListView.positionAtBeginning();
179− waitForRendering(categoryListView);
180− categoryListView.flick(0, -units.gu(60));
181− tryCompare(categoryListView.flicking, false);
182−
183− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
184− mouseClick(tile, tile.width / 2, tile.height - 1);
185− tryCompare(openEffect, "gap", 1);
186−
187− verify(openEffect.positionPx >= pageHeader.height + categoryListView.stickyHeaderHeight);
188− }
189−
190− function test_previewCycle() {
191− var categoryListView = findChild(genericScopeView, "categoryListView");
192− categoryListView.positionAtBeginning();
193−
194− tryCompare(previewListView, "open", false);
195− tryCompare(openEffect, "gap", 0);
196−
197− openPreview();
198−
199− // wait for it to be loaded
200− var currentPreviewItem = findChild(previewListView, "previewLoader0");
201− tryCompareFunction(function() {
202− var parts = currentPreviewItem.source.toString().split("/");
203− var name = parts[parts.length - 1];
204− return name == "GenericPreview.qml";
205− },
206− true);
207− tryCompare(currentPreviewItem, "progress", 1);
208− waitForRendering(currentPreviewItem);
209−
210− checkArrowPosition(0);
211−
212− // flick to the next previews
213− tryCompare(previewListView, "count", 15);
214− for (var i = 1; i < previewListView.count; ++i) {
215−
216− mouseFlick(previewListView, previewListView.width - units.gu(1),
217− previewListView.height / 2,
218− units.gu(2),
219− previewListView.height / 2);
220−
221− // wait for it to be loaded
222− var nextPreviewItem = findChild(previewListView, "previewLoader" + i);
223− tryCompareFunction(function() {
224− var parts = nextPreviewItem.source.toString().split("/");
225− var name = parts[parts.length - 1];
226− return name == "GenericPreview.qml";
227− },
228− true);
229− tryCompare(nextPreviewItem, "progress", 1);
230− waitForRendering(nextPreviewItem);
231− tryCompareFunction(function() {return nextPreviewItem.item !== null}, true);
232−
233− checkArrowPosition(i);
234−
235− // Make sure only the new one has isCurrent set to true
236− compare(nextPreviewItem.item.isCurrent, true);
237−
238− if (currentPreviewItem.item !== undefined && currentPreviewItem.item !== null) {
239− compare(currentPreviewItem.item.isCurrent, false);
240− }
241−
242− currentPreviewItem = nextPreviewItem;
243− }
244− closePreview();
245− }
246−
247− function test_show_spinner() {
248− var categoryListView = findChild(genericScopeView, "categoryListView");
249− waitForRendering(categoryListView);
250− categoryListView.contentY = units.gu(13);
251− openPreview();
252− var previewLoader = findChild(previewListView, "previewLoader0");
253− compare(previewLoader.source.toString().split("/").pop(), "DashPreviewPlaceholder.qml");
254− compare(categoryListView.contentY, 0)
255− tryCompare(previewLoader, "progress", 1.0);
256− tryCompareFunction(function() { return previewLoader.item != undefined; }, true);
257−
258− previewLoader.item.showProcessingAction = true;
259− var waitingForAction = findChild(previewListView, "waitingForActionMouseArea");
260− tryCompare(waitingForAction, "enabled", true);
261− previewLoader.closePreviewSpinner();
262− tryCompare(waitingForAction, "enabled", false);
263−
264− closePreview();
265106 }
266107
267108 function test_changeScope() {
@@ -309,44 +150,17 @@ Item {
309150 compare(renderer, "CardFilterGrid.qml")
310151 }
311152
312− function test_showPreviewCarousel() {
313− tryCompareFunction(function() { return findChild(genericScopeView, "carouselDelegate") != null; }, true);
314− var tile = findChild(genericScopeView, "carouselDelegate");
315− mouseClick(tile, tile.width / 2, tile.height / 2);
316− tryCompare(openEffect, "gap", 1);
317−
318− // check for it opening successfully
319− var currentPreviewItem = findChild(previewListView, "previewLoader0");
320− tryCompareFunction(function() {
321− var parts = currentPreviewItem.source.toString().split("/");
322− var name = parts[parts.length - 1];
323− return name == "DashPreviewPlaceholder.qml";
324− },
325− true);
326− tryCompareFunction(function() {
327− var parts = currentPreviewItem.source.toString().split("/");
328− var name = parts[parts.length - 1];
329− return name == "GenericPreview.qml";
330− },
331− true);
332− tryCompare(currentPreviewItem, "progress", 1);
333− tryCompare(previewListView, "open", true);
334−
335− closePreview();
336− tryCompare(previewListView, "open", false);
337− }
338−
339153 function test_filter_expand_expand_collapse() {
340154 // wait for the item to be there
341− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeaderapplications.scope") != null; }, true);
155+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != null; }, true);
342156
343157 var categoryListView = findChild(genericScopeView, "categoryListView");
344158 categoryListView.contentY = categoryListView.height;
345159
346− var header2 = findChild(genericScopeView, "dashSectionHeaderapplications.scope")
347− var category2 = findChild(genericScopeView, "dashCategoryapplications.scope")
348− var category2FilterGrid = category2.children[0].children[0].children[0];
349− verify(UT.Util.isInstanceOf(category2FilterGrid, "FilterGrid"));
160+ var header2 = findChild(genericScopeView, "dashSectionHeader2")
161+ var category2 = findChild(genericScopeView, "dashCategory2")
162+ var category2FilterGrid = category2.children[0].children[0];
163+ verify(UT.Util.isInstanceOf(category2FilterGrid, "DashFilterGrid"));
350164
351165 waitForRendering(header2);
352166 verify(category2.expandable);
@@ -362,7 +176,7 @@ Item {
362176 tryCompareFunction(
363177 function() {
364178 var header0 = findChild(genericScopeView, "dashSectionHeader0")
365− return header0.y == pageHeader.height;
179+ return header0.y == testPageHeader.height;
366180 },
367181 true);
368182
@@ -377,21 +191,6 @@ Item {
377191 tryCompare(category2, "filtered", true);
378192 }
379193
380− function test_bug1271676_no_move_y_no_preview() {
381− waitForRendering(genericScopeView);
382− var categoryListView = findChild(genericScopeView, "categoryListView");
383− waitForRendering(categoryListView);
384− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategoryapplications.scope") != null; }, true);
385− var category = findChild(genericScopeView, "dashCategoryapplications.scope")
386− categoryListView.contentY = category.y;
387− waitForRendering(categoryListView);
388− var contentYBefore = categoryListView.contentY
389− openPreview("applications.scope", false); // This actually doesn't open anything because we
390− // have code so that the item of installed
391− // does activate instead of preview and never shows a preview
392− compare(categoryListView.contentY, contentYBefore);
393− }
394−
395194 function test_narrow_delegate_ranges_expand() {
396195 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
397196 var category = findChild(genericScopeView, "dashCategory0")
@@ -413,8 +212,8 @@ Item {
413212 PreviewListView {
414213 id: previewListView
415214 anchors.fill: parent
416− openEffect: openEffect
417− categoryView: genericScopeView.categoryView
215+ visible: false
216+ pageHeader: testPageHeader
418217 scope: genericScopeView.scope
419218 }
420219}