on xenial help sign in
Add test for the wrong bg...
commit99eff3905c5f5e587f694fe333b5548d75a908f1 authorAndrea Cimitan <andrea.cimitan@canonical.com> dateMon 12 Aug 2013, 17:11 (13 years ago) parent83fd0fa309ebd3
3 files changed+209−209
Components/CrossFadeImage.qml−2 Shell.qml+5−2 tests/qmltests/tst_Shell.qml+204−205
Components/CrossFadeImage.qml−2
@@ -58,7 +58,6 @@ Item {
5858 }
5959
6060 onSourceChanged: {
61− console.log("here")
6261 // On creation, the souce handler is called before image pointers are set.
6362 if (__currentImage === null) {
6463 __currentImage = image1;
@@ -79,7 +78,6 @@ Item {
7978 // If case the image is still in QML's cache, status will be "Ready" immediately
8079 if (__nextImage.status == Image.Ready || __nextImage.source == "") {
8180 swapImages();
82−
8381 }
8482 }
8583 }
Shell.qml+5−2
@@ -149,13 +149,16 @@ FocusScope {
149149 id: backgroundImage
150150 objectName: "backgroundImage"
151151
152− property url gSettingsPicture: backgroundSettings.pictureUri
152+ property url gSettingsPicture: backgroundSettings.pictureUri.length > 0 ? backgroundSettings.pictureUri : defaultBackground
153153
154154 anchors.fill: parent
155155
156− onGSettingsPictureChanged: source = gSettingsPicture
156+ onGSettingsPictureChanged: {
157+ source = gSettingsPicture
158+ }
157159
158160 onStatusChanged: {
161+ print("################################## image status changed", status, "(", Image.Error,"), source:", source)
159162 if (status == Image.Error && source != defaultBackground) {
160163 source = defaultBackground
161164 }
tests/qmltests/tst_Shell.qml+204−205
@@ -74,210 +74,210 @@ Item {
7474 swipeUntilScopeViewIsReached(dashHome);
7575 }
7676
77−// /*
78−// Test the effect of a right-edge drag on the dash in 3 situations:
79−// 1 - when no application has been launched yet
80−// 2 - when there's a minimized application
81−// 3 - after the last running application has been closed/stopped
77+ /*
78+ Test the effect of a right-edge drag on the dash in 3 situations:
79+ 1 - when no application has been launched yet
80+ 2 - when there's a minimized application
81+ 3 - after the last running application has been closed/stopped
8282
83−// The behavior of Dash on 3 should be the same as on 1.
84−// */
85−// function test_rightEdgeDrag() {
86−// checkRightEdgeDragWithNoRunningApps();
83+ The behavior of Dash on 3 should be the same as on 1.
84+ */
85+ function test_rightEdgeDrag() {
86+ checkRightEdgeDragWithNoRunningApps();
8787
88−// dragLauncherIntoView();
89−
90−// // Launch an app from the launcher
91−// tapOnAppIconInLauncher();
92−// waitUntilApplicationWindowIsFullyVisible();
88+ dragLauncherIntoView();
9389
94−// // Minimize the application we just launched
95−// swipeFromLeftEdge();
96−
97−// waitForUIToSettle();
98−
99−// checkRightEdgeDragWithMinimizedApp();
100−
101−// // Minimize that application once again
102−// swipeFromLeftEdge();
103−
104−// // kill it
105−// ApplicationManager.mainStageApplications.clear();
106−
107−// waitForUIToSettle();
108−
109−// // Right edge behavior should now be the same as before that app was launched
110−// checkRightEdgeDragWithNoRunningApps();
111−// }
112−
113−// /*
114−// Perform a right-edge drag when the Dash is being show and there are
115−// no running/minimized apps to be restored.
116−
117−// The expected behavior is that an animation should be played to hint the
118−// user that his right-edge drag gesture has been successfully recognized
119−// but there is no application to be brought to foreground.
120−// */
121−// function checkRightEdgeDragWithNoRunningApps() {
122−// var touchX = shell.width - (shell.edgeSize / 2);
123−// var touchY = shell.height / 2;
124−
125−// var dash = findChild(shell, "dash");
126−// // check that dash has normal scale and opacity
127−// compare(dash.contentScale, 1.0);
128−// compare(dash.opacity, 1.0);
129−
130−// touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
131−// true /* beginTouch */, false /* endTouch */);
132−
133−// // check that Dash has been scaled down and had its opacity reduced
134−// tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
135−// tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
136−
137−// touchRelease(shell, shell.width * 0.1, touchY);
138−
139−// // and now everything should have gone back to normal
140−// tryCompare(dash, "contentScale", 1.0);
141−// tryCompare(dash, "opacity", 1.0);
142−// }
143−
144−// /*
145−// Perform a right-edge drag when the Dash is being show and there is
146−// a running/minimized app to be restored.
147−
148−// The expected behavior is that the dash should fade away and ultimately be
149−// made invisible once the gesture is finished as the restored app will now
150−// be on foreground.
151−// */
152−// function checkRightEdgeDragWithMinimizedApp() {
153−// var touchX = shell.width - (shell.edgeSize / 2);
154−// var touchY = shell.height / 2;
155−
156−// var dash = findChild(shell, "dash");
157−// // check that dash has normal scale and opacity
158−// tryCompare(dash, "contentScale", 1.0);
159−// tryCompare(dash, "opacity", 1.0);
160−
161−// touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
162−// true /* beginTouch */, false /* endTouch */);
163−
164−// // check that Dash has been scaled down and had its opacity reduced
165−// tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
166−// tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
167−
168−// touchRelease(shell, shell.width * 0.1, touchY);
169−
170−// // dash should have gone away, now that the app is on foreground
171−// tryCompare(dash, "visible", false);
172−// }
173−
174−// // Wait for the whole UI to settle down
175−// function waitForUIToSettle() {
176−// waitUntilApplicationWindowIsFullyHidden();
177−// var dashContentList = findChild(shell, "dashContentList");
178−// tryCompare(dashContentList, "moving", false);
179−// }
180−
181−// function dragLauncherIntoView() {
182−// var launcherPanel = findChild(shell, "launcherPanel");
183−// verify(launcherPanel.x = - launcherPanel.width);
184−// swipeFromLeftEdge();
185−// tryCompare(launcherPanel, "x", 0);
186−// }
187−
188−// function tapOnAppIconInLauncher() {
189−// var launcherPanel = findChild(shell, "launcherPanel");
190−
191−// // pick the first icon, the one at the bottom.
192−// var appIcon = findChild(launcherPanel, "launcherDelegate0")
193−
194−// // Swipe upwards over the launcher to ensure that this icon
195−// // at the bottom is not folded and faded away.
196−// var touchStartX = launcherPanel.width / 2;
197−// var touchStartY = launcherPanel.height / 2;
198−// touchFlick(launcherPanel, touchStartX, touchStartY, touchStartX, 0);
199−// tryCompare(launcherPanel, "moving", false);
200−
201−// // NB tapping (i.e., using touch events) doesn't activate the icon... go figure...
202−// mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
203−// }
204−
205−// function waitUntilApplicationWindowIsFullyVisible() {
206−// var underlay = findChild(shell, "underlay");
207−// tryCompare(underlay, "visible", false);
208−// }
209−
210−// function waitUntilApplicationWindowIsFullyHidden() {
211−// var stages = findChild(shell, "stages");
212−// tryCompare(stages, "fullyHidden", true);
213−// }
214−
215−// function swipeUntilScopeViewIsReached(scopeView) {
216−// while (!itemIsOnScreen(scopeView)) {
217−// if (itemIsToLeftOfScreen(scopeView)) {
218−// swipeRightFromCenter();
219−// } else {
220−// swipeLeftFromCenter();
221−// }
222−// waitUntilItemStopsMoving(scopeView);
223−// }
224−// }
225−
226−// function swipeFromLeftEdge() {
227−// var touchStartX = 2;
228−// var touchStartY = shell.height / 2;
229−// touchFlick(shell, touchStartX, touchStartY, shell.width * 0.75, touchStartY);
230−// }
231−
232−// function swipeLeftFromCenter() {
233−// var touchStartX = shell.width / 2;
234−// var touchStartY = shell.height / 2;
235−// touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
236−// }
237−
238−// function swipeRightFromCenter() {
239−// var touchStartX = shell.width / 2;
240−// var touchStartY = shell.height / 2;
241−// touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
242−// }
243−
244−// function swipeUpFromCenter() {
245−// var touchStartX = shell.width / 2;
246−// var touchStartY = shell.height / 2;
247−// touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
248−// }
249−
250−// function itemIsOnScreen(item) {
251−// var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
252−
253−// return itemRectInShell.x >= 0
254−// && itemRectInShell.y >= 0
255−// && itemRectInShell.x + itemRectInShell.width <= shell.width
256−// && itemRectInShell.y + itemRectInShell.height <= shell.height;
257−// }
258−
259−// function itemIsToLeftOfScreen(item) {
260−// var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
261−// return itemRectInShell.x < 0;
262−// }
263−
264−// function waitUntilItemStopsMoving(item) {
265−// var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
266−// var previousX = itemRectInShell.x;
267−// var previousY = itemRectInShell.y;
268−// var isStill = false;
269−
270−// do {
271−// wait(100);
272−// itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
273−// if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
274−// isStill = true;
275−// } else {
276−// previousX = itemRectInShell.x;
277−// previousY = itemRectInShell.y;
278−// }
279−// } while (!isStill);
280−// }
90+ // Launch an app from the launcher
91+ tapOnAppIconInLauncher();
92+ waitUntilApplicationWindowIsFullyVisible();
93+
94+ // Minimize the application we just launched
95+ swipeFromLeftEdge();
96+
97+ waitForUIToSettle();
98+
99+ checkRightEdgeDragWithMinimizedApp();
100+
101+ // Minimize that application once again
102+ swipeFromLeftEdge();
103+
104+ // kill it
105+ ApplicationManager.mainStageApplications.clear();
106+
107+ waitForUIToSettle();
108+
109+ // Right edge behavior should now be the same as before that app was launched
110+ checkRightEdgeDragWithNoRunningApps();
111+ }
112+
113+ /*
114+ Perform a right-edge drag when the Dash is being show and there are
115+ no running/minimized apps to be restored.
116+
117+ The expected behavior is that an animation should be played to hint the
118+ user that his right-edge drag gesture has been successfully recognized
119+ but there is no application to be brought to foreground.
120+ */
121+ function checkRightEdgeDragWithNoRunningApps() {
122+ var touchX = shell.width - (shell.edgeSize / 2);
123+ var touchY = shell.height / 2;
124+
125+ var dash = findChild(shell, "dash");
126+ // check that dash has normal scale and opacity
127+ compare(dash.contentScale, 1.0);
128+ compare(dash.opacity, 1.0);
129+
130+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
131+ true /* beginTouch */, false /* endTouch */);
132+
133+ // check that Dash has been scaled down and had its opacity reduced
134+ tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
135+ tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
136+
137+ touchRelease(shell, shell.width * 0.1, touchY);
138+
139+ // and now everything should have gone back to normal
140+ tryCompare(dash, "contentScale", 1.0);
141+ tryCompare(dash, "opacity", 1.0);
142+ }
143+
144+ /*
145+ Perform a right-edge drag when the Dash is being show and there is
146+ a running/minimized app to be restored.
147+
148+ The expected behavior is that the dash should fade away and ultimately be
149+ made invisible once the gesture is finished as the restored app will now
150+ be on foreground.
151+ */
152+ function checkRightEdgeDragWithMinimizedApp() {
153+ var touchX = shell.width - (shell.edgeSize / 2);
154+ var touchY = shell.height / 2;
155+
156+ var dash = findChild(shell, "dash");
157+ // check that dash has normal scale and opacity
158+ tryCompare(dash, "contentScale", 1.0);
159+ tryCompare(dash, "opacity", 1.0);
160+
161+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
162+ true /* beginTouch */, false /* endTouch */);
163+
164+ // check that Dash has been scaled down and had its opacity reduced
165+ tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
166+ tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
167+
168+ touchRelease(shell, shell.width * 0.1, touchY);
169+
170+ // dash should have gone away, now that the app is on foreground
171+ tryCompare(dash, "visible", false);
172+ }
173+
174+ // Wait for the whole UI to settle down
175+ function waitForUIToSettle() {
176+ waitUntilApplicationWindowIsFullyHidden();
177+ var dashContentList = findChild(shell, "dashContentList");
178+ tryCompare(dashContentList, "moving", false);
179+ }
180+
181+ function dragLauncherIntoView() {
182+ var launcherPanel = findChild(shell, "launcherPanel");
183+ verify(launcherPanel.x = - launcherPanel.width);
184+ swipeFromLeftEdge();
185+ tryCompare(launcherPanel, "x", 0);
186+ }
187+
188+ function tapOnAppIconInLauncher() {
189+ var launcherPanel = findChild(shell, "launcherPanel");
190+
191+ // pick the first icon, the one at the bottom.
192+ var appIcon = findChild(launcherPanel, "launcherDelegate0")
193+
194+ // Swipe upwards over the launcher to ensure that this icon
195+ // at the bottom is not folded and faded away.
196+ var touchStartX = launcherPanel.width / 2;
197+ var touchStartY = launcherPanel.height / 2;
198+ touchFlick(launcherPanel, touchStartX, touchStartY, touchStartX, 0);
199+ tryCompare(launcherPanel, "moving", false);
200+
201+ // NB tapping (i.e., using touch events) doesn't activate the icon... go figure...
202+ mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
203+ }
204+
205+ function waitUntilApplicationWindowIsFullyVisible() {
206+ var underlay = findChild(shell, "underlay");
207+ tryCompare(underlay, "visible", false);
208+ }
209+
210+ function waitUntilApplicationWindowIsFullyHidden() {
211+ var stages = findChild(shell, "stages");
212+ tryCompare(stages, "fullyHidden", true);
213+ }
214+
215+ function swipeUntilScopeViewIsReached(scopeView) {
216+ while (!itemIsOnScreen(scopeView)) {
217+ if (itemIsToLeftOfScreen(scopeView)) {
218+ swipeRightFromCenter();
219+ } else {
220+ swipeLeftFromCenter();
221+ }
222+ waitUntilItemStopsMoving(scopeView);
223+ }
224+ }
225+
226+ function swipeFromLeftEdge() {
227+ var touchStartX = 2;
228+ var touchStartY = shell.height / 2;
229+ touchFlick(shell, touchStartX, touchStartY, shell.width * 0.75, touchStartY);
230+ }
231+
232+ function swipeLeftFromCenter() {
233+ var touchStartX = shell.width / 2;
234+ var touchStartY = shell.height / 2;
235+ touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
236+ }
237+
238+ function swipeRightFromCenter() {
239+ var touchStartX = shell.width / 2;
240+ var touchStartY = shell.height / 2;
241+ touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
242+ }
243+
244+ function swipeUpFromCenter() {
245+ var touchStartX = shell.width / 2;
246+ var touchStartY = shell.height / 2;
247+ touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
248+ }
249+
250+ function itemIsOnScreen(item) {
251+ var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
252+
253+ return itemRectInShell.x >= 0
254+ && itemRectInShell.y >= 0
255+ && itemRectInShell.x + itemRectInShell.width <= shell.width
256+ && itemRectInShell.y + itemRectInShell.height <= shell.height;
257+ }
258+
259+ function itemIsToLeftOfScreen(item) {
260+ var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
261+ return itemRectInShell.x < 0;
262+ }
263+
264+ function waitUntilItemStopsMoving(item) {
265+ var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
266+ var previousX = itemRectInShell.x;
267+ var previousY = itemRectInShell.y;
268+ var isStill = false;
269+
270+ do {
271+ wait(100);
272+ itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
273+ if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
274+ isStill = true;
275+ } else {
276+ previousX = itemRectInShell.x;
277+ previousY = itemRectInShell.y;
278+ }
279+ } while (!isStill);
280+ }
281281
282282 function test_wallpaper_data() {
283283 return [
@@ -289,7 +289,6 @@ Item {
289289 function test_wallpaper(data) {
290290 var backgroundImage = findChild(shell, "backgroundImage")
291291 GSettingsController.setPictureUri(data.url)
292− wait(1000)
293292 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.url) !== -1; }, true)
294293 tryCompare(backgroundImage, "status", Image.Ready)
295294 }
@@ -297,9 +296,9 @@ Item {
297296 function test_wallpaper_wrong() {
298297 var backgroundImage = findChild(shell, "backgroundImage")
299298 GSettingsController.setPictureUri("wrong")
300− wait(2000)
301− //tryCompareFunction(function() { return oldGSettingsBackground == backgroundSettings.pictureUri; }, true)
302−// tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.url) !== -1; }, true)
299+ tryCompare(backgroundImage, "status", Image.Error)
300+ tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(shell.defaultBackground) !== -1; }, true)
301+ tryCompare(backgroundImage, "status", Image.Ready)
303302 }
304303 }
305304}