@@ -56,49 +56,20 @@ Item {
56 signalName: "sessionStarted"
56 signalName: "sessionStarted"
60+ id: dashCommunicatorSpy
61+ signalName: "setCurrentScopeCalled"
59 UT.UnityTestCase {
64 UT.UnityTestCase {
60 name: "Shell"
65 name: "Shell"
61 when: windowShown
66 when: windowShown
63 function initTestCase() {
68 function initTestCase() {
66− var maxAttempts = 1000;
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.
75− var dashContentList = findChild(shell, "dashContentList");
76− waitForRendering(dashContentList);
77− var homeLoader = findChild(dashContentList, "clickscope loader");
78− ok = homeLoader !== null
79− && homeLoader.item !== undefined;
81− var greeter = findChild(shell, "greeter");
82− ok &= greeter !== null;
84− var launcherPanel = findChild(shell, "launcherPanel");
85− ok &= launcherPanel !== null;
89− console.log("Attempt " + attempts + " failed. Waiting a bit before trying again.");
90− // wait a bit before retrying
93− console.log("All seem fine after " + attempts + " attempts.");
95− } while (!ok && attempts <= maxAttempts);
99 swipeAwayGreeter();
69 swipeAwayGreeter();
101 sessionSpy.target = findChild(shell, "greeter")
71 sessionSpy.target = findChild(shell, "greeter")
72+ dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
104 function cleanup() {
75 function cleanup() {
@@ -111,56 +82,16 @@ Item {
111 // kill all (fake) running apps
82 // kill all (fake) running apps
112 killApps(ApplicationManager);
83 killApps(ApplicationManager);
114− var dashContent = findChild(shell, "dashContent");
85+ waitForUIToSettle();
115− dashContent.closePreview();
117− var dashHome = findChild(shell, "clickscope loader");
118− swipeUntilScopeViewIsReached(dashHome);
120 hideIndicators();
86 hideIndicators();
123− function killApps(apps) {
89+ function killApps() {
125− while (apps.count > 0) {
90+ while (ApplicationManager.count > 1) {
91+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
126− ApplicationManager.stopApplication(apps.get(0).appId);
92+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
128− compare(ApplicationManager.count, 0)
94+ compare(ApplicationManager.count, 1)
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
137− The behavior of Dash on 3 should be the same as on 1.
139− function test_rightEdgeDrag() {
140− checkRightEdgeDragWithNoRunningApps();
142− dragLauncherIntoView();
144− // Launch an app from the launcher
145− tapOnAppIconInLauncher();
146− waitUntilApplicationWindowIsFullyVisible();
148− // Minimize the application we just launched
149− swipeFromLeftEdge(units.gu(27));
151− waitForUIToSettle();
153− checkRightEdgeDragWithMinimizedApp();
155− // Minimize that application once again
156− swipeFromLeftEdge(units.gu(27));
158− // Right edge behavior should now be the same as before that app,
159− // was launched. Manually cleanup beforehand to get to initial
162− waitForUIToSettle();
163− checkRightEdgeDragWithNoRunningApps();
166 function test_leftEdgeDrag_data() {
97 function test_leftEdgeDrag_data() {
@@ -183,7 +114,7 @@ Item {
184 swipeFromLeftEdge(data.swipeLength);
115 swipeFromLeftEdge(data.swipeLength);
185 if (data.appHides)
116 if (data.appHides)
186− waitUntilApplicationWindowIsFullyHidden();
117+ waitUntilDashIsFocused();
188 waitUntilApplicationWindowIsFullyVisible();
119 waitUntilApplicationWindowIsFullyVisible();
@@ -239,100 +170,18 @@ Item {
239 waitForRendering(greeter);
170 waitForRendering(greeter);
243− Perform a right-edge drag when the Dash is being show and there are
244− no running/minimized apps to be restored.
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.
250− function checkRightEdgeDragWithNoRunningApps() {
251− var touchX = shell.width - (shell.edgeSize / 2);
252− var touchY = shell.height / 2;
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);
259− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
260− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
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);
266− touchRelease(shell, shell.width * 0.1, touchY);
268− // and now everything should have gone back to normal
269− tryCompare(dash, "contentScale", 1.0);
270− tryCompare(dash, "opacity", 1.0);
274− Perform a right-edge drag when the Dash is being show and there is
275− a running/minimized app to be restored.
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
281− function checkRightEdgeDragWithMinimizedApp() {
282− var touchX = shell.width - (shell.edgeSize / 2);
283− var touchY = shell.height / 2;
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);
290− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
291− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
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);
297− touchRelease(shell, shell.width * 0.1, touchY);
299− // dash should have gone away, now that the app is on foreground
300− tryCompare(dash, "visible", false);
304 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
174 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
306− When the user minimizes an application (left-edge swipe) he should always end up in the "Running Apps"
176+ When the user minimizes an application (left-edge swipe) he should always end up in the
307− category of the "Applications" scope view.
177+ "Applications" scope view.
311− - scroll to the bottom
312− - reveal launcher and launch an app
180+ - reveal launcher and launch an app that covers the dash
313 - perform long left edge swipe to go minimize the app and go back to the dash.
181 - perform long left edge swipe to go minimize the app and go back to the dash.
314−
182+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
318 function test_minimizingAppTakesToDashApps() {
184 function test_minimizingAppTakesToDashApps() {
319− var dashApps = findChild(shell, "clickscope");
320− swipeUntilScopeViewIsReached(dashApps);
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);
331− // Switch away from the Applications scope.
332− swipeRightFromCenter();
333− waitUntilItemStopsMoving(dashApps);
334− verify(!itemIsOnScreen(dashApps));
336 dragLauncherIntoView();
185 dragLauncherIntoView();
338 // Launch an app from the launcher
187 // Launch an app from the launcher
@@ -340,19 +189,16 @@ Item {
341 waitUntilApplicationWindowIsFullyVisible();
190 waitUntilApplicationWindowIsFullyVisible();
343− // Dragging launcher into view with a little bit of gap (units.gu(1)) should switch to Apps scope
192+ verify(ApplicationManager.focusedApplicationId !== "unity8-dash")
344− dragLauncherIntoView();
345− verify(itemIsOnScreen(dashApps));
194+ dashCommunicatorSpy.clear();
347 // Minimize the application we just launched
195 // Minimize the application we just launched
348 swipeFromLeftEdge(units.gu(27));
196 swipeFromLeftEdge(units.gu(27));
350− // Wait for the whole UI to settle down
198+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
351− waitUntilApplicationWindowIsFullyHidden();
352− waitUntilItemStopsMoving(dashApps);
353− tryCompare(appsCategoryListView, "moving", false);
355− verify(itemIsOnScreen(dashApps));
200+ compare(dashCommunicatorSpy.count, 1);
201+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
358 function test_showInputMethod() {
204 function test_showInputMethod() {
@@ -409,9 +255,14 @@ Item {
410 // Wait for the whole UI to settle down
256 // Wait for the whole UI to settle down
411 function waitForUIToSettle() {
257 function waitForUIToSettle() {
412− waitUntilApplicationWindowIsFullyHidden();
413− var dashContentList = findChild(shell, "dashContentList");
258+ var launcher = findChild(shell, "launcherPanel")
414− tryCompare(dashContentList, "moving", false);
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)
263+ tryCompare(launcher, "x", -launcher.width)
265+ waitForRendering(shell)
417 function dragToCloseIndicatorsPanel() {
268 function dragToCloseIndicatorsPanel() {
@@ -468,24 +319,13 @@ Item {
470 function waitUntilApplicationWindowIsFullyVisible() {
321 function waitUntilApplicationWindowIsFullyVisible() {
471− var underlay = findChild(shell, "underlay");
322+ var appDelegate = findChild(shell, "appDelegate0")
472− tryCompare(underlay, "visible", false);
323+ var surfaceContainer = findChild(appDelegate, "surfaceContainer");
324+ tryCompareFunction(function() { return surfaceContainer.surface !== null; }, true);
475− function waitUntilApplicationWindowIsFullyHidden() {
327+ function waitUntilDashIsFocused() {
476− var stages = findChild(shell, "stages");
328+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
477− tryCompare(stages, "fullyHidden", true);
480− function swipeUntilScopeViewIsReached(scopeView) {
481− while (!itemIsOnScreen(scopeView)) {
482− if (itemIsToLeftOfScreen(scopeView)) {
483− swipeRightFromCenter();
485− swipeLeftFromCenter();
487− waitUntilItemStopsMoving(scopeView);
491 function swipeFromLeftEdge(swipeLength) {
331 function swipeFromLeftEdge(swipeLength) {
@@ -494,24 +334,6 @@ Item {
494 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
334 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
497− function swipeLeftFromCenter() {
498− var touchStartX = shell.width * 3 / 4;
499− var touchStartY = shell.height / 2;
500− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
503− function swipeRightFromCenter() {
504− var touchStartX = shell.width * 3 / 4;
505− var touchStartY = shell.height / 2;
506− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
509− function swipeUpFromCenter() {
510− var touchStartX = shell.width / 2;
511− var touchStartY = shell.height / 2;
512− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
515 function itemIsOnScreen(item) {
337 function itemIsOnScreen(item) {
516 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
338 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
@@ -521,64 +343,6 @@ Item {
521 && itemRectInShell.y + itemRectInShell.height <= shell.height;
343 && itemRectInShell.y + itemRectInShell.height <= shell.height;
524− function itemIsToLeftOfScreen(item) {
525− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
526− return itemRectInShell.x < 0;
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;
537− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
538− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
541− previousX = itemRectInShell.x;
542− previousY = itemRectInShell.y;
547− function test_DashShown_data() {
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},
557− function test_DashShown(data) {
559− // Swipe the greeter in
560− var greeter = findChild(shell, "greeter");
561− Powerd.displayPowerStateChange(Powerd.Off, 0);
562− tryCompare(greeter, "showProgress", 1);
566− dragLauncherIntoView();
567− tapOnAppIconInLauncher();
570− if (data.launcher) {
571− dragLauncherIntoView();
574− if (data.indicators) {
578− var dash = findChild(shell, "dash");
579− tryCompare(dash, "shown", data.expectedShown);
582 function test_focusRequestedHidesGreeter() {
346 function test_focusRequestedHidesGreeter() {
583 var greeter = findChild(shell, "greeter");
347 var greeter = findChild(shell, "greeter");
@@ -587,10 +351,9 @@ Item {
587 tryCompareFunction(function() { return app.surface != null }, true);
351 tryCompareFunction(function() { return app.surface != null }, true);
589 // Minimize the application we just launched
353 // Minimize the application we just launched
590− swipeFromLeftEdge(units.gu(27));
354+ swipeFromLeftEdge(units.gu(26) + 1);
592− // Wait for the whole UI to settle down
356+ waitUntilDashIsFocused();
593− waitUntilApplicationWindowIsFullyHidden();
595 greeter.show();
358 greeter.show();
596 tryCompare(greeter, "showProgress", 1);
359 tryCompare(greeter, "showProgress", 1);
@@ -606,8 +369,9 @@ Item {
607 showIndicators();
370 showIndicators();
372+ var oldCount = ApplicationManager.count;
609 ApplicationManager.startApplication("camera-app");
373 ApplicationManager.startApplication("camera-app");
610− tryCompare(ApplicationManager, "count", 1);
374+ tryCompare(ApplicationManager, "count", oldCount + 1);
612 tryCompare(indicators, "fullyClosed", true);
376 tryCompare(indicators, "fullyClosed", true);
@@ -616,6 +380,7 @@ Item {
616 function test_showGreeterDBusCall() {
380 function test_showGreeterDBusCall() {
617 var greeter = findChild(shell, "greeter")
381 var greeter = findChild(shell, "greeter")
618 tryCompare(greeter, "showProgress", 0)
382 tryCompare(greeter, "showProgress", 0)
383+ waitForRendering(greeter);
619 LightDM.Greeter.showGreeter()
384 LightDM.Greeter.showGreeter()
620 tryCompare(greeter, "showProgress", 1)
385 tryCompare(greeter, "showProgress", 1)
@@ -624,6 +389,7 @@ Item {
624 sessionSpy.clear()
389 sessionSpy.clear()
626 var greeter = findChild(shell, "greeter")
391 var greeter = findChild(shell, "greeter")
392+ waitForRendering(greeter)
627 greeter.show()
393 greeter.show()
628 tryCompare(greeter, "showProgress", 1)
394 tryCompare(greeter, "showProgress", 1)
@@ -644,5 +410,26 @@ Item {
644 ApplicationManager.requestFocusApplication("gallery-app");
410 ApplicationManager.requestFocusApplication("gallery-app");
645 tryCompare(panel, "fullscreenMode", false);
411 tryCompare(panel, "fullscreenMode", false);
414+ function test_leftEdgeDragFullscreen() {
415+ var panel = findChild(shell, "panel");
416+ tryCompare(panel, "fullscreenMode", false)
418+ ApplicationManager.startApplication("camera-app");
419+ tryCompare(panel, "fullscreenMode", true)
421+ var touchStartX = 2;
422+ var touchStartY = shell.height / 2;
424+ touchFlick(shell, touchStartX, touchStartY, units.gu(2), touchStartY, true, false);
426+ compare(panel.fullscreenMode, true);
428+ touchFlick(shell, units.gu(2), touchStartY, units.gu(10), touchStartY, false, false);
430+ tryCompare(panel, "fullscreenMode", false);
432+ touchRelease(shell);