@@ -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
182+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
317183 */
318184 function test_minimizingAppTakesToDashApps() {
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−
336185 dragLauncherIntoView();
337186
338187 // Launch an app from the launcher
@@ -340,19 +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));
200+ compare(dashCommunicatorSpy.count, 1);
201+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
356202 }
357203
358204 function test_showInputMethod() {
@@ -409,9 +255,14 @@ Item {
409255
410256 // Wait for the whole UI to settle down
411257 function waitForUIToSettle() {
412− waitUntilApplicationWindowIsFullyHidden();
413− var dashContentList = findChild(shell, "dashContentList");
414− 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)
415266 }
416267
417268 function dragToCloseIndicatorsPanel() {
@@ -468,24 +319,13 @@ Item {
468319 }
469320
470321 function waitUntilApplicationWindowIsFullyVisible() {
471− var underlay = findChild(shell, "underlay");
472− tryCompare(underlay, "visible", false);
322+ var appDelegate = findChild(shell, "appDelegate0")
323+ var surfaceContainer = findChild(appDelegate, "surfaceContainer");
324+ tryCompareFunction(function() { return surfaceContainer.surface !== null; }, true);
473325 }
474326
475− function waitUntilApplicationWindowIsFullyHidden() {
476− var stages = findChild(shell, "stages");
477− tryCompare(stages, "fullyHidden", true);
478− }
479−
480− function swipeUntilScopeViewIsReached(scopeView) {
481− while (!itemIsOnScreen(scopeView)) {
482− if (itemIsToLeftOfScreen(scopeView)) {
483− swipeRightFromCenter();
484− } else {
485− swipeLeftFromCenter();
486− }
487− waitUntilItemStopsMoving(scopeView);
488− }
327+ function waitUntilDashIsFocused() {
328+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
489329 }
490330
491331 function swipeFromLeftEdge(swipeLength) {
@@ -494,24 +334,6 @@ Item {
494334 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
495335 }
496336
497− function swipeLeftFromCenter() {
498− var touchStartX = shell.width * 3 / 4;
499− var touchStartY = shell.height / 2;
500− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
501− }
502−
503− function swipeRightFromCenter() {
504− var touchStartX = shell.width * 3 / 4;
505− var touchStartY = shell.height / 2;
506− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
507− }
508−
509− function swipeUpFromCenter() {
510− var touchStartX = shell.width / 2;
511− var touchStartY = shell.height / 2;
512− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
513− }
514−
515337 function itemIsOnScreen(item) {
516338 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
517339
@@ -521,64 +343,6 @@ Item {
521343 && itemRectInShell.y + itemRectInShell.height <= shell.height;
522344 }
523345
524− function itemIsToLeftOfScreen(item) {
525− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
526− return itemRectInShell.x < 0;
527− }
528−
529− function waitUntilItemStopsMoving(item) {
530− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
531− var previousX = itemRectInShell.x;
532− var previousY = itemRectInShell.y;
533− var isStill = false;
534−
535− do {
536− wait(100);
537− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
538− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
539− isStill = true;
540− } else {
541− previousX = itemRectInShell.x;
542− previousY = itemRectInShell.y;
543− }
544− } while (!isStill);
545− }
546−
547− function test_DashShown_data() {
548− return [
549− {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
550− {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
551− {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
552− {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
553− {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: false},
554− ]
555− }
556−
557− function test_DashShown(data) {
558− if (data.greeter) {
559− // Swipe the greeter in
560− var greeter = findChild(shell, "greeter");
561− Powerd.displayPowerStateChange(Powerd.Off, 0);
562− tryCompare(greeter, "showProgress", 1);
563− }
564−
565− if (data.app) {
566− dragLauncherIntoView();
567− tapOnAppIconInLauncher();
568− }
569−
570− if (data.launcher) {
571− dragLauncherIntoView();
572− }
573−
574− if (data.indicators) {
575− showIndicators();
576− }
577−
578− var dash = findChild(shell, "dash");
579− tryCompare(dash, "shown", data.expectedShown);
580− }
581−
582346 function test_focusRequestedHidesGreeter() {
583347 var greeter = findChild(shell, "greeter");
584348
@@ -587,10 +351,9 @@ Item {
587351 tryCompareFunction(function() { return app.surface != null }, true);
588352
589353 // Minimize the application we just launched
590− swipeFromLeftEdge(units.gu(27));
354+ swipeFromLeftEdge(units.gu(26) + 1);
591355
592− // Wait for the whole UI to settle down
593− waitUntilApplicationWindowIsFullyHidden();
356+ waitUntilDashIsFocused();
594357
595358 greeter.show();
596359 tryCompare(greeter, "showProgress", 1);
@@ -606,8 +369,9 @@ Item {
606369
607370 showIndicators();
608371
372+ var oldCount = ApplicationManager.count;
609373 ApplicationManager.startApplication("camera-app");
610− tryCompare(ApplicationManager, "count", 1);
374+ tryCompare(ApplicationManager, "count", oldCount + 1);
611375
612376 tryCompare(indicators, "fullyClosed", true);
613377 }
@@ -616,6 +380,7 @@ Item {
616380 function test_showGreeterDBusCall() {
617381 var greeter = findChild(shell, "greeter")
618382 tryCompare(greeter, "showProgress", 0)
383+ waitForRendering(greeter);
619384 LightDM.Greeter.showGreeter()
620385 tryCompare(greeter, "showProgress", 1)
621386 }
@@ -624,6 +389,7 @@ Item {
624389 sessionSpy.clear()
625390
626391 var greeter = findChild(shell, "greeter")
392+ waitForRendering(greeter)
627393 greeter.show()
628394 tryCompare(greeter, "showProgress", 1)
629395
@@ -644,5 +410,26 @@ Item {
644410 ApplicationManager.requestFocusApplication("gallery-app");
645411 tryCompare(panel, "fullscreenMode", false);
646412 }
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+ }
647434 }
648435}