on xenial help sign in
update tst_Shell
commitcd69592d38a7e19a83f99a4496357a7fb1e59779 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 24 Jul 2014, 22:07 (12 years ago) parent4a9697b
8 files changed+68−272
qml/Dash/graphics/phone/screenshots/dash.png qml/Shell.qml+2−1 qml/Stages/PhoneStage.qml+6 qml/Stages/SpreadDelegate.qml+1 tests/mocks/Unity/Application/ApplicationManager.cpp+19 tests/mocks/Unity/Application/ApplicationManager.h+3 tests/mocks/Unity/CMakeLists.txt+1 tests/qmltests/tst_Shell.qml+36−271
qml/Dash/graphics/phone/screenshots/dash.pngnew file

No changes to the content.

qml/Shell.qml+2−1
@@ -85,6 +85,7 @@ Item {
8585
8686 DashCommunicator {
8787 id: dash
88+ objectName: "dashCommunicator"
8889 }
8990
9091 WindowKeysFilter {
@@ -475,7 +476,7 @@ Item {
475476
476477 onShowDashHome: showHome()
477478 onDash: showDash()
478− onDashSwipeChanged: if (dashSwipe && stages.shown) dash.setCurrentScope("clickscope", false, true)
479+ onDashSwipeChanged: if (dashSwipe) dash.setCurrentScope("clickscope", false, true)
479480 onLauncherApplicationSelected: {
480481 if (greeter.fakeActiveForApp !== "") {
481482 lockscreen.show()
qml/Stages/PhoneStage.qml+6
@@ -190,6 +190,12 @@ Item {
190190 snapAnimation.start();
191191 }
192192
193+ // In case the ApplicationManager already holds an app when starting up we're missing animations
194+ // Make sure we end up in the same state
195+ Component.onCompleted: {
196+ spreadView.contentX = -spreadView.shift
197+ }
198+
193199 SequentialAnimation {
194200 id: snapAnimation
195201 property int targetContentX: -spreadView.shift
qml/Stages/SpreadDelegate.qml+1
@@ -37,6 +37,7 @@ Item {
3737
3838 Item {
3939 id: surfaceContainer
40+ objectName: "surfaceContainer" + index
4041 anchors.fill: parent
4142 readonly property var surface: model.surface
4243 property bool appHasCreatedASurface: false
tests/mocks/Unity/Application/ApplicationManager.cpp+19
@@ -41,6 +41,8 @@ ApplicationManager::ApplicationManager(QObject *parent)
4141 m_roleNames.insert(RoleFullscreen, "fullscreen");
4242
4343 buildListOfAvailableApplications();
44+
45+ startDash();
4446}
4547
4648ApplicationManager::~ApplicationManager()
@@ -205,6 +207,10 @@ ApplicationInfo* ApplicationManager::startApplication(const QString &appId,
205207
206208bool ApplicationManager::stopApplication(const QString &appId)
207209{
210+ if (appId == "unity8-dash") {
211+ return false;
212+ }
213+
208214 ApplicationInfo *application = findApplication(appId);
209215 if (application == nullptr)
210216 return false;
@@ -380,6 +386,14 @@ void ApplicationManager::buildListOfAvailableApplications()
380386{
381387 ApplicationInfo *application;
382388
389+ application = new ApplicationInfo(this);
390+ application->setAppId("unity8-dash");
391+ application->setName("Unity 8 Mock Dash");
392+ application->setIcon(QUrl("unity8-dash"));
393+ application->setStage(ApplicationInfo::SideStage);
394+ generateQmlStrings(application);
395+ m_availableApplications.append(application);
396+
383397 application = new ApplicationInfo(this);
384398 application->setAppId("dialer-app");
385399 application->setName("Dialer");
@@ -598,3 +612,8 @@ bool ApplicationManager::isEmpty() const
598612{
599613 return m_runningApplications.isEmpty();
600614}
615+
616+void ApplicationManager::startDash()
617+{
618+ startApplication("unity8-dash");
619+}
tests/mocks/Unity/Application/ApplicationManager.h+3
@@ -118,6 +118,9 @@ class ApplicationManager : public ApplicationManagerInterface {
118118 void focusRequested(const QString &appId);
119119 void emptyChanged(bool empty);
120120
121+ private Q_SLOTS:
122+ void startDash();
123+
121124 private:
122125 void add(ApplicationInfo *application);
123126 void remove(ApplicationInfo* application);
tests/mocks/Unity/CMakeLists.txt+1
@@ -2,6 +2,7 @@ add_subdirectory(Application)
22add_subdirectory(Indicators)
33add_subdirectory(Launcher)
44add_subdirectory(Notifications)
5+add_subdirectory(DashCommunicator)
56
67pkg_search_module(DEE dee-1.0 REQUIRED)
78pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
tests/qmltests/tst_Shell.qml+36−271
@@ -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,17 @@ 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
12389 function killApps(apps) {
12490 if (!apps) return;
125− while (apps.count > 0) {
126− ApplicationManager.stopApplication(apps.get(0).appId);
91+ while (apps.count > 1) {
92+ var appIndex = apps.get(0).appId == "unity8-dash" ? 1 : 0
93+ ApplicationManager.stopApplication(apps.get(appIndex).appId);
12794 }
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();
95+ compare(ApplicationManager.count, 1)
16496 }
16597
16698 function test_leftEdgeDrag_data() {
@@ -183,7 +115,7 @@ Item {
183115
184116 swipeFromLeftEdge(data.swipeLength);
185117 if (data.appHides)
186− waitUntilApplicationWindowIsFullyHidden();
118+ waitUntilDashIsFocused();
187119 else
188120 waitUntilApplicationWindowIsFullyVisible();
189121 }
@@ -238,100 +170,18 @@ Item {
238170 tryCompare(greeter, "showProgress", 0);
239171 }
240172
241− /*
242− Perform a right-edge drag when the Dash is being show and there are
243− no running/minimized apps to be restored.
244−
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.
248− */
249− function checkRightEdgeDragWithNoRunningApps() {
250− var touchX = shell.width - (shell.edgeSize / 2);
251− var touchY = shell.height / 2;
252−
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);
257−
258− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
259− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
260−
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);
264−
265− touchRelease(shell, shell.width * 0.1, touchY);
266−
267− // and now everything should have gone back to normal
268− tryCompare(dash, "contentScale", 1.0);
269− tryCompare(dash, "opacity", 1.0);
270− }
271−
272− /*
273− Perform a right-edge drag when the Dash is being show and there is
274− a running/minimized app to be restored.
275−
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
278− be on foreground.
279− */
280− function checkRightEdgeDragWithMinimizedApp() {
281− var touchX = shell.width - (shell.edgeSize / 2);
282− var touchY = shell.height / 2;
283−
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);
288−
289− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
290− true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
291−
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);
295−
296− touchRelease(shell, shell.width * 0.1, touchY);
297−
298− // dash should have gone away, now that the app is on foreground
299− tryCompare(dash, "visible", false);
300− }
301−
302173 /*
303174 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
304175
305− When the user minimizes an application (left-edge swipe) he should always end up in the "Running Apps"
306− 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.
307178
308179 Steps:
309− - go to apps lens
310− - scroll to the bottom
311− - reveal launcher and launch an app
180+ - reveal launcher and launch an app that covers the dash
312181 - perform long left edge swipe to go minimize the app and go back to the dash.
313−
314− Expected Results
315− - apps lens shown
182+ - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
316183 */
317184 function test_minimizingAppTakesToDashApps() {
318− var dashApps = findChild(shell, "clickscope");
319− swipeUntilScopeViewIsReached(dashApps);
320−
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);
328− }
329−
330− // Switch away from the Applications scope.
331− swipeRightFromCenter();
332− waitUntilItemStopsMoving(dashApps);
333− verify(!itemIsOnScreen(dashApps));
334−
335185 dragLauncherIntoView();
336186
337187 // Launch an app from the launcher
@@ -339,19 +189,16 @@ Item {
339189
340190 waitUntilApplicationWindowIsFullyVisible();
341191
342− // Dragging launcher into view with a little bit of gap (units.gu(1)) should switch to Apps scope
343− dragLauncherIntoView();
344− verify(itemIsOnScreen(dashApps));
192+ verify(ApplicationManager.focusedApplicationId !== "unity8-dash")
345193
194+ dashCommunicatorSpy.clear();
346195 // Minimize the application we just launched
347196 swipeFromLeftEdge(units.gu(27));
348197
349− // Wait for the whole UI to settle down
350− waitUntilApplicationWindowIsFullyHidden();
351− waitUntilItemStopsMoving(dashApps);
352− tryCompare(appsCategoryListView, "moving", false);
198+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
353199
354− verify(itemIsOnScreen(dashApps));
200+ compare(dashCommunicatorSpy.count, 1);
201+ compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
355202 }
356203
357204 function test_showInputMethod() {
@@ -408,9 +255,14 @@ Item {
408255
409256 // Wait for the whole UI to settle down
410257 function waitForUIToSettle() {
411− waitUntilApplicationWindowIsFullyHidden();
412− var dashContentList = findChild(shell, "dashContentList");
413− 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)
414266 }
415267
416268 function dragToCloseIndicatorsPanel() {
@@ -427,6 +279,7 @@ Item {
427279
428280 function dragLauncherIntoView() {
429281 var launcherPanel = findChild(shell, "launcherPanel");
282+ print("launcher is at", launcherPanel.x)
430283 verify(launcherPanel.x = - launcherPanel.width);
431284
432285 var touchStartX = 2;
@@ -467,24 +320,12 @@ Item {
467320 }
468321
469322 function waitUntilApplicationWindowIsFullyVisible() {
470− var underlay = findChild(shell, "underlay");
471− tryCompare(underlay, "visible", false);
323+ var spreadView = findChild(shell, "surfaceContainer0");
324+ tryCompareFunction(function() { return spreadView.surface !== null; }, true);
472325 }
473326
474− function waitUntilApplicationWindowIsFullyHidden() {
475− var stages = findChild(shell, "stages");
476− tryCompare(stages, "fullyHidden", true);
477− }
478−
479− function swipeUntilScopeViewIsReached(scopeView) {
480− while (!itemIsOnScreen(scopeView)) {
481− if (itemIsToLeftOfScreen(scopeView)) {
482− swipeRightFromCenter();
483− } else {
484− swipeLeftFromCenter();
485− }
486− waitUntilItemStopsMoving(scopeView);
487− }
327+ function waitUntilDashIsFocused() {
328+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
488329 }
489330
490331 function swipeFromLeftEdge(swipeLength) {
@@ -493,24 +334,6 @@ Item {
493334 touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY);
494335 }
495336
496− function swipeLeftFromCenter() {
497− var touchStartX = shell.width * 3 / 4;
498− var touchStartY = shell.height / 2;
499− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
500− }
501−
502− function swipeRightFromCenter() {
503− var touchStartX = shell.width * 3 / 4;
504− var touchStartY = shell.height / 2;
505− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
506− }
507−
508− function swipeUpFromCenter() {
509− var touchStartX = shell.width / 2;
510− var touchStartY = shell.height / 2;
511− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
512− }
513−
514337 function itemIsOnScreen(item) {
515338 var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
516339
@@ -520,64 +343,6 @@ Item {
520343 && itemRectInShell.y + itemRectInShell.height <= shell.height;
521344 }
522345
523− function itemIsToLeftOfScreen(item) {
524− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
525− return itemRectInShell.x < 0;
526− }
527−
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;
533−
534− do {
535− wait(100);
536− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
537− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
538− isStill = true;
539− } else {
540− previousX = itemRectInShell.x;
541− previousY = itemRectInShell.y;
542− }
543− } while (!isStill);
544− }
545−
546− function test_DashShown_data() {
547− return [
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},
553− ]
554− }
555−
556− function test_DashShown(data) {
557− if (data.greeter) {
558− // Swipe the greeter in
559− var greeter = findChild(shell, "greeter");
560− Powerd.displayPowerStateChange(Powerd.Off, 0);
561− tryCompare(greeter, "showProgress", 1);
562− }
563−
564− if (data.app) {
565− dragLauncherIntoView();
566− tapOnAppIconInLauncher();
567− }
568−
569− if (data.launcher) {
570− dragLauncherIntoView();
571− }
572−
573− if (data.indicators) {
574− showIndicators();
575− }
576−
577− var dash = findChild(shell, "dash");
578− tryCompare(dash, "shown", data.expectedShown);
579− }
580−
581346 function test_focusRequestedHidesGreeter() {
582347 var greeter = findChild(shell, "greeter");
583348
@@ -588,8 +353,7 @@ Item {
588353 // Minimize the application we just launched
589354 swipeFromLeftEdge(units.gu(27));
590355
591− // Wait for the whole UI to settle down
592− waitUntilApplicationWindowIsFullyHidden();
356+ waitUntilDashIsFocused();
593357
594358 greeter.show();
595359 tryCompare(greeter, "showProgress", 1);
@@ -602,6 +366,7 @@ Item {
602366 function test_showGreeterDBusCall() {
603367 var greeter = findChild(shell, "greeter")
604368 tryCompare(greeter, "showProgress", 0)
369+ waitForRendering(greeter);
605370 LightDM.Greeter.showGreeter()
606371 tryCompare(greeter, "showProgress", 1)
607372 }