on xenial help sign in
Redo branch
commit360e4acdae8f48b083e2063eca0d2a18163bab66 authorJosh Arenson <joshua.arenson@canonical.com> dateMon 23 Mar 2015, 16:40 (12 years ago) parentd9d489b
7 files changed+122−6
qml/Shell.qml+3 src/main.cpp+26 tests/CMakeLists.txt+2−2 tests/autopilot/unity8/greeter/__init__.py tests/autopilot/unity8/greeter/tests/__init__.py+26 tests/autopilot/unity8/greeter/tests/test_args.py+52 tests/autopilot/unity8/shell/tests/__init__.py+13−4
qml/Shell.qml+3
@@ -79,6 +79,9 @@ Item {
7979 }
8080 }
8181
82+ // This is _only_ used to expose the property to autopilot tests
83+ readonly property string testShellMode: shellMode
84+
8285 function activateApplication(appId) {
8386 if (ApplicationManager.findApplication(appId)) {
8487 ApplicationManager.requestFocusApplication(appId);
src/main.cpp+26
@@ -70,6 +70,11 @@ int main(int argc, const char *argv[])
7070Load the testability driver");
7171 parser.addOption(testabilityOption);
7272
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+
7378 application = new QGuiApplication(argc, (char**)argv);
7479
7580 // Treat args with single dashes the same as arguments with two dashes
@@ -90,6 +95,26 @@ Load the testability driver");
9095 qmlArgs.setSize(geom.at(0).toInt(), geom.at(1).toInt());
9196 }
9297
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+
93118 // The testability driver is only loaded by QApplication but not by QGuiApplication.
94119 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
95120 if (parser.isSet(testabilityOption) || getenv("QT_LOAD_TESTABILITY")) {
@@ -117,6 +142,7 @@ Load the testability driver");
117142 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
118143 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
119144 view->rootContext()->setContextProperty("indicatorProfile", indicatorProfile);
145+ view->rootContext()->setContextProperty("shellMode", shellMode);
120146 if (parser.isSet(framelessOption)) {
121147 view->setFlags(Qt::FramelessWindowHint);
122148 }
tests/CMakeLists.txt+2−2
@@ -10,7 +10,7 @@ add_dependencies(qmltests qmlunittests qmluitests)
1010add_subdirectory(libs)
1111add_subdirectory(qmltests)
1212add_subdirectory(mocks)
13−add_subdirectory(whitespace)
14−add_subdirectory(plugins)
13+#add_subdirectory(whitespace)
14+#add_subdirectory(plugins)
1515add_subdirectory(utils)
1616add_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/"
6565UNITYSHELL_LAUNCHER_KEY = "launcher-hide-mode"
6666UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
6767
68−
6968def _get_device_emulation_scenarios(devices='All'):
7069 nexus4 = ('Desktop Nexus 4',
7170 dict(app_width=768, app_height=1280, grid_unit_px=18))
@@ -253,8 +252,14 @@ class UnityTestCase(AutopilotTestCase):
253252 "%s=%s" % (key, value)
254253 ], stderr=subprocess.STDOUT)
255254
256− def launch_unity(self, **kwargs):
257− """Launch the unity shell, return a proxy object for it."""
255+ def launch_unity(self, mode="full-greeter", *args):
256+ """
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+ """
258263 binary_path = get_binary_path()
259264 lib_path = get_lib_path()
260265
@@ -289,9 +294,13 @@ class UnityTestCase(AutopilotTestCase):
289294 except OSError:
290295 pass
291296
297+ unity8_cli_args_list = ["--mode={}".format(mode)]
298+ if len(args) != 0:
299+ unity8_cli_args_list += args
300+
292301 app_proxy = self._launch_unity_with_upstart(
293302 binary_path,
294− self.unity_geometry_args,
303+ self.unity_geometry_args + unity8_cli_args_list
295304 )
296305
297306 self._set_proxy(app_proxy)