on xenial help sign in
Merge from trunk
commita4777e4e98358b64b7ffdb70b32388baa9eff5bd authorMichael Terry <michael.terry@canonical.com> dateMon 16 Sep 2013, 14:38 (13 years ago) parent9b42f9951792d5
13 files changed+126−21
Components/BasicShell.qml+2−1 Greeter/Greeter.qml+1 GreeterShell.qml+6 plugins/Unity/Launcher/backend/launcherbackend.cpp+8−9 run_on_device+2−1 tests/mocks/AccountsService/AccountsService.cpp+9−2 tests/mocks/AccountsService/AccountsService.h+5 tests/plugins/Unity/Launcher/click-icon.svg tests/plugins/Unity/Launcher/launcherbackendtest.cpp+10−2 tests/qmltests/CMakeLists.txt+2−2 tests/qmltests/Greeter/tst_Phone.qml−1 tests/qmltests/tst_GreeterShell.qml+78 tests/qmltests/tst_Shell.qml+3−3
Components/BasicShell.qml+2−1
@@ -33,7 +33,8 @@ FocusScope {
3333 property url defaultBackground: shell.width >= units.gu(60) ? "../graphics/tablet_background.jpg" : "../graphics/phone_background.jpg"
3434 property url background
3535 property url backgroundSource
36− property url backgroundFinal: backgroundSource != undefined && backgroundSource != "" ? backgroundSource : shell.defaultBackground
36+ property url backgroundFallbackSource
37+ property url backgroundFinal: (backgroundSource != undefined && backgroundSource != "") ? backgroundSource : (backgroundFallbackSource != undefined && backgroundFallbackSource != "") ? backgroundFallbackSource : shell.defaultBackground
3738 onBackgroundFinalChanged: shell.background = backgroundFinal
3839
3940 // This is a dummy image that is needed to determine if the picture url
Greeter/Greeter.qml+1
@@ -59,6 +59,7 @@ Showable {
5959
6060 CrossFadeImage {
6161 id: backgroundImage
62+ objectName: "backgroundImage"
6263 anchors.fill: parent
6364 fadeInFirst: false
6465 source: greeter.background
GreeterShell.qml+6
@@ -15,6 +15,7 @@
1515 */
1616
1717import AccountsService 0.1
18+import GSettings 1.0
1819import LightDM 0.1 as LightDM
1920import Powerd 0.1
2021import QtQuick 2.0
@@ -35,6 +36,11 @@ BasicShell {
3536 greeter.hide()
3637 }
3738
39+ GSettings {
40+ id: backgroundSettings
41+ schema.id: "org.gnome.desktop.background"
42+ }
43+ backgroundFallbackSource: backgroundSettings.pictureUri // for ease of customization by system builders
3844 backgroundSource: AccountsService.backgroundFile
3945
4046 Lockscreen {
plugins/Unity/Launcher/backend/launcherbackend.cpp+8−9
@@ -132,11 +132,7 @@ QString LauncherBackend::icon(const QString &appId) const
132132 }
133133 }
134134
135− QFileInfo info(iconName);
136− if (info.exists()) {
137− return info.absoluteFilePath();
138− }
139− return "image://theme/" + iconName;
135+ return iconName;
140136}
141137
142138bool LauncherBackend::isPinned(const QString &appId) const
@@ -296,15 +292,18 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
296292{
297293 QSettings settings(desktopFile, QSettings::IniFormat);
298294
299−
300295 LauncherBackendItem* item = new LauncherBackendItem();
301296 item->desktopFile = desktopFile;
302297 item->displayName = settings.value("Desktop Entry/Name").toString();
303298
304− if (settings.contains("Desktop Entry/Path")) {
305− item->icon = settings.value("Desktop Entry/Path").toString() + "/" + settings.value("Desktop Entry/Icon").toString();
299+ QString iconString = settings.value("Desktop Entry/Icon").toString();
300+ QString pathString = settings.value("Desktop Entry/Path").toString();
301+ if (QFileInfo(iconString).exists()) {
302+ item->icon = QFileInfo(iconString).absoluteFilePath();
303+ } else if (QFileInfo(pathString + '/' + iconString).exists()) {
304+ item->icon = pathString + '/' + iconString;
306305 } else {
307− item->icon = settings.value("Desktop Entry/Icon").toString();
306+ item->icon = "image://theme/" + iconString;
308307 }
309308 item->pinned = false;
310309 return item;
run_on_device+2−1
@@ -65,8 +65,9 @@ setup_adb_forwarding() {
6565}
6666
6767install_dependencies() {
68+ exec_with_adb rm /etc/init/ssh.override
69+ exec_with_adb service ssh start
6870 exec_with_adb apt-get update
69− exec_with_adb apt-get -y install openssh-server
7071 exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb ninja-build devscripts equivs
7172}
7273
tests/mocks/AccountsService/AccountsService.cpp+9−2
@@ -19,7 +19,8 @@
1919#include "AccountsService.h"
2020
2121AccountsService::AccountsService(QObject* parent)
22− : QObject(parent)
22+ : QObject(parent),
23+ m_backgroundFile(TOP_SRCDIR "/graphics/phone_background.jpg")
2324{
2425}
2526
@@ -54,5 +55,11 @@ void AccountsService::setDemoEdgesForCurrentUser(bool)
5455
5556QString AccountsService::getBackgroundFile()
5657{
57− return TOP_SRCDIR "/graphics/phone_background.jpg";
58+ return m_backgroundFile;
59+}
60+
61+void AccountsService::setBackgroundFile(const QString &backgroundFile)
62+{
63+ m_backgroundFile = backgroundFile;
64+ backgroundFileChanged();
5865}
tests/mocks/AccountsService/AccountsService.h+5
@@ -41,6 +41,7 @@ class AccountsService: public QObject
4141 NOTIFY demoEdgesForCurrentUserChanged)
4242 Q_PROPERTY (QString backgroundFile
4343 READ getBackgroundFile
44+ WRITE setBackgroundFile // only available in mock
4445 NOTIFY backgroundFileChanged)
4546
4647public:
@@ -53,12 +54,16 @@ public:
5354 bool getDemoEdgesForCurrentUser();
5455 void setDemoEdgesForCurrentUser(bool demoEdgesForCurrentUser);
5556 QString getBackgroundFile();
57+ void setBackgroundFile(const QString &backgroundFile);
5658
5759Q_SIGNALS:
5860 void userChanged();
5961 void demoEdgesChanged();
6062 void demoEdgesForCurrentUserChanged();
6163 void backgroundFileChanged();
64+
65+private:
66+ QString m_backgroundFile;
6267};
6368
6469#endif
tests/plugins/Unity/Launcher/click-icon.svgnew file

No changes to the content.

tests/plugins/Unity/Launcher/launcherbackendtest.cpp+10−2
@@ -26,6 +26,15 @@ class LauncherBackendTest : public QObject
2626 Q_OBJECT
2727
2828private Q_SLOTS:
29+
30+ void initTestCase()
31+ {
32+ // As we want to test absolute file paths in the .desktop file, we need to modify the
33+ // sample file and replace the path in there with the current build dir.
34+ QSettings settings(QDir::currentPath() + "/click-icon.desktop", QSettings::IniFormat);
35+ settings.setValue("Desktop Entry/Path", QDir::currentPath());
36+ }
37+
2938 void testFileNames()
3039 {
3140 LauncherBackend backend(false);
@@ -66,8 +75,7 @@ private Q_SLOTS:
6675 QTest::newRow("fallback on theme") << "abs-icon" << "image://theme//path/to/icon.png";
6776
6877 // Click packages have a relative icon path but an absolute path as a separate entry
69− // As we don't want to rely on a click app being installed for the test, accept it with the image://theme fallback
70− QTest::newRow("click package icon") << "click-icon" << "image://theme//path/to/some/click/app/click-icon.svg";
78+ QTest::newRow("click package icon") << "click-icon" << QDir::currentPath() + "/click-icon.svg";
7179 }
7280
7381 void testIcon() {
tests/qmltests/CMakeLists.txt+2−2
@@ -27,8 +27,8 @@ set(qmltest_DEFAULT_TARGETS qmluitests)
2727set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
2828set(qmltest_DEFAULT_PROPERTIES "")
2929
30−add_qml_test(. Shell IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
31− ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/liblightdm/single")
30+add_qml_test(. Shell)
31+add_qml_test(. GreeterShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/liblightdm/single")
3232add_manual_qml_test(Components DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
3333add_qml_test(Components DraggingArea)
3434add_qml_test(Components EdgeDemoOverlay)
tests/qmltests/Greeter/tst_Phone.qml−1
@@ -19,7 +19,6 @@ import QtTest 1.0
1919import ".."
2020import "../../../Greeter"
2121import Ubuntu.Components 0.1
22−import LightDM 0.1 as LightDM
2322import Unity.Test 0.1 as UT
2423
2524Item {
tests/qmltests/tst_GreeterShell.qmlnew file+78
@@ -0,0 +1,78 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Michael Terry <michael.terry@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
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+import QtQuick 2.0
21+import QtTest 1.0
22+import AccountsService 0.1
23+import GSettings 1.0
24+import Unity.Application 0.1
25+import Unity.Test 0.1 as UT
26+import Powerd 0.1
27+
28+import "../.."
29+
30+Item {
31+ width: shell.width
32+ height: shell.height
33+
34+ QtObject {
35+ id: applicationArguments
36+
37+ function hasGeometry() {
38+ return false;
39+ }
40+
41+ function width() {
42+ return 0;
43+ }
44+
45+ function height() {
46+ return 0;
47+ }
48+ }
49+
50+ GreeterShell {
51+ id: shell
52+ }
53+
54+ UT.UnityTestCase {
55+ name: "GreeterShell"
56+ when: windowShown
57+
58+ function test_wallpaper_data() {
59+ return [
60+ {tag: "both", accounts: "tests/data/unity/backgrounds/blue.png", gsettings: "tests/data/unity/backgrounds/red.png", expected: "blue.png"},
61+ {tag: "accounts", accounts: "tests/data/unity/backgrounds/blue.png", gsettings: "", expected: "blue.png"},
62+ {tag: "gsettings", accounts: "", gsettings: "tests/data/unity/backgrounds/red.png", expected: "red.png"},
63+ {tag: "none", accounts: "", gsettings: "", expected: shell.defaultBackground},
64+ {tag: "invalid-both", accounts: "invalid", gsettings: "invalid", expected: shell.defaultBackground},
65+ {tag: "invalid-accounts", accounts: "invalid", gsettings: "tests/data/unity/backgrounds/red.png", expected: shell.defaultBackground},
66+ {tag: "invalid-gsettings", accounts: "tests/data/unity/backgrounds/blue.png", gsettings: "invalid", expected: "blue.png"},
67+ ]
68+ }
69+
70+ function test_wallpaper(data) {
71+ var backgroundImage = findChild(shell, "backgroundImage")
72+ GSettingsController.setPictureUri(data.gsettings)
73+ AccountsService.backgroundFile = data.accounts
74+ tryCompareFunction(function() { return backgroundImage.source.toString().indexOf(data.expected) !== -1; }, true)
75+ tryCompare(backgroundImage, "status", Image.Ready)
76+ }
77+ }
78+}
tests/qmltests/tst_Shell.qml+3−3
@@ -135,7 +135,7 @@ Item {
135135
136136 // Try to suspend while proximity is engaged...
137137 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
138− tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
138+ tryCompare(ApplicationManager, "focusedApplicationId", mainApp);
139139
140140 // Now really suspend
141141 Powerd.displayPowerStateChange(Powerd.Off, 0);
@@ -321,8 +321,8 @@ Item {
321321
322322 function test_wallpaper_data() {
323323 return [
324− {tag: "red", url: "../tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
325− {tag: "blue", url: "../tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
324+ {tag: "red", url: "tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
325+ {tag: "blue", url: "tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
326326 {tag: "invalid", url: "invalid", expectedUrl: shell.defaultBackground},
327327 {tag: "empty", url: "", expectedUrl: shell.defaultBackground}
328328 ]