on xenial help sign in
Added test for greeter wallpaper, changed some names from wallpaper->background
adb89cfAndrea Cimitan
Greeter/GreeterContent.qml+8−8
@@ -24,7 +24,7 @@ MouseArea {
24 id: root
24 id: root
25 anchors.fill: parent
25 anchors.fill: parent
26
26
27− property bool ready: wallpaper.source == "" || wallpaper.status == Image.Ready || wallpaper.status == Image.Error
27+ property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error
28 property bool leftTeaserPressed: teasingMouseArea.pressed &&
28 property bool leftTeaserPressed: teasingMouseArea.pressed &&
29 teasingMouseArea.mouseX < teasingMouseArea.width / 2
29 teasingMouseArea.mouseX < teasingMouseArea.width / 2
30 property bool rightTeaserPressed: teasingMouseArea.pressed &&
30 property bool rightTeaserPressed: teasingMouseArea.pressed &&
@@ -34,18 +34,18 @@ MouseArea {
34 signal unlocked(int uid)
34 signal unlocked(int uid)
35
35
36 Rectangle {
36 Rectangle {
37− // In case wallpaper fails to load
37+ // In case background fails to load
38− id: wallpaperBackup
38+ id: backgroundBackup
39 anchors.fill: parent
39 anchors.fill: parent
40 color: "black"
40 color: "black"
41 }
41 }
42
42
43 property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : greeter.defaultBackground
43 property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : greeter.defaultBackground
44− onBackgroundValueChanged: wallpaper.source = backgroundValue
44+ onBackgroundValueChanged: background.source = backgroundValue
45
45
46 CrossFadeImage {
46 CrossFadeImage {
47− id: wallpaper
47+ id: background
48− objectName: "wallpaper"
48+ objectName: "greeterBackground"
49 anchors {
49 anchors {
50 fill: parent
50 fill: parent
51 topMargin: -panel.panelHeight
51 topMargin: -panel.panelHeight
@@ -56,14 +56,14 @@ MouseArea {
56 // See Shell.qml's backgroundSettings treatment for why we need a separate
56 // See Shell.qml's backgroundSettings treatment for why we need a separate
57 // Image, but it boils down to avoiding binding loop detection.
57 // Image, but it boils down to avoiding binding loop detection.
58 Image {
58 Image {
59− source: wallpaper.source
59+ source: background.source
60 height: 0
60 height: 0
61 width: 0
61 width: 0
62 sourceSize.height: 0
62 sourceSize.height: 0
63 sourceSize.width: 0
63 sourceSize.width: 0
64 onStatusChanged: {
64 onStatusChanged: {
65 if (status == Image.Error && source != greeter.defaultBackground) {
65 if (status == Image.Error && source != greeter.defaultBackground) {
66− wallpaper.source = greeter.defaultBackground
66+ background.source = greeter.defaultBackground
67 }
67 }
68 }
68 }
69 }
69 }
Greeter/Lockscreen.qml+3−3
@@ -54,14 +54,14 @@ Showable {
54 }
54 }
55
55
56 Rectangle {
56 Rectangle {
57− // In case wallpaper fails to load or is undefined
57+ // In case background fails to load or is undefined
58− id: wallpaperBackup
58+ id: backgroundBackup
59 anchors.fill: parent
59 anchors.fill: parent
60 color: "black"
60 color: "black"
61 }
61 }
62
62
63 Image {
63 Image {
64− id: wallpaper
64+ id: backgroundImage
65 anchors.fill: parent
65 anchors.fill: parent
66 source: root.required ? root.background : ""
66 source: root.required ? root.background : ""
67 fillMode: Image.PreserveAspectCrop
67 fillMode: Image.PreserveAspectCrop
tests/autopilot/unity8/shell/emulators/main_window.py+6
@@ -43,6 +43,9 @@ class MainWindow(object):
43 objectName="greeterContentLoader"
43 objectName="greeterContentLoader"
44 )
44 )
45
45
46+ def get_greeter_background(self):
47+ return self.app.select_single("CrossFadeImage", objectName="greeterBackground")
48+
46 def get_login_loader(self):
49 def get_login_loader(self):
47 return self.app.select_single("QQuickLoader", objectName="loginLoader")
50 return self.app.select_single("QQuickLoader", objectName="loginLoader")
48
51
@@ -93,3 +96,6 @@ class MainWindow(object):
93
96
94 def get_pinentryField(self):
97 def get_pinentryField(self):
95 return self.app.select_single(objectName="pinentryField")
98 return self.app.select_single(objectName="pinentryField")
99+
100+ def get_shell_background(self):
101+ return self.app.select_single("CrossFadeImage", objectName="backgroundImage")
tests/autopilot/unity8/shell/tests/test_greeter.pynew file+38
@@ -0,0 +1,38 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
21+
22+from testtools.matchers import Equals
23+
24+class TestGreeter(UnityTestCase):
25+
26+ """Tests the Shell Greeter."""
27+
28+ scenarios = _get_device_emulation_scenarios()
29+
30+ def test_greeter_background(self):
31+ """Test that the background of the greeter and the background of the shell are placed correctly
32+
33+ """
34+ self.launch_unity()
35+ self.main_window.get_greeter()
36+ greeter_background = self.main_window.get_greeter_background()
37+ shell_background = self.main_window.get_shell_background()
38+ self.assertThat(greeter_background.globalRect, Equals(shell_background.globalRect))
tests/qmltests/Greeter/tst_Phone.qml+5−5
@@ -120,7 +120,7 @@ Item {
120 tryCompare(LightDM.Infographic, "username", "single")
120 tryCompare(LightDM.Infographic, "username", "single")
121 }
121 }
122
122
123− function test_wallpaper_data() {
123+ function test_background_data() {
124 return [
124 return [
125 {tag: "set", accounts: "../tests/data/unity/backgrounds/blue.png", expected: "blue.png"},
125 {tag: "set", accounts: "../tests/data/unity/backgrounds/blue.png", expected: "blue.png"},
126 {tag: "unset", accounts: "", expected: "background.jpg"},
126 {tag: "unset", accounts: "", expected: "background.jpg"},
@@ -128,12 +128,12 @@ Item {
128 ]
128 ]
129 }
129 }
130
130
131− function test_wallpaper(data) {
131+ function test_background(data) {
132 var loader = findChild(greeter, "greeterContentLoader")
132 var loader = findChild(greeter, "greeterContentLoader")
133− var wallpaper = findChild(loader.item, "wallpaper")
133+ var background = findChild(loader.item, "greeterBackground")
134 AccountsService.backgroundFile = data.accounts
134 AccountsService.backgroundFile = data.accounts
135− tryCompareFunction(function() { return wallpaper.source.toString().indexOf(data.expected) !== -1; }, true)
135+ tryCompareFunction(function() { return background.source.toString().indexOf(data.expected) !== -1; }, true)
136− tryCompare(wallpaper, "status", Image.Ready)
136+ tryCompare(background, "status", Image.Ready)
137 }
137 }
138 }
138 }
139}
139}
tests/qmltests/tst_Shell.qml+2−2
@@ -432,7 +432,7 @@ Item {
432 } while (!isStill);
432 } while (!isStill);
433 }
433 }
434
434
435− function test_wallpaper_data() {
435+ function test_background_data() {
436 return [
436 return [
437 {tag: "red", url: "tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
437 {tag: "red", url: "tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
438 {tag: "blue", url: "tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
438 {tag: "blue", url: "tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
@@ -441,7 +441,7 @@ Item {
441 ]
441 ]
442 }
442 }
443
443
444− function test_wallpaper(data) {
444+ function test_background(data) {
445 var backgroundImage = findChild(shell, "backgroundImage")
445 var backgroundImage = findChild(shell, "backgroundImage")
446 GSettingsController.setPictureUri(data.url)
446 GSettingsController.setPictureUri(data.url)
447 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)
447 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)