@@ -44,16 +44,17 @@ Item {
4444 signal mainStageFocusedApplicationChanged()
4545 }
4646
47−
4847 GenericScopeView {
4948 id: genericScopeView
5049 anchors.fill: parent
51− previewListView: previewListView
5250
5351 UT.UnityTestCase {
52+ id: testCase
5453 name: "GenericScopeView"
5554 when: scopes.loaded && windowShown
5655
56+ property Item previewListView: findChild(genericScopeView, "previewListView")
57+
5758 function init() {
5859 genericScopeView.scope = scopes.getScope(2)
5960 shell.width = units.gu(120)
@@ -65,24 +66,24 @@ Item {
6566 tryCompare(genericScopeView.scope, "isActive", false)
6667 genericScopeView.isCurrent = true
6768 tryCompare(genericScopeView.scope, "isActive", true)
68− previewListView.open = true
69+ testCase.previewListView.open = true
6970 tryCompare(genericScopeView.scope, "isActive", false)
70− previewListView.open = false
71+ testCase.previewListView.open = false
7172 tryCompare(genericScopeView.scope, "isActive", true)
7273 genericScopeView.isCurrent = false
7374 tryCompare(genericScopeView.scope, "isActive", false)
7475 }
7576
7677 function test_showDash() {
77− previewListView.open = true;
78+ testCase.previewListView.open = true;
7879 scopes.getScope(2).showDash();
79− tryCompare(previewListView, "open", false);
80+ tryCompare(testCase.previewListView, "open", false);
8081 }
8182
8283 function test_hideDash() {
83− previewListView.open = true;
84+ testCase.previewListView.open = true;
8485 scopes.getScope(2).hideDash();
85− tryCompare(previewListView, "open", false);
86+ tryCompare(testCase.previewListView, "open", false);
8687 }
8788
8889 function test_searchQuery() {
@@ -176,20 +177,94 @@ Item {
176177 tryCompare(category, "filtered", true);
177178 }
178179
180+ function openPreview() {
181+ tryCompareFunction(function() {
182+ var filterGrid = findChild(genericScopeView, "0");
183+ if (filterGrid != null) {
184+ var tile = findChild(filterGrid, "delegate0");
185+ return tile != null;
186+ }
187+ return false;
188+ },
189+ true);
190+ var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
191+ mouseClick(tile, tile.width / 2, tile.height / 2);
192+ tryCompare(testCase.previewListView, "open", true);
193+ tryCompare(testCase.previewListView, "x", 0);
194+ }
195+
196+ function closePreview() {
197+ var closePreviewMouseArea = findChild(genericScopeView, "pageHeader");
198+ mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
199+
200+ tryCompare(testCase.previewListView, "open", false);
201+ }
202+
203+ function test_previewOpenClose() {
204+ tryCompare(testCase.previewListView, "open", false);
205+
206+ var categoryListView = findChild(genericScopeView, "categoryListView");
207+ categoryListView.positionAtBeginning();
208+
209+ openPreview();
210+ closePreview();
211+ }
212+
213+ function test_showPreviewCarousel() {
214+ tryCompareFunction(function() {
215+ var dashCategory1 = findChild(genericScopeView, "dashCategory1");
216+ if (dashCategory1 != null) {
217+ var tile = findChild(dashCategory1, "carouselDelegate1");
218+ return tile != null;
219+ }
220+ return false;
221+ },
222+ true);
223+
224+ tryCompare(testCase.previewListView, "open", false);
225+
226+ var dashCategory1 = findChild(genericScopeView, "dashCategory1");
227+ var tile = findChild(dashCategory1, "carouselDelegate1");
228+ mouseClick(tile, tile.width / 2, tile.height / 2);
229+ tryCompare(tile, "explicitlyScaled", true);
230+ mouseClick(tile, tile.width / 2, tile.height / 2);
231+ tryCompare(testCase.previewListView, "open", true);
232+ tryCompare(testCase.previewListView, "x", 0);
233+
234+ closePreview();
235+ }
236+
237+ function test_previewCycle() {
238+ var categoryListView = findChild(genericScopeView, "categoryListView");
239+ categoryListView.positionAtBeginning();
240+
241+ tryCompare(testCase.previewListView, "open", false);
242+ var previewListViewList = findChild(previewListView, "listView");
243+
244+ openPreview();
245+
246+ // flick to the next previews
247+ tryCompare(testCase.previewListView, "count", 15);
248+ for (var i = 1; i < testCase.previewListView.count; ++i) {
249+ mouseFlick(testCase.previewListView, testCase.previewListView.width - units.gu(1),
250+ testCase.previewListView.height / 2,
251+ units.gu(2),
252+ testCase.previewListView.height / 2);
253+ tryCompare(previewListViewList, "moving", false);
254+ tryCompare(testCase.previewListView.currentItem, "objectName", "previewItem" + i);
255+
256+ }
257+ closePreview();
258+ }
259+
179260 function test_haeder_logo() {
180261 genericScopeView.scope = scopes.getScope(3);
181262
182263 var image = findChild(genericScopeView, "titleImage");
183264 verify(image, "Could not find the title image");
184265 compare(image.source, Qt.resolvedUrl("../Components/tst_PageHeader/logo-ubuntu-orange.svg"), "Title image has the wrong source");
266+
185267 }
186268 }
187269 }
188−
189− PreviewListView {
190− id: previewListView
191− anchors.fill: parent
192− visible: false
193− scope: genericScopeView.scope
194− }
195270}