Merge lp:~canonical-platform-qa/ubuntu-system-tests/app-launch-introspect into lp:ubuntu-system-tests

Proposed by Richard Huddie
Status: Merged
Approved by: Santiago Baldassin
Approved revision: 539
Merged at revision: 514
Proposed branch: lp:~canonical-platform-qa/ubuntu-system-tests/app-launch-introspect
Merge into: lp:ubuntu-system-tests
Diff against target: 1503 lines (+396/-572)
25 files modified
ubuntu_system_tests/common/config.py (+2/-3)
ubuntu_system_tests/helpers/addressbook/app.py (+3/-4)
ubuntu_system_tests/helpers/application.py (+115/-142)
ubuntu_system_tests/helpers/calculator/app.py (+5/-6)
ubuntu_system_tests/helpers/calculator/config.py (+3/-5)
ubuntu_system_tests/helpers/calendar/app.py (+5/-6)
ubuntu_system_tests/helpers/camera/app.py (+5/-6)
ubuntu_system_tests/helpers/clock/app.py (+5/-6)
ubuntu_system_tests/helpers/dialer_app/app.py (+2/-2)
ubuntu_system_tests/helpers/filemanager/app.py (+5/-6)
ubuntu_system_tests/helpers/gallery/app.py (+7/-7)
ubuntu_system_tests/helpers/gallery/cpo.py (+14/-0)
ubuntu_system_tests/helpers/messaging/app.py (+2/-2)
ubuntu_system_tests/helpers/snap.py (+21/-7)
ubuntu_system_tests/helpers/system_settings/app.py (+42/-14)
ubuntu_system_tests/helpers/telegram/app.py (+2/-2)
ubuntu_system_tests/helpers/terminal/app.py (+9/-8)
ubuntu_system_tests/helpers/terminal/cpo.py (+46/-0)
ubuntu_system_tests/helpers/utils.py (+8/-8)
ubuntu_system_tests/helpers/webbrowser/app.py (+5/-6)
ubuntu_system_tests/host/target_setup.py (+32/-5)
ubuntu_system_tests/host/targets.py (+1/-1)
ubuntu_system_tests/tests/base.py (+4/-4)
ubuntu_system_tests/tests/test_launch_apps.py (+45/-320)
ubuntu_system_tests/tests/test_system_settings.py (+8/-2)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-system-tests/app-launch-introspect
Reviewer Review Type Date Requested Status
Santiago Baldassin (community) Approve
platform-qa-bot continuous-integration Approve
Review via email: mp+318509@code.launchpad.net

Commit message

Use introspection in app launch tests to validate app has launched.

Description of the change

Changes:
- Change config value package_type to unity8_mode for clarity
- Add Snap and Deb application classes, derived from Application.
- Add some missing cpos used to validate app has launched
- Fix the is_discovery() method which was not working correctly when checking if an app is installed.
- Update target_setup.py script to install snap version of apps on a deb session.
- Remove all image analysis from test_launch_apps and replace with introspection.

Currently only the deb version works when launching app once on unity8 deb session. In this case there should be 2 pass and 8 failed. All other variants will fail due to problems with app launch tools.

To test:

python3 -m ubuntu_system_tests.run run ubuntu_system_tests.tests.test_launch_apps.LaunchAppOnceTestCase

python3 -m ubuntu_system_tests.run run ubuntu_system_tests.tests.test_launch_apps.LaunchAppTwiceTestCase

This should be landed in conjunction with following for qa-jenkins-jobs: https://code.launchpad.net/~canonical-platform-qa/qa-jenkins-jobs/ust-add-app-modes/+merge/319313

To post a comment you must log in.
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Thanks for the mp Richard. I'm afraid I disagree on the design followed. With minimal changes we would be able to run tests against an image which has both snaps and deb installed, all as part of the same job. Would you please take a look at this? https://pastebin.ubuntu.com/24140328/

I've just run ./system-tests run ubuntu_system_tests.tests.test_launch_apps.LaunchAppOnceTestCase with the design above and I was able to run the tests for calc, webbrowser and system settings as part of the same execution

review: Needs Fixing
Revision history for this message
Richard Huddie (rhuddie) wrote :

The reason for doing this way is to write the tests without knowledge of the type of app being used. - Hence using the config value.

Although the app-launch tests could be implemented with snap/deb specific knowledge, it wouldn't be good to have a suite of sanity or regression tests where we need to have specific test cases for specific app versions. - The way I see it is you would want to run a sanity suite on a deb image for deb apps and then run exactly the same set of tests on same image for snap apps. With the current way that would just mean changing the config value and re-running the same set of tests on same image. Similarly for a snap based image, you would want to run the suite using snap apps only.

The jenkins jobs I am creating will do this from a single job. See: https://code.launchpad.net/~canonical-platform-qa/qa-jenkins-jobs/ust-add-app-modes/+merge/319313

I'm not sure if I understood your concerns correctly or not, what do you think?

Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

> The reason for doing this way is to write the tests without knowledge of the
> type of app being used. - Hence using the config value.
>
> Although the app-launch tests could be implemented with snap/deb specific
> knowledge, it wouldn't be good to have a suite of sanity or regression tests
> where we need to have specific test cases for specific app versions.

This is actually my point, with the approach I suggested, the tests do not know if they are dealing with a snap or a deb, they are just dealing with an application. So for example in the case of the app launch test cases, the test would call calculator.launch() or web_browser.launch(), and since they are both extending from different classes, the apps will be launched differently.

Right now, we specify a mode and we skip those tests that do not comply with that mode right? With the approach I suggest, we don't specify a mode at all. Every app (either deb or snap) knows how to launch itself

 - The way
> I see it is you would want to run a sanity suite on a deb image for deb apps
> and then run exactly the same set of tests on same image for snap apps.

There you go...so this is what we need to agree on. The way I see it, you have an image and you want to run the sanity suite against that image, no matter what that image has, either debs or snaps or both, as you said, the test do not care

If we follow the mode approach, we would have to start skipping test cases based on the mode right? just as tests are skipped here. And when a deb is moved to snap we'll need to do the other way around. With the approach that I proposed, we don't skip tests at all and when a deb app is snapped, then we just change the inheritance from Deb to Snap

With
> the current way that would just mean changing the config value and re-running
> the same set of tests on same image. Similarly for a snap based image, you
> would want to run the suite using snap apps only.
>

From my point of view the suite of tests is exactly the same either in a pure snap, pure deb or in a mix of debs and snaps like we have now. The tests do not change, what changes, is how you start ans introspect a app or a snap

> The jenkins jobs I am creating will do this from a single job. See:
> https://code.launchpad.net/~canonical-platform-qa/qa-jenkins-jobs/ust-add-app-
> modes/+merge/319313
>

I was not clear. What I don't want to do is to re run the tests and merge the results when we could run the tests once and avoid the post processing

> I'm not sure if I understood your concerns correctly or not, what do you
> think?

Let's go through this over the phone. It'll be much easier, and we can get everyone opinion on this

Revision history for this message
Richard Huddie (rhuddie) wrote :

> This is actually my point, with the approach I suggested, the tests do not
> know if they are dealing with a snap or a deb, they are just dealing with an
> application. So for example in the case of the app launch test cases, the test
> would call calculator.launch() or web_browser.launch(), and since they are
> both extending from different classes, the apps will be launched differently.

But this would only work for for one instance of the app, either deb or snap, right? So if you wanted to run your tests against both deb and snap versions of a single application (as is the case with the app launch tests) you would have to change the base class to do so.

If we were running these tests on an deb based image we would want to test both deb and snap versions of the app, but for a snap based image we would only want to test the snap version of the app. I don't see how the approach you mentioned could work with that scenario?

>
> If we follow the mode approach, we would have to start skipping test cases
> based on the mode right? just as tests are skipped here. And when a deb is
> moved to snap we'll need to do the other way around. With the approach that I
> proposed, we don't skip tests at all and when a deb app is snapped, then we
> just change the inheritance from Deb to Snap

I think this is the key point. Doing this would require a code change, and does not allow for testing both deb and snap versions of a single application at the same time.

>
> Let's go through this over the phone. It'll be much easier, and we can get
> everyone opinion on this

Sure, we can discuss more later.

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
539. By Richard Huddie

Fix flake8.

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Santiago Baldassin (sbaldassin) wrote :

Code looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntu_system_tests/common/config.py'
--- ubuntu_system_tests/common/config.py 2017-03-06 17:27:25 +0000
+++ ubuntu_system_tests/common/config.py 2017-03-14 11:03:55 +0000
@@ -211,10 +211,9 @@
211 default='qemu',211 default='qemu',
212 help_string='Type of target. Either qemu or adb.'),212 help_string='Type of target. Either qemu or adb.'),
213 options.Option(213 options.Option(
214 'package_type',214 'unity8_mode',
215 default='deb',215 default='deb',
216 help_string='Which unity8 package type should be installed during '216 help_string='Which unity8 session to use, either deb or snap.'),
217 'setup. Either snap or deb.'),
218]217]
219218
220219
221220
=== modified file 'ubuntu_system_tests/helpers/addressbook/app.py'
--- ubuntu_system_tests/helpers/addressbook/app.py 2017-02-08 15:03:35 +0000
+++ ubuntu_system_tests/helpers/addressbook/app.py 2017-03-14 11:03:55 +0000
@@ -18,21 +18,20 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
20from collections import namedtuple20from collections import namedtuple
21from ubuntu_system_tests.helpers.application import Application21from ubuntu_system_tests.helpers.application import Snap
2222
23APP_NAME = 'Contacts'23APP_NAME = 'Contacts'
24APP_ID = 'address-book-app'24APP_ID = 'address-book-app'
25APP_SNAP = 'address-book-app'
2625
2726
28Contact = namedtuple('Contact', ['name', 'number', 'expected_reply'])27Contact = namedtuple('Contact', ['name', 'number', 'expected_reply'])
29Contact.__new__.__defaults__ = (None, None, None)28Contact.__new__.__defaults__ = (None, None, None)
3029
3130
32class AddressBook(Application):31class AddressBook(Snap):
3332
34 def __init__(self):33 def __init__(self):
35 super().__init__(APP_NAME, APP_ID, APP_SNAP)34 super().__init__(APP_NAME, APP_ID)
3635
37 def get_main_view(self):36 def get_main_view(self):
38 # TODO Move the address book helper upstream migrating the37 # TODO Move the address book helper upstream migrating the
3938
=== modified file 'ubuntu_system_tests/helpers/application.py'
--- ubuntu_system_tests/helpers/application.py 2017-03-08 01:00:05 +0000
+++ ubuntu_system_tests/helpers/application.py 2017-03-14 11:03:55 +0000
@@ -29,76 +29,75 @@
2929
30from ubuntu_system_tests.helpers import autopilot30from ubuntu_system_tests.helpers import autopilot
31from ubuntu_system_tests.helpers import processes31from ubuntu_system_tests.helpers import processes
32from ubuntu_system_tests.helpers.scopes.apps import (32from ubuntu_system_tests.helpers.snap import (
33 launch_application_from_apps_scope)33 get_snap_revision,
34 is_installed as is_snap_installed,
35)
34from ubuntu_system_tests.helpers.unity8.utils import (36from ubuntu_system_tests.helpers.unity8.utils import (
35 is_unity8_snap,37 is_unity8_snap,
36 launch_application_from_launcher,38 launch_application_from_launcher,
37)39)
38from ubuntu_system_tests.helpers.utils import is_discovery40from ubuntu_system_tests.helpers.utils import is_discovery
3941
40UNITY8_DEB_CMD_PREFIX = ''
41UNITY8_SNAP_CMD_PREFIX = 'unity8-session.'
42APP_SNAP_URL = 'appid://{n}/{n}/current-user-version'
43APP_DEB_URL = 'application:///{n}.desktop'
44
45logger = logging.getLogger(__name__)42logger = logging.getLogger(__name__)
4643logger.setLevel(logging.INFO)
4744
48class ApplicationManagerBase:45
49 """Base class to launch and close unity8 apps."""46class Application:
5047 __metaclass__ = ABCMeta
51 def __init__(self, name, cmd_prefix, launch_param):48
52 self.name = name49 def __init__(self, app_name, app_id):
53 self.cmd_prefix = cmd_prefix50 """
54 self.launch_param = launch_param51 :param app_name: Display name for application.
55 self.rev_id = self._get_rev_id()52 :param app_id: Application id.
5653 """
57 def _get_app_ids(self):54 self.app_name = app_name
58 """Return list of installed app ids."""55 self.app_id = app_id
59 return subprocess.check_output(56 self.proxy_object = None
60 self._get_ids_command()).decode().splitlines()57 self.cmd_prefix = None
6158
62 def _get_rev_id(self):59 def _get_cmd_prefix(self):
60 """Return prefix to use with all ubuntu-app-launch commands.
61 This will depend on whether unity8 is running from a snap
62 session or not.
63 """
64 if self.cmd_prefix is None:
65 self.cmd_prefix = 'unity8-session.' if is_unity8_snap() else ''
66 return self.cmd_prefix
67
68 @abstractmethod
69 def _get_app_rev_id(self, app_id):
63 """Return the application revision ID."""70 """Return the application revision ID."""
64 for app_id in self._get_app_ids():71 pass
65 if app_id.startswith(self.name):
66 return app_id
67 logger.warning(
68 'No id found for app: {}. '
69 'Proceeding with this id value.'.format(self.name))
70 return self.name
7172
72 def _get_start_command(self):73 def _get_start_command(self):
73 """Return command to start application."""74 """Return command to start application."""
74 return [75 return [
75 self.cmd_prefix + 'url-dispatcher',76 self._get_cmd_prefix() + 'url-dispatcher',
76 self.launch_param.format(n=self.name)]77 self._get_launch_params()]
7778
78 def _get_stop_command(self):79 def _get_stop_command(self):
79 """Return command to stop application."""80 """Return command to stop application."""
80 return [self.cmd_prefix + 'ubuntu-app-stop', self.rev_id]81 id = self._get_app_rev_id()
82 return [self._get_cmd_prefix() + 'ubuntu-app-stop', id]
8183
82 def _get_pid_command(self):84 def _get_pid_command(self):
83 """Return command to get application process ID."""85 """Return command to get application process ID."""
84 return [self.cmd_prefix + 'ubuntu-app-pid', self.rev_id]86 id = self._get_app_rev_id()
8587 return [self._get_cmd_prefix() + 'ubuntu-app-pid', id]
86 def _get_ids_command(self):
87 """Return command to get list of available application IDs."""
88 return [self.cmd_prefix + 'ubuntu-app-launch-appids']
89
90 def launch(self):
91 """Launch application."""
92 subprocess.check_call(self._get_start_command())
9388
94 def stop(self):89 def stop(self):
95 """Stop application."""90 """Stop application."""
96 subprocess.check_call(self._get_stop_command())91 cmd = self._get_stop_command()
92 logger.info('application stop command: {}'.format(' '.join(cmd)))
93 subprocess.check_call(cmd)
9794
98 def pid(self):95 def get_pid(self):
99 """Return application process ID."""96 """Return application process ID."""
97 cmd = self._get_pid_command()
98 logger.info('application pid command: {}'.format(' '.join(cmd)))
100 try:99 try:
101 out = subprocess.check_output(self._get_pid_command()).decode()100 out = subprocess.check_output(cmd).decode()
102 except subprocess.CalledProcessError:101 except subprocess.CalledProcessError:
103 pass102 pass
104 else:103 else:
@@ -106,84 +105,24 @@
106 if line.isdigit():105 if line.isdigit():
107 return line106 return line
108 raise RuntimeError(107 raise RuntimeError(
109 'Process ID not found for app ID: {}'.format(self.rev_id))108 'Process ID not found for app ID: {}'.format(self.app_id))
110109
111 def running(self):110 def running(self):
112 """Return boolean to indicate if application is running."""111 """Return boolean to indicate if application is running."""
113 return subprocess.call(self._get_pid_command()) == 0112 return subprocess.call(self._get_pid_command()) == 0
114113
115 def installed(self):114 def launch(self):
116 """Return boolean to indicate if application is installed."""115 """Launch application using command."""
117 app_ids = self._get_app_ids()116 cmd = self._get_start_command()
118 return any(app_id.startswith(self.rev_id) for app_id in app_ids)117 logger.info('application launch command: {}'.format(' '.join(cmd)))
119118 subprocess.check_call(cmd)
120119
121class DebApplicationManager(ApplicationManagerBase):120 def launch_from_app_drawer(self, return_proxy=True):
122 """Application manager for deb based apps on deb based unity8 session."""121 """
123122 Launch app from app drawer.
124 def __init__(self, name):123 """
125 super().__init__(name, UNITY8_DEB_CMD_PREFIX, APP_DEB_URL)124 # TODO: Implement with app drawer helpers.
126125 pass
127
128class SnapApplicationManager(ApplicationManagerBase):
129 """Application manager for snap based apps on snap based unity8 session."""
130
131 def __init__(self, name):
132 super().__init__(name, UNITY8_SNAP_CMD_PREFIX, APP_SNAP_URL)
133
134
135class SnapOnDebApplicationManager(ApplicationManagerBase):
136 """Application manager for snap based apps on deb based unity8 session."""
137
138 def __init__(self, name):
139 super().__init__(name, UNITY8_DEB_CMD_PREFIX, APP_SNAP_URL)
140
141
142class Application:
143 __metaclass__ = ABCMeta
144
145 def __init__(self, app_name, app_id=None, app_snap=None, use_snap=False):
146 """
147 :param app_name: Display name for application.
148 :param app_id: Application id.
149 :param app_snap: Name of application snap.
150 :param use_snap: Use snap version of application even if running from
151 a deb based unity8 session.
152 """
153 self.app_name = app_name
154 self.app_id = app_id
155 self.app_snap = app_snap
156 self.proxy_object = None
157 self.app_manager = None
158 self.use_snap = use_snap
159
160 def _get_application_manager(self):
161 """Get application manager for required application. The type of
162 application used will either be deb or snap based depending on which
163 type of unity8 session is being used. In the case where unity8 is deb
164 based but use_snap property is True, the snap version of app is used.
165 """
166 if self.app_manager is None:
167 if is_unity8_snap():
168 # This is a snap based unity8 session, so must use snap
169 # based application.
170 self.app_manager = SnapApplicationManager(self.app_snap)
171 elif self.use_snap:
172 # This is a deb based unity8 session, but we're requested to
173 # use a snap based application.
174 self.app_manager = SnapOnDebApplicationManager(self.app_snap)
175 else:
176 # This is a deb based unity8 session using deb based
177 # application.
178 self.app_manager = DebApplicationManager(self.app_id)
179
180 def launch_from_scope(self, return_proxy=True):
181 """
182 Launch app from apps scope
183 """
184 launch_application_from_apps_scope(self.app_name)
185 if return_proxy:
186 return self.get_proxy_object()
187126
188 def launch_from_launcher(self, return_proxy=True):127 def launch_from_launcher(self, return_proxy=True):
189 """Drag out the launcher and tap the application icon to start it."""128 """Drag out the launcher and tap the application icon to start it."""
@@ -191,33 +130,16 @@
191 if return_proxy:130 if return_proxy:
192 return self.get_proxy_object()131 return self.get_proxy_object()
193132
194 def launch(self):133 @retry(stop_max_delay=3000,
195 self._get_application_manager()134 wait_fixed=1000,
196 self.app_manager.launch()
197
198 def stop(self):
199 self._get_application_manager()
200 self.app_manager.stop()
201
202 def get_pid(self):
203 self._get_application_manager()
204 return self.app_manager.pid()
205
206 def is_running(self):
207 self._get_application_manager()
208 return self.app_manager.running()
209
210 @retry(stop_max_delay=30000,
211 wait_exponential_multiplier=1000,
212 wait_exponential_max=10000,
213 retry_on_exception=lambda exception: (135 retry_on_exception=lambda exception: (
214 isinstance(exception, ProcessSearchError) or136 isinstance(exception, ProcessSearchError) or
215 isinstance(exception, processes.PidNotFoundError) or137 isinstance(exception, processes.PidNotFoundError) or
138 isinstance(exception, RuntimeError) or
216 isinstance(exception, NoSuchProcess)))139 isinstance(exception, NoSuchProcess)))
217 def get_proxy_object(self):140 def get_proxy_object(self):
218 if self.proxy_object is None:141 if self.proxy_object is None:
219 self.proxy_object = autopilot.get_proxy_object(142 self.proxy_object = autopilot.get_proxy_object(int(self.get_pid()))
220 int(self.get_pid()))
221 return self.proxy_object143 return self.proxy_object
222144
223 @abstractmethod145 @abstractmethod
@@ -231,5 +153,56 @@
231 # In this case always return True to ensure all tests can be153 # In this case always return True to ensure all tests can be
232 # listed on the host machine.154 # listed on the host machine.
233 return True155 return True
234 self._get_application_manager()156 return self._is_installed()
235 return self.app_manager.installed()157
158 @abstractmethod
159 def _is_installed(self, app_id):
160 """Return boolean indicating if app is installed."""
161 pass
162
163
164class Snap(Application):
165
166 app_type = 'snap'
167
168 def __init__(self, app_name, app_id):
169 super().__init__(app_name, app_id)
170 self.app_rev_id = None
171
172 def _get_launch_params(self):
173 """Return required parameters for app launch command."""
174 return 'appid://{n}/{n}/current-user-version'.format(n=self.app_id)
175
176 def _get_app_rev_id(self):
177 """Return the application revision ID."""
178 if self.app_rev_id is None:
179 rev = get_snap_revision(self.app_id)
180 self.app_rev_id = '{n}_{n}_{r}'.format(n=self.app_id, r=rev)
181 return self.app_rev_id
182
183 def _is_installed(self):
184 """Return boolean indicating if app is installed."""
185 return is_snap_installed(self.app_id)
186
187
188class Deb(Application):
189
190 app_type = 'deb'
191
192 def __init__(self, app_name, app_id, package_id=None):
193 super().__init__(app_name, app_id)
194 self.package_id = package_id or app_id
195
196 def _get_launch_params(self):
197 """Return required parameters for app launch command."""
198 return 'application:///{n}.desktop'.format(n=self.app_id)
199
200 def _get_app_rev_id(self):
201 """Return the application revision ID."""
202 return self.app_id
203
204 def _is_installed(self):
205 """Return boolean indicating if app is installed."""
206 output = subprocess.check_output(
207 ['apt-cache', 'policy', self.package_id])
208 return len(output) > 0 and 'Installed: (none)' not in output.decode()
236209
=== modified file 'ubuntu_system_tests/helpers/calculator/app.py'
--- ubuntu_system_tests/helpers/calculator/app.py 2017-02-09 15:14:56 +0000
+++ ubuntu_system_tests/helpers/calculator/app.py 2017-03-14 11:03:55 +0000
@@ -18,17 +18,16 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
2020
21from ubuntu_system_tests.helpers.application import Application21from ubuntu_system_tests.helpers.application import Snap
2222
23APP_NAME = 'Calculator'23APP_NAME = 'Calculator'
24APP_ID = 'ubuntu-calculator-app'24APP_ID = 'ubuntu-calculator-app'
25APP_SNAP = 'ubuntu-calculator-app'25
2626
2727class Calculator(Snap):
28class Calculator(Application):
2928
30 def __init__(self):29 def __init__(self):
31 super().__init__(APP_NAME, APP_ID, APP_SNAP)30 super().__init__(APP_NAME, APP_ID)
3231
33 def get_main_view(self):32 def get_main_view(self):
34 from ubuntu_system_tests.helpers.calculator import cpo # NOQA33 from ubuntu_system_tests.helpers.calculator import cpo # NOQA
3534
=== modified file 'ubuntu_system_tests/helpers/calculator/config.py'
--- ubuntu_system_tests/helpers/calculator/config.py 2017-01-26 13:44:38 +0000
+++ ubuntu_system_tests/helpers/calculator/config.py 2017-03-14 11:03:55 +0000
@@ -19,9 +19,7 @@
19#19#
20import os20import os
21from ubuntu_system_tests.helpers import file_system as fs21from ubuntu_system_tests.helpers import file_system as fs
22from ubuntu_system_tests.helpers.calculator.app import (22from ubuntu_system_tests.helpers.calculator.app import APP_ID
23 APP_SNAP as SNAP_CALCULATOR,
24)
25from ubuntu_system_tests.helpers.configuration import Config23from ubuntu_system_tests.helpers.configuration import Config
26from ubuntu_system_tests.helpers.snap import (24from ubuntu_system_tests.helpers.snap import (
27 get_snap_revision,25 get_snap_revision,
@@ -35,9 +33,9 @@
3533
36 def __init__(self):34 def __init__(self):
37 if is_unity8_snap():35 if is_unity8_snap():
38 rev = get_snap_revision(SNAP_CALCULATOR)36 rev = get_snap_revision(APP_ID)
39 conf_dir = fs.get_home_snap_path(37 conf_dir = fs.get_home_snap_path(
40 SNAP_CALCULATOR, rev, fs.DIR_CONFIG, fs.DIR_CALCULATOR)38 APP_ID, rev, fs.DIR_CONFIG, fs.DIR_CALCULATOR)
41 else:39 else:
42 conf_dir = os.path.join(fs.DIR_HOME_CONFIG, fs.DIR_CALCULATOR)40 conf_dir = os.path.join(fs.DIR_HOME_CONFIG, fs.DIR_CALCULATOR)
43 self.conf_file_path = os.path.join(conf_dir, CALCULATOR_CONF_FILE)41 self.conf_file_path = os.path.join(conf_dir, CALCULATOR_CONF_FILE)
4442
=== modified file 'ubuntu_system_tests/helpers/calendar/app.py'
--- ubuntu_system_tests/helpers/calendar/app.py 2017-02-08 17:47:07 +0000
+++ ubuntu_system_tests/helpers/calendar/app.py 2017-03-14 11:03:55 +0000
@@ -18,17 +18,16 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
2020
21from ubuntu_system_tests.helpers.application import Application21from ubuntu_system_tests.helpers.application import Snap
2222
23APP_NAME = 'Calendar'23APP_NAME = 'Calendar'
24APP_ID = 'ubuntu-calendar-app'24APP_ID = 'ubuntu-calendar-app'
25APP_SNAP = 'ubuntu-calendar-app'25
2626
2727class Calendar(Snap):
28class Calendar(Application):
2928
30 def __init__(self):29 def __init__(self):
31 super().__init__(APP_NAME, APP_ID, APP_SNAP)30 super().__init__(APP_NAME, APP_ID)
3231
33 def get_main_view(self):32 def get_main_view(self):
34 from ubuntu_system_tests.helpers.clock.cpo import MainView # NOQA33 from ubuntu_system_tests.helpers.clock.cpo import MainView # NOQA
3534
=== modified file 'ubuntu_system_tests/helpers/camera/app.py'
--- ubuntu_system_tests/helpers/camera/app.py 2017-02-08 17:47:07 +0000
+++ ubuntu_system_tests/helpers/camera/app.py 2017-03-14 11:03:55 +0000
@@ -17,17 +17,16 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#18#
1919
20from ubuntu_system_tests.helpers.application import Application20from ubuntu_system_tests.helpers.application import Snap
2121
22APP_NAME = 'Camera'22APP_NAME = 'Camera'
23APP_ID = 'camera-app'23APP_ID = 'camera-app'
24APP_SNAP = 'camera-app'24
2525
2626class Camera(Snap):
27class Camera(Application):
2827
29 def __init__(self):28 def __init__(self):
30 super().__init__(APP_NAME, APP_ID, APP_SNAP)29 super().__init__(APP_NAME, APP_ID)
3130
32 def get_main_view(self):31 def get_main_view(self):
33 from ubuntu_system_tests.helpers.camera import cpo # NOQA32 from ubuntu_system_tests.helpers.camera import cpo # NOQA
3433
=== modified file 'ubuntu_system_tests/helpers/clock/app.py'
--- ubuntu_system_tests/helpers/clock/app.py 2017-02-08 17:47:07 +0000
+++ ubuntu_system_tests/helpers/clock/app.py 2017-03-14 11:03:55 +0000
@@ -17,17 +17,16 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#18#
1919
20from ubuntu_system_tests.helpers.application import Application20from ubuntu_system_tests.helpers.application import Snap
2121
22APP_NAME = 'Clock'22APP_NAME = 'Clock'
23APP_ID = 'ubuntu-clock-app'23APP_ID = 'ubuntu-clock-app'
24APP_SNAP = 'ubuntu-clock-app'24
2525
2626class Clock(Snap):
27class Clock(Application):
2827
29 def __init__(self):28 def __init__(self):
30 super().__init__(APP_NAME, APP_ID, APP_SNAP)29 super().__init__(APP_NAME, APP_ID)
3130
32 def get_main_view(self):31 def get_main_view(self):
33 from ubuntu_system_tests.helpers.clock.cpo import MainView # NOQA32 from ubuntu_system_tests.helpers.clock.cpo import MainView # NOQA
3433
=== modified file 'ubuntu_system_tests/helpers/dialer_app/app.py'
--- ubuntu_system_tests/helpers/dialer_app/app.py 2017-02-08 15:03:35 +0000
+++ ubuntu_system_tests/helpers/dialer_app/app.py 2017-03-14 11:03:55 +0000
@@ -17,13 +17,13 @@
17# You should have received a copy of the GNU General Public License17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
20from ubuntu_system_tests.helpers.application import Application20from ubuntu_system_tests.helpers.application import Snap
2121
22APP_NAME = 'Phone'22APP_NAME = 'Phone'
23APP_ID = 'com.ubuntu.dialer'23APP_ID = 'com.ubuntu.dialer'
2424
2525
26class Dialer(Application):26class Dialer(Snap):
2727
28 def __init__(self):28 def __init__(self):
29 super().__init__(APP_NAME, APP_ID)29 super().__init__(APP_NAME, APP_ID)
3030
=== modified file 'ubuntu_system_tests/helpers/filemanager/app.py'
--- ubuntu_system_tests/helpers/filemanager/app.py 2017-02-09 11:43:45 +0000
+++ ubuntu_system_tests/helpers/filemanager/app.py 2017-03-14 11:03:55 +0000
@@ -18,17 +18,16 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
2020
21from ubuntu_system_tests.helpers.application import Application21from ubuntu_system_tests.helpers.application import Snap
2222
23APP_NAME = 'Files'23APP_NAME = 'Files'
24APP_ID = 'ubuntu-filemanager-app'24APP_ID = 'ubuntu-filemanager-app'
25APP_SNAP = 'ubuntu-filemanager-app'25
2626
2727class FileManager(Snap):
28class FileManager(Application):
2928
30 def __init__(self):29 def __init__(self):
31 super().__init__(APP_NAME, APP_ID, APP_SNAP)30 super().__init__(APP_NAME, APP_ID)
3231
33 def get_main_view(self):32 def get_main_view(self):
34 pass33 pass
3534
=== modified file 'ubuntu_system_tests/helpers/gallery/app.py'
--- ubuntu_system_tests/helpers/gallery/app.py 2017-02-08 17:47:07 +0000
+++ ubuntu_system_tests/helpers/gallery/app.py 2017-03-14 11:03:55 +0000
@@ -20,7 +20,7 @@
2020
21from ubuntu_system_tests.helpers import autopilot21from ubuntu_system_tests.helpers import autopilot
22from ubuntu_system_tests.helpers import processes22from ubuntu_system_tests.helpers import processes
23from ubuntu_system_tests.helpers.application import Application23from ubuntu_system_tests.helpers.application import Snap
24from ubuntu_system_tests.helpers.scopes.apps import (24from ubuntu_system_tests.helpers.scopes.apps import (
25 launch_application_from_apps_scope25 launch_application_from_apps_scope
26)26)
@@ -33,19 +33,19 @@
33APP_NAME = 'Gallery'33APP_NAME = 'Gallery'
34APP_WIN_ID = 'com.ubuntu.gallery_gallery'34APP_WIN_ID = 'com.ubuntu.gallery_gallery'
35APP_CLICK = 'com.ubuntu.gallery'35APP_CLICK = 'com.ubuntu.gallery'
36APP_DOMAIN = 'com.ubuntu.gallery'
36APP_ICON_NAME = 'gallery-app.png'37APP_ICON_NAME = 'gallery-app.png'
37APP_ID = 'gallery-app'38APP_ID = 'gallery-app'
38APP_SNAP = 'gallery-app'39
3940
4041class Gallery(Snap):
41class Gallery(Application):
4242
43 def __init__(self):43 def __init__(self):
44 super().__init__(APP_NAME, APP_ID, APP_SNAP)44 super().__init__(APP_NAME, APP_ID)
4545
46 def get_main_view(self):46 def get_main_view(self):
47 from ubuntu_system_tests.helpers.gallery import cpo # NOQA47 from ubuntu_system_tests.helpers.gallery import cpo # NOQA
48 return self.get_proxy_object().events_view48 return self.get_proxy_object().application
4949
5050
51def launch_gallery_app():51def launch_gallery_app():
5252
=== modified file 'ubuntu_system_tests/helpers/gallery/cpo.py'
--- ubuntu_system_tests/helpers/gallery/cpo.py 2016-12-19 18:50:17 +0000
+++ ubuntu_system_tests/helpers/gallery/cpo.py 2017-03-14 11:03:55 +0000
@@ -22,6 +22,7 @@
22from autopilot.introspection.utilities import sort_by_keys22from autopilot.introspection.utilities import sort_by_keys
23from retrying import retry23from retrying import retry
2424
25from ubuntu_system_tests.helpers.gallery.app import APP_DOMAIN
25from ubuntu_system_tests.helpers.input_manager import input_manager26from ubuntu_system_tests.helpers.input_manager import input_manager
26from ubuntu_system_tests.helpers.ubuntuuitools.cpo.header import Header27from ubuntu_system_tests.helpers.ubuntuuitools.cpo.header import Header
27from ubuntu_system_tests.helpers.ubuntuuitools.cpo.common import CustomProxyObjectBase # NOQA28from ubuntu_system_tests.helpers.ubuntuuitools.cpo.common import CustomProxyObjectBase # NOQA
@@ -34,6 +35,19 @@
34APP_PATH_ROOT = b'comubuntugallery'35APP_PATH_ROOT = b'comubuntugallery'
3536
3637
38class comubuntugallery(CustomProxyObjectBase):
39
40 @classmethod
41 def validate_dbus_object(cls, path, state):
42 return validate_dbus_object(
43 path, state, APP_PATH_ROOT, APP_PATH_ROOT,
44 applicationName=APP_DOMAIN)
45
46 @property
47 def application(self):
48 return self.select_single(GalleryApplication, visible=True)
49
50
37class GalleryApplication(CustomProxyObjectBase):51class GalleryApplication(CustomProxyObjectBase):
3852
39 @classmethod53 @classmethod
4054
=== modified file 'ubuntu_system_tests/helpers/messaging/app.py'
--- ubuntu_system_tests/helpers/messaging/app.py 2017-02-08 15:03:35 +0000
+++ ubuntu_system_tests/helpers/messaging/app.py 2017-03-14 11:03:55 +0000
@@ -17,7 +17,7 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#18#
1919
20from ubuntu_system_tests.helpers.application import Application20from ubuntu_system_tests.helpers.application import Snap
21from ubuntu_system_tests.helpers import autopilot21from ubuntu_system_tests.helpers import autopilot
22from ubuntu_system_tests.helpers import processes22from ubuntu_system_tests.helpers import processes
23from ubuntu_system_tests.helpers.scopes.apps import (23from ubuntu_system_tests.helpers.scopes.apps import (
@@ -34,7 +34,7 @@
34APP_WIN_ID = 'messaging-app'34APP_WIN_ID = 'messaging-app'
3535
3636
37class Messaging(Application):37class Messaging(Snap):
3838
39 def __init__(self):39 def __init__(self):
40 super().__init__(APP_NAME, APP_ID)40 super().__init__(APP_NAME, APP_ID)
4141
=== modified file 'ubuntu_system_tests/helpers/snap.py'
--- ubuntu_system_tests/helpers/snap.py 2017-01-26 14:06:10 +0000
+++ ubuntu_system_tests/helpers/snap.py 2017-03-14 11:03:55 +0000
@@ -25,15 +25,29 @@
25SOCK_SNAPD = '/run/snapd.socket'25SOCK_SNAPD = '/run/snapd.socket'
2626
2727
28def get_snap_data(snap_name):
29 """Return snap data dictionary or None if not found."""
30 session = requests_unixsocket.Session()
31 path = quote_plus(SOCK_SNAPD)
32 url = 'http+unix://{p}/v2/snaps/{s}'.format(p=path, s=snap_name)
33 response = session.get(url)
34 if not response.ok:
35 return None
36 return json.loads(response.content.decode())['result']
37
38
28def get_snap_revision(snap_name):39def get_snap_revision(snap_name):
29 """Return the revision of the specified snap.40 """Return the revision of the specified snap.
30 :param snap_name: Name of the required snap package.41 :param snap_name: Name of the required snap package.
31 :return: Revision number as string.42 :return: Revision number as string.
32 """43 """
33 session = requests_unixsocket.Session()44 snap_data = get_snap_data(snap_name)
34 path = quote_plus(SOCK_SNAPD)45 if snap_data is None:
35 url = 'http+unix://{p}/v2/snaps/{s}'.format(p=path, s=snap_name)46 raise RuntimeError(
36 response = session.get(url)47 'Snap {s} not found'.format(s=snap_name))
37 if not response.ok:48 return snap_data['revision']
38 raise ConnectionError('Could not query snapd socket: {}'.format(url))49
39 return json.loads(response.content.decode())['result']['revision']50
51def is_installed(snap_name):
52 """Return boolean indicating if snap is installed or not."""
53 return bool(get_snap_data(snap_name))
4054
=== modified file 'ubuntu_system_tests/helpers/system_settings/app.py'
--- ubuntu_system_tests/helpers/system_settings/app.py 2017-03-11 09:35:38 +0000
+++ ubuntu_system_tests/helpers/system_settings/app.py 2017-03-14 11:03:55 +0000
@@ -19,27 +19,55 @@
19#19#
20from ubuntu_system_tests.helpers import autopilot20from ubuntu_system_tests.helpers import autopilot
21from ubuntu_system_tests.helpers import processes21from ubuntu_system_tests.helpers import processes
22from ubuntu_system_tests.helpers.application import Application22from ubuntu_system_tests.helpers.application import (
23 Deb,
24 Snap,
25)
23from ubuntu_system_tests.helpers.processes import get_process_id26from ubuntu_system_tests.helpers.processes import get_process_id
24from ubuntu_system_tests.helpers.scopes.apps import (27from ubuntu_system_tests.helpers.scopes.apps import (
25 launch_application_from_apps_scope)28 launch_application_from_apps_scope
29)
2630
27APP = 'system-settings'31APP = 'system-settings'
28APP_NAME = 'System Settings'32APP_NAME = 'System Settings'
29APP_WIN_ID = 'ubuntu-system-settings'33APP_WIN_ID = 'ubuntu-system-settings'
30APP_ID = 'ubuntu-system-settings'34APP_ID = 'ubuntu-system-settings'
31APP_SNAP = 'ubuntu-system-settings'35
3236
3337class SystemSettingsDeb(Deb):
34class SystemSettings(Application):38
3539 def __init__(self):
36 def __init__(self):40 super().__init__(APP_NAME, APP_ID)
37 super().__init__(APP_NAME, APP_ID, APP_SNAP)41
3842 def get_main_view(self):
39 def get_main_view(self):43 return get_main_view()
40 from ubuntu_system_tests.helpers.system_settings import cpo # NOQA44
41 pid = get_process_id(APP)45
42 return autopilot.get_proxy_object(pid=pid).main_view46class SystemSettingsSnap(Snap):
47
48 def __init__(self):
49 super().__init__(APP_NAME, APP_ID)
50
51 def get_main_view(self):
52 return get_main_view()
53
54
55def get_main_view():
56 from ubuntu_system_tests.helpers.system_settings import cpo # NOQA
57 pid = get_process_id(APP)
58 return autopilot.get_proxy_object(pid=pid).main_view
59
60
61def get_system_settings_app(mode):
62 """Return system settings application class of required type.
63 :param mode: Either 'snap' or 'deb'.
64 :return: Either SystemSettingsDeb or SystemSettingsSnap class reference.
65 """
66 app_modes = {
67 'deb': SystemSettingsDeb,
68 'snap': SystemSettingsSnap
69 }
70 return app_modes[mode]
4371
4472
45def launch_system_settings(shell):73def launch_system_settings(shell):
4674
=== modified file 'ubuntu_system_tests/helpers/telegram/app.py'
--- ubuntu_system_tests/helpers/telegram/app.py 2017-02-08 15:03:35 +0000
+++ ubuntu_system_tests/helpers/telegram/app.py 2017-03-14 11:03:55 +0000
@@ -16,13 +16,13 @@
16# You should have received a copy of the GNU General Public License16# 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/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19from ubuntu_system_tests.helpers.application import Application19from ubuntu_system_tests.helpers.application import Snap
2020
21APP_NAME = 'Telegram'21APP_NAME = 'Telegram'
22APP_ID = 'com.ubuntu.telegram_telegram'22APP_ID = 'com.ubuntu.telegram_telegram'
2323
2424
25class Telegram(Application):25class Telegram(Snap):
2626
27 def __init__(self):27 def __init__(self):
28 super().__init__(APP_NAME, APP_ID)28 super().__init__(APP_NAME, APP_ID)
2929
=== modified file 'ubuntu_system_tests/helpers/terminal/app.py'
--- ubuntu_system_tests/helpers/terminal/app.py 2017-02-09 11:43:45 +0000
+++ ubuntu_system_tests/helpers/terminal/app.py 2017-03-14 11:03:55 +0000
@@ -18,17 +18,18 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
2020
21from ubuntu_system_tests.helpers.application import Application21from ubuntu_system_tests.helpers.application import Deb
2222
23APP_NAME = 'Terminal'23APP_NAME = 'Terminal'
24APP_ID = 'ubuntu-terminal-app'24APP_ID = 'com.ubuntu.terminal'
25APP_SNAP = 'ubuntu-terminal-app'25APP_PACKAGE_ID = 'ubuntu-terminal-app'
2626
2727
28class Terminal(Application):28class Terminal(Deb):
2929
30 def __init__(self):30 def __init__(self):
31 super().__init__(APP_NAME, APP_ID, APP_SNAP)31 super().__init__(APP_NAME, APP_ID, APP_PACKAGE_ID)
3232
33 def get_main_view(self):33 def get_main_view(self):
34 pass34 from ubuntu_system_tests.helpers.terminal import cpo # NOQA
35 return self.get_proxy_object().main_view
3536
=== added file 'ubuntu_system_tests/helpers/terminal/cpo.py'
--- ubuntu_system_tests/helpers/terminal/cpo.py 1970-01-01 00:00:00 +0000
+++ ubuntu_system_tests/helpers/terminal/cpo.py 2017-03-14 11:03:55 +0000
@@ -0,0 +1,46 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3# Ubuntu System Tests
4# Copyright (C) 2017 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
19from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
20from ubuntu_system_tests.helpers.ubuntuuitools.cpo.common import (
21 CustomProxyObjectBase,
22)
23
24APP_PATH_ROOT = b'comubuntuterminal'
25
26
27class comubuntuterminal(CustomProxyObjectBase):
28 """Autopilot helper object for terminal app."""
29
30 @classmethod
31 def validate_dbus_object(cls, path, state):
32 return validate_dbus_object(
33 path, state, APP_PATH_ROOT, APP_PATH_ROOT,
34 applicationName='com.ubuntu.terminal')
35
36 @property
37 def main_view(self):
38 return self.wait_select_single(MainView)
39
40
41class MainView(CustomProxyObjectBase):
42
43 @classmethod
44 def validate_dbus_object(cls, path, state):
45 return validate_dbus_object(
46 path, state, APP_PATH_ROOT, b'MainView', objectName='terminal')
047
=== modified file 'ubuntu_system_tests/helpers/utils.py'
--- ubuntu_system_tests/helpers/utils.py 2017-02-28 10:57:31 +0000
+++ ubuntu_system_tests/helpers/utils.py 2017-03-14 11:03:55 +0000
@@ -30,7 +30,7 @@
30DUMMY_IMPORT_ERR = ('DummyImportObject being used because try_import failed. '30DUMMY_IMPORT_ERR = ('DummyImportObject being used because try_import failed. '
31 'Check all required dependencies are installed.')31 'Check all required dependencies are installed.')
3232
33is_discovery = None33discovery = None
3434
3535
36def try_import(name, package=None):36def try_import(name, package=None):
@@ -144,16 +144,16 @@
144144
145def is_discovery():145def is_discovery():
146 """Return True if being imported during test discovery."""146 """Return True if being imported during test discovery."""
147 global is_discovery147 global discovery
148 if is_discovery is None:148 if discovery is None:
149 stack_trace = stack()149 stack_trace = stack()
150 stack_trace.reverse()150 stack_trace.reverse()
151 for frame in stack_trace:151 for frame in stack_trace:
152 if frame[3] == 'load_test_suite_from_name':152 if frame[3] == 'list_tests':
153 is_discovery = True153 discovery = True
154 return is_discovery154 return discovery
155 is_discovery = False155 discovery = False
156 return is_discovery156 return discovery
157157
158158
159class AttrDict(dict):159class AttrDict(dict):
160160
=== modified file 'ubuntu_system_tests/helpers/webbrowser/app.py'
--- ubuntu_system_tests/helpers/webbrowser/app.py 2017-02-08 17:02:14 +0000
+++ ubuntu_system_tests/helpers/webbrowser/app.py 2017-03-14 11:03:55 +0000
@@ -18,17 +18,16 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
2020
21from ubuntu_system_tests.helpers.application import Application21from ubuntu_system_tests.helpers.application import Snap
2222
23APP_NAME = 'Browser'23APP_NAME = 'Browser'
24APP_ID = 'webbrowser-app'24APP_ID = 'webbrowser-app'
25APP_SNAP = 'webbrowser-app'25
2626
2727class WebBrowser(Snap):
28class WebBrowser(Application):
2928
30 def __init__(self):29 def __init__(self):
31 super().__init__(APP_NAME, APP_ID, APP_SNAP)30 super().__init__(APP_NAME, APP_ID)
3231
33 def get_main_view(self):32 def get_main_view(self):
34 from ubuntu_system_tests.helpers.webbrowser import cpo # NOQA33 from ubuntu_system_tests.helpers.webbrowser import cpo # NOQA
3534
=== modified file 'ubuntu_system_tests/host/target_setup.py'
--- ubuntu_system_tests/host/target_setup.py 2017-02-20 19:49:08 +0000
+++ ubuntu_system_tests/host/target_setup.py 2017-03-14 11:03:55 +0000
@@ -178,6 +178,17 @@
178 ['apt-get', '-y', '--no-install-recommends', 'install'] +178 ['apt-get', '-y', '--no-install-recommends', 'install'] +
179 packages)179 packages)
180180
181 def install_snaps(self, snaps):
182 if snaps:
183 self.mount_fs_rw()
184 for snap in snaps:
185 cmd = 'refresh' if self.is_snap_installed(snap) else 'install'
186 subprocess.check_call(
187 ['snap', cmd, '--devmode', '--edge', snap])
188
189 def is_snap_installed(self, snap):
190 return os.path.isdir(os.path.join('/snap', snap))
191
181 def are_packages_installed(self, packages):192 def are_packages_installed(self, packages):
182 output = subprocess.check_output(['apt-cache', 'policy'] + packages)193 output = subprocess.check_output(['apt-cache', 'policy'] + packages)
183 return len(output) > 0 and 'Installed: (none)' not in output.decode()194 return len(output) > 0 and 'Installed: (none)' not in output.decode()
@@ -206,15 +217,31 @@
206 # In this case we assume running vivid based ubuntu-touch which217 # In this case we assume running vivid based ubuntu-touch which
207 # already has unity8 running, so just return.218 # already has unity8 running, so just return.
208 return219 return
209 if self.config.get('package_type') == 'snap':220 self.setup_snapd_https_proxy()
210 # install and setup unity8-snap-session221 if self.config.get('unity8_mode') == 'snap':
222 # install unity8-session snap and set as default session
211 self.install_packages(['unity8-session-snap'])223 self.install_packages(['unity8-session-snap'])
212 self.setup_snapd_https_proxy()
213 subprocess.check_call(['unity8-snap-install'])224 subprocess.check_call(['unity8-snap-install'])
214 session_name = 'unity8-snap'225 session_name = 'unity8-snap'
215 else:226 else:
216 # install unity8-desktop-session227 # install deb based unity8-desktop-session and set as default.
217 self.install_packages(['unity8-desktop-session'])228 # also install ubuntu-terminal-app which is tested as deb
229 self.install_packages([
230 'unity8-desktop-session',
231 'ubuntu-terminal-app',
232 ])
233 # Also install applications as snaps, which can also be launched
234 # in a deb based session
235 self.install_snaps([
236 'address-book-app',
237 'camera-app',
238 'gallery-app',
239 'ubuntu-calculator-app',
240 'ubuntu-calendar-app',
241 'ubuntu-clock-app',
242 'ubuntu-filemanager-app',
243 'webbrowser-app',
244 ])
218 session_name = 'unity8'245 session_name = 'unity8'
219 self.set_unity8_default_session(session_name)246 self.set_unity8_default_session(session_name)
220247
221248
=== modified file 'ubuntu_system_tests/host/targets.py'
--- ubuntu_system_tests/host/targets.py 2017-03-07 11:20:22 +0000
+++ ubuntu_system_tests/host/targets.py 2017-03-14 11:03:55 +0000
@@ -183,7 +183,7 @@
183 'network_ready', 'update_apt', 'verbose']:183 'network_ready', 'update_apt', 'verbose']:
184 config[key] = getattr(args, key, False)184 config[key] = getattr(args, key, False)
185 # Add options from config_stack185 # Add options from config_stack
186 for key in ['wifi_ssid', 'wifi_password', 'package_type']:186 for key in ['wifi_ssid', 'wifi_password', 'unity8_mode']:
187 config[key] = config_stack.get(key)187 config[key] = config_stack.get(key)
188 # Add list of required test dependencies188 # Add list of required test dependencies
189 config['test_dependencies'] = debian.get_dependencies(189 config['test_dependencies'] = debian.get_dependencies(
190190
=== modified file 'ubuntu_system_tests/tests/base.py'
--- ubuntu_system_tests/tests/base.py 2017-03-09 02:42:26 +0000
+++ ubuntu_system_tests/tests/base.py 2017-03-14 11:03:55 +0000
@@ -58,10 +58,6 @@
58 disable_edges_intro,58 disable_edges_intro,
59 setup_unity59 setup_unity
60)60)
61from ubuntu_system_tests.helpers.webapp import (
62 DEFAULT_WEBVIEW_INSPECTOR_IP,
63 DEFAULT_WEBVIEW_INSPECTOR_PORT,
64)
6561
66from ubuntu_system_tests.tests.data.definitions import DESKTOP_PLATFORM_NAME62from ubuntu_system_tests.tests.data.definitions import DESKTOP_PLATFORM_NAME
6763
@@ -211,6 +207,10 @@
211 """ Setup the environment for the webapps. This method has to be207 """ Setup the environment for the webapps. This method has to be
212 called before launch the first web app in the test.208 called before launch the first web app in the test.
213 """209 """
210 from ubuntu_system_tests.helpers.webapp import (
211 DEFAULT_WEBVIEW_INSPECTOR_IP,
212 DEFAULT_WEBVIEW_INSPECTOR_PORT,
213 )
214 self.useFixture(JobEnvironmentVariable(214 self.useFixture(JobEnvironmentVariable(
215 global_=True,215 global_=True,
216 UBUNTU_WEBVIEW_DEVTOOLS_HOST=DEFAULT_WEBVIEW_INSPECTOR_IP,216 UBUNTU_WEBVIEW_DEVTOOLS_HOST=DEFAULT_WEBVIEW_INSPECTOR_IP,
217217
=== modified file 'ubuntu_system_tests/tests/test_launch_apps.py'
--- ubuntu_system_tests/tests/test_launch_apps.py 2017-02-13 14:05:03 +0000
+++ ubuntu_system_tests/tests/test_launch_apps.py 2017-03-14 11:03:55 +0000
@@ -18,399 +18,124 @@
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#19#
2020
21import dbus
22import logging21import logging
23import os22
24import pwd23from ubuntu_system_tests.common.config import get_device_config_stack
25import subprocess
26import tempfile
27import time
28
29from autopilot.testcase import AutopilotTestCase
30from collections import namedtuple
31from PIL import Image
32from retrying import retry
33from testtools.content import (
34 attach_file,
35 ContentType,
36)
37
38
39from ubuntu_system_tests.helpers.addressbook.app import AddressBook24from ubuntu_system_tests.helpers.addressbook.app import AddressBook
40from ubuntu_system_tests.helpers.calculator.app import Calculator25from ubuntu_system_tests.helpers.calculator.app import Calculator
26from ubuntu_system_tests.helpers.calculator.fixture_setup import (
27 CalculatorConfigFixture,
28)
41from ubuntu_system_tests.helpers.calendar.app import Calendar29from ubuntu_system_tests.helpers.calendar.app import Calendar
42from ubuntu_system_tests.helpers.camera.app import Camera30from ubuntu_system_tests.helpers.camera.app import Camera
43from ubuntu_system_tests.helpers.clock.app import Clock31from ubuntu_system_tests.helpers.clock.app import Clock
44from ubuntu_system_tests.helpers.filemanager.app import FileManager32from ubuntu_system_tests.helpers.filemanager.app import FileManager
45from ubuntu_system_tests.helpers.gallery.app import Gallery33from ubuntu_system_tests.helpers.gallery.app import Gallery
46from ubuntu_system_tests.helpers.terminal.app import Terminal34from ubuntu_system_tests.helpers.terminal.app import Terminal
47from ubuntu_system_tests.helpers.system_settings.app import SystemSettings35from ubuntu_system_tests.helpers.system_settings.app import (
36 get_system_settings_app,
37)
48from ubuntu_system_tests.helpers.webbrowser.app import WebBrowser38from ubuntu_system_tests.helpers.webbrowser.app import WebBrowser
4939from ubuntu_system_tests.tests.base import BaseUbuntuSystemTestCase
50from ubuntu_system_tests.helpers.calculator.fixture_setup import (
51 CalculatorConfigFixture,
52)
53from ubuntu_system_tests.helpers.images import (
54 convert_rgba_image,
55 get_color_count,
56 get_color_percentage,
57 _rmsdiff as rmsdiff,
58)
59from ubuntu_system_tests.helpers.mir import get_rgba_screenshot
60
61from ubuntu_system_tests.helpers.unity8.utils import is_unity8_snap
62
63APP_LAUNCH_TIMEOUT = 30
64BLACK_THRESHOLD = 17
65PIXELS_X = '1024'
66PIXELS_Y = '768'
67RESOLUTION = '{x}x{y}'.format(x=PIXELS_X, y=PIXELS_Y)
68
69app_ids = None
7040
71logger = logging.getLogger(__name__)41logger = logging.getLogger(__name__)
72logger.setLevel(logging.INFO)42logger.setLevel(logging.INFO)
7343
74# TODO: Remove these AppInfo definitions when autopilot introspection is44
75# working on snap based session.45class AppLaunchBase(BaseUbuntuSystemTestCase):
76AppInfo = namedtuple('AppInfo', ['app_class', 'color_stats_list'])
77APP_INFO_ADDRESSBOOK = AppInfo(AddressBook, [(8, 200, 400)])
78APP_INFO_CAMERA = AppInfo(Camera, [
79 (16, 1700, 2000), # Full screen
80 (16, 28000, 31000)]) # Low space warning
81APP_INFO_GALLERY = AppInfo(Gallery, [(10, 200, 400)])
82APP_INFO_CALCULATOR = AppInfo(Calculator, [(8, 4400, 4800)])
83APP_INFO_CALENDAR = AppInfo(Calendar, [(8, 2300, 2700)])
84APP_INFO_CLOCK = AppInfo(Clock, [
85 (8, 300, 600), # Full screen
86 (8, 4000, 4500)]) # Right hand side dock
87APP_INFO_FILEMANAGER = AppInfo(FileManager, [(8, 1900, 2200)])
88APP_INFO_TERMINAL = AppInfo(Terminal, [(85, 600, 900)])
89APP_INFO_WEBBROWSER = AppInfo(WebBrowser, [(8, 2000, 2300)])
90APP_INFO_SETTINGS = AppInfo(SystemSettings, [
91 (5, 200, 600), # Full screen
92 (5, 2100, 2500), # Left hand side
93 (5, 2800, 3100)]) # Left hand side, compacted
94
95unity8_snap = None
96
97
98# TODO: Remove and replace with SetupUnity8 fixture when working in snap based
99# session.
100def restart_unity8():
101 """Restart unity8 process."""
102 # Ensure unity8 is running in first place
103 wait_for_unity8_running()
104 # kill process and check that unity8 restarts by itself
105 subprocess.check_call(['pkill', 'unity8'])
106 # Allow screen to go black before waiting for it to run again
107 time.sleep(10)
108 wait_for_unity8_running()
109
110
111def wait_for_unity8_running():
112 """Wait until unity8 is displaying on screen."""
113 for c in range(60):
114 screen = get_screenshot()
115 black = get_color_percentage(screen, BLACK_THRESHOLD)
116 count = get_color_count(screen)
117 logger.info('#### BLACK :: {} :: COLORS :: {}'.format(black, count))
118 os.remove(screen)
119 if black < 50 and count > 100:
120 # Black screen is no longer displayed
121 return
122 time.sleep(1)
123 raise RuntimeError('Unity8 UI is not displayed!')
124
125
126def get_command(command):
127 """Return command based on whether unity8 is running from a snap or not.
128 If it is then prefix command with 'unity8-session', otherwise return
129 command with no prefix.
130 """
131 global unity8_snap
132 if unity8_snap is None:
133 unity8_snap = is_unity8_snap()
134 if unity8_snap:
135 return 'unity8-session.{}'.format(command)
136 return command
137
138
139# TODO: Remove all below screenshot analysis when autopilot introspection
140# working on snap based session.
141def get_screenshot():
142 """
143 Take screen shot and return file path of png file
144 :return: Path of PNG screen image file
145 """
146 timestamp = int(time.time())
147 filename_rgba = 'screenshot-{}.rgba'.format(timestamp)
148 filename_png = 'screenshot-{}.png'.format(timestamp)
149 temp_dir = tempfile.gettempdir()
150 filepath_rgba = os.path.join(temp_dir, filename_rgba)
151 filepath_png = os.path.join(temp_dir, filename_png)
152 get_rgba_screenshot(filepath_rgba)
153 convert_rgba_image(filepath_rgba, filepath_png, RESOLUTION)
154 # finished with rgba file so delete it
155 os.remove(filepath_rgba)
156 return filepath_png
157
158
159def images_almost_equal(im1, im2):
160 """ Determine if two images are almost equal or not
161 :return: True if the images have almost same content, False otherwise
162 """
163 try:
164 difference = rmsdiff(im1, im2)
165 except ValueError:
166 logger.info('### Images have no similarity.')
167 return False
168 logger.info('### Image difference :: {}'.format(difference))
169 return difference < 4
170
171
172def image_files_almost_equal(im1_path, im2_path):
173 """ Determine if two image files are equal or not.
174 :param im1_path: File path to first image file.
175 :param im2_path: File path to second image file.
176 :return: True if the image files have same content, False otherwise.
177 """
178 return images_almost_equal(Image.open(im1_path), Image.open(im2_path))
179
180
181# TODO: Remove this when Tutorial and SettingsWizard fixtures working.
182def get_user_account():
183 for account in sorted(pwd.getpwall(), key=lambda x: x.pw_uid):
184 if account.pw_uid > 500 and account.pw_dir.startswith('/home/'):
185 return account
186
187
188# TODO: Remove this and replace with Tutorial fixture when working.
189def disable_edges_demo():
190 # Getting or setting the dbus property must be done from user account,
191 # so use dbus-send with sudo -u to set the user.
192 setting_changed = False
193 user_id = 'User{}'.format(get_user_account().pw_uid)
194 wait_for_user(user_id)
195 user_path = '/org/freedesktop/Accounts/{}'.format(user_id)
196 user_name = get_user_account().pw_name
197 if get_edge_demo_status(user_name, user_path):
198 subprocess.check_call([
199 'sudo', '-u', user_name,
200 'dbus-send', '--system', '--print-reply',
201 '--dest=org.freedesktop.Accounts', user_path,
202 'org.freedesktop.DBus.Properties.Set',
203 'string:com.canonical.unity.AccountsService',
204 'string:demo-edges', 'variant:boolean:false'],
205 stdout=subprocess.DEVNULL)
206 setting_changed = True
207 return setting_changed
208
209
210@retry(wait_fixed=1000,
211 stop_max_attempt_number=30,
212 retry_on_exception=lambda e: (
213 isinstance(e, subprocess.CalledProcessError)))
214def get_edge_demo_status(user_name, user_path):
215 """Return edge demo boolean status."""
216 output = subprocess.check_output([
217 'sudo', '-u', user_name,
218 'dbus-send', '--system', '--print-reply',
219 '--dest=org.freedesktop.Accounts', user_path,
220 'org.freedesktop.DBus.Properties.Get',
221 'string:com.canonical.unity.AccountsService',
222 'string:demo-edges']).decode().strip().split('\n')[-1]
223 return output.split(' ')[-1] == 'true'
224
225
226@retry(wait_fixed=1000,
227 stop_max_attempt_number=30,
228 retry_on_exception=lambda e: isinstance(e, RuntimeError))
229def wait_for_user(user_id):
230 """Wait until user_id object exists under Accounts object."""
231 bus = dbus.SystemBus()
232 obj = bus.get_object(
233 'org.freedesktop.Accounts', '/org/freedesktop/Accounts')
234 intf = dbus.Interface(obj, 'org.freedesktop.DBus.Introspectable')
235 if not 'name="{}"'.format(user_id) in intf.Introspect():
236 raise RuntimeError('User {} does not exist.'.format(user_id))
237
238
239# TODO: Remove this and replace with SettingsWizard fixture when working.
240def disable_settings_wizard():
241 """Disable settings wizard from running on first boot. Return bool
242 indicating if setting was changed."""
243 setting_changed = False
244 base_path = '/home/{}'.format(get_user_account().pw_name)
245 if is_unity8_snap():
246 base_path = os.path.join(base_path, 'snap/unity8-session/common')
247 wizard_file = os.path.join(
248 base_path, '.config/ubuntu-system-settings/wizard-has-run')
249 if not os.path.isfile(wizard_file):
250 wizard_dir = os.path.dirname(wizard_file)
251 if not os.path.isdir(wizard_dir):
252 os.makedirs(wizard_dir)
253 open(wizard_file, 'a').close()
254 setting_changed = True
255 return setting_changed
256
257
258# TODO: Change to BaseUbuntuSystemTestCase when it works on snap based session.
259class AppLaunchBase(AutopilotTestCase):
260
261 @classmethod
262 def setUpClass(cls):
263 wizard_changed = disable_settings_wizard()
264 edges_changed = disable_edges_demo()
265 if wizard_changed or edges_changed:
266 restart_unity8()
26746
268 def setUp(self):47 def setUp(self):
269 super().setUp()48 super().setUp()
270 self.app = None49 self.app = None
271 self.before = None50 self.config_stack = get_device_config_stack()
272 self.after = None
273 wait_for_unity8_running()
27451
275 def tearDown(self):52 def tearDown(self):
276 if self.app:53 if self.app:
277 self.close_app()54 self.app.stop()
278 if self.before and os.path.isfile(self.before):
279 os.remove(self.before)
280 self.before = None
281 if self.after and os.path.isfile(self.after):
282 os.remove(self.after)
283 self.after = None
284 super().tearDown()55 super().tearDown()
28556
286 def close_app(self):57 def check_app_launch(self, app_class, launch_count):
287 self.app.stop()58 self.app = app_class()
288 time.sleep(10)59 if not self.app.is_installed():
28960 reason = '{n} not installed as {t}'.format(
290 def maximise_window(self):61 n=self.app.app_id, t=self.app.app_type)
291 self.keyboard.press_and_release('Ctrl+LeftMeta+Up')62 self.app = None
292 time.sleep(10)63 self.skipTest(reason)
293
294 def check_app_launch(self, app_info, launch_count):
295 self.app = app_info.app_class()
296 logger.info('### TESTING APP NAME :: {}'.format(self.app.app_name))
297 self.maximise_window()
298 for count in range(1, launch_count + 1):64 for count in range(1, launch_count + 1):
299 logger.info('### APP LAUNCH :: {}'.format(count))
300 # TODO: Replace all screenshot analysis with introspection when
301 # autopilot working on snap based session.
302 self.before = get_screenshot()
303 self.attach_screenshot(
304 self.before, 'before_launched_{}'.format(count))
305 self.app.launch()65 self.app.launch()
306 time.sleep(10)66 self.assertIsNotNone(self.app.get_main_view())
307 self.maximise_window()67 logger.info('App launch {c} successful'.format(c=count))
308 self.after = get_screenshot()
309 self.attach_screenshot(
310 self.after, 'after_launched_{}'.format(count))
311 if count < launch_count:68 if count < launch_count:
312 # Only close the app here if this is not the last iteration.69 # Only close the app here if this is not the last iteration.
313 # Otherwise it will be closed automatically in tearDown.70 # Otherwise it will be closed automatically in tearDown.
314 self.close_app()71 self.app.stop()
315 black = get_color_percentage(self.after, BLACK_THRESHOLD)
316 count = get_color_count(self.after)
317 logger.info(
318 '### ID {} :: BLACK {} :: COLORS '
319 '{}'.format(self.app.app_id, black, count, self.before,
320 self.after))
321 self.assertFalse(
322 image_files_almost_equal(self.before, self.after),
323 'No difference on screen detected after app launched.')
324 self.validate_color_stats(app_info, count, black)
325
326 def validate_color_stats(self, app_info, color_count, black_percent):
327 exceptions = []
328 for stats in app_info.color_stats_list:
329 black_max = stats[0]
330 colors_min = stats[1]
331 colors_max = stats[2]
332 try:
333 self.assertGreater(color_count, colors_min)
334 self.assertLess(color_count, colors_max)
335 self.assertLess(black_percent, black_max)
336 except AssertionError as e:
337 exceptions.append(e)
338 else:
339 break
340 if len(exceptions) == len(app_info.color_stats_list):
341 # An exception was raised for every stats item, which means
342 # that none of them matched. So raise the first exception here.
343 raise exceptions[0]
344
345 def attach_screenshot(self, file_path, name):
346 attach_file(
347 self, file_path, name=name,
348 content_type=ContentType('image', 'png'), buffer_now=True)
34972
35073
351class LaunchAppOnceTestCase(AppLaunchBase):74class LaunchAppOnceTestCase(AppLaunchBase):
35275
353 def test_launch_addressbook_app(self):76 def test_launch_addressbook_app(self):
354 self.check_app_launch(APP_INFO_ADDRESSBOOK, 1)77 self.check_app_launch(AddressBook, 1)
35578
356 def test_launch_camera_app(self):79 def test_launch_camera_app(self):
357 self.check_app_launch(APP_INFO_CAMERA, 1)80 self.check_app_launch(Camera, 1)
35881
359 def test_launch_gallery_app(self):82 def test_launch_gallery_app(self):
360 self.check_app_launch(APP_INFO_GALLERY, 1)83 self.check_app_launch(Gallery, 1)
36184
362 def test_launch_calculator_app(self):85 def test_launch_calculator_app(self):
363 self.useFixture(CalculatorConfigFixture(first_run=False))86 self.useFixture(CalculatorConfigFixture(first_run=False))
364 self.check_app_launch(APP_INFO_CALCULATOR, 1)87 self.check_app_launch(Calculator, 1)
36588
366 def test_launch_calendar_app(self):89 def test_launch_calendar_app(self):
367 self.check_app_launch(APP_INFO_CALENDAR, 1)90 self.check_app_launch(Calendar, 1)
36891
369 def test_launch_clock_app(self):92 def test_launch_clock_app(self):
370 self.check_app_launch(APP_INFO_CLOCK, 1)93 self.check_app_launch(Clock, 1)
37194
372 def test_launch_filemanager_app(self):95 def test_launch_filemanager_app(self):
373 self.check_app_launch(APP_INFO_FILEMANAGER, 1)96 self.check_app_launch(FileManager, 1)
37497
375 def test_launch_terminal_app(self):98 def test_launch_terminal_app(self):
376 self.check_app_launch(APP_INFO_TERMINAL, 1)99 self.check_app_launch(Terminal, 1)
377100
378 def test_launch_webbrowser_app(self):101 def test_launch_webbrowser_app(self):
379 self.check_app_launch(APP_INFO_WEBBROWSER, 1)102 self.check_app_launch(WebBrowser, 1)
380103
381 def test_launch_systemsettings_app(self):104 def test_launch_systemsettings_app(self):
382 self.check_app_launch(APP_INFO_SETTINGS, 1)105 app = get_system_settings_app(self.config_stack.get('unity8_mode'))
106 self.check_app_launch(app, 1)
383107
384108
385class LaunchAppTwiceTestCase(AppLaunchBase):109class LaunchAppTwiceTestCase(AppLaunchBase):
386110
387 def test_launch_addressbook_app_twice(self):111 def test_launch_addressbook_app_twice(self):
388 self.check_app_launch(APP_INFO_ADDRESSBOOK, 2)112 self.check_app_launch(AddressBook, 2)
389113
390 def test_launch_camera_app_twice(self):114 def test_launch_camera_app_twice(self):
391 self.check_app_launch(APP_INFO_CAMERA, 2)115 self.check_app_launch(Camera, 2)
392116
393 def test_launch_gallery_app_twice(self):117 def test_launch_gallery_app_twice(self):
394 self.check_app_launch(APP_INFO_GALLERY, 2)118 self.check_app_launch(Gallery, 2)
395119
396 def test_launch_calculator_app_twice(self):120 def test_launch_calculator_app_twice(self):
397 self.useFixture(CalculatorConfigFixture(first_run=False))121 self.useFixture(CalculatorConfigFixture(first_run=False))
398 self.check_app_launch(APP_INFO_CALCULATOR, 2)122 self.check_app_launch(Calculator, 2)
399123
400 def test_launch_calendar_app_twice(self):124 def test_launch_calendar_app_twice(self):
401 self.check_app_launch(APP_INFO_CALENDAR, 2)125 self.check_app_launch(Calendar, 2)
402126
403 def test_launch_clock_app_twice(self):127 def test_launch_clock_app_twice(self):
404 self.check_app_launch(APP_INFO_CLOCK, 2)128 self.check_app_launch(Clock, 2)
405129
406 def test_launch_filemanager_app_twice(self):130 def test_launch_filemanager_app_twice(self):
407 self.check_app_launch(APP_INFO_FILEMANAGER, 2)131 self.check_app_launch(FileManager, 2)
408132
409 def test_launch_terminal_app_twice(self):133 def test_launch_terminal_app_twice(self):
410 self.check_app_launch(APP_INFO_TERMINAL, 2)134 self.check_app_launch(Terminal, 2)
411135
412 def test_launch_webbrowser_app_twice(self):136 def test_launch_webbrowser_app_twice(self):
413 self.check_app_launch(APP_INFO_WEBBROWSER, 2)137 self.check_app_launch(WebBrowser, 2)
414138
415 def test_launch_systemsettings_app_twice(self):139 def test_launch_systemsettings_app_twice(self):
416 self.check_app_launch(APP_INFO_SETTINGS, 2)140 app = get_system_settings_app(self.config_stack.get('unity8_mode'))
141 self.check_app_launch(app, 2)
417142
=== modified file 'ubuntu_system_tests/tests/test_system_settings.py'
--- ubuntu_system_tests/tests/test_system_settings.py 2017-03-08 01:00:05 +0000
+++ ubuntu_system_tests/tests/test_system_settings.py 2017-03-14 11:03:55 +0000
@@ -20,6 +20,8 @@
2020
21from autopilot.matchers import Eventually21from autopilot.matchers import Eventually
22from testtools.matchers import Equals22from testtools.matchers import Equals
23
24from ubuntu_system_tests.common.config import get_device_config_stack
23from ubuntu_system_tests.helpers.network.utils import turn_on_wifi25from ubuntu_system_tests.helpers.network.utils import turn_on_wifi
2426
25from ubuntu_system_tests.helpers.indicators.network.cpo import (27from ubuntu_system_tests.helpers.indicators.network.cpo import (
@@ -28,7 +30,9 @@
28from ubuntu_system_tests.helpers import network30from ubuntu_system_tests.helpers import network
29from ubuntu_system_tests.helpers import system_settings31from ubuntu_system_tests.helpers import system_settings
30from ubuntu_system_tests.helpers.indicators.indicators import IndicatorsFactory32from ubuntu_system_tests.helpers.indicators.indicators import IndicatorsFactory
31from ubuntu_system_tests.helpers.system_settings.app import SystemSettings33from ubuntu_system_tests.helpers.system_settings.app import (
34 get_system_settings_app,
35)
32from ubuntu_system_tests.tests import base36from ubuntu_system_tests.tests import base
3337
34SOUND_SETTINGS_PAGE = 'soundPage'38SOUND_SETTINGS_PAGE = 'soundPage'
@@ -76,7 +80,9 @@
7680
77 def setUp(self):81 def setUp(self):
78 super().setUp()82 super().setUp()
79 system_settings_app = SystemSettings()83 self.config_stack = get_device_config_stack()
84 system_settings_app = get_system_settings_app(
85 self.config_stack.get('unity8_mode'))()
80 system_settings_app.launch()86 system_settings_app.launch()
81 self.system_settings = system_settings_app.get_main_view()87 self.system_settings = system_settings_app.get_main_view()
8288

Subscribers

People subscribed via source and target branches

to all changes: