on xenial help sign in
Regression test for bug LP #1193419
commitdd84c495306aeb2928d631811f481b55778f13c9 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 19 Jul 2013, 18:36 (13 years ago) parentb43f069
6 files changed+179−3
Dash/Apps/RunningApplicationsGrid.qml+1 Dash/DashApps.qml+2 Dash/DashHome.qml+1 Shell.qml+4 tests/mocks/Unity/fake_scopes.cpp+2−2 tests/qmltests/tst_Shell.qml+169−1
Dash/Apps/RunningApplicationsGrid.qml+1
@@ -20,6 +20,7 @@ import "../../Components"
2020ResponsiveFlowView {
2121 id: root
2222 clip: true
23+ objectName: "runningApplicationsGrid"
2324
2425 signal updateScreenshots
2526
Dash/DashApps.qml+2
@@ -23,6 +23,7 @@ import "Apps"
2323
2424ScopeView {
2525 id: scopeView
26+ objectName: "DashApps"
2627
2728 // FIXME: a way to aggregate these models would be ideal
2829 property var mainStageApplicationsModel: shell.applicationManager.mainStageApplications
@@ -99,6 +100,7 @@ ScopeView {
99100
100101 ScopeListView {
101102 id: categoryView
103+ objectName: "categoryListView"
102104 anchors.fill: parent
103105 model: SortFilterProxyModel {
104106 model: categoryListModel
Dash/DashHome.qml+1
@@ -26,6 +26,7 @@ import "Music"
2626
2727ScopeView {
2828 id: root
29+ objectName: "DashHome"
2930
3031 onMovementStarted: listView.showHeader()
3132
Shell.qml+4
@@ -129,6 +129,7 @@ FocusScope {
129129
130130 Item {
131131 id: underlay
132+ objectName: "underlay"
132133 anchors.fill: parent
133134
134135 // Whether the underlay is fully covered by opaque UI elements.
@@ -207,6 +208,7 @@ FocusScope {
207208
208209 Showable {
209210 id: stages
211+ objectName: "stages"
210212
211213 x: width
212214
@@ -407,6 +409,7 @@ FocusScope {
407409
408410 Greeter {
409411 id: greeter
412+ objectName: "greeter"
410413
411414 available: true
412415 hides: [launcher, panel.indicators, hud]
@@ -545,6 +548,7 @@ FocusScope {
545548
546549 Launcher {
547550 id: launcher
551+ objectName: "launcher"
548552
549553 anchors.top: parent.top
550554 anchors.bottom: parent.bottom
tests/mocks/Unity/fake_scopes.cpp+2−2
@@ -52,8 +52,8 @@ void Scopes::updateScopes()
5252 clear();
5353 addScope(new Scope("MockScope1", "People", true, this));
5454 addScope(new Scope("MockScope2", "Music", false, this));
55− addScope(new Scope("MockScope3", "Home", true, this));
56− addScope(new Scope("MockScope4", "Applications", true, this));
55+ addScope(new Scope("home.scope", "Home", true, this));
56+ addScope(new Scope("applications.scope", "Applications", true, this));
5757 addScope(new Scope("MockScope5", "Videos", true, this));
5858
5959 if (!m_loaded) {
tests/qmltests/tst_Shell.qml+169−1
@@ -20,6 +20,7 @@
2020import QtQuick 2.0
2121import QtTest 1.0
2222import Unity.Test 0.1 as UT
23+import Ubuntu.Application 0.1
2324
2425import "../.."
2526
@@ -35,10 +36,23 @@ Shell {
3536 var touchY = shell.height / 2;
3637 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
3738
38− var dash = findChild(shell, "dash");
3939 // wait until the animation has finished
40+
41+ var dash = findChild(shell, "dash");
4042 tryCompare(dash, "contentScale", 1.0);
4143 tryCompare(dash, "opacity", 1.0);
44+
45+ var greeter = findChild(shell, "greeter");
46+ tryCompare(greeter, "x", -greeter.width);
47+ }
48+
49+ function cleanup() {
50+ // kill all (fake) running apps
51+ ApplicationManager.mainStageApplications.clear();
52+ ApplicationManager.sideStageApplications.clear();
53+
54+ var dashHome = findChild(shell, "DashHome");
55+ swipeUntilScopeViewIsReached(dashHome);
4256 }
4357
4458 /*
@@ -71,5 +85,159 @@ Shell {
7185 tryCompare(dash, "contentScale", 1.0);
7286 tryCompare(dash, "opacity", 1.0);
7387 }
88+
89+ /*
90+ Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
91+
92+ When the user minimizes an application (left-edge swipe) he should always end up in the "Running Apps"
93+ category of the "Applications" scope view.
94+
95+ Steps:
96+ - go to apps lens
97+ - scroll to the bottom
98+ - reveal launcher and launch an app
99+ - perform long left edge swipe to go minimize the app and go back to the dash.
100+
101+ Expected Results
102+ - apps lens shown and Running Apps visible on screen
103+ */
104+ function test_minimizingAppTakesToRunningApps() {
105+ var dashApps = findChild(shell, "DashApps");
106+
107+ swipeUntilScopeViewIsReached(dashApps);
108+
109+ // swipe finger up until the running/recent apps section (which we assume
110+ // it's the first one) is as far from view as possible.
111+ var appsCategoryListView = findChild(dashApps, "categoryListView");
112+ while (!appsCategoryListView.atYEnd) {
113+ swipeUpFromCenter();
114+ tryCompare(appsCategoryListView, "moving", false);
115+ }
116+
117+ // Switch away from the Applications scope.
118+ swipeRightFromCenter();
119+ waitUntilItemStopsMoving(dashApps);
120+ verify(!itemIsOnScreen(dashApps));
121+
122+ dragLauncherIntoView();
123+
124+ // Launch an app from the launcher
125+ tapOnAppIconInLauncher();
126+
127+ waitUntilApplicationWindowIsFullyVisible();
128+
129+ // Minimize the application we just launched
130+ swipeFromLeftEdge();
131+
132+ // Wait for the whole UI to settle down
133+ waitUntilApplicationWindowIsFullyHidden();
134+ waitUntilItemStopsMoving(dashApps);
135+ tryCompare(appsCategoryListView, "moving", false);
136+
137+ verify(itemIsOnScreen(dashApps));
138+ var runningApplicationsGrid = findChild(dashApps, "runningApplicationsGrid");
139+ verify(itemIsOnScreen(runningApplicationsGrid));
140+ }
141+
142+ function dragLauncherIntoView() {
143+ var launcherPanel = findChild(shell, "launcherPanel");
144+ verify(launcherPanel.x = - launcherPanel.width);
145+ swipeFromLeftEdge();
146+ tryCompare(launcherPanel, "x", 0);
147+ }
148+
149+ function tapOnAppIconInLauncher() {
150+ var launcherPanel = findChild(shell, "launcherPanel");
151+
152+ // pick the first icon, the one at the bottom.
153+ var appIcon = findChild(launcherPanel, "launcherDelegate0")
154+
155+ // Swipe upwards over the launcher to ensure that this icon
156+ // at the bottom is not folded and faded away.
157+ var touchStartX = launcherPanel.width / 2;
158+ var touchStartY = launcherPanel.height / 2;
159+ touchFlick(launcherPanel, touchStartX, touchStartY, touchStartX, 0);
160+ tryCompare(launcherPanel, "moving", false);
161+
162+ // NB tapping (i.e., using touch events) doesn't activate the icon... go figure...
163+ mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
164+ }
165+
166+ function waitUntilApplicationWindowIsFullyVisible() {
167+ var underlay = findChild(shell, "underlay");
168+ tryCompare(underlay, "visible", false);
169+ }
170+
171+ function waitUntilApplicationWindowIsFullyHidden() {
172+ var stages = findChild(shell, "stages");
173+ tryCompare(stages, "fullyHidden", true);
174+ }
175+
176+ function swipeUntilScopeViewIsReached(scopeView) {
177+ while (!itemIsOnScreen(scopeView)) {
178+ if (itemIsToLeftOfScreen(scopeView)) {
179+ swipeRightFromCenter();
180+ } else {
181+ swipeLeftFromCenter();
182+ }
183+ waitUntilItemStopsMoving(scopeView);
184+ }
185+ }
186+
187+ function swipeFromLeftEdge() {
188+ var touchStartX = 2;
189+ var touchStartY = shell.height / 2;
190+ touchFlick(shell, touchStartX, touchStartY, shell.width * 0.75, touchStartY);
191+ }
192+
193+ function swipeLeftFromCenter() {
194+ var touchStartX = shell.width / 2;
195+ var touchStartY = shell.height / 2;
196+ touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
197+ }
198+
199+ function swipeRightFromCenter() {
200+ var touchStartX = shell.width / 2;
201+ var touchStartY = shell.height / 2;
202+ touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
203+ }
204+
205+ function swipeUpFromCenter() {
206+ var touchStartX = shell.width / 2;
207+ var touchStartY = shell.height / 2;
208+ touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
209+ }
210+
211+ function waitUntilItemStopsMoving(item) {
212+ var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
213+ var previousX = itemRectInShell.x;
214+ var previousY = itemRectInShell.y;
215+ var isStill = false;
216+
217+ do {
218+ wait(100);
219+ itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
220+ if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
221+ isStill = true;
222+ } else {
223+ previousX = itemRectInShell.x;
224+ previousY = itemRectInShell.y;
225+ }
226+ } while (!isStill);
227+ }
228+
229+ function itemIsOnScreen(item) {
230+ var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
231+
232+ return itemRectInShell.x >= 0
233+ && itemRectInShell.y >= 0
234+ && itemRectInShell.x + itemRectInShell.width <= shell.width
235+ && itemRectInShell.y + itemRectInShell.height <= shell.height;
236+ }
237+
238+ function itemIsToLeftOfScreen(item) {
239+ var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
240+ return itemRectInShell.x < 0;
241+ }
74242 }
75243}