@@ -57,6 +57,11 @@ Item {
57 signalName: "sessionStarted"
57 signalName: "sessionStarted"
61+ id: dashCommunicatorSpy
62+ signalName: "setCurrentScopeCalled"
60 Telephony.CallEntry {
65 Telephony.CallEntry {
61 id: phoneCall
66 id: phoneCall
62 phoneNumber: "+447812221111"
67 phoneNumber: "+447812221111"
@@ -67,44 +72,10 @@ Item {
67 when: windowShown
72 when: windowShown
69 function initTestCase() {
74 function initTestCase() {
72− var maxAttempts = 1000;
74− // Qt loads a qml scene asynchronously. So early on, some findChild() calls made in
75− // tests may fail because the desired child item wasn't loaded yet.
76− // Thus here we try to ensure the scene has been fully loaded before proceeding with the tests.
77− // As I couldn't find an API in QQuickView & friends to tell me that the scene is 100% loaded
78− // (all items instantiated, etc), I resort to checking the existence of some key items until
79− // repeatedly until they're all there.
81− var dashContentList = findChild(shell, "dashContentList");
82− waitForRendering(dashContentList);
83− var homeLoader = findChild(dashContentList, "clickscope loader");
84− ok = homeLoader !== null
85− && homeLoader.item !== undefined;
87− var greeter = findChild(shell, "greeter");
88− ok &= greeter !== null;
90− var launcherPanel = findChild(shell, "launcherPanel");
91− ok &= launcherPanel !== null;
95− console.log("Attempt " + attempts + " failed. Waiting a bit before trying again.");
96− // wait a bit before retrying
99− console.log("All seem fine after " + attempts + " attempts.");
101− } while (!ok && attempts <= maxAttempts);
105 swipeAwayGreeter();
75 swipeAwayGreeter();
107 sessionSpy.target = findChild(shell, "greeter")
77 sessionSpy.target = findChild(shell, "greeter")
78+ dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
110 function cleanup() {
81 function cleanup() {
@@ -117,56 +88,16 @@ Item {
117 // kill all (fake) running apps
88 // kill all (fake) running apps
118 killApps(ApplicationManager);
89 killApps(ApplicationManager);
120− var dashContent = findChild(shell, "dashContent");
91+ waitForUIToSettle();
121− dashContent.closePreview();
123− var dashHome = findChild(shell, "clickscope loader");
124− swipeUntilScopeViewIsReached(dashHome);
126 hideIndicators();
92 hideIndicators();
129− function killApps(apps) {
95+ function killApps() {
131− while (apps.count > 0) {
96+ while (ApplicationManager.count > 1) {
97+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
132− ApplicationManager.stopApplication(apps.get(0).appId);
98+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
134− compare(ApplicationManager.count, 0)
100+ compare(ApplicationManager.count, 1)
138− Test the effect of a right-edge drag on the dash in 3 situations:
139− 1 - when no application has been launched yet
140− 2 - when there's a minimized application
141− 3 - after the last running application has been closed/stopped
143− The behavior of Dash on 3 should be the same as on 1.
145− function test_rightEdgeDrag() {
146− checkRightEdgeDragWithNoRunningApps();
148− dragLauncherIntoView();
150− // Launch an app from the launcher
151− tapOnAppIconInLauncher();
152− waitUntilApplicationWindowIsFullyVisible();
154− // Minimize the application we just launched
155− swipeFromLeftEdge(units.gu(27));
157− waitForUIToSettle();
159− checkRightEdgeDragWithMinimizedApp();
161− // Minimize that application once again
162− swipeFromLeftEdge(units.gu(27));
164− // Right edge behavior should now be the same as before that app,
165− // was launched. Manually cleanup beforehand to get to initial
168− waitForUIToSettle();
169− checkRightEdgeDragWithNoRunningApps();
172 function test_leftEdgeDrag_data() {
103 function test_leftEdgeDrag_data() {
@@ -189,7 +120,7 @@ Item {
190 swipeFromLeftEdge(data.swipeLength);
121 swipeFromLeftEdge(data.swipeLength);
191 if (data.appHides)
122 if (data.appHides)
192− waitUntilApplicationWindowIsFullyHidden();
123+ waitUntilDashIsFocused();
194 waitUntilApplicationWindowIsFullyVisible();
125 waitUntilApplicationWindowIsFullyVisible();
@@ -244,100 +175,18 @@ Item {
244 waitForRendering(greeter);
175 waitForRendering(greeter);
248− Perform a right-edge drag when the Dash is being show and there are
249− no running/minimized apps to be restored.
251− The expected behavior is that an animation should be played to hint the
252− user that his right-edge drag gesture has been successfully recognized
253− but there is no application to be brought to foreground.
255− function checkRightEdgeDragWithNoRunningApps() {
256− var touchX = shell.width - (shell.edgeSize / 2);
257− var touchY = shell.height / 2;
259− var dash = findChild(shell, "dash");
260− // check that dash has normal scale and opacity
261− tryCompare(dash, "contentScale", 1.0);
262− tryCompare(dash, "opacity", 1.0);
264− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
265− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
267− // check that Dash has been scaled down and had its opacity reduced
268− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
269− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
271− touchRelease(shell, shell.width * 0.1, touchY);
273− // and now everything should have gone back to normal
274− tryCompare(dash, "contentScale", 1.0);
275− tryCompare(dash, "opacity", 1.0);
279− Perform a right-edge drag when the Dash is being show and there is
280− a running/minimized app to be restored.
282− The expected behavior is that the dash should fade away and ultimately be
283− made invisible once the gesture is finished as the restored app will now
286− function checkRightEdgeDragWithMinimizedApp() {
287− var touchX = shell.width - (shell.edgeSize / 2);
288− var touchY = shell.height / 2;
290− var dash = findChild(shell, "dash");
291− // check that dash has normal scale and opacity
292− tryCompare(dash, "contentScale", 1.0);
293− tryCompare(dash, "opacity", 1.0);
295− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
296− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
298− // check that Dash has been scaled down and had its opacity reduced
299− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
300− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
302− touchRelease(shell, shell.width * 0.1, touchY);
304− // dash should have gone away, now that the app is on foreground
305− tryCompare(dash, "visible", false);
309 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
179 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
311− When the user minimizes an application (left-edge swipe) he should always end up in the "Running Apps"
181+ When the user minimizes an application (left-edge swipe) he should always end up in the
312− category of the "Applications" scope view.
182+ "Applications" scope view.
316− - scroll to the bottom
317− - reveal launcher and launch an app
185+ - reveal launcher and launch an app that covers the dash
318 - perform long left edge swipe to go minimize the app and go back to the dash.
186 - perform long left edge swipe to go minimize the app and go back to the dash.
319−
187+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
323 function test_minimizingAppTakesToDashApps() {
189 function test_minimizingAppTakesToDashApps() {
324− var dashApps = findChild(shell, "clickscope");
325− swipeUntilScopeViewIsReached(dashApps);
327− // swipe finger up until the running/recent apps section (which we assume
328− // it's the first one) is as far from view as possible.
329− // We also assume that DashApps is tall enough that it's scrollable
330− var appsCategoryListView = findChild(dashApps, "categoryListView");
331− while (!appsCategoryListView.atYEnd) {
332− swipeUpFromCenter();
333− tryCompare(appsCategoryListView, "moving", false);
336− // Switch away from the Applications scope.
337− swipeRightFromCenter();
338− waitUntilItemStopsMoving(dashApps);
339− verify(!itemIsOnScreen(dashApps));
341 dragLauncherIntoView();
190 dragLauncherIntoView();
343 // Launch an app from the launcher
192 // Launch an app from the launcher
@@ -345,19 +194,16 @@ Item {
346 waitUntilApplicationWindowIsFullyVisible();
195 waitUntilApplicationWindowIsFullyVisible();
348− // Dragging launcher into view with a little bit of gap (units.gu(1)) should switch to Apps scope
197+ verify(ApplicationManager.focusedApplicationId !== "unity8-dash")
349− dragLauncherIntoView();
350− verify(itemIsOnScreen(dashApps));
199+ dashCommunicatorSpy.clear();
352 // Minimize the application we just launched
200 // Minimize the application we just launched
353 swipeFromLeftEdge(units.gu(27));
201 swipeFromLeftEdge(units.gu(27));
355− // Wait for the whole UI to settle down
203+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
356− waitUntilApplicationWindowIsFullyHidden();
357− waitUntilItemStopsMoving(dashApps);
358− tryCompare(appsCategoryListView, "moving", false);
360− verify(itemIsOnScreen(dashApps));
205+ compare(dashCommunicatorSpy.count, 1);
206+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
363 function test_showInputMethod() {
209 function test_showInputMethod() {
@@ -414,9 +260,14 @@ Item {
415 // Wait for the whole UI to settle down
261 // Wait for the whole UI to settle down
416 function waitForUIToSettle() {
262 function waitForUIToSettle() {
417− waitUntilApplicationWindowIsFullyHidden();
418− var dashContentList = findChild(shell, "dashContentList");
263+ var launcher = findChild(shell, "launcherPanel")
419− tryCompare(dashContentList, "moving", false);
264+ tryCompareFunction(function() {return launcher.x === 0 || launcher.x === -launcher.width;}, true);
265+ if (launcher.x === 0) {
266+ mouseClick(shell, shell.width / 2, shell.height / 2)
268+ tryCompare(launcher, "x", -launcher.width)
270+ waitForRendering(shell)
422 function dragToCloseIndicatorsPanel() {
273 function dragToCloseIndicatorsPanel() {
@@ -473,24 +324,13 @@ Item {
475 function waitUntilApplicationWindowIsFullyVisible() {
326 function waitUntilApplicationWindowIsFullyVisible() {
476− var underlay = findChild(shell, "underlay");
327+ var appDelegate = findChild(shell, "appDelegate0")
477− tryCompare(underlay, "visible", false);
328+ var surfaceContainer = findChild(appDelegate, "surfaceContainer");
329+ tryCompareFunction(function() { return surfaceContainer.surface !== null; }, true);
480− function waitUntilApplicationWindowIsFullyHidden() {
332+ function waitUntilDashIsFocused() {
481− var stages = findChild(shell, "stages");
333+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
482− tryCompare(stages, "fullyHidden", true);
485− function swipeUntilScopeViewIsReached(scopeView) {
486− while (!itemIsOnScreen(scopeView)) {
487− if (itemIsToLeftOfScreen(scopeView)) {
488− swipeRightFromCenter();
490− swipeLeftFromCenter();
492− waitUntilItemStopsMoving(scopeView);
496 function swipeFromLeftEdge(swipeLength) {
336 function swipeFromLeftEdge(swipeLength) {
@@ -499,24 +339,6 @@ Item {
499 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
339 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
502− function swipeLeftFromCenter() {
503− var touchStartX = shell.width * 3 / 4;
504− var touchStartY = shell.height / 2;
505− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
508− function swipeRightFromCenter() {
509− var touchStartX = shell.width * 3 / 4;
510− var touchStartY = shell.height / 2;
511− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
514− function swipeUpFromCenter() {
515− var touchStartX = shell.width / 2;
516− var touchStartY = shell.height / 2;
517− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
520 function itemIsOnScreen(item) {
342 function itemIsOnScreen(item) {
521 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
343 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
@@ -526,64 +348,6 @@ Item {
526 && itemRectInShell.y + itemRectInShell.height <= shell.height;
348 && itemRectInShell.y + itemRectInShell.height <= shell.height;
529− function itemIsToLeftOfScreen(item) {
530− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
531− return itemRectInShell.x < 0;
534− function waitUntilItemStopsMoving(item) {
535− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
536− var previousX = itemRectInShell.x;
537− var previousY = itemRectInShell.y;
538− var isStill = false;
542− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
543− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
546− previousX = itemRectInShell.x;
547− previousY = itemRectInShell.y;
552− function test_DashShown_data() {
554− {tag: "in focus", greeter: false, app: false, launcher: false, indicators: false, expectedShown: true},
555− {tag: "under greeter", greeter: true, app: false, launcher: false, indicators: false, expectedShown: false},
556− {tag: "under app", greeter: false, app: true, launcher: false, indicators: false, expectedShown: false},
557− {tag: "under launcher", greeter: false, app: false, launcher: true, indicators: false, expectedShown: true},
558− {tag: "under indicators", greeter: false, app: false, launcher: false, indicators: true, expectedShown: false},
562− function test_DashShown(data) {
564− // Swipe the greeter in
565− var greeter = findChild(shell, "greeter");
566− LightDM.Greeter.showGreeter();
567− tryCompare(greeter, "showProgress", 1);
571− dragLauncherIntoView();
572− tapOnAppIconInLauncher();
575− if (data.launcher) {
576− dragLauncherIntoView();
579− if (data.indicators) {
583− var dash = findChild(shell, "dash");
584− tryCompare(dash, "shown", data.expectedShown);
587 function test_focusRequestedHidesGreeter() {
351 function test_focusRequestedHidesGreeter() {
588 var greeter = findChild(shell, "greeter");
352 var greeter = findChild(shell, "greeter");
@@ -592,10 +356,9 @@ Item {
592 tryCompareFunction(function() { return app.surface != null }, true);
356 tryCompareFunction(function() { return app.surface != null }, true);
594 // Minimize the application we just launched
358 // Minimize the application we just launched
595− swipeFromLeftEdge(units.gu(27));
359+ swipeFromLeftEdge(units.gu(26) + 1);
597− // Wait for the whole UI to settle down
361+ waitUntilDashIsFocused();
598− waitUntilApplicationWindowIsFullyHidden();
600 greeter.show();
363 greeter.show();
601 tryCompare(greeter, "showProgress", 1);
364 tryCompare(greeter, "showProgress", 1);
@@ -611,8 +374,9 @@ Item {
612 showIndicators();
375 showIndicators();
377+ var oldCount = ApplicationManager.count;
614 ApplicationManager.startApplication("camera-app");
378 ApplicationManager.startApplication("camera-app");
615− tryCompare(ApplicationManager, "count", 1);
379+ tryCompare(ApplicationManager, "count", oldCount + 1);
617 tryCompare(indicators, "fullyClosed", true);
381 tryCompare(indicators, "fullyClosed", true);
@@ -621,6 +385,7 @@ Item {
621 function test_showGreeterDBusCall() {
385 function test_showGreeterDBusCall() {
622 var greeter = findChild(shell, "greeter")
386 var greeter = findChild(shell, "greeter")
623 tryCompare(greeter, "showProgress", 0)
387 tryCompare(greeter, "showProgress", 0)
388+ waitForRendering(greeter);
624 LightDM.Greeter.showGreeter()
389 LightDM.Greeter.showGreeter()
625 tryCompare(greeter, "showProgress", 1)
390 tryCompare(greeter, "showProgress", 1)
@@ -629,6 +394,7 @@ Item {
629 sessionSpy.clear()
394 sessionSpy.clear()
631 var greeter = findChild(shell, "greeter")
396 var greeter = findChild(shell, "greeter")
397+ waitForRendering(greeter)
632 greeter.show()
398 greeter.show()
633 tryCompare(greeter, "showProgress", 1)
399 tryCompare(greeter, "showProgress", 1)
@@ -649,5 +415,26 @@ Item {
649 ApplicationManager.requestFocusApplication("gallery-app");
415 ApplicationManager.requestFocusApplication("gallery-app");
650 tryCompare(panel, "fullscreenMode", false);
416 tryCompare(panel, "fullscreenMode", false);
419+ function test_leftEdgeDragFullscreen() {
420+ var panel = findChild(shell, "panel");
421+ tryCompare(panel, "fullscreenMode", false)
423+ ApplicationManager.startApplication("camera-app");
424+ tryCompare(panel, "fullscreenMode", true)
426+ var touchStartX = 2;
427+ var touchStartY = shell.height / 2;
429+ touchFlick(shell, touchStartX, touchStartY, units.gu(2), touchStartY, true, false);
431+ compare(panel.fullscreenMode, true);
433+ touchFlick(shell, units.gu(2), touchStartY, units.gu(10), touchStartY, false, false);
435+ tryCompare(panel, "fullscreenMode", false);
437+ touchRelease(shell);