@@ -48,16 +48,17 @@ Item {
4848 signal mainStageFocusedApplicationChanged()
4949 }
5050
51−
5251 GenericScopeView {
5352 id: genericScopeView
5453 anchors.fill: parent
55− previewListView: previewListView
5654
5755 UT.UnityTestCase {
56+ id: testCase
5857 name: "GenericScopeView"
5958 when: scopes.loaded && windowShown
6059
60+ property Item previewListView: findChild(genericScopeView, "previewListView")
61+
6162 function init() {
6263 genericScopeView.scope = scopes.getScope(2)
6364 shell.width = units.gu(120)
@@ -69,24 +70,24 @@ Item {
6970 tryCompare(genericScopeView.scope, "isActive", false)
7071 genericScopeView.isCurrent = true
7172 tryCompare(genericScopeView.scope, "isActive", true)
72− previewListView.open = true
73+ testCase.previewListView.open = true
7374 tryCompare(genericScopeView.scope, "isActive", false)
74− previewListView.open = false
75+ testCase.previewListView.open = false
7576 tryCompare(genericScopeView.scope, "isActive", true)
7677 genericScopeView.isCurrent = false
7778 tryCompare(genericScopeView.scope, "isActive", false)
7879 }
7980
8081 function test_showDash() {
81− previewListView.open = true;
82+ testCase.previewListView.open = true;
8283 scopes.getScope(2).showDash();
83− tryCompare(previewListView, "open", false);
84+ tryCompare(testCase.previewListView, "open", false);
8485 }
8586
8687 function test_hideDash() {
87− previewListView.open = true;
88+ testCase.previewListView.open = true;
8889 scopes.getScope(2).hideDash();
89− tryCompare(previewListView, "open", false);
90+ tryCompare(testCase.previewListView, "open", false);
9091 }
9192
9293 function test_searchQuery() {
@@ -179,13 +180,86 @@ Item {
179180 mouseClick(header0, header0.width / 2, header0.height / 2);
180181 tryCompare(category, "filtered", true);
181182 }
182− }
183− }
184183
185− PreviewListView {
186− id: previewListView
187− anchors.fill: parent
188− visible: false
189− scope: genericScopeView.scope
184+ function openPreview() {
185+ tryCompareFunction(function() {
186+ var filterGrid = findChild(genericScopeView, "0");
187+ if (filterGrid != null) {
188+ var tile = findChild(filterGrid, "delegate0");
189+ return tile != null;
190+ }
191+ return false;
192+ },
193+ true);
194+ var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
195+ mouseClick(tile, tile.width / 2, tile.height / 2);
196+ tryCompare(testCase.previewListView, "open", true);
197+ tryCompare(testCase.previewListView, "x", 0);
198+ }
199+
200+ function closePreview() {
201+ var closePreviewMouseArea = findChild(genericScopeView, "innerPageHeader");
202+ mouseClick(closePreviewMouseArea, units.gu(2), units.gu(2));
203+
204+ tryCompare(testCase.previewListView, "open", false);
205+ }
206+
207+ function test_previewOpenClose() {
208+ tryCompare(testCase.previewListView, "open", false);
209+
210+ var categoryListView = findChild(genericScopeView, "categoryListView");
211+ categoryListView.positionAtBeginning();
212+
213+ openPreview();
214+ closePreview();
215+ }
216+
217+ function test_showPreviewCarousel() {
218+ tryCompareFunction(function() {
219+ var dashCategory1 = findChild(genericScopeView, "dashCategory1");
220+ if (dashCategory1 != null) {
221+ var tile = findChild(dashCategory1, "carouselDelegate1");
222+ return tile != null;
223+ }
224+ return false;
225+ },
226+ true);
227+
228+ tryCompare(testCase.previewListView, "open", false);
229+
230+ var dashCategory1 = findChild(genericScopeView, "dashCategory1");
231+ var tile = findChild(dashCategory1, "carouselDelegate1");
232+ mouseClick(tile, tile.width / 2, tile.height / 2);
233+ tryCompare(tile, "explicitlyScaled", true);
234+ mouseClick(tile, tile.width / 2, tile.height / 2);
235+ tryCompare(testCase.previewListView, "open", true);
236+ tryCompare(testCase.previewListView, "x", 0);
237+
238+ closePreview();
239+ }
240+
241+ function test_previewCycle() {
242+ var categoryListView = findChild(genericScopeView, "categoryListView");
243+ categoryListView.positionAtBeginning();
244+
245+ tryCompare(testCase.previewListView, "open", false);
246+ var previewListViewList = findChild(previewListView, "listView");
247+
248+ openPreview();
249+
250+ // flick to the next previews
251+ tryCompare(testCase.previewListView, "count", 15);
252+ for (var i = 1; i < testCase.previewListView.count; ++i) {
253+ mouseFlick(testCase.previewListView, testCase.previewListView.width - units.gu(1),
254+ testCase.previewListView.height / 2,
255+ units.gu(2),
256+ testCase.previewListView.height / 2);
257+ tryCompare(previewListViewList, "moving", false);
258+ tryCompare(testCase.previewListView.currentItem, "objectName", "previewItem" + i);
259+
260+ }
261+ closePreview();
262+ }
263+ }
190264 }
191265}