@@ -56,49 +56,20 @@ Item {
5656 signalName: "sessionStarted"
5757 }
5858
59+ SignalSpy {
60+ id: dashCommunicatorSpy
61+ signalName: "setCurrentScopeCalled"
62+ }
63+
5964 UT.UnityTestCase {
6065 name: "Shell"
6166 when: windowShown
6267
6368 function initTestCase() {
64− var ok = false;
65− var attempts = 0;
66− var maxAttempts = 1000;
67−
68− // Qt loads a qml scene asynchronously. So early on, some findChild() calls made in
69− // tests may fail because the desired child item wasn't loaded yet.
70− // Thus here we try to ensure the scene has been fully loaded before proceeding with the tests.
71− // As I couldn't find an API in QQuickView & friends to tell me that the scene is 100% loaded
72− // (all items instantiated, etc), I resort to checking the existence of some key items until
73− // repeatedly until they're all there.
74− do {
75− var dashContentList = findChild(shell, "dashContentList");
76− waitForRendering(dashContentList);
77− var homeLoader = findChild(dashContentList, "clickscope loader");
78− ok = homeLoader !== null
79− && homeLoader.item !== undefined;
80−
81− var greeter = findChild(shell, "greeter");
82− ok &= greeter !== null;
83−
84− var launcherPanel = findChild(shell, "launcherPanel");
85− ok &= launcherPanel !== null;
86−
87− attempts++;
88− if (!ok) {
89− console.log("Attempt " + attempts + " failed. Waiting a bit before trying again.");
90− // wait a bit before retrying
91− wait(100);
92− } else {
93− console.log("All seem fine after " + attempts + " attempts.");
94− }
95− } while (!ok && attempts <= maxAttempts);
96−
97− verify(ok);
98−
9969 swipeAwayGreeter();
10070
10171 sessionSpy.target = findChild(shell, "greeter")
72+ dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
10273 }
10374
10475 function cleanup() {
@@ -111,56 +82,16 @@ Item {
11182 // kill all (fake) running apps
11283 killApps(ApplicationManager);
11384
114− var dashContent = findChild(shell, "dashContent");
115− dashContent.closePreview();
116−
117− var dashHome = findChild(shell, "clickscope loader");
118− swipeUntilScopeViewIsReached(dashHome);
119−
85+ waitForUIToSettle();
12086 hideIndicators();
12187 }
12288
123− function killApps(apps) {
124− if (!apps) return;
125− while (apps.count > 0) {
126− ApplicationManager.stopApplication(apps.get(0).appId);
89+ function killApps() {
90+ while (ApplicationManager.count > 1) {
91+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
92+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
12793 }
128− compare(ApplicationManager.count, 0)
129− }
130−
131− /*
132− Test the effect of a right-edge drag on the dash in 3 situations:
133− 1 - when no application has been launched yet
134− 2 - when there's a minimized application
135− 3 - after the last running application has been closed/stopped
136−
137− The behavior of Dash on 3 should be the same as on 1.
138− */
139− function test_rightEdgeDrag() {
140− checkRightEdgeDragWithNoRunningApps();
141−
142− dragLauncherIntoView();
143−
144− // Launch an app from the launcher
145− tapOnAppIconInLauncher();
146− waitUntilApplicationWindowIsFullyVisible();
147−
148− // Minimize the application we just launched
149− swipeFromLeftEdge(units.gu(27));
150−
151− waitForUIToSettle();
152−
153− checkRightEdgeDragWithMinimizedApp();
154−
155− // Minimize that application once again
156− swipeFromLeftEdge(units.gu(27));
157−
158− // Right edge behavior should now be the same as before that app,
159− // was launched. Manually cleanup beforehand to get to initial
160− // state.
161− cleanup();
162− waitForUIToSettle();
163− checkRightEdgeDragWithNoRunningApps();
94+ compare(ApplicationManager.count, 1)
16495 }
16596
16697 function test_leftEdgeDrag_data() {
@@ -183,7 +114,7 @@ Item {
183114
184115 swipeFromLeftEdge(data.swipeLength);
185116 if (data.appHides)
186− waitUntilApplicationWindowIsFullyHidden();
117+ waitUntilDashIsFocused();
187118 else
188119 waitUntilApplicationWindowIsFullyVisible();
189120 }
@@ -239,100 +170,18 @@ Item {
239170 waitForRendering(greeter);
240171 }
241172
242− /*
243− Perform a right-edge drag when the Dash is being show and there are
244− no running/minimized apps to be restored.
245−
246− The expected behavior is that an animation should be played to hint the
247− user that his right-edge drag gesture has been successfully recognized
248− but there is no application to be brought to foreground.
249− */
250− function checkRightEdgeDragWithNoRunningApps() {
251− var touchX = shell.width - (shell.edgeSize / 2);
252− var touchY = shell.height / 2;
253−
254− var dash = findChild(shell, "dash");
255− // check that dash has normal scale and opacity
256− tryCompare(dash, "contentScale", 1.0);
257− tryCompare(dash, "opacity", 1.0);
258−
259− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
260− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
261−
262− // check that Dash has been scaled down and had its opacity reduced
263− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
264− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
265−
266− touchRelease(shell, shell.width * 0.1, touchY);
267−
268− // and now everything should have gone back to normal
269− tryCompare(dash, "contentScale", 1.0);
270− tryCompare(dash, "opacity", 1.0);
271− }
272−
273− /*
274− Perform a right-edge drag when the Dash is being show and there is
275− a running/minimized app to be restored.
276−
277− The expected behavior is that the dash should fade away and ultimately be
278− made invisible once the gesture is finished as the restored app will now
279− be on foreground.
280− */
281− function checkRightEdgeDragWithMinimizedApp() {
282− var touchX = shell.width - (shell.edgeSize / 2);
283− var touchY = shell.height / 2;
284−
285− var dash = findChild(shell, "dash");
286− // check that dash has normal scale and opacity
287− tryCompare(dash, "contentScale", 1.0);
288− tryCompare(dash, "opacity", 1.0);
289−
290− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
291− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
292−
293− // check that Dash has been scaled down and had its opacity reduced
294− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
295− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
296−
297− touchRelease(shell, shell.width * 0.1, touchY);
298−
299− // dash should have gone away, now that the app is on foreground
300− tryCompare(dash, "visible", false);
301− }
302−
303173 /*
304174 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
305175
306− When the user minimizes an application (left-edge swipe) he should always end up in the "Running Apps"
307− category of the "Applications" scope view.
176+ When the user minimizes an application (left-edge swipe) he should always end up in the
177+ "Applications" scope view.
308178
309179 Steps:
310− - go to apps lens
311− - scroll to the bottom
312− - reveal launcher and launch an app
180+ - reveal launcher and launch an app that covers the dash
313181 - perform long left edge swipe to go minimize the app and go back to the dash.
314−
315− Expected Results
316− - apps lens shown and Running Apps visible on screen
182+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
317183 */
318− function test_minimizingAppTakesToRunningApps() {
319− var dashApps = findChild(shell, "clickscope");
320− swipeUntilScopeViewIsReached(dashApps);
321−
322− // swipe finger up until the running/recent apps section (which we assume
323− // it's the first one) is as far from view as possible.
324− // We also assume that DashApps is tall enough that it's scrollable
325− var appsCategoryListView = findChild(dashApps, "categoryListView");
326− while (!appsCategoryListView.atYEnd) {
327− swipeUpFromCenter();
328− tryCompare(appsCategoryListView, "moving", false);
329− }
330−
331− // Switch away from the Applications scope.
332− swipeRightFromCenter();
333− waitUntilItemStopsMoving(dashApps);
334− verify(!itemIsOnScreen(dashApps));
335−
184+ function test_minimizingAppTakesToDashApps() {
336185 dragLauncherIntoView();
337186
338187 // Launch an app from the launcher
@@ -340,23 +189,16 @@ Item {
340189
341190 waitUntilApplicationWindowIsFullyVisible();
342191
343− // Dragging launcher into view with a little bit of gap (units.gu(1)) should switch to Apps scope
344− dragLauncherIntoView();
345− verify(itemIsOnScreen(dashApps));
192+ verify(ApplicationManager.focusedApplicationId !== "unity8-dash")
346193
194+ dashCommunicatorSpy.clear();
347195 // Minimize the application we just launched
348196 swipeFromLeftEdge(units.gu(27));
349197
350− // Wait for the whole UI to settle down
351− waitUntilApplicationWindowIsFullyHidden();
352− waitUntilItemStopsMoving(dashApps);
353− tryCompare(appsCategoryListView, "moving", false);
198+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
354199
355− verify(itemIsOnScreen(dashApps));
356−
357− var runningApplicationsGrid = findChild(appsCategoryListView, "running.apps.category");
358− verify(runningApplicationsGrid);
359− verify(itemIsOnScreen(runningApplicationsGrid));
200+ compare(dashCommunicatorSpy.count, 1);
201+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
360202 }
361203
362204 function test_showInputMethod() {
@@ -413,9 +255,14 @@ Item {
413255
414256 // Wait for the whole UI to settle down
415257 function waitForUIToSettle() {
416− waitUntilApplicationWindowIsFullyHidden();
417− var dashContentList = findChild(shell, "dashContentList");
418− tryCompare(dashContentList, "moving", false);
258+ var launcher = findChild(shell, "launcherPanel")
259+ tryCompareFunction(function() {return launcher.x === 0 || launcher.x === -launcher.width;}, true);
260+ if (launcher.x === 0) {
261+ mouseClick(shell, shell.width / 2, shell.height / 2)
262+ }
263+ tryCompare(launcher, "x", -launcher.width)
264+
265+ waitForRendering(shell)
419266 }
420267
421268 function dragToCloseIndicatorsPanel() {
@@ -472,24 +319,13 @@ Item {
472319 }
473320
474321 function waitUntilApplicationWindowIsFullyVisible() {
475− var underlay = findChild(shell, "underlay");
476− tryCompare(underlay, "visible", false);
477− }
478−
479− function waitUntilApplicationWindowIsFullyHidden() {
480− var stages = findChild(shell, "stages");
481− tryCompare(stages, "fullyHidden", true);
322+ var appDelegate = findChild(shell, "appDelegate0")
323+ var surfaceContainer = findChild(appDelegate, "surfaceContainer");
324+ tryCompareFunction(function() { return surfaceContainer.surface !== null; }, true);
482325 }
483326
484− function swipeUntilScopeViewIsReached(scopeView) {
485− while (!itemIsOnScreen(scopeView)) {
486− if (itemIsToLeftOfScreen(scopeView)) {
487− swipeRightFromCenter();
488− } else {
489− swipeLeftFromCenter();
490− }
491− waitUntilItemStopsMoving(scopeView);
492− }
327+ function waitUntilDashIsFocused() {
328+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
493329 }
494330
495331 function swipeFromLeftEdge(swipeLength) {
@@ -498,24 +334,6 @@ Item {
498334 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
499335 }
500336
501− function swipeLeftFromCenter() {
502− var touchStartX = shell.width * 3 / 4;
503− var touchStartY = shell.height / 2;
504− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
505− }
506−
507− function swipeRightFromCenter() {
508− var touchStartX = shell.width * 3 / 4;
509− var touchStartY = shell.height / 2;
510− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
511− }
512−
513− function swipeUpFromCenter() {
514− var touchStartX = shell.width / 2;
515− var touchStartY = shell.height / 2;
516− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
517− }
518−
519337 function itemIsOnScreen(item) {
520338 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
521339
@@ -525,64 +343,6 @@ Item {
525343 && itemRectInShell.y + itemRectInShell.height <= shell.height;
526344 }
527345
528− function itemIsToLeftOfScreen(item) {
529− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
530− return itemRectInShell.x < 0;
531− }
532−
533− function waitUntilItemStopsMoving(item) {
534− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
535− var previousX = itemRectInShell.x;
536− var previousY = itemRectInShell.y;
537− var isStill = false;
538−
539− do {
540− wait(100);
541− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
542− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
543− isStill = true;
544− } else {
545− previousX = itemRectInShell.x;
546− previousY = itemRectInShell.y;
547− }
548− } while (!isStill);
549− }
550−
551− function test_DashShown_data() {
552− return [
553− {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
554− {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
555− {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
556− {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
557− {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: false},
558− ]
559− }
560−
561− function test_DashShown(data) {
562− if (data.greeter) {
563− // Swipe the greeter in
564− var greeter = findChild(shell, "greeter");
565− Powerd.displayPowerStateChange(Powerd.Off, 0);
566− tryCompare(greeter, "showProgress", 1);
567− }
568−
569− if (data.app) {
570− dragLauncherIntoView();
571− tapOnAppIconInLauncher();
572− }
573−
574− if (data.launcher) {
575− dragLauncherIntoView();
576− }
577−
578− if (data.indicators) {
579− showIndicators();
580− }
581−
582− var dash = findChild(shell, "dash");
583− tryCompare(dash, "shown", data.expectedShown);
584− }
585−
586346 function test_focusRequestedHidesGreeter() {
587347 var greeter = findChild(shell, "greeter");
588348
@@ -591,10 +351,9 @@ Item {
591351 tryCompareFunction(function() { return app.surface != null }, true);
592352
593353 // Minimize the application we just launched
594− swipeFromLeftEdge(units.gu(27));
354+ swipeFromLeftEdge(units.gu(26) + 1);
595355
596− // Wait for the whole UI to settle down
597− waitUntilApplicationWindowIsFullyHidden();
356+ waitUntilDashIsFocused();
598357
599358 greeter.show();
600359 tryCompare(greeter, "showProgress", 1);
@@ -610,8 +369,9 @@ Item {
610369
611370 showIndicators();
612371
372+ var oldCount = ApplicationManager.count;
613373 ApplicationManager.startApplication("camera-app");
614− tryCompare(ApplicationManager, "count", 1);
374+ tryCompare(ApplicationManager, "count", oldCount + 1);
615375
616376 tryCompare(indicators, "fullyClosed", true);
617377 }
@@ -620,6 +380,7 @@ Item {
620380 function test_showGreeterDBusCall() {
621381 var greeter = findChild(shell, "greeter")
622382 tryCompare(greeter, "showProgress", 0)
383+ waitForRendering(greeter);
623384 LightDM.Greeter.showGreeter()
624385 tryCompare(greeter, "showProgress", 1)
625386 }
@@ -628,6 +389,7 @@ Item {
628389 sessionSpy.clear()
629390
630391 var greeter = findChild(shell, "greeter")
392+ waitForRendering(greeter)
631393 greeter.show()
632394 tryCompare(greeter, "showProgress", 1)
633395
@@ -648,5 +410,26 @@ Item {
648410 ApplicationManager.requestFocusApplication("gallery-app");
649411 tryCompare(panel, "fullscreenMode", false);
650412 }
413+
414+ function test_leftEdgeDragFullscreen() {
415+ var panel = findChild(shell, "panel");
416+ tryCompare(panel, "fullscreenMode", false)
417+
418+ ApplicationManager.startApplication("camera-app");
419+ tryCompare(panel, "fullscreenMode", true)
420+
421+ var touchStartX = 2;
422+ var touchStartY = shell.height / 2;
423+
424+ touchFlick(shell, touchStartX, touchStartY, units.gu(2), touchStartY, true, false);
425+
426+ compare(panel.fullscreenMode, true);
427+
428+ touchFlick(shell, units.gu(2), touchStartY, units.gu(10), touchStartY, false, false);
429+
430+ tryCompare(panel, "fullscreenMode", false);
431+
432+ touchRelease(shell);
433+ }
651434 }
652435}