@@ -57,6 +57,11 @@ Item {
5757 signalName: "sessionStarted"
5858 }
5959
60+ SignalSpy {
61+ id: dashCommunicatorSpy
62+ signalName: "setCurrentScopeCalled"
63+ }
64+
6065 Telephony.CallEntry {
6166 id: phoneCall
6267 phoneNumber: "+447812221111"
@@ -67,44 +72,10 @@ Item {
6772 when: windowShown
6873
6974 function initTestCase() {
70− var ok = false;
71− var attempts = 0;
72− var maxAttempts = 1000;
73−
74− // Qt loads a qml scene asynchronously. So early on, some findChild() calls made in
75− // tests may fail because the desired child item wasn't loaded yet.
76− // Thus here we try to ensure the scene has been fully loaded before proceeding with the tests.
77− // As I couldn't find an API in QQuickView & friends to tell me that the scene is 100% loaded
78− // (all items instantiated, etc), I resort to checking the existence of some key items until
79− // repeatedly until they're all there.
80− do {
81− var dashContentList = findChild(shell, "dashContentList");
82− waitForRendering(dashContentList);
83− var homeLoader = findChild(dashContentList, "clickscope loader");
84− ok = homeLoader !== null
85− && homeLoader.item !== undefined;
86−
87− var greeter = findChild(shell, "greeter");
88− ok &= greeter !== null;
89−
90− var launcherPanel = findChild(shell, "launcherPanel");
91− ok &= launcherPanel !== null;
92−
93− attempts++;
94− if (!ok) {
95− console.log("Attempt " + attempts + " failed. Waiting a bit before trying again.");
96− // wait a bit before retrying
97− wait(100);
98− } else {
99− console.log("All seem fine after " + attempts + " attempts.");
100− }
101− } while (!ok && attempts <= maxAttempts);
102−
103− verify(ok);
104−
10575 swipeAwayGreeter();
10676
10777 sessionSpy.target = findChild(shell, "greeter")
78+ dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
10879 }
10980
11081 function cleanup() {
@@ -117,56 +88,16 @@ Item {
11788 // kill all (fake) running apps
11889 killApps(ApplicationManager);
11990
120− var dashContent = findChild(shell, "dashContent");
121− dashContent.closePreview();
122−
123− var dashHome = findChild(shell, "clickscope loader");
124− swipeUntilScopeViewIsReached(dashHome);
125−
91+ waitForUIToSettle();
12692 hideIndicators();
12793 }
12894
129− function killApps(apps) {
130− if (!apps) return;
131− while (apps.count > 0) {
132− ApplicationManager.stopApplication(apps.get(0).appId);
95+ function killApps() {
96+ while (ApplicationManager.count > 1) {
97+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
98+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
13399 }
134− compare(ApplicationManager.count, 0)
135− }
136−
137− /*
138− Test the effect of a right-edge drag on the dash in 3 situations:
139− 1 - when no application has been launched yet
140− 2 - when there's a minimized application
141− 3 - after the last running application has been closed/stopped
142−
143− The behavior of Dash on 3 should be the same as on 1.
144− */
145− function test_rightEdgeDrag() {
146− checkRightEdgeDragWithNoRunningApps();
147−
148− dragLauncherIntoView();
149−
150− // Launch an app from the launcher
151− tapOnAppIconInLauncher();
152− waitUntilApplicationWindowIsFullyVisible();
153−
154− // Minimize the application we just launched
155− swipeFromLeftEdge(units.gu(27));
156−
157− waitForUIToSettle();
158−
159− checkRightEdgeDragWithMinimizedApp();
160−
161− // Minimize that application once again
162− swipeFromLeftEdge(units.gu(27));
163−
164− // Right edge behavior should now be the same as before that app,
165− // was launched. Manually cleanup beforehand to get to initial
166− // state.
167− cleanup();
168− waitForUIToSettle();
169− checkRightEdgeDragWithNoRunningApps();
100+ compare(ApplicationManager.count, 1)
170101 }
171102
172103 function test_leftEdgeDrag_data() {
@@ -189,7 +120,7 @@ Item {
189120
190121 swipeFromLeftEdge(data.swipeLength);
191122 if (data.appHides)
192− waitUntilApplicationWindowIsFullyHidden();
123+ waitUntilDashIsFocused();
193124 else
194125 waitUntilApplicationWindowIsFullyVisible();
195126 }
@@ -244,100 +175,18 @@ Item {
244175 waitForRendering(greeter);
245176 }
246177
247− /*
248− Perform a right-edge drag when the Dash is being show and there are
249− no running/minimized apps to be restored.
250−
251− The expected behavior is that an animation should be played to hint the
252− user that his right-edge drag gesture has been successfully recognized
253− but there is no application to be brought to foreground.
254− */
255− function checkRightEdgeDragWithNoRunningApps() {
256− var touchX = shell.width - (shell.edgeSize / 2);
257− var touchY = shell.height / 2;
258−
259− var dash = findChild(shell, "dash");
260− // check that dash has normal scale and opacity
261− tryCompare(dash, "contentScale", 1.0);
262− tryCompare(dash, "opacity", 1.0);
263−
264− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
265− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
266−
267− // check that Dash has been scaled down and had its opacity reduced
268− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
269− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
270−
271− touchRelease(shell, shell.width * 0.1, touchY);
272−
273− // and now everything should have gone back to normal
274− tryCompare(dash, "contentScale", 1.0);
275− tryCompare(dash, "opacity", 1.0);
276− }
277−
278− /*
279− Perform a right-edge drag when the Dash is being show and there is
280− a running/minimized app to be restored.
281−
282− The expected behavior is that the dash should fade away and ultimately be
283− made invisible once the gesture is finished as the restored app will now
284− be on foreground.
285− */
286− function checkRightEdgeDragWithMinimizedApp() {
287− var touchX = shell.width - (shell.edgeSize / 2);
288− var touchY = shell.height / 2;
289−
290− var dash = findChild(shell, "dash");
291− // check that dash has normal scale and opacity
292− tryCompare(dash, "contentScale", 1.0);
293− tryCompare(dash, "opacity", 1.0);
294−
295− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
296− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
297−
298− // check that Dash has been scaled down and had its opacity reduced
299− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
300− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
301−
302− touchRelease(shell, shell.width * 0.1, touchY);
303−
304− // dash should have gone away, now that the app is on foreground
305− tryCompare(dash, "visible", false);
306− }
307−
308178 /*
309179 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
310180
311− When the user minimizes an application (left-edge swipe) he should always end up in the "Running Apps"
312− category of the "Applications" scope view.
181+ When the user minimizes an application (left-edge swipe) he should always end up in the
182+ "Applications" scope view.
313183
314184 Steps:
315− - go to apps lens
316− - scroll to the bottom
317− - reveal launcher and launch an app
185+ - reveal launcher and launch an app that covers the dash
318186 - perform long left edge swipe to go minimize the app and go back to the dash.
319−
320− Expected Results
321− - apps lens shown
187+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
322188 */
323189 function test_minimizingAppTakesToDashApps() {
324− var dashApps = findChild(shell, "clickscope");
325− swipeUntilScopeViewIsReached(dashApps);
326−
327− // swipe finger up until the running/recent apps section (which we assume
328− // it's the first one) is as far from view as possible.
329− // We also assume that DashApps is tall enough that it's scrollable
330− var appsCategoryListView = findChild(dashApps, "categoryListView");
331− while (!appsCategoryListView.atYEnd) {
332− swipeUpFromCenter();
333− tryCompare(appsCategoryListView, "moving", false);
334− }
335−
336− // Switch away from the Applications scope.
337− swipeRightFromCenter();
338− waitUntilItemStopsMoving(dashApps);
339− verify(!itemIsOnScreen(dashApps));
340−
341190 dragLauncherIntoView();
342191
343192 // Launch an app from the launcher
@@ -345,19 +194,16 @@ Item {
345194
346195 waitUntilApplicationWindowIsFullyVisible();
347196
348− // Dragging launcher into view with a little bit of gap (units.gu(1)) should switch to Apps scope
349− dragLauncherIntoView();
350− verify(itemIsOnScreen(dashApps));
197+ verify(ApplicationManager.focusedApplicationId !== "unity8-dash")
351198
199+ dashCommunicatorSpy.clear();
352200 // Minimize the application we just launched
353201 swipeFromLeftEdge(units.gu(27));
354202
355− // Wait for the whole UI to settle down
356− waitUntilApplicationWindowIsFullyHidden();
357− waitUntilItemStopsMoving(dashApps);
358− tryCompare(appsCategoryListView, "moving", false);
203+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
359204
360− verify(itemIsOnScreen(dashApps));
205+ compare(dashCommunicatorSpy.count, 1);
206+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
361207 }
362208
363209 function test_showInputMethod() {
@@ -414,9 +260,14 @@ Item {
414260
415261 // Wait for the whole UI to settle down
416262 function waitForUIToSettle() {
417− waitUntilApplicationWindowIsFullyHidden();
418− var dashContentList = findChild(shell, "dashContentList");
419− tryCompare(dashContentList, "moving", false);
263+ var launcher = findChild(shell, "launcherPanel")
264+ tryCompareFunction(function() {return launcher.x === 0 || launcher.x === -launcher.width;}, true);
265+ if (launcher.x === 0) {
266+ mouseClick(shell, shell.width / 2, shell.height / 2)
267+ }
268+ tryCompare(launcher, "x", -launcher.width)
269+
270+ waitForRendering(shell)
420271 }
421272
422273 function dragToCloseIndicatorsPanel() {
@@ -473,24 +324,13 @@ Item {
473324 }
474325
475326 function waitUntilApplicationWindowIsFullyVisible() {
476− var underlay = findChild(shell, "underlay");
477− tryCompare(underlay, "visible", false);
327+ var appDelegate = findChild(shell, "appDelegate0")
328+ var surfaceContainer = findChild(appDelegate, "surfaceContainer");
329+ tryCompareFunction(function() { return surfaceContainer.surface !== null; }, true);
478330 }
479331
480− function waitUntilApplicationWindowIsFullyHidden() {
481− var stages = findChild(shell, "stages");
482− tryCompare(stages, "fullyHidden", true);
483− }
484−
485− function swipeUntilScopeViewIsReached(scopeView) {
486− while (!itemIsOnScreen(scopeView)) {
487− if (itemIsToLeftOfScreen(scopeView)) {
488− swipeRightFromCenter();
489− } else {
490− swipeLeftFromCenter();
491− }
492− waitUntilItemStopsMoving(scopeView);
493− }
332+ function waitUntilDashIsFocused() {
333+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
494334 }
495335
496336 function swipeFromLeftEdge(swipeLength) {
@@ -499,24 +339,6 @@ Item {
499339 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
500340 }
501341
502− function swipeLeftFromCenter() {
503− var touchStartX = shell.width * 3 / 4;
504− var touchStartY = shell.height / 2;
505− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
506− }
507−
508− function swipeRightFromCenter() {
509− var touchStartX = shell.width * 3 / 4;
510− var touchStartY = shell.height / 2;
511− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
512− }
513−
514− function swipeUpFromCenter() {
515− var touchStartX = shell.width / 2;
516− var touchStartY = shell.height / 2;
517− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
518− }
519−
520342 function itemIsOnScreen(item) {
521343 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
522344
@@ -526,64 +348,6 @@ Item {
526348 && itemRectInShell.y + itemRectInShell.height <= shell.height;
527349 }
528350
529− function itemIsToLeftOfScreen(item) {
530− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
531− return itemRectInShell.x < 0;
532− }
533−
534− function waitUntilItemStopsMoving(item) {
535− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
536− var previousX = itemRectInShell.x;
537− var previousY = itemRectInShell.y;
538− var isStill = false;
539−
540− do {
541− wait(100);
542− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
543− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
544− isStill = true;
545− } else {
546− previousX = itemRectInShell.x;
547− previousY = itemRectInShell.y;
548− }
549− } while (!isStill);
550− }
551−
552− function test_DashShown_data() {
553− return [
554− {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
555− {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
556− {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
557− {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
558− {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: false},
559− ]
560− }
561−
562− function test_DashShown(data) {
563− if (data.greeter) {
564− // Swipe the greeter in
565− var greeter = findChild(shell, "greeter");
566− LightDM.Greeter.showGreeter();
567− tryCompare(greeter, "showProgress", 1);
568− }
569−
570− if (data.app) {
571− dragLauncherIntoView();
572− tapOnAppIconInLauncher();
573− }
574−
575− if (data.launcher) {
576− dragLauncherIntoView();
577− }
578−
579− if (data.indicators) {
580− showIndicators();
581− }
582−
583− var dash = findChild(shell, "dash");
584− tryCompare(dash, "shown", data.expectedShown);
585− }
586−
587351 function test_focusRequestedHidesGreeter() {
588352 var greeter = findChild(shell, "greeter");
589353
@@ -592,10 +356,9 @@ Item {
592356 tryCompareFunction(function() { return app.surface != null }, true);
593357
594358 // Minimize the application we just launched
595− swipeFromLeftEdge(units.gu(27));
359+ swipeFromLeftEdge(units.gu(26) + 1);
596360
597− // Wait for the whole UI to settle down
598− waitUntilApplicationWindowIsFullyHidden();
361+ waitUntilDashIsFocused();
599362
600363 greeter.show();
601364 tryCompare(greeter, "showProgress", 1);
@@ -611,8 +374,9 @@ Item {
611374
612375 showIndicators();
613376
377+ var oldCount = ApplicationManager.count;
614378 ApplicationManager.startApplication("camera-app");
615− tryCompare(ApplicationManager, "count", 1);
379+ tryCompare(ApplicationManager, "count", oldCount + 1);
616380
617381 tryCompare(indicators, "fullyClosed", true);
618382 }
@@ -621,6 +385,7 @@ Item {
621385 function test_showGreeterDBusCall() {
622386 var greeter = findChild(shell, "greeter")
623387 tryCompare(greeter, "showProgress", 0)
388+ waitForRendering(greeter);
624389 LightDM.Greeter.showGreeter()
625390 tryCompare(greeter, "showProgress", 1)
626391 }
@@ -629,6 +394,7 @@ Item {
629394 sessionSpy.clear()
630395
631396 var greeter = findChild(shell, "greeter")
397+ waitForRendering(greeter)
632398 greeter.show()
633399 tryCompare(greeter, "showProgress", 1)
634400
@@ -649,5 +415,26 @@ Item {
649415 ApplicationManager.requestFocusApplication("gallery-app");
650416 tryCompare(panel, "fullscreenMode", false);
651417 }
418+
419+ function test_leftEdgeDragFullscreen() {
420+ var panel = findChild(shell, "panel");
421+ tryCompare(panel, "fullscreenMode", false)
422+
423+ ApplicationManager.startApplication("camera-app");
424+ tryCompare(panel, "fullscreenMode", true)
425+
426+ var touchStartX = 2;
427+ var touchStartY = shell.height / 2;
428+
429+ touchFlick(shell, touchStartX, touchStartY, units.gu(2), touchStartY, true, false);
430+
431+ compare(panel.fullscreenMode, true);
432+
433+ touchFlick(shell, units.gu(2), touchStartY, units.gu(10), touchStartY, false, false);
434+
435+ tryCompare(panel, "fullscreenMode", false);
436+
437+ touchRelease(shell);
438+ }
652439 }
653440}