@@ -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.
316− - apps lens shown and Running Apps visible on screen
318− function test_minimizingAppTakesToRunningApps() {
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,23 +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);
356−
201+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
357− var runningApplicationsGrid = findChild(appsCategoryListView, "running.apps.category");
358− verify(runningApplicationsGrid);
359− verify(itemIsOnScreen(runningApplicationsGrid));
362 function test_showInputMethod() {
204 function test_showInputMethod() {
@@ -413,9 +255,14 @@ Item {
414 // Wait for the whole UI to settle down
256 // Wait for the whole UI to settle down
415 function waitForUIToSettle() {
257 function waitForUIToSettle() {
416− waitUntilApplicationWindowIsFullyHidden();
417− var dashContentList = findChild(shell, "dashContentList");
258+ var launcher = findChild(shell, "launcherPanel")
418− 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)
421 function dragToCloseIndicatorsPanel() {
268 function dragToCloseIndicatorsPanel() {
@@ -472,24 +319,13 @@ Item {
474 function waitUntilApplicationWindowIsFullyVisible() {
321 function waitUntilApplicationWindowIsFullyVisible() {
475− var underlay = findChild(shell, "underlay");
322+ var appDelegate = findChild(shell, "appDelegate0")
476− tryCompare(underlay, "visible", false);
323+ var surfaceContainer = findChild(appDelegate, "surfaceContainer");
477− }
324+ tryCompareFunction(function() { return surfaceContainer.surface !== null; }, true);
479− function waitUntilApplicationWindowIsFullyHidden() {
480− var stages = findChild(shell, "stages");
481− tryCompare(stages, "fullyHidden", true);
484− function swipeUntilScopeViewIsReached(scopeView) {
327+ function waitUntilDashIsFocused() {
485− while (!itemIsOnScreen(scopeView)) {
328+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
486− if (itemIsToLeftOfScreen(scopeView)) {
487− swipeRightFromCenter();
489− swipeLeftFromCenter();
491− waitUntilItemStopsMoving(scopeView);
495 function swipeFromLeftEdge(swipeLength) {
331 function swipeFromLeftEdge(swipeLength) {
@@ -498,24 +334,6 @@ Item {
498 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
334 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
501− function swipeLeftFromCenter() {
502− var touchStartX = shell.width * 3 / 4;
503− var touchStartY = shell.height / 2;
504− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
507− function swipeRightFromCenter() {
508− var touchStartX = shell.width * 3 / 4;
509− var touchStartY = shell.height / 2;
510− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
513− function swipeUpFromCenter() {
514− var touchStartX = shell.width / 2;
515− var touchStartY = shell.height / 2;
516− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
519 function itemIsOnScreen(item) {
337 function itemIsOnScreen(item) {
520 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
338 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
@@ -525,64 +343,6 @@ Item {
525 && itemRectInShell.y + itemRectInShell.height <= shell.height;
343 && itemRectInShell.y + itemRectInShell.height <= shell.height;
528− function itemIsToLeftOfScreen(item) {
529− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
530− return itemRectInShell.x < 0;
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;
541− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
542− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
545− previousX = itemRectInShell.x;
546− previousY = itemRectInShell.y;
551− function test_DashShown_data() {
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},
561− function test_DashShown(data) {
563− // Swipe the greeter in
564− var greeter = findChild(shell, "greeter");
565− Powerd.displayPowerStateChange(Powerd.Off, 0);
566− tryCompare(greeter, "showProgress", 1);
570− dragLauncherIntoView();
571− tapOnAppIconInLauncher();
574− if (data.launcher) {
575− dragLauncherIntoView();
578− if (data.indicators) {
582− var dash = findChild(shell, "dash");
583− tryCompare(dash, "shown", data.expectedShown);
586 function test_focusRequestedHidesGreeter() {
346 function test_focusRequestedHidesGreeter() {
587 var greeter = findChild(shell, "greeter");
347 var greeter = findChild(shell, "greeter");
@@ -591,10 +351,9 @@ Item {
591 tryCompareFunction(function() { return app.surface != null }, true);
351 tryCompareFunction(function() { return app.surface != null }, true);
593 // Minimize the application we just launched
353 // Minimize the application we just launched
594− swipeFromLeftEdge(units.gu(27));
354+ swipeFromLeftEdge(units.gu(26) + 1);
596− // Wait for the whole UI to settle down
356+ waitUntilDashIsFocused();
597− waitUntilApplicationWindowIsFullyHidden();
599 greeter.show();
358 greeter.show();
600 tryCompare(greeter, "showProgress", 1);
359 tryCompare(greeter, "showProgress", 1);
@@ -610,8 +369,9 @@ Item {
611 showIndicators();
370 showIndicators();
372+ var oldCount = ApplicationManager.count;
613 ApplicationManager.startApplication("camera-app");
373 ApplicationManager.startApplication("camera-app");
614− tryCompare(ApplicationManager, "count", 1);
374+ tryCompare(ApplicationManager, "count", oldCount + 1);
616 tryCompare(indicators, "fullyClosed", true);
376 tryCompare(indicators, "fullyClosed", true);
@@ -620,6 +380,7 @@ Item {
620 function test_showGreeterDBusCall() {
380 function test_showGreeterDBusCall() {
621 var greeter = findChild(shell, "greeter")
381 var greeter = findChild(shell, "greeter")
622 tryCompare(greeter, "showProgress", 0)
382 tryCompare(greeter, "showProgress", 0)
383+ waitForRendering(greeter);
623 LightDM.Greeter.showGreeter()
384 LightDM.Greeter.showGreeter()
624 tryCompare(greeter, "showProgress", 1)
385 tryCompare(greeter, "showProgress", 1)
@@ -628,6 +389,7 @@ Item {
628 sessionSpy.clear()
389 sessionSpy.clear()
630 var greeter = findChild(shell, "greeter")
391 var greeter = findChild(shell, "greeter")
392+ waitForRendering(greeter)
631 greeter.show()
393 greeter.show()
632 tryCompare(greeter, "showProgress", 1)
394 tryCompare(greeter, "showProgress", 1)
@@ -648,5 +410,26 @@ Item {
648 ApplicationManager.requestFocusApplication("gallery-app");
410 ApplicationManager.requestFocusApplication("gallery-app");
649 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);