Merge lp:~canonical-platform-qa/ubuntu-system-settings/main_window_objectName into lp:ubuntu-system-settings
- main_window_objectName
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ken VanDine |
Approved revision: | 1322 |
Merged at revision: | 1333 |
Proposed branch: | lp:~canonical-platform-qa/ubuntu-system-settings/main_window_objectName |
Merge into: | lp:ubuntu-system-settings |
Diff against target: |
238 lines (+78/-69) 3 files modified
src/qml/MainWindow.qml (+2/-2) tests/autopilot/ubuntu_system_settings/__init__.py (+25/-55) tests/autopilot/ubuntu_system_settings/tests/__init__.py (+51/-12) |
To merge this branch: | bzr merge lp:~canonical-platform-qa/ubuntu-system-settings/main_window_objectName |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonas G. Drange (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Sebastien Bacher (community) | Needs Information | ||
Brendan Donegan (community) | Approve | ||
Review via email: mp+250262@code.launchpad.net |
Commit message
On the autopilot tests, select the main window by object name.
Added a proxy object for the application.
Cleaned up the launching methods.
Description of the change
In order to test the integration between system settings and other applications, we need to assign a unique name to the MainWindow.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1318
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Brendan Donegan (brendan-donegan) wrote : | # |
LGTM but obviously the jenkins issues need to be fixed before merging
Sebastien Bacher (seb128) wrote : | # |
That changeset seems to do more than changing the name of the mainview object, can you update the description/commit message to give some details?b
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1319
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1320
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1320
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1321
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1322
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Leo Arias (elopio) wrote : | # |
I finally found my mistake that was causing errors in jenkins.
I added more info to the commit message, and this is ready for a new review.
Jonas G. Drange (jonas-drange) wrote : | # |
Tests run fine on unity7 and 8, changes look good. If you have time you could maybe roughly explain ubuntuuitoolkit
WFM
Leo Arias (elopio) wrote : | # |
> If you have time you could
> maybe roughly explain ubuntuuitoolkit
When autopilot returns a qml element with select single, what it returns is a default proxy object. What this default proxy does is to make it easier the access to qml properties and adds some handy things like waits and methods to inspect the element and its children.
We can extend the default proxy object with a custom proxy object. We link a custom proxy object to a specific QML component, so we can put in that object methods that will make it easier to write tests using that component. For example, a custom proxy object for a check box will have a method "check" and a method "uncheck" that will take care of moving the pointer to the right point and do the click.
We defined a class ubuntuuitoolkit
In here, we are using the toolkit base for the application proxy. The application has some properties that no other QML component has, so at some point we will probably make a specific base class for applications. For now, this one is good for everything.
Preview Diff
1 | === modified file 'src/qml/MainWindow.qml' |
2 | --- src/qml/MainWindow.qml 2015-02-13 08:57:51 +0000 |
3 | +++ src/qml/MainWindow.qml 2015-02-20 17:41:08 +0000 |
4 | @@ -1,7 +1,7 @@ |
5 | /* |
6 | * This file is part of system-settings |
7 | * |
8 | - * Copyright (C) 2013 Canonical Ltd. |
9 | + * Copyright (C) 2013, 2014, 2015 Canonical Ltd. |
10 | * |
11 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
12 | * |
13 | @@ -28,7 +28,7 @@ |
14 | width: units.gu(50) |
15 | height: units.gu(90) |
16 | applicationName: "ubuntu-system-settings" |
17 | - objectName: "mainView" |
18 | + objectName: "systemSettingsMainView" |
19 | automaticOrientation: true |
20 | useDeprecatedToolbar: false |
21 | anchorToKeyboard: true |
22 | |
23 | === modified file 'tests/autopilot/ubuntu_system_settings/__init__.py' |
24 | --- tests/autopilot/ubuntu_system_settings/__init__.py 2015-02-18 21:00:56 +0000 |
25 | +++ tests/autopilot/ubuntu_system_settings/__init__.py 2015-02-20 17:41:08 +0000 |
26 | @@ -1,7 +1,7 @@ |
27 | |
28 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
29 | # |
30 | -# Copyright (C) 2014 Canonical Ltd. |
31 | +# Copyright (C) 2014, 2015 Canonical Ltd. |
32 | # |
33 | # This program is free software; you can redistribute it and/or modify |
34 | # it under the terms of the GNU Lesser General Public License as published by |
35 | @@ -27,70 +27,39 @@ |
36 | from autopilot.input import Keyboard |
37 | import autopilot.logging |
38 | import ubuntuuitoolkit |
39 | -from autopilot import introspection, platform |
40 | +from autopilot import introspection |
41 | from ubuntu_system_settings.utils.i18n import ugettext as _ |
42 | |
43 | logger = logging.getLogger(__name__) |
44 | |
45 | |
46 | -class SystemSettings(): |
47 | +class SystemSettings(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase): |
48 | + |
49 | """Helper class for System Settings application""" |
50 | |
51 | - APP_PATH = '/usr/bin/system-settings' |
52 | - DESKTOP_FILE = '/usr/share/applications/ubuntu-system-settings.desktop' |
53 | - |
54 | - def __init__(self, testobj, panel=None): |
55 | - """Constructor. Launches system settings application |
56 | - |
57 | - :param testobj: An AutopilotTestCase object, needed to call |
58 | - testobj.launch_test_application() |
59 | - |
60 | - :param panel: Launch to a specific panel. Default None. |
61 | - """ |
62 | - self.testobj = testobj |
63 | - self.panel = panel |
64 | - # Launches application |
65 | - self.app = self.launch( |
66 | - self.testobj, |
67 | - self.APP_PATH, |
68 | - self.DESKTOP_FILE, |
69 | - panel=self.panel) |
70 | - |
71 | - def launch(self, testobj, app_path, desktop_file, panel=None): |
72 | - """Launch system settings application |
73 | - |
74 | - :param testobj: An AutopilotTestCase object, needed to call |
75 | - testobj.launch_test_application() |
76 | - |
77 | - :param panel: Launch to a specific panel. Default None. |
78 | - |
79 | - :returns: A proxy object that represents the application. Introspection |
80 | - data is retrievable via this object. |
81 | - """ |
82 | - params = [app_path] |
83 | - if platform.model() != 'Desktop': |
84 | - params.append('--desktop_file_hint={}'.format(desktop_file)) |
85 | - |
86 | - # Launch to a specific panel |
87 | - if panel is not None: |
88 | - params.append(panel) |
89 | - |
90 | - app = testobj.launch_test_application( |
91 | - *params, |
92 | - app_type='qt', |
93 | - emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase, |
94 | - capture_output=True) |
95 | - |
96 | - return app |
97 | + @classmethod |
98 | + def validate_dbus_object(cls, path, state): |
99 | + name = introspection.get_classname_from_path(path) |
100 | + return ((name == b'SystemSettings' and |
101 | + state['applicationName'][1] == 'SystemSettings') or |
102 | + (name == b'ubuntu-system-settings' and |
103 | + state['applicationName'][1] == 'ubuntu-system-settings')) |
104 | |
105 | @property |
106 | def main_view(self): |
107 | """Return main view""" |
108 | - return self.app.select_single(MainWindow) |
109 | - |
110 | - |
111 | -class MainWindow(ubuntuuitoolkit.MainView): |
112 | - """An emulator class that makes it easy to interact with the UI.""" |
113 | + return self.select_single(objectName='systemSettingsMainView') |
114 | + |
115 | + |
116 | +class SystemSettingsMainWindow(ubuntuuitoolkit.MainView): |
117 | + |
118 | + """Autopilot helper for the Main Window.""" |
119 | + |
120 | + @classmethod |
121 | + def validate_dbus_object(cls, path, state): |
122 | + name = introspection.get_classname_from_path(path) |
123 | + return (name == b'MainWindow' and |
124 | + state['objectName'][1] == 'systemSettingsMainView') |
125 | |
126 | @autopilot.logging.log_action(logger.debug) |
127 | def click_item(self, object_name): |
128 | @@ -788,7 +757,8 @@ |
129 | objectName='resetLauncherDialog') |
130 | |
131 | def _wait_and_return_main_system_settins_page(self): |
132 | - main_view = self.get_root_instance().select_single(MainWindow) |
133 | + main_view = self.get_root_instance().select_single( |
134 | + objectName='systemSettingsMainView') |
135 | main_view.system_settings_page.active.wait_for(True) |
136 | return main_view.system_settings_page |
137 | |
138 | |
139 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py' |
140 | --- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-01-28 15:02:09 +0000 |
141 | +++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-02-20 17:41:08 +0000 |
142 | @@ -1,28 +1,39 @@ |
143 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
144 | -# Copyright 2013 Canonical |
145 | -# |
146 | -# This program is free software: you can redistribute it and/or modify it |
147 | -# under the terms of the GNU General Public License version 3, as published |
148 | -# by the Free Software Foundation. |
149 | +# Copyright 2013, 2014, 2015 Canonical |
150 | +# |
151 | +# This program is free software; you can redistribute it and/or modify |
152 | +# it under the terms of the GNU Lesser General Public License as published by |
153 | +# the Free Software Foundation; version 3. |
154 | +# |
155 | +# This program is distributed in the hope that it will be useful, |
156 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
157 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
158 | +# GNU Lesser General Public License for more details. |
159 | +# |
160 | +# You should have received a copy of the GNU Lesser General Public License |
161 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
162 | |
163 | """ Tests for Ubuntu System Settings """ |
164 | + |
165 | from __future__ import absolute_import |
166 | |
167 | - |
168 | import dbus |
169 | import dbusmock |
170 | import os |
171 | import subprocess |
172 | +from datetime import datetime |
173 | +from time import sleep |
174 | + |
175 | import ubuntuuitoolkit |
176 | - |
177 | +from autopilot import platform |
178 | from autopilot.matchers import Eventually |
179 | from dbusmock.templates.networkmanager import DEVICE_IFACE |
180 | -from datetime import datetime |
181 | from fixtures import EnvironmentVariable |
182 | +from gi.repository import UPowerGlib |
183 | from testtools.matchers import Equals, NotEquals, GreaterThan |
184 | -from time import sleep |
185 | -from ubuntu_system_settings import SystemSettings |
186 | -from gi.repository import UPowerGlib |
187 | + |
188 | +import ubuntu_system_settings |
189 | + |
190 | |
191 | ACCOUNTS_IFACE = 'org.freedesktop.Accounts' |
192 | ACCOUNTS_USER_IFACE = 'org.freedesktop.Accounts.User' |
193 | @@ -61,9 +72,12 @@ |
194 | |
195 | """Base class for Ubuntu System Settings.""" |
196 | |
197 | + APP_PATH = '/usr/bin/system-settings' |
198 | + DESKTOP_FILE = '/usr/share/applications/ubuntu-system-settings.desktop' |
199 | + |
200 | def setUp(self, panel=None): |
201 | super(UbuntuSystemSettingsTestCase, self).setUp() |
202 | - self.system_settings = SystemSettings(self, panel=panel) |
203 | + self.system_settings = self.launch(panel) |
204 | self.main_view = self.system_settings.main_view |
205 | self.assertThat( |
206 | self.main_view.visible, |
207 | @@ -75,6 +89,31 @@ |
208 | lambda: gsettings.get_value('rotation-lock').get_boolean(), |
209 | Eventually(Equals(value.get_boolean()))) |
210 | |
211 | + def launch(self, panel=None): |
212 | + """Launch system settings application |
213 | + |
214 | + :param testobj: An AutopilotTestCase object, needed to call |
215 | + testobj.launch_test_application() |
216 | + |
217 | + :param panel: Launch to a specific panel. Default None. |
218 | + |
219 | + :returns: A proxy object that represents the application. Introspection |
220 | + data is retrievable via this object. |
221 | + """ |
222 | + params = [self.APP_PATH] |
223 | + if platform.model() != 'Desktop': |
224 | + params.append('--desktop_file_hint={}'.format(self.DESKTOP_FILE)) |
225 | + |
226 | + # Launch to a specific panel |
227 | + if panel is not None: |
228 | + params.append(panel) |
229 | + |
230 | + return self.launch_test_application( |
231 | + *params, |
232 | + app_type='qt', |
233 | + emulator_base=ubuntu_system_settings.SystemSettings, |
234 | + capture_output=True) |
235 | + |
236 | |
237 | class UbuntuSystemSettingsUpowerTestCase(UbuntuSystemSettingsTestCase, |
238 | dbusmock.DBusTestCase): |
FAILED: Continuous integration, rev:1317 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- ci/1984/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 1434 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- vivid-i386- ci/254 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 1271 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 1432 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 1432/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 18189
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- ci/1984/ rebuild
http://