on xenial help sign in
Added test for greeter wallpaper, changed some names from wallpaper->background
commitadb89cf48db89f7f673017a928916d5bd1172975 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 22 Oct 2013, 16:59 (13 years ago) parent40296e9
6 files changed+62−18
Greeter/GreeterContent.qml+8−8 Greeter/Lockscreen.qml+3−3 tests/autopilot/unity8/shell/emulators/main_window.py+6 tests/autopilot/unity8/shell/tests/test_greeter.py+38 tests/qmltests/Greeter/tst_Phone.qml+5−5 tests/qmltests/tst_Shell.qml+2−2
Greeter/GreeterContent.qml+8−8
@@ -24,7 +24,7 @@ MouseArea {
2424 id: root
2525 anchors.fill: parent
2626
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
2828 property bool leftTeaserPressed: teasingMouseArea.pressed &&
2929 teasingMouseArea.mouseX < teasingMouseArea.width / 2
3030 property bool rightTeaserPressed: teasingMouseArea.pressed &&
@@ -34,18 +34,18 @@ MouseArea {
3434 signal unlocked(int uid)
3535
3636 Rectangle {
37− // In case wallpaper fails to load
38− id: wallpaperBackup
37+ // In case background fails to load
38+ id: backgroundBackup
3939 anchors.fill: parent
4040 color: "black"
4141 }
4242
4343 property url backgroundValue: AccountsService.backgroundFile != undefined && AccountsService.backgroundFile.length > 0 ? AccountsService.backgroundFile : greeter.defaultBackground
44− onBackgroundValueChanged: wallpaper.source = backgroundValue
44+ onBackgroundValueChanged: background.source = backgroundValue
4545
4646 CrossFadeImage {
47− id: wallpaper
48− objectName: "wallpaper"
47+ id: background
48+ objectName: "greeterBackground"
4949 anchors {
5050 fill: parent
5151 topMargin: -panel.panelHeight
@@ -56,14 +56,14 @@ MouseArea {
5656 // See Shell.qml's backgroundSettings treatment for why we need a separate
5757 // Image, but it boils down to avoiding binding loop detection.
5858 Image {
59− source: wallpaper.source
59+ source: background.source
6060 height: 0
6161 width: 0
6262 sourceSize.height: 0
6363 sourceSize.width: 0
6464 onStatusChanged: {
6565 if (status == Image.Error && source != greeter.defaultBackground) {
66− wallpaper.source = greeter.defaultBackground
66+ background.source = greeter.defaultBackground
6767 }
6868 }
6969 }
Greeter/Lockscreen.qml+3−3
@@ -54,14 +54,14 @@ Showable {
5454 }
5555
5656 Rectangle {
57− // In case wallpaper fails to load or is undefined
58− id: wallpaperBackup
57+ // In case background fails to load or is undefined
58+ id: backgroundBackup
5959 anchors.fill: parent
6060 color: "black"
6161 }
6262
6363 Image {
64− id: wallpaper
64+ id: backgroundImage
6565 anchors.fill: parent
6666 source: root.required ? root.background : ""
6767 fillMode: Image.PreserveAspectCrop
tests/autopilot/unity8/shell/emulators/main_window.py+6
@@ -43,6 +43,9 @@ class MainWindow(object):
4343 objectName="greeterContentLoader"
4444 )
4545
46+ def get_greeter_background(self):
47+ return self.app.select_single("CrossFadeImage", objectName="greeterBackground")
48+
4649 def get_login_loader(self):
4750 return self.app.select_single("QQuickLoader", objectName="loginLoader")
4851
@@ -93,3 +96,6 @@ class MainWindow(object):
9396
9497 def get_pinentryField(self):
9598 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 {
120120 tryCompare(LightDM.Infographic, "username", "single")
121121 }
122122
123− function test_wallpaper_data() {
123+ function test_background_data() {
124124 return [
125125 {tag: "set", accounts: "../tests/data/unity/backgrounds/blue.png", expected: "blue.png"},
126126 {tag: "unset", accounts: "", expected: "background.jpg"},
@@ -128,12 +128,12 @@ Item {
128128 ]
129129 }
130130
131− function test_wallpaper(data) {
131+ function test_background(data) {
132132 var loader = findChild(greeter, "greeterContentLoader")
133− var wallpaper = findChild(loader.item, "wallpaper")
133+ var background = findChild(loader.item, "greeterBackground")
134134 AccountsService.backgroundFile = data.accounts
135− tryCompareFunction(function() { return wallpaper.source.toString().indexOf(data.expected) !== -1; }, true)
136− tryCompare(wallpaper, "status", Image.Ready)
135+ tryCompareFunction(function() { return background.source.toString().indexOf(data.expected) !== -1; }, true)
136+ tryCompare(background, "status", Image.Ready)
137137 }
138138 }
139139}
tests/qmltests/tst_Shell.qml+2−2
@@ -432,7 +432,7 @@ Item {
432432 } while (!isStill);
433433 }
434434
435− function test_wallpaper_data() {
435+ function test_background_data() {
436436 return [
437437 {tag: "red", url: "tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
438438 {tag: "blue", url: "tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
@@ -441,7 +441,7 @@ Item {
441441 ]
442442 }
443443
444− function test_wallpaper(data) {
444+ function test_background(data) {
445445 var backgroundImage = findChild(shell, "backgroundImage")
446446 GSettingsController.setPictureUri(data.url)
447447 tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expectedUrl) !== -1; }, true)