@@ -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,17 @@ 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(apps) {
124 if (!apps) return;
90 if (!apps) return;
125− while (apps.count > 0) {
91+ while (apps.count > 1) {
92+ var appIndex = apps.get(0).appId == "unity8-dash" ? 1 : 0
126− ApplicationManager.stopApplication(apps.get(0).appId);
93+ ApplicationManager.stopApplication(apps.get(appIndex).appId);
128− compare(ApplicationManager.count, 0)
95+ 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() {
98 function test_leftEdgeDrag_data() {
@@ -183,7 +115,7 @@ Item {
184 swipeFromLeftEdge(data.swipeLength);
116 swipeFromLeftEdge(data.swipeLength);
185 if (data.appHides)
117 if (data.appHides)
186− waitUntilApplicationWindowIsFullyHidden();
118+ waitUntilDashIsFocused();
188 waitUntilApplicationWindowIsFullyVisible();
120 waitUntilApplicationWindowIsFullyVisible();
@@ -238,100 +170,18 @@ Item {
238 tryCompare(greeter, "showProgress", 0);
170 tryCompare(greeter, "showProgress", 0);
242− Perform a right-edge drag when the Dash is being show and there are
243− no running/minimized apps to be restored.
245− The expected behavior is that an animation should be played to hint the
246− user that his right-edge drag gesture has been successfully recognized
247− but there is no application to be brought to foreground.
249− function checkRightEdgeDragWithNoRunningApps() {
250− var touchX = shell.width - (shell.edgeSize / 2);
251− var touchY = shell.height / 2;
253− var dash = findChild(shell, "dash");
254− // check that dash has normal scale and opacity
255− tryCompare(dash, "contentScale", 1.0);
256− tryCompare(dash, "opacity", 1.0);
258− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
259− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
261− // check that Dash has been scaled down and had its opacity reduced
262− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
263− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
265− touchRelease(shell, shell.width * 0.1, touchY);
267− // and now everything should have gone back to normal
268− tryCompare(dash, "contentScale", 1.0);
269− tryCompare(dash, "opacity", 1.0);
273− Perform a right-edge drag when the Dash is being show and there is
274− a running/minimized app to be restored.
276− The expected behavior is that the dash should fade away and ultimately be
277− made invisible once the gesture is finished as the restored app will now
280− function checkRightEdgeDragWithMinimizedApp() {
281− var touchX = shell.width - (shell.edgeSize / 2);
282− var touchY = shell.height / 2;
284− var dash = findChild(shell, "dash");
285− // check that dash has normal scale and opacity
286− tryCompare(dash, "contentScale", 1.0);
287− tryCompare(dash, "opacity", 1.0);
289− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
290− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
292− // check that Dash has been scaled down and had its opacity reduced
293− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
294− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
296− touchRelease(shell, shell.width * 0.1, touchY);
298− // dash should have gone away, now that the app is on foreground
299− tryCompare(dash, "visible", false);
303 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
305− 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
306− category of the "Applications" scope view.
177+ "Applications" scope view.
310− - scroll to the bottom
311− - reveal launcher and launch an app
180+ - reveal launcher and launch an app that covers the dash
312 - 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.
313−
182+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
317 function test_minimizingAppTakesToDashApps() {
184 function test_minimizingAppTakesToDashApps() {
318− var dashApps = findChild(shell, "clickscope");
319− swipeUntilScopeViewIsReached(dashApps);
321− // swipe finger up until the running/recent apps section (which we assume
322− // it's the first one) is as far from view as possible.
323− // We also assume that DashApps is tall enough that it's scrollable
324− var appsCategoryListView = findChild(dashApps, "categoryListView");
325− while (!appsCategoryListView.atYEnd) {
326− swipeUpFromCenter();
327− tryCompare(appsCategoryListView, "moving", false);
330− // Switch away from the Applications scope.
331− swipeRightFromCenter();
332− waitUntilItemStopsMoving(dashApps);
333− verify(!itemIsOnScreen(dashApps));
335 dragLauncherIntoView();
185 dragLauncherIntoView();
337 // Launch an app from the launcher
187 // Launch an app from the launcher
@@ -339,19 +189,16 @@ Item {
340 waitUntilApplicationWindowIsFullyVisible();
190 waitUntilApplicationWindowIsFullyVisible();
342− // Dragging launcher into view with a little bit of gap (units.gu(1)) should switch to Apps scope
192+ verify(ApplicationManager.focusedApplicationId !== "unity8-dash")
343− dragLauncherIntoView();
344− verify(itemIsOnScreen(dashApps));
194+ dashCommunicatorSpy.clear();
346 // Minimize the application we just launched
195 // Minimize the application we just launched
347 swipeFromLeftEdge(units.gu(27));
196 swipeFromLeftEdge(units.gu(27));
349− // Wait for the whole UI to settle down
198+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
350− waitUntilApplicationWindowIsFullyHidden();
351− waitUntilItemStopsMoving(dashApps);
352− tryCompare(appsCategoryListView, "moving", false);
354− verify(itemIsOnScreen(dashApps));
200+ compare(dashCommunicatorSpy.count, 1);
201+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
357 function test_showInputMethod() {
204 function test_showInputMethod() {
@@ -408,9 +255,14 @@ Item {
409 // Wait for the whole UI to settle down
256 // Wait for the whole UI to settle down
410 function waitForUIToSettle() {
257 function waitForUIToSettle() {
411− waitUntilApplicationWindowIsFullyHidden();
412− var dashContentList = findChild(shell, "dashContentList");
258+ var launcher = findChild(shell, "launcherPanel")
413− 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)
416 function dragToCloseIndicatorsPanel() {
268 function dragToCloseIndicatorsPanel() {
@@ -427,6 +279,7 @@ Item {
428 function dragLauncherIntoView() {
280 function dragLauncherIntoView() {
429 var launcherPanel = findChild(shell, "launcherPanel");
281 var launcherPanel = findChild(shell, "launcherPanel");
282+ print("launcher is at", launcherPanel.x)
430 verify(launcherPanel.x = - launcherPanel.width);
283 verify(launcherPanel.x = - launcherPanel.width);
432 var touchStartX = 2;
285 var touchStartX = 2;
@@ -467,24 +320,12 @@ Item {
469 function waitUntilApplicationWindowIsFullyVisible() {
322 function waitUntilApplicationWindowIsFullyVisible() {
470− var underlay = findChild(shell, "underlay");
323+ var spreadView = findChild(shell, "surfaceContainer0");
471− tryCompare(underlay, "visible", false);
324+ tryCompareFunction(function() { return spreadView.surface !== null; }, true);
474− function waitUntilApplicationWindowIsFullyHidden() {
327+ function waitUntilDashIsFocused() {
475− var stages = findChild(shell, "stages");
328+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
476− tryCompare(stages, "fullyHidden", true);
479− function swipeUntilScopeViewIsReached(scopeView) {
480− while (!itemIsOnScreen(scopeView)) {
481− if (itemIsToLeftOfScreen(scopeView)) {
482− swipeRightFromCenter();
484− swipeLeftFromCenter();
486− waitUntilItemStopsMoving(scopeView);
490 function swipeFromLeftEdge(swipeLength) {
331 function swipeFromLeftEdge(swipeLength) {
@@ -493,24 +334,6 @@ Item {
493 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
334 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
496− function swipeLeftFromCenter() {
497− var touchStartX = shell.width * 3 / 4;
498− var touchStartY = shell.height / 2;
499− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
502− function swipeRightFromCenter() {
503− var touchStartX = shell.width * 3 / 4;
504− var touchStartY = shell.height / 2;
505− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
508− function swipeUpFromCenter() {
509− var touchStartX = shell.width / 2;
510− var touchStartY = shell.height / 2;
511− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
514 function itemIsOnScreen(item) {
337 function itemIsOnScreen(item) {
515 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
338 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
@@ -520,64 +343,6 @@ Item {
520 && itemRectInShell.y + itemRectInShell.height <= shell.height;
343 && itemRectInShell.y + itemRectInShell.height <= shell.height;
523− function itemIsToLeftOfScreen(item) {
524− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
525− return itemRectInShell.x < 0;
528− function waitUntilItemStopsMoving(item) {
529− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
530− var previousX = itemRectInShell.x;
531− var previousY = itemRectInShell.y;
532− var isStill = false;
536− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
537− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
540− previousX = itemRectInShell.x;
541− previousY = itemRectInShell.y;
546− function test_DashShown_data() {
548− {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
549− {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
550− {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
551− {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
552− {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: false},
556− function test_DashShown(data) {
558− // Swipe the greeter in
559− var greeter = findChild(shell, "greeter");
560− Powerd.displayPowerStateChange(Powerd.Off, 0);
561− tryCompare(greeter, "showProgress", 1);
565− dragLauncherIntoView();
566− tapOnAppIconInLauncher();
569− if (data.launcher) {
570− dragLauncherIntoView();
573− if (data.indicators) {
577− var dash = findChild(shell, "dash");
578− tryCompare(dash, "shown", data.expectedShown);
581 function test_focusRequestedHidesGreeter() {
346 function test_focusRequestedHidesGreeter() {
582 var greeter = findChild(shell, "greeter");
347 var greeter = findChild(shell, "greeter");
@@ -588,8 +353,7 @@ Item {
588 // Minimize the application we just launched
353 // Minimize the application we just launched
589 swipeFromLeftEdge(units.gu(27));
354 swipeFromLeftEdge(units.gu(27));
591− // Wait for the whole UI to settle down
356+ waitUntilDashIsFocused();
592− waitUntilApplicationWindowIsFullyHidden();
594 greeter.show();
358 greeter.show();
595 tryCompare(greeter, "showProgress", 1);
359 tryCompare(greeter, "showProgress", 1);
@@ -602,6 +366,7 @@ Item {
602 function test_showGreeterDBusCall() {
366 function test_showGreeterDBusCall() {
603 var greeter = findChild(shell, "greeter")
367 var greeter = findChild(shell, "greeter")
604 tryCompare(greeter, "showProgress", 0)
368 tryCompare(greeter, "showProgress", 0)
369+ waitForRendering(greeter);
605 LightDM.Greeter.showGreeter()
370 LightDM.Greeter.showGreeter()
606 tryCompare(greeter, "showProgress", 1)
371 tryCompare(greeter, "showProgress", 1)