on xenial help sign in
Ugly code pushed somewhere
e8d32a0Andrea Cimitan
Components/CrossFadeImage.qml+8−1
@@ -43,6 +43,8 @@ Item {
43 property Image __currentImage: image1
43 property Image __currentImage: image1
44 property Image __nextImage: image2
44 property Image __nextImage: image2
45
45
46+ signal swapped
47+
46 function swapImages() {
48 function swapImages() {
47 __currentImage.z = 0
49 __currentImage.z = 0
48 __nextImage.z = 1
50 __nextImage.z = 1
@@ -55,7 +57,10 @@ Item {
55 var tmpImage = __currentImage
57 var tmpImage = __currentImage
56 __currentImage = __nextImage
58 __currentImage = __nextImage
57 __nextImage = tmpImage
59 __nextImage = tmpImage
60+ console.log("swapped here")
61+ swapped()
58 }
62 }
63+ onSwapped: console.log("swapped component signal")
59
64
60 onSourceChanged: {
65 onSourceChanged: {
61 // On creation, the souce handler is called before image pointers are set.
66 // On creation, the souce handler is called before image pointers are set.
@@ -85,7 +90,7 @@ Item {
85 Connections {
90 Connections {
86 target: __nextImage
91 target: __nextImage
87 onStatusChanged: {
92 onStatusChanged: {
88− if (__nextImage.status == Image.Ready) {
93+ if (__nextImage.status == Image.Ready || __nextImage.status == Image.Error) {
89 swapImages();
94 swapImages();
90 }
95 }
91 }
96 }
@@ -96,6 +101,7 @@ Item {
96 anchors.fill: parent
101 anchors.fill: parent
97 cache: false
102 cache: false
98 asynchronous: true
103 asynchronous: true
104+ fillMode: Image.PreserveAspectCrop
99 z: 1
105 z: 1
100 }
106 }
101
107
@@ -104,6 +110,7 @@ Item {
104 anchors.fill: parent
110 anchors.fill: parent
105 cache: false
111 cache: false
106 asynchronous: true
112 asynchronous: true
113+ fillMode: Image.PreserveAspectCrop
107 z: 0
114 z: 0
108 }
115 }
109
116
Greeter/GreeterContent.qml−1
@@ -37,7 +37,6 @@ MouseArea {
37
37
38 source: shell.background
38 source: shell.background
39 anchors.fill: parent
39 anchors.fill: parent
40− crossFade: false
41 fadeInFirst: false
40 fadeInFirst: false
42 }
41 }
43
42
Shell.qml+32−8
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import GSettings 1.0
18import Ubuntu.Application 0.1
19import Ubuntu.Application 0.1
19import Ubuntu.Components 0.1
20import Ubuntu.Components 0.1
20import Ubuntu.Gestures 0.1
21import Ubuntu.Gestures 0.1
@@ -41,8 +42,8 @@ FocusScope {
41 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
42 height: tablet ? units.gu(100) : applicationArguments.hasGeometry() ? applicationArguments.height() : units.gu(71)
42
43
43 property real edgeSize: units.gu(2)
44 property real edgeSize: units.gu(2)
44− property url default_background: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
45+ property url defaultBackground: shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg"
45− property url background: default_background
46+ property url background: backgroundSettings.pictureUri
46 readonly property real panelHeight: panel.panelHeight
47 readonly property real panelHeight: panel.panelHeight
47
48
48 property bool dashShown: dash.shown
49 property bool dashShown: dash.shown
@@ -115,6 +116,11 @@ FocusScope {
115 }
116 }
116 }
117 }
117
118
119+ GSettings {
120+ id: backgroundSettings
121+ schema.id: "org.gnome.desktop.background"
122+ }
123+
118 VolumeControl {
124 VolumeControl {
119 id: volumeControl
125 id: volumeControl
120 }
126 }
@@ -139,12 +145,32 @@ FocusScope {
139 // through the translucent parts of the shell surface.
145 // through the translucent parts of the shell surface.
140 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
146 visible: !fullyCovered && !applicationSurfaceShouldBeSeen
141
147
142− Image {
148+ CrossFadeImage {
143 id: backgroundImage
149 id: backgroundImage
150+ objectName: "backgroundImage"
151+
152+ property url oldWorkingBackground: shell.defaultBackground
153+
144 source: shell.background
154 source: shell.background
145− sourceSize.width: parent.width
146− sourceSize.height: parent.height
147 anchors.fill: parent
155 anchors.fill: parent
156+ onSwapped: {
157+ console.log("swapped")
158+// if (status == Image.Ready) {
159+// console.log("hhhhhhhhhhhhhhhhhhhhhhh", source)
160+// oldWorkingBackground = source
161+// }
162+ }
163+
164+// onStatusChanged: {
165+// if (status == Image.Error) {
166+// GSettingsController.setPictureUri(oldWorkingBackground)
167+// console.log("pic",backgroundSettings.pictureUri.toString(), oldWorkingBackground.toString())
168+// //backgroundSettings.pictureUri = oldWorkingBackground
169+// } else {
170+// console.log("XXXXXXXXXX else",status, source.toString(), oldWorkingBackground.toString())
171+// oldWorkingBackground = source
172+// }
173+// }
148 }
174 }
149
175
150 Rectangle {
176 Rectangle {
@@ -189,7 +215,6 @@ FocusScope {
189 }
215 }
190 }
216 }
191
217
192−
193 Item {
218 Item {
194 id: stagesOuterContainer
219 id: stagesOuterContainer
195
220
@@ -254,7 +279,6 @@ FocusScope {
254 ignoreUnknownSignals: true
279 ignoreUnknownSignals: true
255 }
280 }
256
281
257−
258 Stage {
282 Stage {
259 id: mainStage
283 id: mainStage
260
284
@@ -430,7 +454,7 @@ FocusScope {
430 onUnlocked: greeter.hide()
454 onUnlocked: greeter.hide()
431 onSelected: {
455 onSelected: {
432 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
456 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
433− shell.background = bgPath ? bgPath : default_background
457+ shell.background = bgPath ? bgPath : defaultBackground
434 }
458 }
435
459
436 onLeftTeaserPressedChanged: {
460 onLeftTeaserPressedChanged: {
debian/control+3−1
@@ -56,8 +56,10 @@ Description: Indicators client test application
56
56
57Package: unity8
57Package: unity8
58Architecture: any
58Architecture: any
59+Depends: gsettings-desktop-schemas,
59−Depends: qmenumodel-qml,
60+ qmenumodel-qml,
60 qtdeclarative5-dee-plugin,
61 qtdeclarative5-dee-plugin,
62+ qtdeclarative5-gsettings1.0,
61 qtdeclarative5-ubuntu-ui-toolkit-plugin,
63 qtdeclarative5-ubuntu-ui-toolkit-plugin,
62 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
64 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
63 qtdeclarative5-xmllistmodel-plugin,
65 qtdeclarative5-xmllistmodel-plugin,
tests/mocks/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(GSettings)
1add_subdirectory(libusermetrics)
2add_subdirectory(libusermetrics)
2add_subdirectory(LightDM)
3add_subdirectory(LightDM)
3add_subdirectory(QMenuModel)
4add_subdirectory(QMenuModel)
tests/qmltests/CMakeLists.txt+1−1
@@ -26,7 +26,7 @@ set(qmltest_DEFAULT_TARGETS qmluitests)
26set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
26set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
27set(qmltest_DEFAULT_PROPERTIES "")
27set(qmltest_DEFAULT_PROPERTIES "")
28
28
29−add_qml_test(. Shell IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
29+add_qml_test(. Shell IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks
30 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
30 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
31add_manual_qml_test(Components DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
31add_manual_qml_test(Components DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
32add_qml_test(Components DraggingArea)
32add_qml_test(Components DraggingArea)
tests/qmltests/tst_Shell.qml+246−215
@@ -19,6 +19,7 @@
19
19
20import QtQuick 2.0
20import QtQuick 2.0
21import QtTest 1.0
21import QtTest 1.0
22+import GSettings 1.0
22import Ubuntu.Application 0.1
23import Ubuntu.Application 0.1
23import Unity.Test 0.1 as UT
24import Unity.Test 0.1 as UT
24
25
@@ -48,234 +49,264 @@ Item {
48 id: shell
49 id: shell
49 }
50 }
50
51
52+ GSettings {
53+ id: backgroundSettings
54+ schema.id: "org.gnome.desktop.background"
55+ }
56+
51 UT.UnityTestCase {
57 UT.UnityTestCase {
52 name: "Shell"
58 name: "Shell"
53 when: windowShown
59 when: windowShown
54
60
55− function initTestCase() {
61+// function initTestCase() {
56− // swipe away the greeter/lockscreen
62+// // swipe away the greeter/lockscreen
57− var touchX = shell.width - (shell.edgeSize / 2);
63+// var touchX = shell.width - (shell.edgeSize / 2);
58− var touchY = shell.height / 2;
64+// var touchY = shell.height / 2;
59− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
65+// touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
60−
61− var dash = findChild(shell, "dash");
62− // wait until the animation has finished
63− tryCompare(dash, "contentScale", 1.0);
64− tryCompare(dash, "opacity", 1.0);
65− }
66−
67− function cleanup() {
68− // kill all (fake) running apps
69− ApplicationManager.mainStageApplications.clear();
70− ApplicationManager.sideStageApplications.clear();
71−
72− var dashHome = findChild(shell, "DashHome");
73− swipeUntilScopeViewIsReached(dashHome);
74− }
75−
76− /*
77− Test the effect of a right-edge drag on the dash in 3 situations:
78− 1 - when no application has been launched yet
79− 2 - when there's a minimized application
80− 3 - after the last running application has been closed/stopped
81−
82− The behavior of Dash on 3 should be the same as on 1.
83− */
84− function test_rightEdgeDrag() {
85− checkRightEdgeDragWithNoRunningApps();
86−
87− dragLauncherIntoView();
88−
89− // Launch an app from the launcher
90− tapOnAppIconInLauncher();
91− waitUntilApplicationWindowIsFullyVisible();
92−
93− // Minimize the application we just launched
94− swipeFromLeftEdge();
95−
96− waitForUIToSettle();
97−
98− checkRightEdgeDragWithMinimizedApp();
99−
100− // Minimize that application once again
101− swipeFromLeftEdge();
102−
103− // kill it
104− ApplicationManager.mainStageApplications.clear();
105−
106− waitForUIToSettle();
107−
108− // Right edge behavior should now be the same as before that app was launched
109− checkRightEdgeDragWithNoRunningApps();
110− }
111−
112− /*
113− Perform a right-edge drag when the Dash is being show and there are
114− no running/minimized apps to be restored.
115−
116− The expected behavior is that an animation should be played to hint the
117− user that his right-edge drag gesture has been successfully recognized
118− but there is no application to be brought to foreground.
119− */
120− function checkRightEdgeDragWithNoRunningApps() {
121− var touchX = shell.width - (shell.edgeSize / 2);
122− var touchY = shell.height / 2;
123−
124− var dash = findChild(shell, "dash");
125− // check that dash has normal scale and opacity
126− compare(dash.contentScale, 1.0);
127− compare(dash.opacity, 1.0);
128−
129− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
130− true /* beginTouch */, false /* endTouch */);
131−
132− // check that Dash has been scaled down and had its opacity reduced
133− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
134− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
135−
136− touchRelease(shell, shell.width * 0.1, touchY);
137−
138− // and now everything should have gone back to normal
139− tryCompare(dash, "contentScale", 1.0);
140− tryCompare(dash, "opacity", 1.0);
141− }
142−
143− /*
144− Perform a right-edge drag when the Dash is being show and there is
145− a running/minimized app to be restored.
146
66
147− The expected behavior is that the dash should fade away and ultimately be
67+// var dash = findChild(shell, "dash");
148− made invisible once the gesture is finished as the restored app will now
68+// // wait until the animation has finished
149− be on foreground.
69+// tryCompare(dash, "contentScale", 1.0);
150− */
70+// tryCompare(dash, "opacity", 1.0);
151− function checkRightEdgeDragWithMinimizedApp() {
71+// }
152− var touchX = shell.width - (shell.edgeSize / 2);
153− var touchY = shell.height / 2;
154
72
155− var dash = findChild(shell, "dash");
73+// function cleanup() {
156− // check that dash has normal scale and opacity
74+// // kill all (fake) running apps
157− tryCompare(dash, "contentScale", 1.0);
75+// ApplicationManager.mainStageApplications.clear();
158− tryCompare(dash, "opacity", 1.0);
76+// ApplicationManager.sideStageApplications.clear();
159
77
160− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
161− true /* beginTouch */, false /* endTouch */);
162−
163− // check that Dash has been scaled down and had its opacity reduced
164− tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
165− tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
166−
167− touchRelease(shell, shell.width * 0.1, touchY);
168−
169− // dash should have gone away, now that the app is on foreground
170− tryCompare(dash, "visible", false);
171− }
172−
173− // Wait for the whole UI to settle down
174− function waitForUIToSettle() {
175− waitUntilApplicationWindowIsFullyHidden();
176− var dashContentList = findChild(shell, "dashContentList");
78+// var dashHome = findChild(shell, "DashHome");
177− tryCompare(dashContentList, "moving", false);
178− }
179−
180− function dragLauncherIntoView() {
181− var launcherPanel = findChild(shell, "launcherPanel");
182− verify(launcherPanel.x = - launcherPanel.width);
183− swipeFromLeftEdge();
184− tryCompare(launcherPanel, "x", 0);
185− }
186−
187− function tapOnAppIconInLauncher() {
188− var launcherPanel = findChild(shell, "launcherPanel");
189−
190− // pick the first icon, the one at the bottom.
191− var appIcon = findChild(launcherPanel, "launcherDelegate0")
192−
193− // Swipe upwards over the launcher to ensure that this icon
194− // at the bottom is not folded and faded away.
195− var touchStartX = launcherPanel.width / 2;
196− var touchStartY = launcherPanel.height / 2;
197− touchFlick(launcherPanel, touchStartX, touchStartY, touchStartX, 0);
198− tryCompare(launcherPanel, "moving", false);
199−
200− // NB tapping (i.e., using touch events) doesn't activate the icon... go figure...
201− mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
202− }
203−
204− function waitUntilApplicationWindowIsFullyVisible() {
205− var underlay = findChild(shell, "underlay");
206− tryCompare(underlay, "visible", false);
207− }
208−
209− function waitUntilApplicationWindowIsFullyHidden() {
210− var stages = findChild(shell, "stages");
211− tryCompare(stages, "fullyHidden", true);
212− }
213−
214− function swipeUntilScopeViewIsReached(scopeView) {
79+// swipeUntilScopeViewIsReached(dashHome);
215− while (!itemIsOnScreen(scopeView)) {
216− if (itemIsToLeftOfScreen(scopeView)) {
217− swipeRightFromCenter();
218− } else {
219− swipeLeftFromCenter();
220− }
221− waitUntilItemStopsMoving(scopeView);
222− }
223− }
224−
225− function swipeFromLeftEdge() {
226− var touchStartX = 2;
227− var touchStartY = shell.height / 2;
228− touchFlick(shell, touchStartX, touchStartY, shell.width * 0.75, touchStartY);
229− }
230−
231− function swipeLeftFromCenter() {
232− var touchStartX = shell.width / 2;
233− var touchStartY = shell.height / 2;
234− touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
235− }
236−
237− function swipeRightFromCenter() {
238− var touchStartX = shell.width / 2;
239− var touchStartY = shell.height / 2;
240− touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
241− }
242−
243− function swipeUpFromCenter() {
244− var touchStartX = shell.width / 2;
245− var touchStartY = shell.height / 2;
246− touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
247− }
80+// }
248
81
249− function itemIsOnScreen(item) {
82+// /*
250− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
83+// Test the effect of a right-edge drag on the dash in 3 situations:
84+// 1 - when no application has been launched yet
85+// 2 - when there's a minimized application
86+// 3 - after the last running application has been closed/stopped
87+
88+// The behavior of Dash on 3 should be the same as on 1.
89+// */
90+// function test_rightEdgeDrag() {
91+// checkRightEdgeDragWithNoRunningApps();
92+
93+// dragLauncherIntoView();
94+
95+// // Launch an app from the launcher
96+// tapOnAppIconInLauncher();
97+// waitUntilApplicationWindowIsFullyVisible();
251
98
99+// // Minimize the application we just launched
100+// swipeFromLeftEdge();
101+
102+// waitForUIToSettle();
103+
104+// checkRightEdgeDragWithMinimizedApp();
105+
106+// // Minimize that application once again
107+// swipeFromLeftEdge();
108+
109+// // kill it
110+// ApplicationManager.mainStageApplications.clear();
111+
112+// waitForUIToSettle();
113+
114+// // Right edge behavior should now be the same as before that app was launched
115+// checkRightEdgeDragWithNoRunningApps();
116+// }
117+
118+// /*
119+// Perform a right-edge drag when the Dash is being show and there are
120+// no running/minimized apps to be restored.
121+
122+// The expected behavior is that an animation should be played to hint the
123+// user that his right-edge drag gesture has been successfully recognized
124+// but there is no application to be brought to foreground.
125+// */
126+// function checkRightEdgeDragWithNoRunningApps() {
127+// var touchX = shell.width - (shell.edgeSize / 2);
128+// var touchY = shell.height / 2;
129+
130+// var dash = findChild(shell, "dash");
131+// // check that dash has normal scale and opacity
132+// compare(dash.contentScale, 1.0);
133+// compare(dash.opacity, 1.0);
134+
135+// touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
136+// true /* beginTouch */, false /* endTouch */);
137+
138+// // check that Dash has been scaled down and had its opacity reduced
139+// tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
140+// tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
141+
142+// touchRelease(shell, shell.width * 0.1, touchY);
143+
144+// // and now everything should have gone back to normal
145+// tryCompare(dash, "contentScale", 1.0);
146+// tryCompare(dash, "opacity", 1.0);
147+// }
148+
149+// /*
150+// Perform a right-edge drag when the Dash is being show and there is
151+// a running/minimized app to be restored.
152+
153+// The expected behavior is that the dash should fade away and ultimately be
154+// made invisible once the gesture is finished as the restored app will now
155+// be on foreground.
156+// */
157+// function checkRightEdgeDragWithMinimizedApp() {
158+// var touchX = shell.width - (shell.edgeSize / 2);
159+// var touchY = shell.height / 2;
160+
161+// var dash = findChild(shell, "dash");
162+// // check that dash has normal scale and opacity
163+// tryCompare(dash, "contentScale", 1.0);
164+// tryCompare(dash, "opacity", 1.0);
165+
166+// touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
167+// true /* beginTouch */, false /* endTouch */);
168+
169+// // check that Dash has been scaled down and had its opacity reduced
170+// tryCompareFunction(function() { return dash.contentScale <= 0.9; }, true);
171+// tryCompareFunction(function() { return dash.opacity <= 0.5; }, true);
172+
173+// touchRelease(shell, shell.width * 0.1, touchY);
174+
175+// // dash should have gone away, now that the app is on foreground
176+// tryCompare(dash, "visible", false);
177+// }
178+
179+// // Wait for the whole UI to settle down
180+// function waitForUIToSettle() {
181+// waitUntilApplicationWindowIsFullyHidden();
182+// var dashContentList = findChild(shell, "dashContentList");
183+// tryCompare(dashContentList, "moving", false);
184+// }
185+
186+// function dragLauncherIntoView() {
187+// var launcherPanel = findChild(shell, "launcherPanel");
188+// verify(launcherPanel.x = - launcherPanel.width);
189+// swipeFromLeftEdge();
190+// tryCompare(launcherPanel, "x", 0);
191+// }
192+
193+// function tapOnAppIconInLauncher() {
194+// var launcherPanel = findChild(shell, "launcherPanel");
195+
196+// // pick the first icon, the one at the bottom.
197+// var appIcon = findChild(launcherPanel, "launcherDelegate0")
198+
199+// // Swipe upwards over the launcher to ensure that this icon
200+// // at the bottom is not folded and faded away.
201+// var touchStartX = launcherPanel.width / 2;
202+// var touchStartY = launcherPanel.height / 2;
203+// touchFlick(launcherPanel, touchStartX, touchStartY, touchStartX, 0);
204+// tryCompare(launcherPanel, "moving", false);
205+
206+// // NB tapping (i.e., using touch events) doesn't activate the icon... go figure...
207+// mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
208+// }
209+
210+// function waitUntilApplicationWindowIsFullyVisible() {
211+// var underlay = findChild(shell, "underlay");
212+// tryCompare(underlay, "visible", false);
213+// }
214+
215+// function waitUntilApplicationWindowIsFullyHidden() {
216+// var stages = findChild(shell, "stages");
217+// tryCompare(stages, "fullyHidden", true);
218+// }
219+
220+// function swipeUntilScopeViewIsReached(scopeView) {
221+// while (!itemIsOnScreen(scopeView)) {
222+// if (itemIsToLeftOfScreen(scopeView)) {
223+// swipeRightFromCenter();
224+// } else {
225+// swipeLeftFromCenter();
226+// }
227+// waitUntilItemStopsMoving(scopeView);
228+// }
229+// }
230+
231+// function swipeFromLeftEdge() {
232+// var touchStartX = 2;
233+// var touchStartY = shell.height / 2;
234+// touchFlick(shell, touchStartX, touchStartY, shell.width * 0.75, touchStartY);
235+// }
236+
237+// function swipeLeftFromCenter() {
238+// var touchStartX = shell.width / 2;
239+// var touchStartY = shell.height / 2;
240+// touchFlick(shell, touchStartX, touchStartY, 0, touchStartY);
241+// }
242+
243+// function swipeRightFromCenter() {
244+// var touchStartX = shell.width / 2;
245+// var touchStartY = shell.height / 2;
246+// touchFlick(shell, touchStartX, touchStartY, shell.width, touchStartY);
247+// }
248+
249+// function swipeUpFromCenter() {
250+// var touchStartX = shell.width / 2;
251+// var touchStartY = shell.height / 2;
252+// touchFlick(shell, touchStartX, touchStartY, touchStartX, 0);
253+// }
254+
255+// function itemIsOnScreen(item) {
256+// var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
257+
252− return itemRectInShell.x >= 0
258+// return itemRectInShell.x >= 0
253− && itemRectInShell.y >= 0
259+// && itemRectInShell.y >= 0
254− && itemRectInShell.x + itemRectInShell.width <= shell.width
260+// && itemRectInShell.x + itemRectInShell.width <= shell.width
255− && itemRectInShell.y + itemRectInShell.height <= shell.height;
261+// && itemRectInShell.y + itemRectInShell.height <= shell.height;
262+// }
263+
264+// function itemIsToLeftOfScreen(item) {
265+// var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
266+// return itemRectInShell.x < 0;
267+// }
268+
269+// function waitUntilItemStopsMoving(item) {
270+// var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
271+// var previousX = itemRectInShell.x;
272+// var previousY = itemRectInShell.y;
273+// var isStill = false;
274+
275+// do {
276+// wait(100);
277+// itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
278+// if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
279+// isStill = true;
280+// } else {
281+// previousX = itemRectInShell.x;
282+// previousY = itemRectInShell.y;
283+// }
284+// } while (!isStill);
285+// }
286+
287+ function test_wallpaper_data() {
288+ return [
289+ {tag: "red", url: "tests/data/unity/backgrounds/red.png"},
290+ {tag: "blue", url: "tests/data/unity/backgrounds/blue.png"}
291+ ]
256 }
292 }
257
293
258− function itemIsToLeftOfScreen(item) {
294+ function test_wallpaper(data) {
259− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
295+ var backgroundImage = findChild(shell, "backgroundImage")
260− return itemRectInShell.x < 0;
296+ GSettingsController.setPictureUri(data.url)
297+ tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.url) !== -1; }, true)
298+ tryCompare(backgroundImage, "status", Image.Ready)
261 }
299 }
262
300
263− function waitUntilItemStopsMoving(item) {
301+ function test_wallpaper_wrong() {
264− var itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
302+ var backgroundImage = findChild(shell, "backgroundImage")
265− var previousX = itemRectInShell.x;
303+ var oldGSettingsBackground = backgroundSettings.pictureUri
266− var previousY = itemRectInShell.y;
304+ var oldShellBackground = shell.background
267− var isStill = false;
268−
269− do {
270− wait(100);
305+ wait(2000)
271− itemRectInShell = item.mapToItem(shell, 0, 0, item.width, item.height);
306+ GSettingsController.setPictureUri("wrong")
272− if (itemRectInShell.x == previousX && itemRectInShell.y == previousY) {
307+ console.log("WRONG ", oldGSettingsBackground, backgroundSettings.pictureUri)
273− isStill = true;
308+ //tryCompareFunction(function() { return oldGSettingsBackground == backgroundSettings.pictureUri; }, true)
274− } else {
309+// tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.url) !== -1; }, true)
275− previousX = itemRectInShell.x;
276− previousY = itemRectInShell.y;
277− }
278− } while (!isStill);
279 }
310 }
280 }
311 }
281}
312}