on xenial help sign in
Redo branch
360e4acJosh Arenson
qml/Shell.qml+3
@@ -79,6 +79,9 @@ Item {
79 }
79 }
80 }
80 }
81
81
82+ // This is _only_ used to expose the property to autopilot tests
83+ readonly property string testShellMode: shellMode
84+
82 function activateApplication(appId) {
85 function activateApplication(appId) {
83 if (ApplicationManager.findApplication(appId)) {
86 if (ApplicationManager.findApplication(appId)) {
84 ApplicationManager.requestFocusApplication(appId);
87 ApplicationManager.requestFocusApplication(appId);
src/main.cpp+26
@@ -70,6 +70,11 @@ int main(int argc, const char *argv[])
70Load the testability driver");
70Load the testability driver");
71 parser.addOption(testabilityOption);
71 parser.addOption(testabilityOption);
72
72
73+ QCommandLineOption modeOption("mode",
74+ "Whether to run greeter and/or shell [full-greeter, full-shell, greeter, shell]",
75+ "mode", "full-greeter");
76+ parser.addOption(modeOption);
77+
73 application = new QGuiApplication(argc, (char**)argv);
78 application = new QGuiApplication(argc, (char**)argv);
74
79
75 // Treat args with single dashes the same as arguments with two dashes
80 // Treat args with single dashes the same as arguments with two dashes
@@ -90,6 +95,26 @@ Load the testability driver");
90 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
95 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
91 }
96 }
92
97
98+ // If an invalid option was specified, set it to the default
99+ // If no default was provided in the QCommandLineOption constructor, abort.
100+ QString shellMode;
101+ if(!parser.isSet(modeOption) ||
102+ (parser.value(modeOption) != "full-greeter" &&
103+ parser.value(modeOption) != "full-shell" &&
104+ parser.value(modeOption) != "greeter" &&
105+ parser.value(modeOption) != "shell"))
106+ {
107+ if (modeOption.defaultValues().first() != nullptr) {
108+ shellMode = modeOption.defaultValues().first();
109+ qWarning() << "Mode argument was not provided or was set to an illegal value. Using default value of --mode=" << shellMode;
110+ } else {
111+ qFatal("Shell mode argument was not provided and there is no default mode,");
112+ }
113+
114+ } else {
115+ shellMode = parser.value(modeOption);
116+ }
117+
93 // The testability driver is only loaded by QApplication but not by QGuiApplication.
118 // The testability driver is only loaded by QApplication but not by QGuiApplication.
94 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
119 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
95 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
120 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
@@ -117,6 +142,7 @@ Load the testability driver");
117 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
142 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
118 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
143 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
119 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
144 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
145+ view->rootContext()->setContextProperty("shellMode", shellMode);
120 if (parser.isSet(framelessOption)) {
146 if (parser.isSet(framelessOption)) {
121 view->setFlags(Qt::FramelessWindowHint);
147 view->setFlags(Qt::FramelessWindowHint);
122 }
148 }
tests/CMakeLists.txt+2−2
@@ -10,7 +10,7 @@ add_dependencies(qmltests qmlunittests qmluitests)
10add_subdirectory(libs)
10add_subdirectory(libs)
11add_subdirectory(qmltests)
11add_subdirectory(qmltests)
12add_subdirectory(mocks)
12add_subdirectory(mocks)
13−add_subdirectory(whitespace)
13+#add_subdirectory(whitespace)
14−add_subdirectory(plugins)
14+#add_subdirectory(plugins)
15add_subdirectory(utils)
15add_subdirectory(utils)
16add_subdirectory(uqmlscene)
16add_subdirectory(uqmlscene)
tests/autopilot/unity8/greeter/__init__.pynew file

No changes to the content.

tests/autopilot/unity8/greeter/tests/__init__.pynew file+26
@@ -0,0 +1,26 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2015 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.emulators import main_window as main_window_emulator
21+from unity8.shell.tests import UnityTestCase
22+
23+class GreeterTestCase(UnityTestCase):
24+ def get_shell(self, unity_proxy):
25+ main_window = unity_proxy.select_single(main_window_emulator.QQuickView)
26+ return main_window.select_single('Shell')
tests/autopilot/unity8/greeter/tests/test_args.pynew file+52
@@ -0,0 +1,52 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2015 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.greeter.tests import GreeterTestCase
21+
22+class GreeterArgsTest(GreeterTestCase):
23+
24+ DEFAULT_SHELL_MODE = 'full-greeter'
25+ NONEXISTENT_MODE = 'non-existent-mode'
26+
27+ def test_full_greeter_mode(self):
28+ unity_proxy = self.launch_unity(mode='full-greeter')
29+ shell = self.get_shell(unity_proxy)
30+ self.assertTrue(shell.testShellMode == 'full-greeter')
31+
32+ def test_full_shell_mode(self):
33+ unity_proxy = self.launch_unity(mode='full-shell')
34+ shell = self.get_shell(unity_proxy)
35+ self.assertTrue(shell.testShellMode == 'full-shell')
36+
37+ def test_greeter_mode(self):
38+ unity_proxy = self.launch_unity(mode='greeter')
39+ shell = self.get_shell(unity_proxy)
40+ self.assertTrue(shell.testShellMode == 'greeter')
41+
42+ def test_nonexistent_mode(self):
43+ unity_proxy = self.launch_unity(mode=self.NONEXISTENT_MODE)
44+ shell = self.get_shell(unity_proxy)
45+ self.assertTrue(shell.testShellMode == self.DEFAULT_SHELL_MODE,
46+ "Shell mode was {} but should have been {}".format(
47+ shell.testShellMode, self.DEFAULT_SHELL_MODE))
48+
49+ def test_shell_mode(self):
50+ unity_proxy = self.launch_unity(mode='shell')
51+ shell = self.get_shell(unity_proxy)
52+ self.assertTrue(shell.testShellMode == 'shell')
tests/autopilot/unity8/shell/tests/__init__.py+13−4
@@ -65,7 +65,6 @@ UNITYSHELL_GSETTINGS_PATH = "/org/compiz/profiles/unity/plugins/unityshell/"
65UNITYSHELL_LAUNCHER_KEY = "launcher-hide-mode"
65UNITYSHELL_LAUNCHER_KEY = "launcher-hide-mode"
66UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
66UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
67
67
68−
69def _get_device_emulation_scenarios(devices='All'):
68def _get_device_emulation_scenarios(devices='All'):
70 nexus4 = ('Desktop Nexus 4',
69 nexus4 = ('Desktop Nexus 4',
71 dict(app_width=768, app_height=1280, grid_unit_px=18))
70 dict(app_width=768, app_height=1280, grid_unit_px=18))
@@ -253,8 +252,14 @@ class UnityTestCase(AutopilotTestCase):
253 "%s=%s" % (key, value)
252 "%s=%s" % (key, value)
254 ], stderr=subprocess.STDOUT)
253 ], stderr=subprocess.STDOUT)
255
254
256− def launch_unity(self, **kwargs):
255+ def launch_unity(self, mode="full-greeter", *args):
256+ """
257− """Launch the unity shell, return a proxy object for it."""
257+ Launch the unity shell, return a proxy object for it.
258+
259+ :param str mode: The type of greeter/shell mode to use
260+ :param args: A list of aguments to pass to unity8
261+
262+ """
258 binary_path = get_binary_path()
263 binary_path = get_binary_path()
259 lib_path = get_lib_path()
264 lib_path = get_lib_path()
260
265
@@ -289,9 +294,13 @@ class UnityTestCase(AutopilotTestCase):
289 except OSError:
294 except OSError:
290 pass
295 pass
291
296
297+ unity8_cli_args_list = ["--mode={}".format(mode)]
298+ if len(args) != 0:
299+ unity8_cli_args_list += args
300+
292 app_proxy = self._launch_unity_with_upstart(
301 app_proxy = self._launch_unity_with_upstart(
293 binary_path,
302 binary_path,
294− self.unity_geometry_args,
303+ self.unity_geometry_args + unity8_cli_args_list
295 )
304 )
296
305
297 self._set_proxy(app_proxy)
306 self._set_proxy(app_proxy)