Merge lp:~canonical-platform-qa/ubuntu-system-tests/base_tests_refactor into lp:ubuntu-system-tests

Proposed by Sergio Cazzolato
Status: Merged
Approved by: Richard Huddie
Approved revision: 326
Merged at revision: 330
Proposed branch: lp:~canonical-platform-qa/ubuntu-system-tests/base_tests_refactor
Merge into: lp:ubuntu-system-tests
Diff against target: 3824 lines (+1338/-1076)
68 files modified
ubuntu_system_tests/helpers/__init__.py (+8/-0)
ubuntu_system_tests/helpers/addressbook/__init__.py (+54/-0)
ubuntu_system_tests/helpers/autopilot/__init__.py (+76/-272)
ubuntu_system_tests/helpers/autopilot/list.py (+78/-0)
ubuntu_system_tests/helpers/autopilot/object.py (+137/-0)
ubuntu_system_tests/helpers/autopilot/platform.py (+94/-0)
ubuntu_system_tests/helpers/calculator/__init__.py (+41/-1)
ubuntu_system_tests/helpers/camera/__init__.py (+58/-0)
ubuntu_system_tests/helpers/camera/_cpo.py (+2/-3)
ubuntu_system_tests/helpers/clock/__init__.py (+48/-1)
ubuntu_system_tests/helpers/context.py (+23/-0)
ubuntu_system_tests/helpers/data.py (+4/-11)
ubuntu_system_tests/helpers/device.py (+2/-2)
ubuntu_system_tests/helpers/dialer_app/__init__.py (+53/-0)
ubuntu_system_tests/helpers/gallery/__init__.py (+69/-1)
ubuntu_system_tests/helpers/mediaplayer/__init__.py (+18/-5)
ubuntu_system_tests/helpers/messaging/__init__.py (+59/-0)
ubuntu_system_tests/helpers/messaging/_cpo.py (+3/-2)
ubuntu_system_tests/helpers/music.py (+46/-2)
ubuntu_system_tests/helpers/scopes/__init__.py (+3/-2)
ubuntu_system_tests/helpers/scopes/apps/__init__.py (+19/-0)
ubuntu_system_tests/helpers/scopes/apps/_cpo.py (+4/-1)
ubuntu_system_tests/helpers/scopes/base.py (+2/-6)
ubuntu_system_tests/helpers/scopes/music/_cpo.py (+2/-1)
ubuntu_system_tests/helpers/scopes/music/_preview.py (+2/-2)
ubuntu_system_tests/helpers/scopes/photos/_category.py (+2/-1)
ubuntu_system_tests/helpers/system_settings/__init__.py (+45/-1)
ubuntu_system_tests/helpers/timer.py (+6/-3)
ubuntu_system_tests/helpers/ubuntu_keyboard/__init__.py (+9/-0)
ubuntu_system_tests/helpers/ubuntuuitoolkit/optiontoggle.py (+1/-2)
ubuntu_system_tests/helpers/ubuntuuitoolkit/pageheader.py (+1/-2)
ubuntu_system_tests/helpers/unity8/__init__.py (+37/-0)
ubuntu_system_tests/helpers/unity8/dash.py (+2/-2)
ubuntu_system_tests/helpers/unity8/phone_stage.py (+2/-3)
ubuntu_system_tests/helpers/webapp/__init__.py (+37/-7)
ubuntu_system_tests/helpers/webapp/ebay.py (+23/-0)
ubuntu_system_tests/helpers/webapp/here.py (+24/-0)
ubuntu_system_tests/helpers/webbrowser/__init__.py (+50/-1)
ubuntu_system_tests/tests/app_startup/test_application_startup.py (+48/-29)
ubuntu_system_tests/tests/base.py (+23/-619)
ubuntu_system_tests/tests/base_messaging.py (+17/-19)
ubuntu_system_tests/tests/base_webbrowser.py (+2/-1)
ubuntu_system_tests/tests/indicators/test_indicator_battery.py (+1/-1)
ubuntu_system_tests/tests/indicators/test_indicator_bluetooth.py (+1/-1)
ubuntu_system_tests/tests/indicators/test_indicator_datetime.py (+1/-1)
ubuntu_system_tests/tests/indicators/test_indicator_network.py (+4/-4)
ubuntu_system_tests/tests/indicators/test_indicator_sound.py (+1/-1)
ubuntu_system_tests/tests/scopes/test_default_scopes.py (+5/-2)
ubuntu_system_tests/tests/scopes/test_photos_scope.py (+2/-1)
ubuntu_system_tests/tests/scopes/test_video_scope.py (+3/-3)
ubuntu_system_tests/tests/test_add_contact.py (+4/-2)
ubuntu_system_tests/tests/test_app_switcher.py (+9/-5)
ubuntu_system_tests/tests/test_bluetooth.py (+2/-1)
ubuntu_system_tests/tests/test_calculator.py (+2/-1)
ubuntu_system_tests/tests/test_calls.py (+18/-13)
ubuntu_system_tests/tests/test_camera.py (+12/-10)
ubuntu_system_tests/tests/test_clock.py (+2/-1)
ubuntu_system_tests/tests/test_messaging_sms.py (+5/-3)
ubuntu_system_tests/tests/test_rotation.py (+2/-1)
ubuntu_system_tests/tests/test_sdcard.py (+8/-7)
ubuntu_system_tests/tests/test_settings_wizard.py (+3/-2)
ubuntu_system_tests/tests/test_sim_pin.py (+2/-1)
ubuntu_system_tests/tests/test_system_settings.py (+2/-1)
ubuntu_system_tests/tests/test_ubuntu_keyboard.py (+3/-3)
ubuntu_system_tests/tests/test_with_dialer.py (+2/-1)
ubuntu_system_tests/tests/test_with_webbrowser.py (+8/-6)
ubuntu_system_tests/tests/webapps/test_ebay.py (+1/-1)
ubuntu_system_tests/tests/webapps/test_here.py (+1/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-system-tests/base_tests_refactor
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Richard Huddie (community) Approve
Review via email: mp+285372@code.launchpad.net

This proposal supersedes a proposal from 2016-02-03.

Commit message

Refactoring base test class and autopilot helpers. The idea is to reduce the tests/base and autopilot.py files length.

First step is implemented. For that different methods were move mainly to autopilot helper and this helper was split in different files.

The second part which is pushed and within it all the methods to launch and close apps are moved to the helpers.

Description of the change

To validate this: run 1 test of each test suite and ubuntu_system_tests.tests.app_startup.test_application_startup

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote : Posted in a previous version of this proposal

Changes seem reasonable, I've made some minor comments below.

There will be a lot of conflicts with the app-name-cpo-dbus-validation branch, so would make sense to get that branch landed first.

I'll do some further testing with this branch to make sure its working fine.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote : Posted in a previous version of this proposal

Answers

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote : Posted in a previous version of this proposal

This diff seems to be showing the app-startup changes too? I see that branch is marked as pre-requisite, so it shouldn't be including those changes. Is this branch up to date with that one?

review: Needs Information
Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote : Posted in a previous version of this proposal

Yes, this branch is up to date with the other one, I created the dependency to avoid rework and because I am using the startup tests to validate the changes done as part of the refactor.

Revision history for this message
Richard Huddie (rhuddie) wrote : Posted in a previous version of this proposal

There are currently conflicts with trunk. Also, given that the app-startup branch has now landed we can remove that as pre-requisite. Hopefully that will sort out the diff.

Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote :

Pre-requisite removed, now gonna see why there are conflicts. I'll try to push the update today

320. By Sergio Cazzolato

Changes based on MP comments

321. By Sergio Cazzolato

Merge with trunk

Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote :

Conflicts resolved. I forgot to push the last merge that I did. Try now.

322. By Sergio Cazzolato

Fixing import error

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
323. By Sergio Cazzolato

Fixing flake errors

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

This is looking good. I have not run through any of the tests yet, but will do so. With such a big change it will affect all tests.

I've just made some minor comments below. It would be good to get this landed as it gets difficult to maintain such a large MP!

review: Needs Fixing
324. By Sergio Cazzolato

Minor fixes based on MP comments

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
325. By Sergio Cazzolato

Adding removed tests and moving problematic dependency

Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote :

Answers and changes done

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

test failure:

Traceback (most recent call last):
  File "/tmp/adt-run.BxCKoY/build.zbE/real-tree/ubuntu_system_tests/tests/webapps/test_ebay.py", line 34, in setUp
    self.web_app = self.launch_ebay_webapp()
AttributeError: 'EbayTestCase' object has no attribute 'launch_ebay_webapp'

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

2 more failures:

11:06:49.854 ERROR testresult:44 - traceback: {{{
Traceback (most recent call last):
  File "/tmp/adt-run.8bDTba/build.SDF/real-tree/ubuntu_system_tests/tests/indicators/test_indicator_network.py", line 182, in test_wifi_settings_item_open_correct_page
    settings_app = self.get_system_settings_proxy()
AttributeError: 'NetworkIndicatorTestCase' object has no attribute 'get_system_settings_proxy'
}}}

11:07:40.034 ERROR testresult:44 - traceback: {{{
Traceback (most recent call last):
  File "/tmp/adt-run.8bDTba/build.SDF/real-tree/ubuntu_system_tests/tests/indicators/test_indicator_network.py", line 171, in test_cellular_settings_item_open_correct_page
    settings_app = self.get_system_settings_proxy()
AttributeError: 'NetworkIndicatorTestCase' object has no attribute 'get_system_settings_proxy'
}}}

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

Confirm that I've run a multitude of tests on this branch, with the above 3 failures being the only ones related to this change. So once these are fixed, it is ready for approval.

326. By Sergio Cazzolato

Fixing broken links

Revision history for this message
Sergio Cazzolato (sergio-j-cazzolato) wrote :

Fixes pushed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Richard Huddie (rhuddie) wrote :

Confirm broken tests now working, so approving. Great job!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_system_tests/helpers/__init__.py'
2--- ubuntu_system_tests/helpers/__init__.py 2015-10-05 16:52:13 +0000
3+++ ubuntu_system_tests/helpers/__init__.py 2016-02-10 11:57:12 +0000
4@@ -68,3 +68,11 @@
5 return validator(result)
6 else:
7 return bool(result)
8+
9+
10+class AttrDict(dict):
11+ """ Class used to access to the dict keys as parameters """
12+
13+ def __init__(self, *args, **kwargs):
14+ super(AttrDict, self).__init__(*args, **kwargs)
15+ self.__dict__ = self
16
17=== modified file 'ubuntu_system_tests/helpers/addressbook/__init__.py'
18--- ubuntu_system_tests/helpers/addressbook/__init__.py 2015-09-07 11:10:31 +0000
19+++ ubuntu_system_tests/helpers/addressbook/__init__.py 2016-02-10 11:57:12 +0000
20@@ -20,5 +20,59 @@
21
22 from collections import namedtuple
23
24+from ubuntu_system_tests.helpers import autopilot
25+from ubuntu_system_tests.helpers import processes
26+from ubuntu_system_tests.helpers.scopes.apps import (
27+ launch_application_from_apps_scope
28+)
29+from ubuntu_system_tests.helpers.unity8 import (
30+ close_app, launch_application_from_launcher
31+)
32+
33+APP = 'address-book-app'
34+APP_NAME = 'Contacts'
35+APP_WIN_ID = 'address-book-app'
36+
37+
38 Contact = namedtuple('Contact', ['name', 'number', 'expected_reply'])
39 Contact.__new__.__defaults__ = (None, None, None)
40+
41+
42+def launch_address_book():
43+ """
44+ Launch the address book app from apps scope and return proxy object.
45+
46+ :return: Proxy object for address book application.
47+
48+ """
49+ launch_application_from_apps_scope(APP_NAME)
50+ return get_address_book_app_proxy()
51+
52+
53+def close_address_book():
54+ """ Close the address book app using task switcher """
55+ if is_address_book_app_running():
56+ close_app(APP_WIN_ID)
57+
58+
59+def is_address_book_app_running():
60+ """ Indicate if the address book app is currently running """
61+ return processes.is_process_running(APP)
62+
63+
64+def launch_address_book_from_launcher():
65+ """Drag out the launcher and tap the address book icon to start it."""
66+ launch_application_from_launcher(APP_WIN_ID)
67+ return get_address_book_app_proxy()
68+
69+
70+def get_address_book_app_proxy():
71+ """
72+ Return address book app proxy object from existing process.
73+
74+ :return: Proxy object for address book application.
75+
76+ """
77+ from ubuntu_system_tests.helpers.addressbook import _cpo # NOQA
78+ proxy = autopilot.get_proxy_object_for_existing_app(APP)
79+ return proxy.main_window
80
81=== added directory 'ubuntu_system_tests/helpers/autopilot'
82=== renamed file 'ubuntu_system_tests/helpers/autopilot.py' => 'ubuntu_system_tests/helpers/autopilot/__init__.py'
83--- ubuntu_system_tests/helpers/autopilot.py 2016-02-03 18:08:14 +0000
84+++ ubuntu_system_tests/helpers/autopilot/__init__.py 2016-02-10 11:57:12 +0000
85@@ -18,20 +18,16 @@
86 # along with this program. If not, see <http://www.gnu.org/licenses/>.
87 #
88
89-import configparser
90-import os
91-import subprocess
92-import systemimage.config as sys_info
93 import sys
94-import time
95+from contextlib import contextmanager
96
97+import ubuntuuitoolkit
98 from autopilot import introspection
99-from autopilot.display import is_point_on_any_screen
100 from autopilot.exceptions import StateNotFoundError
101-from autopilot.platform import model
102-from contextlib import contextmanager
103+
104+from ubuntu_system_tests.helpers import context
105+from ubuntu_system_tests.helpers import processes
106 from ubuntu_system_tests.helpers import wait_until
107-from ubuntu_system_tests.helpers import click
108
109 CO_ORD_MAX = (sys.maxsize, sys.maxsize)
110
111@@ -46,31 +42,14 @@
112 proxy._poll_time = original_timeout
113
114
115-def get_proxy_object_for_existing_process(
116- process_name, base_custom_proxy_object):
117- """Return the proxy object for a currently running process."""
118- return introspection.get_proxy_object_for_existing_process(
119- pid=_get_pid(process_name),
120- emulator_base=base_custom_proxy_object
121- )
122-
123-
124-# Pulled from the UX tests
125-def _get_pid(process_name):
126- """Returns pid for currently running browser process."""
127- for i in range(10):
128- try:
129- return int(
130- subprocess.check_output(
131- ['pidof', process_name]).strip()
132- )
133- except subprocess.CalledProcessError:
134- time.sleep(1)
135+def _get_pid(pname):
136+ """ Wait until the process pname is running and retrieve its pid. Raise
137+ Runtime exception when the process is not started after 10 seconds
138+ """
139+ if wait_until(processes.is_process_running, pname):
140+ return processes.get_process_id(pname)
141 else:
142- raise RuntimeError(
143- 'Could not find autopilot interface for {} after 10 '
144- 'seconds'.format(process_name)
145- )
146+ raise RuntimeError('Could not find process: {} '.format(pname))
147
148
149 def validate_dbus_object(path, state, root_name, class_name, **kwargs):
150@@ -92,98 +71,6 @@
151 return False
152
153
154-def order_by_y_coord(object_list, include_off_screen=False):
155- """
156- Return an ordered list of objects ordered by y co-ordinate first
157- and then x co-ordinate second if y co-ordinates match.
158-
159- :param object_list: List of objects containing globalRect property.
160- :param include_off_screen: Whether to include objects that are not within
161- the bounds of any screen.
162- :return: List of sorted objects.
163-
164- """
165- return _order_by_key(object_list, _get_y_and_x, include_off_screen)
166-
167-
168-def order_by_x_coord(object_list, include_off_screen=False):
169- """
170- Return an ordered list of objects ordered by x co-ordinate first
171- and then y co-ordinate second if x co-ordinates match.
172-
173- :param object_list: List of objects containing globalRect property.
174- :param include_off_screen: Whether to include objects that are not within
175- the bounds of any screen.
176- :return: List of sorted objects.
177-
178- """
179- return _order_by_key(object_list, _get_x_and_y, include_off_screen)
180-
181-
182-def _order_by_key(object_list, sort_key, include_off_screen):
183- """
184- Return an ordered list of objects ordered by key.
185-
186- :param object_list: List of objects containing globalRect property.
187- :param sort_key: Sorting key to use.
188- :param include_off_screen: Whether to include objects that are not within
189- the bounds of any screen.
190- :return: List of sorted objects.
191-
192- """
193- objects = []
194- for obj in object_list:
195- try:
196- # If obj is no longer valid this can cause excpetion
197- point = obj.globalRect.x, obj.globalRect.y
198- if include_off_screen:
199- objects.append(obj)
200- elif is_point_on_any_screen(point):
201- objects.append(obj)
202- except StateNotFoundError:
203- pass
204- return sorted(objects, key=sort_key)
205-
206-
207-def _get_y_and_x(item):
208- """
209- Return y and x co-ordinates for specified object.
210-
211- :param item: Item to check
212- :return: (y, x) co-ordinates
213- """
214- try:
215- # If item is no longer valid this can cause excpetion
216- co_ords = item.globalRect.y, item.globalRect.x
217- except StateNotFoundError:
218- # Trying to sort an object that no longer exists
219- # return a dummy key value so this item is sorted last
220- co_ords = CO_ORD_MAX
221- return co_ords
222-
223-
224-def _get_x_and_y(item):
225- """
226- Return x and y co-ordinates for specified object.
227-
228- :param item: Item to check
229- :return: (x, y) co-ordinates
230- """
231- try:
232- # If item is no longer valid this can cause excpetion
233- co_ords = item.globalRect.x, item.globalRect.y
234- except StateNotFoundError:
235- # Trying to sort an object that no longer exists
236- # return a dummy key value so this item is sorted last
237- co_ords = CO_ORD_MAX
238- return co_ords
239-
240-
241-def get_object_path(item):
242- """Return the object path of a specified item."""
243- return item._path.decode('utf-8')
244-
245-
246 def get_path_root(object_path):
247 """Return the name of the root node of specified path."""
248 is_string = isinstance(object_path, str)
249@@ -195,128 +82,6 @@
250 return root
251
252
253-def _get_parent_by_type(item, required_type, **kwargs):
254- """Return a parent item of the required type.
255- :param item: The child item to start searching from.
256- :param required_type: String name of parent object type required.
257- :param kwargs: This is used for logging purposes only.
258- :return: Parent object matching required type.
259- :raises: StateNotFoundError if no matching object type can be found.
260- """
261- parent = item.get_parent()
262- path = get_object_path(parent).split('/')
263- try:
264- index = path.index(required_type)
265- except ValueError:
266- raise StateNotFoundError(
267- '{}, and properties: {}'.format(required_type, kwargs))
268- for count in range(1, len(path) - index):
269- parent = parent.get_parent()
270- return parent
271-
272-
273-def validate_properties(item, **kwargs):
274- """Return True if item properties match specified keyword properties."""
275- props = item.get_properties()
276- for key in kwargs.keys():
277- if props[key] != kwargs[key]:
278- return False
279- return True
280-
281-
282-def get_parent(item, required_type, **kwargs):
283- """Return a parent object of specified type and properties.
284- :param item: The child item to start searching from.
285- :param required_type: String name of parent object type required.
286- :param kwargs: Any properties to match on the parent object.
287- :return: Parent object matching required type and properties.
288- :raises: StateNotFoundError if no matching object can be found.
289- """
290- parent = item
291- while True:
292- parent = _get_parent_by_type(parent, required_type, **kwargs)
293- if validate_properties(parent, **kwargs):
294- return parent
295- parent = parent.get_parent()
296-
297-
298-"""
299-
300-The following methods are for performing platform feature detection.
301-
302-These methods may in future be moved into the autopilot.platform module.
303-Whilst the API will remain the same, the implementation of the methods may
304-change depening on the specific requirements of the supported devices.
305-
306-"""
307-
308-
309-def get_device_name():
310- """
311- Return the device's model name.
312-
313- If this is run on desktop, it will return 'desktop'.
314-
315- """
316- return sys_info.config.device or model().lower()
317-
318-
319-def get_channel_name():
320- """ Return the build channel name. In case there is not channel defined, it
321- return the default value
322- """
323- default = 'ubuntu-touch/rc-proposed/bq-aquaris.en'
324- return _get_image_info('service', 'channel', default)
325-
326-
327-def get_build_number():
328- """ Return the build number. In case there is not channel defined, it
329- return the default value
330- """
331- return _get_image_info('service', 'build_number', '0')
332-
333-
334-def _get_image_info(category, item, default):
335- """ Return the image item requested. In case it is not defined, it return
336- the default value
337- """
338- file = '/etc/system-image/channel.ini'
339- if not os.path.isfile(file):
340- return default
341- parser = configparser.ConfigParser()
342- parser.read(file)
343- return parser[category][item]
344-
345-
346-def is_agps_supported():
347- """Return True if a agps is supported, False if it is not."""
348- agps_supported = True
349- try:
350- subprocess.check_call(
351- ['dpkg-query --status ubuntu-location-provider-here'],
352- shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
353- except subprocess.CalledProcessError:
354- agps_supported = False
355- return agps_supported
356-
357-
358-def is_camera_supported():
359- """Return True if a camera is supported, False if it is not."""
360- return click.is_package_installed('com.ubuntu.camera')
361-
362-
363-def is_wifi_supported():
364- """Return True if wifi is supported, False if it is not."""
365- wifi_supported = True
366- try:
367- subprocess.check_call(
368- ['nmcli -t -f type device | grep wifi'],
369- shell=True, stdout=subprocess.DEVNULL)
370- except subprocess.CalledProcessError:
371- wifi_supported = False
372- return wifi_supported
373-
374-
375 def is_element(predicate, *args, **kwargs):
376 """
377 Evaluate the predicate with the args and indicate if it raises
378@@ -435,28 +200,67 @@
379 return _patched_select(True, root, class_object, class_name, **kwargs)
380
381
382-def is_not_moving(elem, move_time=0.5):
383- """ Indicate if the element has not changed its position after a period
384- based on its globalRect coordinates
385- :param elem: autopilot element to check
386- :param move_time: time between the coordinates are retrieved
387- :return: True when the x and y coordinates are equal, False otherwise
388- """
389- x1, y1, h1, w1 = elem.globalRect
390- time.sleep(move_time)
391- x2, y2, h2, w2 = elem.globalRect
392-
393- return x1 == x2 and y1 == y2
394-
395-
396-def wait_until_is_not_moving(elem, move_time=0.5, timeout=10):
397- """ Wait until the autopilot element is not moving based on its globalRect
398- coordinates
399- :param elem: autopilot element to check
400- :param move_time: time in seconds between the coordinates are retrieved
401- :param timeout: total time to wait until the element is not moving
402- :return: True when the element is not moving before the timeout is reached,
403- otherwise return False
404- """
405- return wait_until(is_not_moving, elem, move_time, timeout=timeout,
406- period=0)
407+def get_proxy_object(pid):
408+ return introspection.get_proxy_object_for_existing_process(
409+ pid=pid,
410+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase,
411+ )
412+
413+
414+def get_proxy_object_for_existing_process(
415+ process_name, base_custom_proxy_object):
416+ """Return the proxy object for a currently running process."""
417+ return introspection.get_proxy_object_for_existing_process(
418+ pid=_get_pid(process_name),
419+ emulator_base=base_custom_proxy_object
420+ )
421+
422+
423+def get_proxy_object_for_existing_app(
424+ process_name, cleanup_process=None,
425+ base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
426+ """
427+ Return proxy object from existing application process.
428+
429+ Add cleanup action to close the application using cleanup_process
430+ parameter. If cleanup_process is None then process_name is used as the
431+ cleanup target using ensure_application_closed().
432+
433+ :param pname: Name of required application process.
434+ :param cleanup_process: Name of process to clean up.
435+ :param base: custom emulator base for proxy object
436+ :return: Proxy object for the desired application.
437+
438+ """
439+ if not cleanup_process:
440+ cleanup_process = process_name
441+ proxy = get_proxy_object_for_existing_process(process_name, base)
442+ context.shared.add_cleanup(processes.ensure_application_closed,
443+ cleanup_process)
444+ return proxy
445+
446+
447+def get_job_proxy_object(pname):
448+ pid = _get_pid(pname)
449+ return get_proxy_object(pid)
450+
451+
452+def get_proxy_object_for_existing_qmlscene_process(qmlfile):
453+ """
454+ Return proxy object from existing qmlscene process.
455+
456+ Add cleanup action to close the application using cleanup_process
457+ parameter. If cleanup_process is None then process_id is used as the
458+ cleanup target using processes.stop_qmlscene_process().
459+
460+ :param qmlfile: Thje name of the QML file for the required process
461+ :return: Proxy object for the desired qmlscene process
462+
463+ """
464+ process_id = processes.get_qmlscene_process_id(qmlfile)
465+ proxy = introspection.get_proxy_object_for_existing_process(
466+ pid=process_id,
467+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase
468+ )
469+ context.shared.add_cleanup(processes.stop_qmlscene_process, qmlfile)
470+ return proxy
471
472=== added file 'ubuntu_system_tests/helpers/autopilot/list.py'
473--- ubuntu_system_tests/helpers/autopilot/list.py 1970-01-01 00:00:00 +0000
474+++ ubuntu_system_tests/helpers/autopilot/list.py 2016-02-10 11:57:12 +0000
475@@ -0,0 +1,78 @@
476+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
477+
478+#
479+# Ubuntu System Tests
480+# Copyright (C) 2016 Canonical
481+#
482+# This program is free software: you can redistribute it and/or modify
483+# it under the terms of the GNU General Public License as published by
484+# the Free Software Foundation, either version 3 of the License, or
485+# (at your option) any later version.
486+#
487+# This program is distributed in the hope that it will be useful,
488+# but WITHOUT ANY WARRANTY; without even the implied warranty of
489+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
490+# GNU General Public License for more details.
491+#
492+# You should have received a copy of the GNU General Public License
493+# along with this program. If not, see <http://www.gnu.org/licenses/>.
494+#
495+
496+from autopilot.display import is_point_on_any_screen
497+from autopilot.exceptions import StateNotFoundError
498+
499+from ubuntu_system_tests.helpers.autopilot.object import (
500+ _get_y_and_x, _get_x_and_y)
501+
502+
503+def order_by_x_coord(object_list, include_off_screen=False):
504+ """
505+ Return an ordered list of objects ordered by x co-ordinate first
506+ and then y co-ordinate second if x co-ordinates match.
507+
508+ :param object_list: List of objects containing globalRect property.
509+ :param include_off_screen: Whether to include objects that are not within
510+ the bounds of any screen.
511+ :return: List of sorted objects.
512+
513+ """
514+ return _order_by_key(object_list, _get_x_and_y, include_off_screen)
515+
516+
517+def _order_by_key(object_list, sort_key, include_off_screen):
518+ """
519+ Return an ordered list of objects ordered by key.
520+
521+ :param object_list: List of objects containing globalRect property.
522+ :param sort_key: Sorting key to use.
523+ :param include_off_screen: Whether to include objects that are not within
524+ the bounds of any screen.
525+ :return: List of sorted objects.
526+
527+ """
528+ objects = []
529+ for obj in object_list:
530+ try:
531+ # If obj is no longer valid this can cause excpetion
532+ point = obj.globalRect.x, obj.globalRect.y
533+ if include_off_screen:
534+ objects.append(obj)
535+ elif is_point_on_any_screen(point):
536+ objects.append(obj)
537+ except StateNotFoundError:
538+ pass
539+ return sorted(objects, key=sort_key)
540+
541+
542+def order_by_y_coord(object_list, include_off_screen=False):
543+ """
544+ Return an ordered list of objects ordered by y co-ordinate first
545+ and then x co-ordinate second if y co-ordinates match.
546+
547+ :param object_list: List of objects containing globalRect property.
548+ :param include_off_screen: Whether to include objects that are not within
549+ the bounds of any screen.
550+ :return: List of sorted objects.
551+
552+ """
553+ return _order_by_key(object_list, _get_y_and_x, include_off_screen)
554
555=== added file 'ubuntu_system_tests/helpers/autopilot/object.py'
556--- ubuntu_system_tests/helpers/autopilot/object.py 1970-01-01 00:00:00 +0000
557+++ ubuntu_system_tests/helpers/autopilot/object.py 2016-02-10 11:57:12 +0000
558@@ -0,0 +1,137 @@
559+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
560+
561+#
562+# Ubuntu System Tests
563+# Copyright (C) 2016 Canonical
564+#
565+# This program is free software: you can redistribute it and/or modify
566+# it under the terms of the GNU General Public License as published by
567+# the Free Software Foundation, either version 3 of the License, or
568+# (at your option) any later version.
569+#
570+# This program is distributed in the hope that it will be useful,
571+# but WITHOUT ANY WARRANTY; without even the implied warranty of
572+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
573+# GNU General Public License for more details.
574+#
575+# You should received a copy of the GNU General Public License
576+# along with this program. If not, see <http://www.gnu.org/licenses/>.
577+#
578+
579+import time
580+
581+from autopilot.exceptions import StateNotFoundError
582+
583+from ubuntu_system_tests.helpers import wait_until
584+from ubuntu_system_tests.helpers.autopilot import CO_ORD_MAX
585+
586+
587+def _get_y_and_x(item):
588+ """
589+ Return y and x co-ordinates for specified object.
590+
591+ :param item: Item to check
592+ :return: (y, x) co-ordinates
593+ """
594+ try:
595+ # If item is no longer valid this can cause excpetion
596+ co_ords = item.globalRect.y, item.globalRect.x
597+ except StateNotFoundError:
598+ # Trying to sort an object that no longer exists
599+ # return a dummy key value so this item is sorted last
600+ co_ords = CO_ORD_MAX
601+ return co_ords
602+
603+
604+def _get_x_and_y(item):
605+ """
606+ Return x and y co-ordinates for specified object.
607+
608+ :param item: Item to check
609+ :return: (x, y) co-ordinates
610+ """
611+ try:
612+ # If item is no longer valid this can cause excpetion
613+ co_ords = item.globalRect.x, item.globalRect.y
614+ except StateNotFoundError:
615+ # Trying to sort an object that no longer exists
616+ # return a dummy key value so this item is sorted last
617+ co_ords = CO_ORD_MAX
618+ return co_ords
619+
620+
621+def get_object_path(item):
622+ """Return the object path of a specified item."""
623+ return item._path.decode('utf-8')
624+
625+
626+def wait_until_is_not_moving(elem, move_time=0.5, timeout=10):
627+ """ Wait until the autopilot element is not moving based on its globalRect
628+ coordinates
629+ :param elem: autopilot element to check
630+ :param move_time: time in seconds between the coordinates are retrieved
631+ :param timeout: total time to wait until the element is not moving
632+ :return: True when the element is not moving before the timeout is reached,
633+ otherwise return False
634+ """
635+ return wait_until(is_not_moving, elem, move_time, timeout=timeout,
636+ period=0)
637+
638+
639+def is_not_moving(elem, move_time=0.5):
640+ """ Indicate if the element has not changed its position after a period
641+ based on its globalRect coordinates
642+ :param elem: autopilot element to check
643+ :param move_time: time between the coordinates are retrieved
644+ :return: True when the x and y coordinates are equal, False otherwise
645+ """
646+ x1, y1, h1, w1 = elem.globalRect
647+ time.sleep(move_time)
648+ x2, y2, h2, w2 = elem.globalRect
649+
650+ return x1 == x2 and y1 == y2
651+
652+
653+def _get_parent_by_type(item, required_type, **kwargs):
654+ """Return a parent item of the required type.
655+ :param item: The child item to start searching from.
656+ :param required_type: String name of parent object type required.
657+ :param kwargs: This is used for logging purposes only.
658+ :return: Parent object matching required type.
659+ :raises: StateNotFoundError if no matching object type can be found.
660+ """
661+ parent = item.get_parent()
662+ path = get_object_path(parent).split('/')
663+ try:
664+ index = path.index(required_type)
665+ except ValueError:
666+ raise StateNotFoundError(
667+ '{}, and properties: {}'.format(required_type, kwargs))
668+ for count in range(1, len(path) - index):
669+ parent = parent.get_parent()
670+ return parent
671+
672+
673+def validate_properties(item, **kwargs):
674+ """Return True if item properties match specified keyword properties."""
675+ props = item.get_properties()
676+ for key in kwargs.keys():
677+ if props[key] != kwargs[key]:
678+ return False
679+ return True
680+
681+
682+def get_parent(item, required_type, **kwargs):
683+ """Return a parent object of specified type and properties.
684+ :param item: The child item to start searching from.
685+ :param required_type: String name of parent object type required.
686+ :param kwargs: Any properties to match on the parent object.
687+ :return: Parent object matching required type and properties.
688+ :raises: StateNotFoundError if no matching object can be found.
689+ """
690+ parent = item
691+ while True:
692+ parent = _get_parent_by_type(parent, required_type, **kwargs)
693+ if validate_properties(parent, **kwargs):
694+ return parent
695+ parent = parent.get_parent()
696
697=== added file 'ubuntu_system_tests/helpers/autopilot/platform.py'
698--- ubuntu_system_tests/helpers/autopilot/platform.py 1970-01-01 00:00:00 +0000
699+++ ubuntu_system_tests/helpers/autopilot/platform.py 2016-02-10 11:57:12 +0000
700@@ -0,0 +1,94 @@
701+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
702+
703+#
704+# Ubuntu System Tests
705+# Copyright (C) 2016 Canonical
706+#
707+# This program is free software: you can redistribute it and/or modify
708+# it under the terms of the GNU General Public License as published by
709+# the Free Software Foundation, either version 3 of the License, or
710+# (at your option) any later version.
711+#
712+# This program is distributed in the hope that it will be useful,
713+# but WITHOUT ANY WARRANTY; without even the implied warranty of
714+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
715+# GNU General Public License for more details.
716+#
717+# You should have received a copy of the GNU General Public License
718+# along with this program. If not, see <http://www.gnu.org/licenses/>.
719+#
720+
721+import configparser
722+import os
723+import subprocess
724+
725+from autopilot.platform import model
726+from systemimage import config as sys_info
727+
728+from ubuntu_system_tests.helpers import click
729+
730+
731+def get_device_name():
732+ """
733+ Return the device's model name.
734+
735+ If this is run on desktop, it will return 'desktop'.
736+
737+ """
738+ return sys_info.config.device or model().lower()
739+
740+
741+def get_channel_name():
742+ """ Return the build channel name. In case there is not channel defined, it
743+ return the default value
744+ """
745+ default = 'ubuntu-touch/rc-proposed/bq-aquaris.en'
746+ return _get_image_info('service', 'channel', default)
747+
748+
749+def get_build_number():
750+ """ Return the build number. In case there is not channel defined, it
751+ return the default value
752+ """
753+ return _get_image_info('service', 'build_number', '0')
754+
755+
756+def _get_image_info(category, item, default):
757+ """ Return the image item requested. In case it is not defined, it return
758+ the default value
759+ """
760+ file = '/etc/system-image/channel.ini'
761+ if not os.path.isfile(file):
762+ return default
763+ parser = configparser.ConfigParser()
764+ parser.read(file)
765+ return parser[category][item]
766+
767+
768+def is_agps_supported():
769+ """Return True if a agps is supported, False if it is not."""
770+ agps_supported = True
771+ try:
772+ subprocess.check_call(
773+ ['dpkg-query --status ubuntu-location-provider-here'],
774+ shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
775+ except subprocess.CalledProcessError:
776+ agps_supported = False
777+ return agps_supported
778+
779+
780+def is_camera_supported():
781+ """Return True if a camera is supported, False if it is not."""
782+ return click.is_package_installed('com.ubuntu.camera')
783+
784+
785+def is_wifi_supported():
786+ """Return True if wifi is supported, False if it is not."""
787+ wifi_supported = True
788+ try:
789+ subprocess.check_call(
790+ ['nmcli -t -f type device | grep wifi'],
791+ shell=True, stdout=subprocess.DEVNULL)
792+ except subprocess.CalledProcessError:
793+ wifi_supported = False
794+ return wifi_supported
795
796=== modified file 'ubuntu_system_tests/helpers/calculator/__init__.py'
797--- ubuntu_system_tests/helpers/calculator/__init__.py 2015-10-30 11:52:23 +0000
798+++ ubuntu_system_tests/helpers/calculator/__init__.py 2016-02-10 11:57:12 +0000
799@@ -2,7 +2,7 @@
800
801 #
802 # Ubuntu System Tests
803-# Copyright (C) 2015 Canonical
804+# Copyright (C) 2015, 2016 Canonical
805 #
806 # This program is free software: you can redistribute it and/or modify
807 # it under the terms of the GNU General Public License as published by
808@@ -17,3 +17,43 @@
809 # You should have received a copy of the GNU General Public License
810 # along with this program. If not, see <http://www.gnu.org/licenses/>.
811 #
812+
813+from ubuntu_system_tests.helpers import autopilot
814+from ubuntu_system_tests.helpers import processes
815+from ubuntu_system_tests.helpers.scopes.apps import (
816+ launch_application_from_apps_scope
817+)
818+from ubuntu_system_tests.helpers.unity8 import close_app
819+from ubuntu_system_tests.helpers import wait_until
820+
821+
822+APP_NAME = 'Calculator'
823+APP_WIN_ID = 'com.ubuntu.calculator_calculator'
824+QML = 'ubuntu-calculator-app'
825+
826+
827+def launch_calculator_app():
828+ """
829+ Launch calculator app from apps scope and return its proxy object.
830+ """
831+ launch_application_from_apps_scope(APP_NAME)
832+ wait_until(is_calculator_app_running, period=0.5)
833+ return get_calculator_app_proxy()
834+
835+
836+def close_calculator_app():
837+ """ Close the calculator app using task switcher """
838+ if is_calculator_app_running():
839+ close_app(APP_WIN_ID)
840+
841+
842+def is_calculator_app_running():
843+ """ Indicate if the calculator app is currently running """
844+ return processes.is_qmlscene_running_with_qmlfile(QML)
845+
846+
847+def get_calculator_app_proxy():
848+ """Return the proxy object of the calculator app."""
849+ from ubuntu_system_tests.helpers.calculator import _cpo # NOQA
850+ proxy = autopilot.get_proxy_object_for_existing_qmlscene_process(QML)
851+ return proxy.main_view
852
853=== modified file 'ubuntu_system_tests/helpers/camera/__init__.py'
854--- ubuntu_system_tests/helpers/camera/__init__.py 2015-10-26 18:39:02 +0000
855+++ ubuntu_system_tests/helpers/camera/__init__.py 2016-02-10 11:57:12 +0000
856@@ -21,9 +21,23 @@
857 import os
858 import warlock
859
860+from ubuntu_system_tests.helpers import autopilot
861+from ubuntu_system_tests.helpers import click
862 from ubuntu_system_tests.helpers import file_system as fs
863+from ubuntu_system_tests.helpers import processes
864+from ubuntu_system_tests.helpers.scopes.apps import (
865+ launch_application_from_apps_scope
866+)
867+from ubuntu_system_tests.helpers.unity8 import (
868+ close_app, launch_application_from_launcher
869+)
870 from ubuntu_system_tests.helpers import wait_until
871
872+APP = 'camera-app'
873+APP_NAME = 'Camera'
874+APP_WIN_ID = 'com.ubuntu.camera_camera'
875+APP_CLICK = 'com.ubuntu.camera'
876+
877 config_schema = {
878 'name': 'CameraConfig',
879 'properties': {
880@@ -45,6 +59,50 @@
881 }
882
883
884+def launch_camera_app():
885+ """
886+ Launch the camera app from dash and return proxy object.
887+
888+ :return: Proxy object for camera application.
889+
890+ """
891+ launch_application_from_apps_scope(APP_NAME)
892+ return get_camera_app_proxy()
893+
894+
895+def close_camera_app():
896+ """ Close the camera app using task switcher """
897+ if is_camera_app_running():
898+ close_app(APP_WIN_ID)
899+
900+
901+def is_camera_app_running():
902+ """ Indicate if the camera app is currently running """
903+ return processes.is_process_running(APP)
904+
905+
906+def launch_camera_app_from_launcher():
907+ """Drag out the launcher and tap the camera icon to start it."""
908+ launch_application_from_launcher(APP_WIN_ID)
909+ return get_camera_app_proxy()
910+
911+
912+def get_camera_app_proxy():
913+ """
914+ Return camera app proxy object from existing process and add
915+ cleanup actions to close the application.
916+
917+ :return: Proxy object for camera application.
918+
919+ """
920+ from ubuntu_system_tests.helpers.camera._cpo import MainWindow
921+ proxy = autopilot.get_proxy_object_for_existing_app(
922+ APP,
923+ cleanup_process=click.get_click_app_identifier(APP_CLICK)
924+ )
925+ return MainWindow(proxy)
926+
927+
928 def get_config(**kwargs):
929 return warlock.model_factory(config_schema)(kwargs)
930
931
932=== modified file 'ubuntu_system_tests/helpers/camera/_cpo.py'
933--- ubuntu_system_tests/helpers/camera/_cpo.py 2016-02-03 10:40:06 +0000
934+++ ubuntu_system_tests/helpers/camera/_cpo.py 2016-02-10 11:57:12 +0000
935@@ -25,9 +25,8 @@
936
937 from camera_app.emulators.main_window import MainWindow
938 from camera_app.emulators.panel import Panel
939-
940-from ubuntu_system_tests.helpers.autopilot import (
941- order_by_x_coord, validate_dbus_object)
942+from ubuntu_system_tests.helpers.autopilot.list import order_by_x_coord
943+from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
944 from ubuntu_system_tests.helpers import wait_until
945
946 logger = logging.getLogger(__name__)
947
948=== modified file 'ubuntu_system_tests/helpers/clock/__init__.py'
949--- ubuntu_system_tests/helpers/clock/__init__.py 2015-09-22 03:39:11 +0000
950+++ ubuntu_system_tests/helpers/clock/__init__.py 2016-02-10 11:57:12 +0000
951@@ -1,7 +1,7 @@
952 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
953 #
954 # Ubuntu System Tests
955-# Copyright (C) 2015 Canonical
956+# Copyright (C) 2015-2016 Canonical
957 #
958 # This program is free software: you can redistribute it and/or modify
959 # it under the terms of the GNU General Public License as published by
960@@ -16,3 +16,50 @@
961 # You should have received a copy of the GNU General Public License
962 # along with this program. If not, see <http://www.gnu.org/licenses/>.
963 #
964+
965+from ubuntu_system_tests.helpers import autopilot
966+from ubuntu_system_tests.helpers import processes
967+from ubuntu_system_tests.helpers.scopes.apps import (
968+ launch_application_from_apps_scope
969+)
970+from ubuntu_system_tests.helpers.unity8 import close_app
971+from ubuntu_system_tests.helpers import wait_until
972+
973+APP_NAME = 'Clock'
974+APP_WIN_ID = 'com.ubuntu.clock_clock'
975+QML = 'ubuntu-clock-app'
976+
977+
978+def launch_clock_app():
979+ """
980+ Launch the clock app from apps scope and return proxy object.
981+
982+ :return: Proxy object for clock application.
983+
984+ """
985+ launch_application_from_apps_scope(APP_NAME)
986+ wait_until(is_clock_app_running, period=0.5)
987+ return get_clock_app_proxy()
988+
989+
990+def close_clock_app():
991+ """ Close the calendar app using task switcher """
992+ if is_clock_app_running():
993+ close_app(APP_WIN_ID)
994+
995+
996+def is_clock_app_running():
997+ """ Indicate if the clock app is currently running """
998+ return processes.is_qmlscene_running_with_qmlfile(QML)
999+
1000+
1001+def get_clock_app_proxy():
1002+ """
1003+ Return clock app proxy object from existing process.
1004+
1005+ :return: Proxy object for calendar application.
1006+
1007+ """
1008+ from ubuntu_system_tests.helpers.clock import _cpo # NOQA
1009+ proxy = autopilot.get_proxy_object_for_existing_qmlscene_process(QML)
1010+ return proxy.main_view
1011
1012=== added file 'ubuntu_system_tests/helpers/context.py'
1013--- ubuntu_system_tests/helpers/context.py 1970-01-01 00:00:00 +0000
1014+++ ubuntu_system_tests/helpers/context.py 2016-02-10 11:57:12 +0000
1015@@ -0,0 +1,23 @@
1016+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1017+
1018+#
1019+# Ubuntu System Tests
1020+# Copyright (C) 2016 Canonical
1021+#
1022+# This program is free software: you can redistribute it and/or modify
1023+# it under the terms of the GNU General Public License as published by
1024+# the Free Software Foundation, either version 3 of the License, or
1025+# (at your option) any later version.
1026+#
1027+# This program is distributed in the hope that it will be useful,
1028+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1029+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1030+# GNU General Public License for more details.
1031+#
1032+# You should have received a copy of the GNU General Public License
1033+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1034+#
1035+
1036+from ubuntu_system_tests.helpers import AttrDict
1037+
1038+shared = AttrDict()
1039
1040=== modified file 'ubuntu_system_tests/helpers/data.py'
1041--- ubuntu_system_tests/helpers/data.py 2015-09-23 21:12:39 +0000
1042+++ ubuntu_system_tests/helpers/data.py 2016-02-10 11:57:12 +0000
1043@@ -21,9 +21,13 @@
1044 from json import (load, JSONDecoder)
1045 from os import path, walk
1046
1047+from ubuntu_system_tests.helpers import AttrDict
1048 from ubuntu_system_tests.helpers import file_system as fs
1049
1050
1051+_full_dict = AttrDict()
1052+
1053+
1054 class AttrDictDecoder(JSONDecoder):
1055 """ Class used to decode a dict into a AttrDict object """
1056
1057@@ -31,17 +35,6 @@
1058 JSONDecoder.__init__(self, object_hook=dict_to_attr_dict)
1059
1060
1061-class AttrDict(dict):
1062- """ Class used to access to the dict keys as parameters """
1063-
1064- def __init__(self, *args, **kwargs):
1065- super(AttrDict, self).__init__(*args, **kwargs)
1066- self.__dict__ = self
1067-
1068-
1069-_full_dict = AttrDict()
1070-
1071-
1072 def _get_metadata_file(dir):
1073 """ Retrieve the metadata file path from a dir, in case there is not one
1074 return None """
1075
1076=== modified file 'ubuntu_system_tests/helpers/device.py'
1077--- ubuntu_system_tests/helpers/device.py 2016-01-15 11:19:35 +0000
1078+++ ubuntu_system_tests/helpers/device.py 2016-02-10 11:57:12 +0000
1079@@ -21,7 +21,7 @@
1080 import json
1081 import os
1082
1083-from ubuntu_system_tests.helpers import autopilot
1084+from ubuntu_system_tests.helpers.autopilot.platform import get_device_name
1085 from ubuntu_system_tests.helpers import file_system as fs
1086
1087
1088@@ -79,7 +79,7 @@
1089 if device_metadata:
1090 return device_metadata
1091
1092- device_id = autopilot.get_device_name()
1093+ device_id = get_device_name()
1094 data_file = os.path.join(fs.DIR_TEST_DATA_DEVICES, device_id + '.json')
1095
1096 if not os.path.isfile(data_file):
1097
1098=== modified file 'ubuntu_system_tests/helpers/dialer_app/__init__.py'
1099--- ubuntu_system_tests/helpers/dialer_app/__init__.py 2015-11-13 16:54:39 +0000
1100+++ ubuntu_system_tests/helpers/dialer_app/__init__.py 2016-02-10 11:57:12 +0000
1101@@ -18,6 +18,59 @@
1102 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1103 #
1104
1105+from ubuntu_system_tests.helpers import autopilot
1106+from ubuntu_system_tests.helpers import processes
1107+from ubuntu_system_tests.helpers.scopes.apps import (
1108+ launch_application_from_apps_scope
1109+)
1110+from ubuntu_system_tests.helpers.unity8 import (
1111+ close_app, launch_application_from_launcher
1112+)
1113+
1114+APP = 'dialer-app'
1115+APP_NAME = 'Phone'
1116+APP_WIN_ID = 'dialer-app'
1117+
1118+
1119+def launch_dialer_app():
1120+ """
1121+ Launch the dialer app from apps scope and return proxy object.
1122+
1123+ :return: Proxy object for dialer application.
1124+
1125+ """
1126+ launch_application_from_apps_scope(APP_NAME)
1127+ return get_dialer_app_proxy()
1128+
1129+
1130+def close_dialer_app():
1131+ """ Close the dialer app using task switcher """
1132+ if is_dialer_app_running():
1133+ close_app(APP_WIN_ID)
1134+
1135+
1136+def is_dialer_app_running():
1137+ """ Indicate if the dialer app is currently running """
1138+ return processes.is_process_running(APP)
1139+
1140+
1141+def get_dialer_app_proxy():
1142+ """
1143+ Return dialer app proxy object from existing process.
1144+
1145+ :return: Proxy object for dialer application.
1146+
1147+ """
1148+ from ubuntu_system_tests.helpers.dialer_app import _cpo # NOQA
1149+ proxy = autopilot.get_proxy_object_for_existing_app(APP)
1150+ return proxy.main_view
1151+
1152+
1153+def launch_dialer_app_from_launcher():
1154+ """Drag out the launcher and tap the dialer app icon to start it."""
1155+ launch_application_from_launcher(APP_WIN_ID)
1156+ return get_dialer_app_proxy()
1157+
1158
1159 def unformatted_phone_number(phone_number):
1160 """Remove any spaces or format characters from phone_number."""
1161
1162=== modified file 'ubuntu_system_tests/helpers/gallery/__init__.py'
1163--- ubuntu_system_tests/helpers/gallery/__init__.py 2015-11-16 13:44:28 +0000
1164+++ ubuntu_system_tests/helpers/gallery/__init__.py 2016-02-10 11:57:12 +0000
1165@@ -2,7 +2,7 @@
1166
1167 #
1168 # Ubuntu System Tests
1169-# Copyright (C) 2015 Canonical
1170+# Copyright (C) 2015-2016 Canonical
1171 #
1172 # This program is free software: you can redistribute it and/or modify
1173 # it under the terms of the GNU General Public License as published by
1174@@ -17,3 +17,71 @@
1175 # You should have received a copy of the GNU General Public License
1176 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1177 #
1178+
1179+from ubuntu_system_tests.helpers import autopilot
1180+from ubuntu_system_tests.helpers import click
1181+from ubuntu_system_tests.helpers import processes
1182+from ubuntu_system_tests.helpers.scopes.apps import (
1183+ launch_application_from_apps_scope
1184+)
1185+from ubuntu_system_tests.helpers.unity8 import (
1186+ close_app, launch_application_from_launcher
1187+)
1188+
1189+APP = 'gallery-app'
1190+APP_NAME = 'Gallery'
1191+APP_WIN_ID = 'com.ubuntu.gallery_gallery'
1192+APP_CLICK = 'com.ubuntu.gallery'
1193+
1194+
1195+def launch_gallery_app():
1196+ """
1197+ Launch the gallery app from apps scope and return proxy object.
1198+
1199+ :return: Proxy object for gallery application.
1200+
1201+ """
1202+ from ubuntu_system_tests.helpers.gallery._cpo import EventsView
1203+ launch_application_from_apps_scope(APP_NAME)
1204+ return EventsView(get_gallery_app_proxy())
1205+
1206+
1207+def close_gallery_app():
1208+ """ Close the gallery app using task switcher """
1209+ if is_gallery_app_running():
1210+ close_app(APP_WIN_ID)
1211+
1212+
1213+def is_gallery_app_running():
1214+ """ Indicate if the gallery app is currently running """
1215+ return processes.is_process_running(APP)
1216+
1217+
1218+def get_gallery_app_proxy():
1219+ """
1220+ Return gallery app proxy object from existing process.
1221+
1222+ :return: Proxy object for gallery application.
1223+
1224+ """
1225+ proxy = autopilot.get_proxy_object_for_existing_app(
1226+ APP, cleanup_process=click.get_click_app_identifier(APP_CLICK))
1227+ return proxy
1228+
1229+
1230+def get_gallery_events_view():
1231+ """Return a gallery_app EventsView custom proxy object."""
1232+ from ubuntu_system_tests.helpers.gallery._cpo import EventsView
1233+ return EventsView(get_gallery_app_proxy())
1234+
1235+
1236+def get_gallery_photo_viewer():
1237+ """Return a gallery_app PhotoViewer custom proxy object."""
1238+ from ubuntu_system_tests.helpers.gallery._cpo import PhotoViewer
1239+ return PhotoViewer(get_gallery_app_proxy())
1240+
1241+
1242+def launch_gallery_app_from_launcher():
1243+ """Drag out the launcher and tap the gallery app icon to start it."""
1244+ launch_application_from_launcher(APP_WIN_ID)
1245+ return get_gallery_app_proxy()
1246
1247=== modified file 'ubuntu_system_tests/helpers/mediaplayer/__init__.py'
1248--- ubuntu_system_tests/helpers/mediaplayer/__init__.py 2015-10-27 22:05:21 +0000
1249+++ ubuntu_system_tests/helpers/mediaplayer/__init__.py 2016-02-10 11:57:12 +0000
1250@@ -22,6 +22,7 @@
1251
1252 from enum import IntEnum
1253
1254+from ubuntu_system_tests.helpers import autopilot
1255 from ubuntu_system_tests.helpers.dbus_observer import DBusObserver
1256 from ubuntu_system_tests.helpers import processes
1257 from ubuntu_system_tests.helpers.threads import StoppingThread
1258@@ -29,6 +30,23 @@
1259 APP = 'mediaplayer-app'
1260
1261
1262+def get_media_player_proxy():
1263+ """
1264+ Return media player app proxy object from existing process.
1265+
1266+ :return: Proxy object for media player application.
1267+
1268+ """
1269+ from ubuntu_system_tests.helpers.mediaplayer._cpo import MainWindow
1270+ proxy = autopilot.get_proxy_object_for_existing_app(APP)
1271+ return MainWindow(proxy)
1272+
1273+
1274+def is_mediaplayer_running():
1275+ """ Indicate if the mediaplayer is running """
1276+ return processes.is_process_running(APP)
1277+
1278+
1279 class PlaybackStatus(IntEnum):
1280 """Media player playback states."""
1281 Null = 0
1282@@ -72,11 +90,6 @@
1283 self.result.set()
1284
1285
1286-def is_mediaplayer_running():
1287- """ Indicate if the mediaplayer is running """
1288- return processes.is_process_running(APP)
1289-
1290-
1291 def play_video(src_video):
1292 """ Play the src video in the media player """
1293 processes.start_application(APP, src_video)
1294
1295=== modified file 'ubuntu_system_tests/helpers/messaging/__init__.py'
1296--- ubuntu_system_tests/helpers/messaging/__init__.py 2016-01-06 13:19:19 +0000
1297+++ ubuntu_system_tests/helpers/messaging/__init__.py 2016-02-10 11:57:12 +0000
1298@@ -19,6 +19,20 @@
1299
1300 from collections import namedtuple
1301 from math import ceil
1302+import ubuntuuitoolkit
1303+
1304+from ubuntu_system_tests.helpers import autopilot
1305+from ubuntu_system_tests.helpers import processes
1306+from ubuntu_system_tests.helpers.scopes.apps import (
1307+ launch_application_from_apps_scope
1308+)
1309+from ubuntu_system_tests.helpers.unity8 import (
1310+ close_app, launch_application_from_launcher
1311+)
1312+
1313+APP = 'messaging-app'
1314+APP_NAME = 'Messaging'
1315+APP_WIN_ID = 'messaging-app'
1316
1317 # Number of characters sent in a single SMS message
1318 SMS_MESSAGE_SIZE = 153
1319@@ -35,6 +49,51 @@
1320 Search.__new__.__defaults__ = (None, None, None)
1321
1322
1323+def launch_messaging_app():
1324+ """
1325+ Launch the messaging app from apps scope and return proxy object.
1326+
1327+ :return: Proxy object for messaging application.
1328+
1329+ """
1330+ launch_application_from_apps_scope(APP_NAME)
1331+ return get_messaging_app_proxy()
1332+
1333+
1334+def close_messaging_app():
1335+ """ Close the messaging app using task switcher """
1336+ if is_messaging_app_running():
1337+ close_app(APP_WIN_ID)
1338+
1339+
1340+def is_messaging_app_running():
1341+ """ Indicate if the messaging app is currently running """
1342+ return processes.is_process_running(APP)
1343+
1344+
1345+def get_messaging_app_proxy(
1346+ base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
1347+ """
1348+ Return messaging app proxy object from existing process.
1349+
1350+ :return: Proxy object for messaging application.
1351+
1352+ """
1353+ if not base:
1354+ return autopilot.get_proxy_object_for_existing_app(APP,
1355+ base=base)
1356+
1357+ from ubuntu_system_tests.helpers.messaging._cpo import MainView
1358+ proxy = autopilot.get_proxy_object_for_existing_app(APP)
1359+ return proxy.wait_select_single(MainView)
1360+
1361+
1362+def launch_messaging_app_from_launcher():
1363+ """Drag out the launcher and tap the messaging app icon to start it."""
1364+ launch_application_from_launcher(APP)
1365+ return get_messaging_app_proxy()
1366+
1367+
1368 def calculate_sent_message_count(body, size=SMS_MESSAGE_SIZE):
1369 """
1370 Calculate the number of sms messages required to send the message.
1371
1372=== modified file 'ubuntu_system_tests/helpers/messaging/_cpo.py'
1373--- ubuntu_system_tests/helpers/messaging/_cpo.py 2016-02-03 10:40:06 +0000
1374+++ ubuntu_system_tests/helpers/messaging/_cpo.py 2016-02-10 11:57:12 +0000
1375@@ -28,8 +28,9 @@
1376 from messaging_app import emulators as messaging_emulators
1377
1378 from ubuntu_system_tests.helpers.autopilot import (
1379- order_by_y_coord, patched_select_single, validate_dbus_object,
1380- wait_select_many)
1381+ patched_select_single, validate_dbus_object, wait_select_many
1382+)
1383+from ubuntu_system_tests.helpers.autopilot.list import order_by_y_coord
1384 from ubuntu_system_tests.helpers.system_settings import SIM_1, SIM_2
1385
1386 logger = logging.getLogger(__name__)
1387
1388=== modified file 'ubuntu_system_tests/helpers/music.py'
1389--- ubuntu_system_tests/helpers/music.py 2016-01-26 18:36:22 +0000
1390+++ ubuntu_system_tests/helpers/music.py 2016-02-10 11:57:12 +0000
1391@@ -16,15 +16,59 @@
1392 # You should have received a copy of the GNU General Public License
1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1394
1395+import ubuntuuitoolkit
1396
1397+from ubuntu_system_tests.helpers import autopilot
1398 from ubuntu_system_tests.helpers import file_system as fs
1399 from ubuntu_system_tests.helpers import processes
1400-
1401-
1402+from ubuntu_system_tests.helpers.scopes.apps import (
1403+ launch_application_from_apps_scope
1404+)
1405+from ubuntu_system_tests.helpers.unity8 import close_app
1406+from ubuntu_system_tests.helpers import wait_until
1407+
1408+APP = 'music-app'
1409+APP_NAME = 'Music'
1410+APP_WIN_ID = 'com.ubuntu.music_music'
1411 QML = 'music-app.qml'
1412
1413
1414+def launch_music_app():
1415+ """
1416+ Launch the music app from apps scope and return proxy object.
1417+
1418+ :return: Proxy object for music application.
1419+
1420+ """
1421+ launch_application_from_apps_scope(APP_NAME)
1422+ wait_until(is_music_app_running, period=0.5)
1423+ return get_music_app_proxy()
1424+
1425+
1426+def close_music_app():
1427+ """ Close the music app using task switcher """
1428+ if is_music_app_running():
1429+ close_app(APP_WIN_ID)
1430+
1431+
1432+def is_music_app_running():
1433+ """ Indicate if the music app is currently running """
1434+ return processes.is_qmlscene_running_with_qmlfile(APP)
1435+
1436+
1437+def get_music_app_proxy():
1438+ """
1439+ Return music app proxy object from existing process.
1440+
1441+ :return: Proxy object for music application.
1442+
1443+ """
1444+ proxy = autopilot.get_proxy_object_for_existing_qmlscene_process(APP)
1445+ return proxy.wait_select_single(ubuntuuitoolkit.MainView)
1446+
1447+
1448 def stop_music_app():
1449+ """ Stop the music app qml process """
1450 processes.stop_qmlscene_process(QML)
1451
1452
1453
1454=== modified file 'ubuntu_system_tests/helpers/scopes/__init__.py'
1455--- ubuntu_system_tests/helpers/scopes/__init__.py 2016-01-05 15:28:08 +0000
1456+++ ubuntu_system_tests/helpers/scopes/__init__.py 2016-02-10 11:57:12 +0000
1457@@ -23,8 +23,9 @@
1458
1459 from ubuntu_system_tests.helpers import file_system as fs
1460 from ubuntu_system_tests.helpers import url_dispatcher
1461-from ubuntu_system_tests.helpers.autopilot import (
1462- get_channel_name, get_device_name)
1463+from ubuntu_system_tests.helpers.autopilot.platform import (
1464+ get_device_name, get_channel_name
1465+)
1466 from ubuntu_system_tests.helpers.scopes import data as scope_data
1467 from ubuntu_system_tests.helpers.unity8 import get_dash
1468
1469
1470=== modified file 'ubuntu_system_tests/helpers/scopes/apps/__init__.py'
1471--- ubuntu_system_tests/helpers/scopes/apps/__init__.py 2015-10-19 09:56:33 +0000
1472+++ ubuntu_system_tests/helpers/scopes/apps/__init__.py 2016-02-10 11:57:12 +0000
1473@@ -18,4 +18,23 @@
1474 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1475 #
1476
1477+from ubuntu_system_tests.helpers.scopes import go_to_apps_scope
1478+from ubuntu_system_tests.helpers import timer
1479+
1480+
1481 APP_STORE_TITLE = 'Ubuntu Store'
1482+
1483+
1484+def launch_application_from_apps_scope(app_name, category=None):
1485+ """
1486+ Launch an app from apps scope and return proxy object.
1487+
1488+ :param app_name: Name of the displayed application.
1489+ :param category: Category name app is displayed in. If None then the
1490+ category name will be discovered automatically.
1491+ """
1492+ apps_scope = go_to_apps_scope()
1493+ if not category:
1494+ category = apps_scope.get_app_category(app_name)
1495+ apps_scope.click_scope_item(category, app_name)
1496+ timer.start(timer.LAUNCH_ID)
1497
1498=== modified file 'ubuntu_system_tests/helpers/scopes/apps/_cpo.py'
1499--- ubuntu_system_tests/helpers/scopes/apps/_cpo.py 2016-02-03 10:31:33 +0000
1500+++ ubuntu_system_tests/helpers/scopes/apps/_cpo.py 2016-02-10 11:57:12 +0000
1501@@ -21,7 +21,10 @@
1502 from autopilot import exceptions, introspection
1503
1504 from ubuntu_system_tests.helpers.autopilot import (
1505- get_parent, get_patched_registry, order_by_y_coord, validate_dbus_object)
1506+ get_patched_registry, validate_dbus_object
1507+)
1508+from ubuntu_system_tests.helpers.autopilot.list import order_by_y_coord
1509+from ubuntu_system_tests.helpers.autopilot.object import get_parent
1510 from ubuntu_system_tests.helpers.scopes.apps import _clickscope
1511 from ubuntu_system_tests.helpers.scopes.base import GenericScopeView
1512 from ubuntu_system_tests.helpers.unity8 import UNITY8_DASH_PATH_ROOT
1513
1514=== modified file 'ubuntu_system_tests/helpers/scopes/base.py'
1515--- ubuntu_system_tests/helpers/scopes/base.py 2016-01-22 18:18:38 +0000
1516+++ ubuntu_system_tests/helpers/scopes/base.py 2016-02-10 11:57:12 +0000
1517@@ -23,12 +23,9 @@
1518 from autopilot import exceptions
1519 from collections import namedtuple
1520 from unity8 import dash as unity8_dash
1521-
1522-from ubuntu_system_tests.helpers.autopilot import order_by_y_coord
1523+from ubuntu_system_tests.helpers.autopilot.list import order_by_y_coord
1524 from ubuntu_system_tests.helpers.ubuntuuitoolkit.pageheader import (
1525- DashPageHeader
1526-)
1527-from ubuntu_system_tests.helpers import timer
1528+ DashPageHeader)
1529 from ubuntu_system_tests.helpers.unity8 import get_dash
1530 from ubuntu_system_tests.helpers.url_dispatcher import go_to_url
1531
1532@@ -75,7 +72,6 @@
1533 x, y, width, height = icon.globalRect
1534 self.pointing_device.move(x + 1, y + 1)
1535 self.pointing_device.click(press_duration=press_duration)
1536- timer.start(timer.LAUNCH_ID)
1537
1538 def _get_data_from_object(self, object):
1539 """
1540
1541=== modified file 'ubuntu_system_tests/helpers/scopes/music/_cpo.py'
1542--- ubuntu_system_tests/helpers/scopes/music/_cpo.py 2016-02-03 10:40:06 +0000
1543+++ ubuntu_system_tests/helpers/scopes/music/_cpo.py 2016-02-10 11:57:12 +0000
1544@@ -21,8 +21,9 @@
1545 from autopilot import exceptions
1546
1547 from ubuntu_system_tests.helpers.autopilot import (
1548- is_element, order_by_y_coord, patched_wait_select_single, wait_select_many,
1549+ is_element, patched_wait_select_single, wait_select_many,
1550 validate_dbus_object)
1551+from ubuntu_system_tests.helpers.autopilot.list import order_by_y_coord
1552 from ubuntu_system_tests.helpers.scopes.base import (
1553 GenericScopeView as GenericScopeViewBase)
1554 from ubuntu_system_tests.helpers.ubuntuuitoolkit import pageheader
1555
1556=== modified file 'ubuntu_system_tests/helpers/scopes/music/_preview.py'
1557--- ubuntu_system_tests/helpers/scopes/music/_preview.py 2016-02-03 10:40:06 +0000
1558+++ ubuntu_system_tests/helpers/scopes/music/_preview.py 2016-02-10 11:57:12 +0000
1559@@ -19,8 +19,8 @@
1560 #
1561
1562 from unity8.dash import Preview as DashPreview
1563-
1564-from ubuntu_system_tests.helpers.autopilot import wait_until_is_not_moving
1565+from ubuntu_system_tests.helpers.autopilot.object import \
1566+ wait_until_is_not_moving
1567
1568
1569 class Preview(DashPreview):
1570
1571=== modified file 'ubuntu_system_tests/helpers/scopes/photos/_category.py'
1572--- ubuntu_system_tests/helpers/scopes/photos/_category.py 2016-02-03 10:40:06 +0000
1573+++ ubuntu_system_tests/helpers/scopes/photos/_category.py 2016-02-10 11:57:12 +0000
1574@@ -21,7 +21,8 @@
1575 from ubuntuuitoolkit import UbuntuUIToolkitCustomProxyObjectBase
1576
1577 from ubuntu_system_tests.helpers.autopilot import (
1578- is_element, order_by_x_coord, validate_dbus_object)
1579+ is_element, validate_dbus_object)
1580+from ubuntu_system_tests.helpers.autopilot.list import order_by_x_coord
1581 from ubuntu_system_tests.helpers.unity8 import UNITY8_DASH_PATH_ROOT
1582
1583
1584
1585=== modified file 'ubuntu_system_tests/helpers/system_settings/__init__.py'
1586--- ubuntu_system_tests/helpers/system_settings/__init__.py 2016-01-18 09:29:20 +0000
1587+++ ubuntu_system_tests/helpers/system_settings/__init__.py 2016-02-10 11:57:12 +0000
1588@@ -25,13 +25,57 @@
1589 check_output,
1590 )
1591
1592-SETTINGS_PROCESS = 'ubuntu-system-settings'
1593+from ubuntu_system_tests.helpers import autopilot
1594+from ubuntu_system_tests.helpers import processes
1595+from ubuntu_system_tests.helpers.scopes.apps import (
1596+ launch_application_from_apps_scope
1597+)
1598+from ubuntu_system_tests.helpers.unity8 import close_app
1599+
1600+APP = 'system-settings'
1601+APP_NAME = 'System Settings'
1602+APP_WIN_ID = 'ubuntu-system-settings'
1603
1604 SIM_1 = '1'
1605 SIM_2 = '2'
1606 SIM_ASK = 'ask'
1607
1608
1609+def launch_system_settings():
1610+ """
1611+ Launch system settings from apps scope and return proxy object.
1612+
1613+ :return: Proxy object for system settings.
1614+
1615+ """
1616+ launch_application_from_apps_scope(APP_NAME)
1617+ return get_system_settings_proxy()
1618+
1619+
1620+def close_system_settings():
1621+ """ Close the system settings app using task switcher """
1622+ if is_system_settings_running():
1623+ close_app(APP_WIN_ID)
1624+
1625+
1626+def is_system_settings_running():
1627+ """ Indicate if the system settings is currently running """
1628+ return processes.is_process_running(APP)
1629+
1630+
1631+def get_system_settings_proxy():
1632+ """
1633+ Return system settings proxy object from existing process.
1634+
1635+ :return: Proxy object for system settings.
1636+
1637+ """
1638+ from ubuntu_system_tests.helpers.system_settings import _cpo # NOQA
1639+ proxy = autopilot.get_proxy_object_for_existing_app(
1640+ APP, cleanup_process=APP_WIN_ID)
1641+ return proxy.main_view
1642+
1643+
1644 def get_ril_modem_for_sim(sim):
1645 """
1646 Convert the sim slot number to ril modem id, /ril_0 or /ril_1.
1647
1648=== modified file 'ubuntu_system_tests/helpers/timer.py'
1649--- ubuntu_system_tests/helpers/timer.py 2016-01-21 18:25:17 +0000
1650+++ ubuntu_system_tests/helpers/timer.py 2016-02-10 11:57:12 +0000
1651@@ -19,15 +19,18 @@
1652
1653 from datetime import datetime
1654
1655+from ubuntu_system_tests.helpers import context
1656+
1657 start_times = {}
1658
1659 LAUNCH_ID = 'launch'
1660
1661
1662 def start(id):
1663- """ Start the timer identified with the id """
1664- global start_times
1665- start_times[id] = datetime.now()
1666+ """ Start the timer identified with the id when it has being enabled """
1667+ if id in context.shared.timers:
1668+ global start_times
1669+ start_times[id] = datetime.now()
1670
1671
1672 def _get_elapsed_time(id):
1673
1674=== modified file 'ubuntu_system_tests/helpers/ubuntu_keyboard/__init__.py'
1675--- ubuntu_system_tests/helpers/ubuntu_keyboard/__init__.py 2015-12-15 19:31:52 +0000
1676+++ ubuntu_system_tests/helpers/ubuntu_keyboard/__init__.py 2016-02-10 11:57:12 +0000
1677@@ -20,6 +20,15 @@
1678
1679 from ubuntu_keyboard.emulators.keyboard import Keyboard
1680
1681+from ubuntu_system_tests.helpers import autopilot
1682+
1683+APP = 'maliit-server'
1684+
1685+
1686+def get_ubuntu_keyboard_proxy():
1687+ from ubuntu_system_tests.helpers.ubuntu_keyboard import _cpo # NOQA
1688+ return autopilot.get_proxy_object_for_existing_app(APP)
1689+
1690
1691 def is_keyboard_shifted():
1692 keyboard = Keyboard()
1693
1694=== modified file 'ubuntu_system_tests/helpers/ubuntuuitoolkit/optiontoggle.py'
1695--- ubuntu_system_tests/helpers/ubuntuuitoolkit/optiontoggle.py 2016-01-08 17:39:01 +0000
1696+++ ubuntu_system_tests/helpers/ubuntuuitoolkit/optiontoggle.py 2016-02-10 11:57:12 +0000
1697@@ -18,8 +18,7 @@
1698 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1699
1700 from ubuntuuitoolkit import UbuntuUIToolkitCustomProxyObjectBase
1701-
1702-from ubuntu_system_tests.helpers.autopilot import order_by_y_coord
1703+from ubuntu_system_tests.helpers.autopilot.list import order_by_y_coord
1704
1705
1706 class OptionToggle(UbuntuUIToolkitCustomProxyObjectBase):
1707
1708=== modified file 'ubuntu_system_tests/helpers/ubuntuuitoolkit/pageheader.py'
1709--- ubuntu_system_tests/helpers/ubuntuuitoolkit/pageheader.py 2015-11-06 22:41:22 +0000
1710+++ ubuntu_system_tests/helpers/ubuntuuitoolkit/pageheader.py 2016-02-10 11:57:12 +0000
1711@@ -18,8 +18,7 @@
1712 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1713
1714 from ubuntuuitoolkit import UbuntuUIToolkitCustomProxyObjectBase
1715-
1716-from ubuntu_system_tests.helpers.autopilot import order_by_y_coord
1717+from ubuntu_system_tests.helpers.autopilot.list import order_by_y_coord
1718
1719
1720 class DashPageHeader(UbuntuUIToolkitCustomProxyObjectBase):
1721
1722=== modified file 'ubuntu_system_tests/helpers/unity8/__init__.py'
1723--- ubuntu_system_tests/helpers/unity8/__init__.py 2016-02-03 10:40:06 +0000
1724+++ ubuntu_system_tests/helpers/unity8/__init__.py 2016-02-10 11:57:12 +0000
1725@@ -24,6 +24,9 @@
1726 from autopilot import introspection
1727 from autopilot.matchers import Eventually
1728 from testtools.matchers import Equals
1729+
1730+from ubuntu_system_tests.helpers import context
1731+from ubuntu_system_tests.helpers import timer
1732 from ubuntu_system_tests.helpers.unity8 import greeter
1733
1734 UNITY8_PATH_ROOT = b'unity8'
1735@@ -57,3 +60,37 @@
1736 emulator_base=UbuntuUIToolkitCustomProxyObjectBase,
1737 )
1738 return dash_proxy.select_single(Dash)
1739+
1740+
1741+def launch_application_from_launcher(app_name):
1742+ """
1743+ Launch an app from the launcher.
1744+
1745+ :param app_name: Name of the displayed application.
1746+
1747+ """
1748+ unity = context.shared.unity
1749+ timer.start(timer.LAUNCH_ID)
1750+ unity.main_window.launch_application(app_name)
1751+
1752+
1753+def close_app(app_name):
1754+ """Close an app using task switcher and check process is stopped."""
1755+ unity = context.shared.unity
1756+
1757+ # Get the windows name
1758+ stage = unity.main_window.swipe_to_show_app_switcher()
1759+ app_window_name = 'appWindow_' + app_name
1760+ app_windows = stage.get_app_window_names()
1761+ if app_window_name not in app_windows:
1762+ raise RuntimeError(
1763+ 'Window {} no included in windows list {}'.format(
1764+ app_window_name, app_windows
1765+ ))
1766+
1767+ # Close the windows and assert that it is closed
1768+ stage.close_app(app_name)
1769+ app_windows = stage.get_app_window_names()
1770+ if app_window_name in app_windows:
1771+ raise RuntimeError(
1772+ 'Window {} not closed correctly'.format(app_window_name))
1773
1774=== modified file 'ubuntu_system_tests/helpers/unity8/dash.py'
1775--- ubuntu_system_tests/helpers/unity8/dash.py 2016-02-03 10:40:06 +0000
1776+++ ubuntu_system_tests/helpers/unity8/dash.py 2016-02-10 11:57:12 +0000
1777@@ -24,8 +24,8 @@
1778 from unity8 import dash as unity8_dash
1779
1780 from ubuntu_system_tests.helpers.autopilot import (
1781- order_by_x_coord, patched_wait_select_single, validate_dbus_object,
1782- wait_select_many)
1783+ patched_wait_select_single, validate_dbus_object, wait_select_many)
1784+from ubuntu_system_tests.helpers.autopilot.list import order_by_x_coord
1785 from ubuntu_system_tests.helpers.ubuntuuitoolkit.pageheader import (
1786 DashPageHeader
1787 )
1788
1789=== modified file 'ubuntu_system_tests/helpers/unity8/phone_stage.py'
1790--- ubuntu_system_tests/helpers/unity8/phone_stage.py 2016-02-03 10:40:06 +0000
1791+++ ubuntu_system_tests/helpers/unity8/phone_stage.py 2016-02-10 11:57:12 +0000
1792@@ -23,9 +23,8 @@
1793 from autopilot import logging as autopilot_logging
1794 from autopilot.exceptions import StateNotFoundError
1795 from ubuntuuitoolkit import UbuntuUIToolkitCustomProxyObjectBase
1796-
1797-from ubuntu_system_tests.helpers.autopilot import (
1798- order_by_x_coord, validate_dbus_object)
1799+from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
1800+from ubuntu_system_tests.helpers.autopilot.list import order_by_x_coord
1801 from ubuntu_system_tests.helpers.unity8 import UNITY8_PATH_ROOT
1802
1803 logger = logging.getLogger(__name__)
1804
1805=== modified file 'ubuntu_system_tests/helpers/webapp/__init__.py'
1806--- ubuntu_system_tests/helpers/webapp/__init__.py 2015-10-30 14:05:06 +0000
1807+++ ubuntu_system_tests/helpers/webapp/__init__.py 2016-02-10 11:57:12 +0000
1808@@ -28,7 +28,13 @@
1809 from selenium.webdriver.chrome.options import Options
1810 from selenium.webdriver.common.touch_actions import TouchActions
1811
1812+from ubuntu_system_tests.helpers import autopilot
1813+from ubuntu_system_tests.helpers import context
1814 from ubuntu_system_tests.helpers import processes
1815+from ubuntu_system_tests.helpers.scopes.apps import (
1816+ launch_application_from_apps_scope
1817+)
1818+from ubuntu_system_tests.helpers import wait_until
1819
1820 DEFAULT_WEBVIEW_INSPECTOR_IP = '127.0.0.1'
1821 DEFAULT_WEBVIEW_INSPECTOR_PORT = 9221
1822@@ -36,13 +42,16 @@
1823 logger = logging.getLogger(__name__)
1824
1825
1826-def get_webdriver(cleanup_method):
1827- """ Retrieve the webdriver for the current webapp container """
1828- driver = setup_webdriver()
1829- cleanup_method(driver.quit)
1830-
1831- driver.implicitly_wait(30)
1832- return driver
1833+def launch_webapp(app_name, web_app_package):
1834+ """ Launch the webapp and return the webapp proxy object
1835+ :param app_name: The name in the apps scope
1836+ :param web_app_package: The package name
1837+ :return: Proxy object for webapp
1838+ """
1839+ launch_application_from_apps_scope(app_name)
1840+ context.shared.add_cleanup(ensure_webapp_closed, web_app_package)
1841+ wait_until(is_webapp_runing, web_app_package)
1842+ return get_webapp_proxy(web_app_package)
1843
1844
1845 def is_webapp_runing(web_app):
1846@@ -73,6 +82,18 @@
1847 raise RuntimeError('No such webapp {} running'.format(webapp_id))
1848
1849
1850+def get_webapp_proxy(web_app_package):
1851+ """ Return webapp proxy object from existing process.
1852+ :param web_app_package: The package name
1853+ :return: Proxy object for webapp.
1854+ """
1855+ from ubuntu_system_tests.helpers.webapp import _cpo # NOQA
1856+
1857+ pid = get_webapp_pid(web_app_package)
1858+ proxy = autopilot.get_proxy_object(pid)
1859+ return proxy.wait_select_single('BrowserWindow')
1860+
1861+
1862 def ensure_webapp_closed(web_app):
1863 try:
1864 webapp_id = _get_webapp_id(web_app)
1865@@ -81,6 +102,15 @@
1866 pass
1867
1868
1869+def get_webdriver(cleanup_method):
1870+ """ Retrieve the webdriver for the current webapp container """
1871+ driver = setup_webdriver()
1872+ cleanup_method(driver.quit)
1873+
1874+ driver.implicitly_wait(30)
1875+ return driver
1876+
1877+
1878 def setup_webdriver():
1879 options = _get_webdriver_options()
1880 chromedriver_exec_path = get_chromedriver_exec_path()
1881
1882=== modified file 'ubuntu_system_tests/helpers/webapp/ebay.py'
1883--- ubuntu_system_tests/helpers/webapp/ebay.py 2015-10-15 03:11:59 +0000
1884+++ ubuntu_system_tests/helpers/webapp/ebay.py 2016-02-10 11:57:12 +0000
1885@@ -20,8 +20,31 @@
1886
1887 from selenium.webdriver.support.ui import WebDriverWait
1888
1889+from ubuntu_system_tests.helpers.unity8 import close_app
1890+from ubuntu_system_tests.helpers import webapp
1891 from ubuntu_system_tests.helpers.webapp import BasePage
1892
1893+WEBAPP_NAME = 'eBay'
1894+WEBAPP_PACKAGE = 'com.ubuntu.developer.webapps.webapp-ebay'
1895+WEBAPP_WIN_ID = 'com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay'
1896+
1897+
1898+def launch_ebay_webapp():
1899+ """ Launch the Ebay webapp from apps scope and return its proxy object
1900+ """
1901+ return webapp.launch_webapp(WEBAPP_NAME, WEBAPP_PACKAGE)
1902+
1903+
1904+def close_ebay_webapp():
1905+ """ Close the ebay webapp using task switcher """
1906+ if is_ebay_webapp_running():
1907+ close_app(WEBAPP_WIN_ID)
1908+
1909+
1910+def is_ebay_webapp_running():
1911+ """ Indicate if the ebay webapp is currently running """
1912+ return webapp.is_webapp_runing(WEBAPP_PACKAGE)
1913+
1914
1915 class Homepage(BasePage):
1916 _search_box_id = 'kw'
1917
1918=== modified file 'ubuntu_system_tests/helpers/webapp/here.py'
1919--- ubuntu_system_tests/helpers/webapp/here.py 2015-10-21 05:52:09 +0000
1920+++ ubuntu_system_tests/helpers/webapp/here.py 2016-02-10 11:57:12 +0000
1921@@ -25,8 +25,32 @@
1922 from selenium.webdriver.support import expected_conditions as EC
1923 from selenium.webdriver.support.ui import WebDriverWait
1924
1925+from ubuntu_system_tests.helpers.unity8 import close_app
1926+from ubuntu_system_tests.helpers import webapp
1927 from ubuntu_system_tests.helpers.webapp import BasePage
1928
1929+WEBAPP_NAME = 'HERE Maps'
1930+WEBAPP_PACKAGE = 'com.nokia.heremaps'
1931+WEBAPP_WIN_ID = 'com.nokia.heremaps_here'
1932+
1933+
1934+def launch_here_webapp():
1935+ """ Launch the Here webapp from apps scope and return its proxy object
1936+ """
1937+ return webapp.launch_webapp(WEBAPP_NAME, WEBAPP_PACKAGE)
1938+
1939+
1940+def close_here_webapp():
1941+ """ Close the here webapp using task switcher """
1942+ if is_here_webapp_running():
1943+ close_app(WEBAPP_WIN_ID)
1944+
1945+
1946+def is_here_webapp_running():
1947+ """ Indicate if the here webapp is currently running """
1948+ webapp_package = WEBAPP_PACKAGE
1949+ return webapp.is_webapp_runing(webapp_package)
1950+
1951
1952 class Homepage(BasePage):
1953 _my_location = "//a[@class='mh5_Button position available']"
1954
1955=== modified file 'ubuntu_system_tests/helpers/webbrowser/__init__.py'
1956--- ubuntu_system_tests/helpers/webbrowser/__init__.py 2016-01-26 18:36:22 +0000
1957+++ ubuntu_system_tests/helpers/webbrowser/__init__.py 2016-02-10 11:57:12 +0000
1958@@ -2,7 +2,7 @@
1959
1960 #
1961 # Ubuntu System Tests
1962-# Copyright (C) 2015 Canonical
1963+# Copyright (C) 2015-2016 Canonical
1964 #
1965 # This program is free software: you can redistribute it and/or modify
1966 # it under the terms of the GNU General Public License as published by
1967@@ -18,9 +18,58 @@
1968 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1969 #
1970
1971+from ubuntu_system_tests.helpers import autopilot
1972 from ubuntu_system_tests.helpers import processes
1973+from ubuntu_system_tests.helpers.scopes.apps import (
1974+ launch_application_from_apps_scope
1975+)
1976+from ubuntu_system_tests.helpers.unity8 import (
1977+ close_app, launch_application_from_launcher
1978+)
1979
1980 APP = 'webbrowser-app'
1981+APP_NAME = 'Browser'
1982+APP_WIN_ID = 'webbrowser-app'
1983+
1984+
1985+def launch_webbrowser_app():
1986+ """
1987+ Launch the webbrowser app from apps scope and return proxy object.
1988+
1989+ :return: Proxy object for webbrowser application.
1990+
1991+ """
1992+ launch_application_from_apps_scope(APP_NAME)
1993+ return get_webbrowser_app_proxy()
1994+
1995+
1996+def close_webbrowser_app():
1997+ """ Close the webbrowser app using task switcher """
1998+ if is_webbrowser_app_running():
1999+ close_app(APP_WIN_ID)
2000+
2001+
2002+def is_webbrowser_app_running():
2003+ """ Indicate if the webbrowser app is currently running """
2004+ return processes.is_process_running(APP)
2005+
2006+
2007+def get_webbrowser_app_proxy():
2008+ """
2009+ Return webbrowser app proxy object from existing process.
2010+
2011+ :return: Proxy object for webbrowser application.
2012+
2013+ """
2014+ from ubuntu_system_tests.helpers.webbrowser import _cpo # NOQA
2015+ proxy = autopilot.get_proxy_object_for_existing_app(APP)
2016+ return proxy.main_window
2017+
2018+
2019+def launch_webbrowser_from_launcher():
2020+ """Start webbrowser from the launcher."""
2021+ launch_application_from_launcher(APP_WIN_ID)
2022+ return get_webbrowser_app_proxy()
2023
2024
2025 def get_webbrowser_process_id():
2026
2027=== modified file 'ubuntu_system_tests/tests/app_startup/test_application_startup.py'
2028--- ubuntu_system_tests/tests/app_startup/test_application_startup.py 2016-01-28 22:33:33 +0000
2029+++ ubuntu_system_tests/tests/app_startup/test_application_startup.py 2016-02-10 11:57:12 +0000
2030@@ -23,17 +23,31 @@
2031 import traceback
2032
2033 from ubuntu_system_tests import config
2034-from ubuntu_system_tests.helpers import autopilot
2035+from ubuntu_system_tests.helpers import addressbook
2036+from ubuntu_system_tests.helpers.autopilot.platform import (
2037+ get_channel_name, get_device_name, get_build_number
2038+)
2039+from ubuntu_system_tests.helpers import calculator
2040+from ubuntu_system_tests.helpers import camera
2041 from ubuntu_system_tests.helpers.camera.fixture_setup import (
2042 SetCameraAccessRequests
2043 )
2044+from ubuntu_system_tests.helpers import clock
2045 from ubuntu_system_tests.helpers.clock.fixture_setup import (
2046 SetClockAccessRequests)
2047+from ubuntu_system_tests.helpers import context
2048+from ubuntu_system_tests.helpers import dialer_app
2049 from ubuntu_system_tests.helpers import file_system as fs
2050+from ubuntu_system_tests.helpers import gallery
2051 from ubuntu_system_tests.helpers.location.fixture_setup import (
2052 SetLocationAccessRequests)
2053+from ubuntu_system_tests.helpers import music
2054+from ubuntu_system_tests.helpers import messaging
2055+from ubuntu_system_tests.helpers import system_settings
2056 from ubuntu_system_tests.helpers.testbed import run_command_with_sudo
2057 from ubuntu_system_tests.helpers import timer
2058+from ubuntu_system_tests.helpers.webapp import ebay, here
2059+from ubuntu_system_tests.helpers import webbrowser
2060 from ubuntu_system_tests.helpers.webbrowser.fixture_setup import (
2061 WebbrowserTestEnvironment
2062 )
2063@@ -52,10 +66,14 @@
2064
2065 def setUp(self):
2066 super().setUp()
2067+ self._setup_timers()
2068 self.shell = self.restart_unity()
2069 self.addCleanup(self._clear_qml_cache)
2070 self._log_global_info()
2071
2072+ def _setup_timers(self):
2073+ context.shared.timers.append(timer.LAUNCH_ID)
2074+
2075 def _clear_qml_cache(self):
2076 fs.clean_dir(os.path.join(fs.DIR_HOME_CACHE, 'QML'))
2077 run_command_with_sudo('sysctl -w vm.drop_caches=3')
2078@@ -74,9 +92,9 @@
2079
2080 def _log_global_info(self):
2081 global_info = {"run_id": RUN_ID,
2082- "device": autopilot.get_device_name(),
2083- "channel": autopilot.get_channel_name(),
2084- "build_number": autopilot.get_build_number()}
2085+ "device": get_device_name(),
2086+ "channel": get_channel_name(),
2087+ "build_number": get_build_number()}
2088
2089 logger.info("Global Info <= {}".format(global_info))
2090
2091@@ -121,43 +139,44 @@
2092 class AppStartupTestCase(BaseAppStartupTestCase):
2093
2094 def test_dialer_startup(self):
2095- self._run_test('dialer', self.launch_dialer_app,
2096- self.close_dialer_app,
2097+ self._run_test('dialer', dialer_app.launch_dialer_app,
2098+ dialer_app.close_dialer_app,
2099 loaded_method=self.shell.ensure_app_loaded)
2100
2101 def test_calculator_startup(self):
2102- self._run_test('calculator', self.launch_calculator_app,
2103- self.close_calculator_app,
2104+ self._run_test('calculator', calculator.launch_calculator_app,
2105+ calculator.close_calculator_app,
2106 loaded_method=self.shell.ensure_app_loaded)
2107
2108 def test_address_book_startup(self):
2109- self._run_test('address_book', self.launch_address_book,
2110- self.close_address_book,
2111+ self._run_test('address_book', addressbook.launch_address_book,
2112+ addressbook.close_address_book,
2113 loaded_method=self.shell.ensure_app_loaded)
2114
2115 def test_messaging_startup(self):
2116- self._run_test('messaging', self.launch_messaging_app,
2117- self.close_messaging_app,
2118+ self._run_test('messaging', messaging.launch_messaging_app,
2119+ messaging.close_messaging_app,
2120 loaded_method=self.shell.ensure_app_loaded)
2121
2122 def test_ebay_startup(self):
2123- self._run_test('ebay', self.launch_ebay_webapp,
2124- self.close_ebay_webapp,
2125+ self._run_test('ebay', ebay.launch_ebay_webapp,
2126+ ebay.close_ebay_webapp,
2127 loaded_method=self.shell.ensure_app_loaded)
2128
2129 def test_system_settings_startup(self):
2130- self._run_test('system_settings', self.launch_system_settings,
2131- self.close_system_settings,
2132+ self._run_test('system_settings',
2133+ system_settings.launch_system_settings,
2134+ system_settings.close_system_settings,
2135 loaded_method=self.shell.ensure_app_loaded)
2136
2137 def test_gallery_startup(self):
2138- self._run_test('gallery', self.launch_gallery_app_from_launcher,
2139- self.close_gallery_app,
2140+ self._run_test('gallery', gallery.launch_gallery_app_from_launcher,
2141+ gallery.close_gallery_app,
2142 loaded_method=self.shell.ensure_app_loaded)
2143
2144 def test_music_startup(self):
2145- self._run_test('music', self.launch_music_app,
2146- self.close_music_app,
2147+ self._run_test('music', music.launch_music_app,
2148+ music.close_music_app,
2149 loaded_method=self.shell.ensure_app_loaded)
2150
2151
2152@@ -168,12 +187,12 @@
2153 super().setUp()
2154
2155 def _launch_camera_app(self):
2156- camera = self.launch_camera_app()
2157- camera.ensure_camera_ready()
2158+ camera_app = camera.launch_camera_app()
2159+ camera_app.ensure_camera_ready()
2160
2161 def test_camera_startup(self):
2162 self._run_test('camera', self._launch_camera_app,
2163- self.close_camera_app)
2164+ camera.close_camera_app)
2165
2166
2167 class WebBrowserAppStartupTestCase(BaseAppStartupTestCase):
2168@@ -183,8 +202,8 @@
2169 super().setUp()
2170
2171 def test_webbrowser_startup(self):
2172- self._run_test('webbrowser', self.launch_webbrowser_app,
2173- self.close_webbrowser_app,
2174+ self._run_test('webbrowser', webbrowser.launch_webbrowser_app,
2175+ webbrowser.close_webbrowser_app,
2176 loaded_method=self.shell.ensure_app_loaded)
2177
2178
2179@@ -195,8 +214,8 @@
2180 super().setUp()
2181
2182 def test_clock_startup(self):
2183- self._run_test('clock', self.launch_clock_app,
2184- self.close_clock_app,
2185+ self._run_test('clock', clock.launch_clock_app,
2186+ clock.close_clock_app,
2187 loaded_method=self.shell.ensure_app_loaded)
2188
2189
2190@@ -207,6 +226,6 @@
2191 super().setUp()
2192
2193 def test_here_startup(self):
2194- self._run_test('here', self.launch_here_webapp,
2195- self.close_here_webapp,
2196+ self._run_test('here', here.launch_here_webapp,
2197+ here.close_here_webapp,
2198 loaded_method=self.shell.ensure_app_loaded)
2199
2200=== modified file 'ubuntu_system_tests/tests/base.py'
2201--- ubuntu_system_tests/tests/base.py 2016-02-05 19:18:50 +0000
2202+++ ubuntu_system_tests/tests/base.py 2016-02-10 11:57:12 +0000
2203@@ -2,7 +2,7 @@
2204
2205 #
2206 # Ubuntu System Tests
2207-# Copyright (C) 2014, 2015 Canonical
2208+# Copyright (C) 2014-2016 Canonical
2209 #
2210 # This program is free software: you can redistribute it and/or modify
2211 # it under the terms of the GNU General Public License as published by
2212@@ -23,7 +23,6 @@
2213 import psutil
2214 from retrying import retry
2215 import stat
2216-import subprocess
2217 from tempfile import mkstemp
2218 import threading
2219
2220@@ -31,12 +30,10 @@
2221 exceptions,
2222 get_test_configuration,
2223 input,
2224- introspection,
2225 logging as autopilot_logging,
2226 testcase
2227 )
2228 from autopilot.matchers import Eventually
2229-import ubuntuuitoolkit
2230 from autopilot._fixtures import OSKAlwaysEnabled
2231 from autopilot.introspection import _object_registry as object_registry
2232 from testtools.matchers import Equals
2233@@ -44,30 +41,20 @@
2234 from unity8 import process_helpers
2235 from unity8.sensors import FakePlatformSensors
2236
2237-from ubuntu_system_tests.helpers import autopilot as autopilot_helpers
2238-from ubuntu_system_tests.helpers import click
2239+from ubuntu_system_tests.helpers import autopilot
2240+from ubuntu_system_tests.helpers import context
2241 from ubuntu_system_tests.helpers import images
2242 from ubuntu_system_tests.helpers import mir
2243-from ubuntu_system_tests.helpers import processes
2244 from ubuntu_system_tests.helpers import screen
2245-from ubuntu_system_tests.helpers import timer
2246 from ubuntu_system_tests.helpers import unity8
2247+from ubuntu_system_tests.helpers.unity8 import get_dash
2248+from ubuntu_system_tests.helpers.unity8.shell import Unity8 # NOQA
2249 from ubuntu_system_tests.helpers import wait_until
2250 from ubuntu_system_tests.helpers import webapp
2251-from ubuntu_system_tests.helpers.processes import ensure_application_closed
2252-from ubuntu_system_tests.helpers.scopes import go_to_apps_scope
2253-from ubuntu_system_tests.helpers.unity8 import get_dash
2254-from ubuntu_system_tests.helpers.unity8.shell import Unity8 # NOQA
2255
2256 # Any test name ending with this will leave device locked
2257 TEST_ID_DEVICE_LOCKED = 'device_locked'
2258
2259-# Apps and cleanup names
2260-CALCULATOR_APP = 'ubuntu-calculator-app'
2261-
2262-CATEGORY_LOCAL = 'local'
2263-CATEGORY_PREDEFINED = 'predefined'
2264-
2265 logger = logging.getLogger(__name__)
2266
2267
2268@@ -86,6 +73,21 @@
2269 def setUp(self):
2270 super().setUp()
2271 self._reset_autopilot_registry()
2272+ self._init_shared_context()
2273+
2274+ def _init_shared_context(self):
2275+ # The shared context is reset for each test
2276+ context.shared.clear()
2277+ context.shared.add_cleanup = self.addCleanup
2278+ context.shared.timers = []
2279+
2280+ # Retry added until fix for bug 1427946 in QtMir is landed
2281+ @retry(stop_max_delay=30000,
2282+ retry_on_exception=lambda exception: (
2283+ isinstance(exception, psutil.NoSuchProcess) or
2284+ isinstance(exception, ValueError)))
2285+ def _get_unity8_proxy_object(self):
2286+ return autopilot.get_job_proxy_object('unity8')
2287
2288 @autopilot_logging.log_action(logger.info)
2289 def launch_unity(self, fake_sensors=False):
2290@@ -111,7 +113,8 @@
2291 else:
2292 self._start_unity_with_testability()
2293
2294- unity = self.get_job_proxy_object('unity8')
2295+ unity = self._get_unity8_proxy_object()
2296+ context.shared.unity = unity
2297 unity.wait_for_greeter_content()
2298 # Workaround to remove the UInput keyboard created by autopilot.
2299 # This stops the OSK from being displayed, so must remove it.
2300@@ -125,21 +128,6 @@
2301 def _start_unity_with_testability(self):
2302 process_helpers.start_job('unity8', 'QT_LOAD_TESTABILITY=1')
2303
2304- # Retry added until fix for bug 1427946 in QtMir is landed
2305- @retry(stop_max_delay=30000,
2306- retry_on_exception=lambda exception: (
2307- isinstance(exception, psutil.NoSuchProcess) or
2308- isinstance(exception, ValueError)))
2309- def get_job_proxy_object(self, pname):
2310- pid = process_helpers.get_job_pid(pname)
2311- return self.get_proxy_object(pid)
2312-
2313- def get_proxy_object(self, pid):
2314- return introspection.get_proxy_object_for_existing_process(
2315- pid=pid,
2316- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase,
2317- )
2318-
2319 def _remove_autopilot_keyboard(self):
2320 """Remove the UInput simulated keyboard automatically created by
2321 autopilot which stops the OSK from appearing."""
2322@@ -225,13 +213,9 @@
2323 test_id = self.id().split('.')[-1]
2324 return not test_id.endswith(TEST_ID_DEVICE_LOCKED)
2325
2326- def ensure_application_closed(self, app_name):
2327- """Stop the app before unity8 is restarted so it's not orphaned."""
2328- subprocess.call(['ubuntu-app-stop', app_name])
2329-
2330 def _get_screenshot_size(self, x, y, width, height):
2331 """ Calculate the screenshot size """
2332- unity = self.get_job_proxy_object('unity8')
2333+ unity = context.shared.unity
2334 if width and height:
2335 return width, height
2336 else:
2337@@ -251,461 +235,6 @@
2338 return images.get_image_from_rgba(
2339 file_path, self._get_screenshot_size(x, y, width, height))
2340
2341- def _launch_application_from_apps_scope(self, app_name, category=None):
2342- """
2343- Launch an app from apps scope and return proxy object.
2344-
2345- :param app_name: Name of the displayed application.
2346- :param category: Category name app is displayed in. If None then the
2347- category name will be discovered automatically.
2348- :return: Proxy object for application.
2349-
2350- """
2351- apps_scope = go_to_apps_scope()
2352- if not category:
2353- category = apps_scope.get_app_category(app_name)
2354- apps_scope.click_scope_item(category, app_name)
2355-
2356- def _launch_application_from_launcher(self, app_name):
2357- """
2358- Launch an app from the launcher.
2359-
2360- :param app_name: Name of the displayed application.
2361-
2362- """
2363- unity = self.get_job_proxy_object('unity8')
2364- timer.start(timer.LAUNCH_ID)
2365- unity.main_window.launch_application(app_name)
2366-
2367- def _get_proxy_object_for_existing_app(
2368- self,
2369- process_name,
2370- cleanup_process=None,
2371- base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
2372- """
2373- Return proxy object from existing application process.
2374-
2375- Add cleanup action to close the application using cleanup_process
2376- parameter. If cleanup_process is None then process_name is used as the
2377- cleanup target using ensure_application_closed().
2378-
2379- :param process_name: Name of required application process.
2380- :param cleanup_process: Name of process to clean up.
2381- :param base: custom emulator base for proxy object
2382- :return: Proxy object for the desired application.
2383-
2384- """
2385- if not cleanup_process:
2386- cleanup_process = process_name
2387- proxy = autopilot_helpers.get_proxy_object_for_existing_process(
2388- process_name,
2389- base)
2390- self.addCleanup(ensure_application_closed, cleanup_process)
2391- return proxy
2392-
2393- def _get_proxy_object_for_existing_qmlscene_process(self, qmlfile):
2394- """
2395- Return proxy object from existing qmlscene process.
2396-
2397- Add cleanup action to close the application using cleanup_process
2398- parameter. If cleanup_process is None then process_id is used as the
2399- cleanup target using processes.stop_qmlscene_process().
2400-
2401- :param qmlfile: Thje name of the QML file for the required process
2402- :return: Proxy object for the desired qmlscene process
2403-
2404- """
2405- process_id = processes.get_qmlscene_process_id(qmlfile)
2406- proxy = introspection.get_proxy_object_for_existing_process(
2407- pid=process_id,
2408- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase
2409- )
2410- self.addCleanup(processes.stop_qmlscene_process, qmlfile)
2411- return proxy
2412-
2413- def _get_proxy_object_for_existing_webapp(self, qmlfile):
2414- """
2415- Return proxy object from existing qmlscene process.
2416-
2417- Add cleanup action to close the application using cleanup_process
2418- parameter. If cleanup_process is None then process_id is used as the
2419- cleanup target using processes.stop_qmlscene_process().
2420-
2421- :param qmlfile: Thje name of the QML file for the required process
2422- :return: Proxy object for the desired qmlscene process
2423-
2424- """
2425- process_id = processes.get_qmlscene_process_id(qmlfile)
2426- proxy = introspection.get_proxy_object_for_existing_process(
2427- pid=process_id,
2428- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase
2429- )
2430- self.addCleanup(processes.stop_qmlscene_process, qmlfile)
2431- return proxy
2432-
2433- def launch_address_book(self):
2434- """
2435- Launch the address book app from apps scope and return proxy object.
2436-
2437- :return: Proxy object for address book application.
2438-
2439- """
2440- self._launch_application_from_apps_scope(
2441- 'Contacts', CATEGORY_PREDEFINED)
2442- return self.get_address_book_app_proxy()
2443-
2444- def close_address_book(self):
2445- """ Close the address book app using task switcher """
2446- if self.is_address_book_app_running():
2447- self._close_app('address-book-app')
2448-
2449- def is_address_book_app_running(self):
2450- """ Indicate if the address book app is currently running """
2451- return processes.is_process_running('address-book-app')
2452-
2453- def launch_address_book_from_launcher(self):
2454- """Drag out the launcher and tap the address book icon to start it."""
2455- self._launch_application_from_launcher('address-book-app')
2456- return self.get_address_book_app_proxy()
2457-
2458- def get_address_book_app_proxy(self):
2459- """
2460- Return address book app proxy object from existing process.
2461-
2462- :return: Proxy object for address book application.
2463-
2464- """
2465- from ubuntu_system_tests.helpers.addressbook import _cpo # NOQA
2466- wait_until(self.is_address_book_app_running, period=0.5)
2467- proxy = self._get_proxy_object_for_existing_app('address-book-app')
2468- return proxy.main_window
2469-
2470- def launch_camera_app(self):
2471- """
2472- Launch the camera app from dash and return proxy object.
2473-
2474- :return: Proxy object for camera application.
2475-
2476- """
2477- self._launch_application_from_apps_scope('Camera', CATEGORY_PREDEFINED)
2478- return self.get_camera_app_proxy()
2479-
2480- def close_camera_app(self):
2481- """ Close the camera app using task switcher """
2482- if self.is_camera_app_running():
2483- self._close_app('com.ubuntu.camera_camera')
2484-
2485- def is_camera_app_running(self):
2486- """ Indicate if the camera app is currently running """
2487- return processes.is_process_running('camera-app')
2488-
2489- def launch_camera_app_from_launcher(self):
2490- """Drag out the launcher and tap the camera icon to start it."""
2491- self._launch_application_from_launcher('com.ubuntu.camera_camera')
2492- return self.get_camera_app_proxy()
2493-
2494- def get_camera_app_proxy(self):
2495- """
2496- Return camera app proxy object from existing process and add
2497- cleanup actions to close the application.
2498-
2499- :return: Proxy object for camera application.
2500-
2501- """
2502- from ubuntu_system_tests.helpers.camera._cpo import MainWindow
2503- wait_until(self.is_camera_app_running, period=0.5)
2504- proxy = self._get_proxy_object_for_existing_app(
2505- 'camera-app',
2506- cleanup_process=click.get_click_app_identifier('com.ubuntu.camera')
2507- )
2508- return MainWindow(proxy)
2509-
2510- def launch_dialer_app(self):
2511- """
2512- Launch the dialer app from apps scope and return proxy object.
2513-
2514- :return: Proxy object for dialer application.
2515-
2516- """
2517- self._launch_application_from_apps_scope('Phone', CATEGORY_PREDEFINED)
2518- return self.get_dialer_app_proxy()
2519-
2520- def close_dialer_app(self):
2521- """ Close the dialer app using task switcher """
2522- if self.is_dialer_app_running():
2523- self._close_app('dialer-app')
2524-
2525- def is_dialer_app_running(self):
2526- """ Indicate if the dialer app is currently running """
2527- return processes.is_process_running('dialer-app')
2528-
2529- def get_dialer_app_proxy(self):
2530- """
2531- Return dialer app proxy object from existing process.
2532-
2533- :return: Proxy object for dialer application.
2534-
2535- """
2536- from ubuntu_system_tests.helpers.dialer_app import _cpo # NOQA
2537- wait_until(self.is_dialer_app_running, period=0.5)
2538- proxy = self._get_proxy_object_for_existing_app('dialer-app')
2539- return proxy.main_view
2540-
2541- def launch_gallery_app(self):
2542- """
2543- Launch the gallery app from apps scope and return proxy object.
2544-
2545- :return: Proxy object for gallery application.
2546-
2547- """
2548- from ubuntu_system_tests.helpers.gallery._cpo import EventsView
2549- self._launch_application_from_apps_scope('Gallery', CATEGORY_LOCAL)
2550- return EventsView(self.get_gallery_app_proxy())
2551-
2552- def close_gallery_app(self):
2553- """ Close the gallery app using task switcher """
2554- if self.is_gallery_app_running():
2555- self._close_app('com.ubuntu.gallery_gallery')
2556-
2557- def is_gallery_app_running(self):
2558- """ Indicate if the gallery app is currently running """
2559- return processes.is_process_running('gallery-app')
2560-
2561- def get_gallery_app_proxy(self):
2562- """
2563- Return gallery app proxy object from existing process.
2564-
2565- :return: Proxy object for gallery application.
2566-
2567- """
2568- wait_until(self.is_gallery_app_running, period=0.5)
2569- proxy = self._get_proxy_object_for_existing_app(
2570- 'gallery-app',
2571- cleanup_process=click.get_click_app_identifier(
2572- 'com.ubuntu.gallery'))
2573- return proxy
2574-
2575- def get_gallery_events_view(self):
2576- """Return a gallery_app EventsView custom proxy object."""
2577- from ubuntu_system_tests.helpers.gallery._cpo import EventsView
2578- return EventsView(self.get_gallery_app_proxy())
2579-
2580- def get_gallery_photo_viewer(self):
2581- """Return a gallery_app PhotoViewer custom proxy object."""
2582- from ubuntu_system_tests.helpers.gallery._cpo import PhotoViewer
2583- return PhotoViewer(self.get_gallery_app_proxy())
2584-
2585- def get_media_player_proxy(self):
2586- """
2587- Return media player app proxy object from existing process.
2588-
2589- :return: Proxy object for media player application.
2590-
2591- """
2592- from ubuntu_system_tests.helpers.mediaplayer._cpo import MainWindow
2593- proxy = self._get_proxy_object_for_existing_app('mediaplayer-app')
2594- return MainWindow(proxy)
2595-
2596- def launch_messaging_app(self):
2597- """
2598- Launch the messaging app from apps scope and return proxy object.
2599-
2600- :return: Proxy object for messaging application.
2601-
2602- """
2603- self._launch_application_from_apps_scope(
2604- 'Messaging', CATEGORY_PREDEFINED)
2605- return self.get_messaging_app_proxy()
2606-
2607- def close_messaging_app(self):
2608- """ Close the messaging app using task switcher """
2609- if self.is_messaging_app_running():
2610- self._close_app('messaging-app')
2611-
2612- def is_messaging_app_running(self):
2613- """ Indicate if the messaging app is currently running """
2614- return processes.is_process_running('messaging-app')
2615-
2616- def get_messaging_app_proxy(
2617- self, base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
2618- """
2619- Return messaging app proxy object from existing process.
2620-
2621- :return: Proxy object for messaging application.
2622-
2623- """
2624- wait_until(self.is_messaging_app_running, period=0.5)
2625- if not base:
2626- return self._get_proxy_object_for_existing_app('messaging-app',
2627- base=base)
2628-
2629- from ubuntu_system_tests.helpers.messaging._cpo import MainView
2630- proxy = self._get_proxy_object_for_existing_app('messaging-app')
2631- return proxy.wait_select_single(MainView)
2632-
2633- def launch_system_settings(self):
2634- """
2635- Launch system settings from apps scope and return proxy object.
2636-
2637- :return: Proxy object for system settings.
2638-
2639- """
2640- self._launch_application_from_apps_scope(
2641- 'System Settings', CATEGORY_LOCAL)
2642- return self.get_system_settings_proxy()
2643-
2644- def close_system_settings(self):
2645- """ Close the system settings app using task switcher """
2646- if self.is_system_settings_running():
2647- self._close_app('ubuntu-system-settings')
2648-
2649- def is_system_settings_running(self):
2650- """ Indicate if the system settings is currently running """
2651- return processes.is_process_running('system-settings')
2652-
2653- def get_system_settings_proxy(self):
2654- """
2655- Return system settings proxy object from existing process.
2656-
2657- :return: Proxy object for system settings.
2658-
2659- """
2660- from ubuntu_system_tests.helpers.system_settings import _cpo # NOQA
2661- wait_until(self.is_system_settings_running, period=0.5)
2662- proxy = self._get_proxy_object_for_existing_app(
2663- 'system-settings', cleanup_process='ubuntu-system-settings')
2664- return proxy.main_view
2665-
2666- def launch_webbrowser_app(self):
2667- """
2668- Launch the webbrowser app from apps scope and return proxy object.
2669-
2670- :return: Proxy object for webbrowser application.
2671-
2672- """
2673- self._launch_application_from_apps_scope(
2674- 'Browser', CATEGORY_PREDEFINED)
2675- return self.get_webbrowser_app_proxy()
2676-
2677- def close_webbrowser_app(self):
2678- """ Close the webbrowser app using task switcher """
2679- if self.is_webbrowser_app_running():
2680- self._close_app('webbrowser-app')
2681-
2682- def is_webbrowser_app_running(self):
2683- """ Indicate if the webbrowser app is currently running """
2684- return processes.is_process_running('webbrowser-app')
2685-
2686- def get_webbrowser_app_proxy(self):
2687- """
2688- Return webbrowser app proxy object from existing process.
2689-
2690- :return: Proxy object for webbrowser application.
2691-
2692- """
2693- from ubuntu_system_tests.helpers.webbrowser import _cpo # NOQA
2694- wait_until(self.is_webbrowser_app_running, period=0.5)
2695- proxy = self._get_proxy_object_for_existing_app('webbrowser-app')
2696- return proxy.main_window
2697-
2698- def launch_calendar_app(self):
2699- """
2700- Launch the calendar app from apps scope and return proxy object.
2701-
2702- :return: Proxy object for calendar application.
2703-
2704- """
2705- self._launch_application_from_apps_scope('Calendar', CATEGORY_LOCAL)
2706- wait_until(self.is_calendar_app_running, period=0.5)
2707-
2708- return self.get_calendar_app_proxy()
2709-
2710- def close_calendar_app(self):
2711- """ Close the calendar app using task switcher """
2712- if self.is_calendar_app_running():
2713- self._close_app('calendar')
2714-
2715- def is_calendar_app_running(self):
2716- """ Indicate if the calendar app is currently running """
2717- return processes.is_qmlscene_running_with_qmlfile('calendar')
2718-
2719- def get_calendar_app_proxy(self):
2720- """
2721- Return calendar app proxy object from existing process.
2722-
2723- :return: Proxy object for calendar application.
2724-
2725- """
2726- proxy = self._get_proxy_object_for_existing_qmlscene_process(
2727- 'calendar')
2728- return proxy.main_window
2729-
2730- def launch_clock_app(self):
2731- """
2732- Launch the clock app from apps scope and return proxy object.
2733-
2734- :return: Proxy object for clock application.
2735-
2736- """
2737- self._launch_application_from_apps_scope('Clock', CATEGORY_PREDEFINED)
2738- wait_until(self.is_clock_app_running, period=0.5)
2739- return self.get_clock_app_proxy()
2740-
2741- def close_clock_app(self):
2742- """ Close the calendar app using task switcher """
2743- if self.is_clock_app_running():
2744- self._close_app('com.ubuntu.clock_clock')
2745-
2746- def is_clock_app_running(self):
2747- """ Indicate if the clock app is currently running """
2748- return processes.is_qmlscene_running_with_qmlfile('ubuntu-clock-app')
2749-
2750- def get_clock_app_proxy(self):
2751- """
2752- Return clock app proxy object from existing process.
2753-
2754- :return: Proxy object for calendar application.
2755-
2756- """
2757- from ubuntu_system_tests.helpers.clock import _cpo # NOQA
2758- proxy = self._get_proxy_object_for_existing_qmlscene_process(
2759- 'ubuntu-clock-app')
2760- return proxy.main_view
2761-
2762- def launch_webbrowser_from_launcher(self):
2763- """Start webbrowser from the launcher."""
2764- self._launch_application_from_launcher('webbrowser-app')
2765- return self.get_webbrowser_app_proxy()
2766-
2767- def launch_messaging_app_from_launcher(self):
2768- """Drag out the launcher and tap the messaging app icon to start it."""
2769- self._launch_application_from_launcher('messaging-app')
2770- return self.get_messaging_app_proxy()
2771-
2772- def launch_dialer_app_from_launcher(self):
2773- """Drag out the launcher and tap the dialer app icon to start it."""
2774- self._launch_application_from_launcher('dialer-app')
2775- return self.get_dialer_app_proxy()
2776-
2777- def launch_gallery_app_from_launcher(self):
2778- """Drag out the launcher and tap the gallery app icon to start it."""
2779- self._launch_application_from_launcher('com.ubuntu.gallery_gallery')
2780- return self.get_gallery_app_proxy()
2781-
2782- def get_webapp_proxy(self, web_app_package):
2783- """ Return webapp proxy object from existing process.
2784- :param web_app_package: The package name
2785- :return: Proxy object for webapp.
2786- """
2787- from ubuntu_system_tests.helpers.webapp import _cpo # NOQA
2788-
2789- pid = webapp.get_webapp_pid(web_app_package)
2790- proxy = introspection.get_proxy_object_for_existing_process(
2791- pid=pid,
2792- emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase
2793- )
2794- return proxy.wait_select_single('BrowserWindow')
2795-
2796 def setup_webapp_environment(self):
2797 """ Setup the environment for the webapps. This method has to be
2798 called before launch the first web app in the test.
2799@@ -715,128 +244,3 @@
2800 UBUNTU_WEBVIEW_DEVTOOLS_HOST=webapp.DEFAULT_WEBVIEW_INSPECTOR_IP,
2801 UBUNTU_WEBVIEW_DEVTOOLS_PORT=str(
2802 webapp.DEFAULT_WEBVIEW_INSPECTOR_PORT)))
2803-
2804- def launch_webapp(self, app_name, web_app_package):
2805- """ Launch the webapp and return the webapp proxy object
2806- :param app_name: The name in the apps scope
2807- :param web_app_package: The package name
2808- :return: Proxy object for webapp
2809- """
2810- apps_scope = go_to_apps_scope()
2811- apps_scope.click_scope_item(CATEGORY_LOCAL, app_name)
2812- self.addCleanup(webapp.ensure_webapp_closed, web_app_package)
2813- wait_until(webapp.is_webapp_runing, web_app_package)
2814- return self.get_webapp_proxy(web_app_package)
2815-
2816- def launch_calculator_app(self):
2817- """
2818- Launch calculator app from apps scope and return its proxy object.
2819- """
2820- self._launch_application_from_apps_scope(
2821- 'Calculator', CATEGORY_LOCAL)
2822- wait_until(self.is_calculator_app_running, period=0.5)
2823- return self.get_calculator_app_proxy()
2824-
2825- def close_calculator_app(self):
2826- """ Close the calculator app using task switcher """
2827- if self.is_calculator_app_running():
2828- self._close_app('com.ubuntu.calculator_calculator')
2829-
2830- def is_calculator_app_running(self):
2831- """ Indicate if the calculator app is currently running """
2832- return processes.is_qmlscene_running_with_qmlfile(
2833- 'ubuntu-calculator-app')
2834-
2835- def get_calculator_app_proxy(self):
2836- """Return the proxy object of the calculator app."""
2837- from ubuntu_system_tests.helpers.calculator import _cpo # NOQA
2838- proxy = self._get_proxy_object_for_existing_qmlscene_process(
2839- CALCULATOR_APP)
2840- return proxy.main_view
2841-
2842- def get_ubuntu_keyboard_proxy(self):
2843- from ubuntu_system_tests.helpers.ubuntu_keyboard import _cpo # NOQA
2844- return self._get_proxy_object_for_existing_app('maliit-server')
2845-
2846- def launch_ebay_webapp(self):
2847- """ Launch the Ebay webapp from apps scope and return its proxy object
2848- """
2849- webapp_name = 'eBay'
2850- webapp_package = 'com.ubuntu.developer.webapps.webapp-ebay'
2851- return self.launch_webapp(webapp_name, webapp_package)
2852-
2853- def close_ebay_webapp(self):
2854- """ Close the ebay webapp using task switcher """
2855- if self.is_ebay_webapp_running():
2856- self._close_app(
2857- 'com.ubuntu.developer.webapps.webapp-ebay_webapp-ebay')
2858-
2859- def is_ebay_webapp_running(self):
2860- """ Indicate if the ebay webapp is currently running """
2861- webapp_package = 'com.ubuntu.developer.webapps.webapp-ebay'
2862- return webapp.is_webapp_runing(webapp_package)
2863-
2864- def launch_here_webapp(self):
2865- """ Launch the Here webapp from apps scope and return its proxy object
2866- """
2867- webapp_name = 'HERE Maps'
2868- webapp_package = 'com.nokia.heremaps'
2869- return self.launch_webapp(webapp_name, webapp_package)
2870-
2871- def close_here_webapp(self):
2872- """ Close the here webapp using task switcher """
2873- if self.is_here_webapp_running():
2874- self._close_app('com.nokia.heremaps_here')
2875-
2876- def is_here_webapp_running(self):
2877- """ Indicate if the here webapp is currently running """
2878- webapp_package = 'com.nokia.heremaps'
2879- return webapp.is_webapp_runing(webapp_package)
2880-
2881- def launch_music_app(self):
2882- """
2883- Launch the music app from apps scope and return proxy object.
2884-
2885- :return: Proxy object for music application.
2886-
2887- """
2888- self._launch_application_from_apps_scope('Music')
2889- wait_until(self.is_music_app_running, period=0.5)
2890- return self.get_music_app_proxy()
2891-
2892- def close_music_app(self):
2893- """ Close the music app using task switcher """
2894- if self.is_music_app_running():
2895- self._close_app('com.ubuntu.music_music')
2896-
2897- def is_music_app_running(self):
2898- """ Indicate if the music app is currently running """
2899- return processes.is_qmlscene_running_with_qmlfile('music-app')
2900-
2901- def get_music_app_proxy(self):
2902- """
2903- Return music app proxy object from existing process.
2904-
2905- :return: Proxy object for music application.
2906-
2907- """
2908- proxy = self._get_proxy_object_for_existing_qmlscene_process(
2909- 'music-app')
2910- return proxy.wait_select_single(ubuntuuitoolkit.MainView)
2911-
2912- def _close_app(self, app_name):
2913- """Close an app using task switcher and check process is stopped."""
2914- unity_proxy = self.get_job_proxy_object('unity8')
2915-
2916- # Get the windows name
2917- stage = unity_proxy.main_window.swipe_to_show_app_switcher()
2918- app_window_name = 'appWindow_' + app_name
2919- app_windows = stage.get_app_window_names()
2920- count = len(app_windows)
2921- self.assertTrue(app_window_name in app_windows)
2922-
2923- # Close the windows and assert that it is closed
2924- stage.close_app(app_name)
2925- app_windows = stage.get_app_window_names()
2926- self.assertFalse(app_window_name in app_windows)
2927- self.assertEqual(len(app_windows), count - 1)
2928
2929=== modified file 'ubuntu_system_tests/tests/base_messaging.py'
2930--- ubuntu_system_tests/tests/base_messaging.py 2015-12-22 17:34:23 +0000
2931+++ ubuntu_system_tests/tests/base_messaging.py 2016-02-10 11:57:12 +0000
2932@@ -25,20 +25,17 @@
2933 Contact,
2934 fixture_setup as address_book_fixture
2935 )
2936+from ubuntu_system_tests.helpers import camera
2937 from ubuntu_system_tests.helpers import file_system as fs
2938+from ubuntu_system_tests.helpers import gallery
2939 from ubuntu_system_tests.helpers.messaging import fixture_setup
2940 from ubuntu_system_tests.helpers import messaging as messaging_helpers
2941+from ubuntu_system_tests.helpers import processes
2942 from ubuntu_system_tests.helpers import system_settings
2943-from ubuntu_system_tests.helpers.system_settings import SETTINGS_PROCESS
2944 from ubuntu_system_tests.helpers.unity8 import get_dash
2945 from ubuntu_system_tests.helpers import wait_until
2946 from ubuntu_system_tests.tests.base_telephony import BaseTelephonyTestCase
2947
2948-CAMERA_APP = 'Camera'
2949-CAMERA_PROCESS = 'camera-app'
2950-GALLERY_APP = 'Gallery'
2951-GALLERY_PROCESS = 'gallery-app'
2952-
2953 CONTACT_NAME_1 = 'Fulano de Tal'
2954 REPLY_1 = 'ACK'
2955
2956@@ -63,7 +60,7 @@
2957
2958 def launch_messaging(self):
2959 """Launch the messaging app from apps scope."""
2960- self.main_view = self.launch_messaging_app()
2961+ self.main_view = messaging_helpers.launch_messaging_app()
2962
2963 def get_messaging_app(self):
2964 """
2965@@ -71,7 +68,7 @@
2966 Store proxy object in self.main_view.
2967
2968 """
2969- self.main_view = self.get_messaging_app_proxy()
2970+ self.main_view = messaging_helpers.get_messaging_app_proxy()
2971
2972 def receive_message_and_get_notification(self, to, from_, message,
2973 media_url=None, timeout=60):
2974@@ -463,25 +460,25 @@
2975
2976 def _add_attachment_from_gallery(self, attachment):
2977 """Add an attachment using the gallery app."""
2978- self._open_app_to_attach_content(GALLERY_APP)
2979- gallery_app = self.get_gallery_events_view()
2980- self.addCleanup(self.ensure_application_closed, GALLERY_PROCESS)
2981+ self._open_app_to_attach_content(gallery.APP_NAME)
2982+ gallery_app = gallery.get_gallery_events_view()
2983+ self.addCleanup(processes.ensure_application_closed, gallery.APP)
2984 sample_photo_location = os.path.join(fs.DIR_HOME_CAMERA_PICTURES,
2985 attachment.identifier)
2986 gallery_app.pick_photo(sample_photo_location)
2987
2988 def _add_attachment_from_camera(self, attachment):
2989 """Add an attachment using the camera app."""
2990- self._open_app_to_attach_content(CAMERA_APP)
2991- camera_app = self.get_camera_app_proxy()
2992- self.addCleanup(self.ensure_application_closed, CAMERA_PROCESS)
2993+ self._open_app_to_attach_content(camera.APP_NAME)
2994+ camera_app = camera.get_camera_app_proxy()
2995+ self.addCleanup(processes.ensure_application_closed, camera.APP)
2996 camera_app.take_photo_and_select()
2997
2998 def _add_attachment_from_camera_photoroll(self, attachment):
2999 """Add an attachment using the camera app photoroll."""
3000- self._open_app_to_attach_content(CAMERA_APP)
3001- camera_app = self.get_camera_app_proxy()
3002- self.addCleanup(self.ensure_application_closed, CAMERA_PROCESS)
3003+ self._open_app_to_attach_content(camera.APP_NAME)
3004+ camera_app = camera.get_camera_app_proxy()
3005+ self.addCleanup(processes.ensure_application_closed, camera.APP)
3006 camera_app.swipe_to_gallery(self)
3007 camera_app.select_photo_from_roll()
3008
3009@@ -495,7 +492,7 @@
3010 :param value: Value to set: 'ask', '1' or '2' (sim slot)
3011
3012 """
3013- settings = self.launch_system_settings()
3014+ settings = system_settings.launch_system_settings()
3015 cellular = settings.go_to_cellular_page()
3016
3017 if value is '1' or value is '2':
3018@@ -505,7 +502,8 @@
3019 settings.scroll_to_and_click(selector)
3020 selector.selected.wait_for(True)
3021 self.dash.swipe_screen_from_left()
3022- self.addCleanup(self.ensure_application_closed, SETTINGS_PROCESS)
3023+ self.addCleanup(processes.ensure_application_closed,
3024+ system_settings.APP)
3025
3026 def click_message_url(self, message_text):
3027 """Click the message text in a message bubble."""
3028
3029=== modified file 'ubuntu_system_tests/tests/base_webbrowser.py'
3030--- ubuntu_system_tests/tests/base_webbrowser.py 2015-11-16 12:15:59 +0000
3031+++ ubuntu_system_tests/tests/base_webbrowser.py 2016-02-10 11:57:12 +0000
3032@@ -18,6 +18,7 @@
3033 # along with this program. If not, see <http://www.gnu.org/licenses/>.
3034 #
3035
3036+from ubuntu_system_tests.helpers import webbrowser
3037 from ubuntu_system_tests.helpers.webbrowser.fixture_setup import (
3038 WebbrowserTestEnvironment)
3039 from ubuntu_system_tests.tests import base
3040@@ -29,7 +30,7 @@
3041 super().setUp()
3042 self.useFixture(WebbrowserTestEnvironment())
3043 self.unity_proxy = self.restart_unity()
3044- self.browser = self.launch_webbrowser_app()
3045+ self.browser = webbrowser.launch_webbrowser_app()
3046
3047 def _get_current_url(self):
3048 """Return currently opened url."""
3049
3050=== modified file 'ubuntu_system_tests/tests/indicators/test_indicator_battery.py'
3051--- ubuntu_system_tests/tests/indicators/test_indicator_battery.py 2016-01-15 11:19:35 +0000
3052+++ ubuntu_system_tests/tests/indicators/test_indicator_battery.py 2016-02-10 11:57:12 +0000
3053@@ -55,7 +55,7 @@
3054 3. Ensure battery settings open.
3055 """
3056 self.indicator_page.open_battery_settings()
3057- settings_app = self.get_system_settings_proxy()
3058+ settings_app = system_settings.get_system_settings_proxy()
3059 system_settings.ensure_power_settings_page_visible(settings_app)
3060
3061 @skipUnless(platform.image_codename() in SUPPORTED_DEVICES,
3062
3063=== modified file 'ubuntu_system_tests/tests/indicators/test_indicator_bluetooth.py'
3064--- ubuntu_system_tests/tests/indicators/test_indicator_bluetooth.py 2015-09-14 16:31:29 +0000
3065+++ ubuntu_system_tests/tests/indicators/test_indicator_bluetooth.py 2016-02-10 11:57:12 +0000
3066@@ -41,6 +41,6 @@
3067 3. Ensure bluetooth settings open
3068 """
3069 self.indicator_page.open_bluetooth_settings()
3070- settings_app = self.get_system_settings_proxy()
3071+ settings_app = system_settings.get_system_settings_proxy()
3072 system_settings.ensure_settings_page_visible(settings_app,
3073 BLUETOOTH_SETTINGS_PAGE)
3074
3075=== modified file 'ubuntu_system_tests/tests/indicators/test_indicator_datetime.py'
3076--- ubuntu_system_tests/tests/indicators/test_indicator_datetime.py 2015-09-14 16:31:29 +0000
3077+++ ubuntu_system_tests/tests/indicators/test_indicator_datetime.py 2016-02-10 11:57:12 +0000
3078@@ -41,6 +41,6 @@
3079 3. Ensure date time settings open.
3080 """
3081 self.indicator_page.open_date_time_settings()
3082- settings_app = self.get_system_settings_proxy()
3083+ settings_app = system_settings.get_system_settings_proxy()
3084 system_settings.ensure_settings_page_visible(settings_app,
3085 DATETIME_SETTINGS_PAGE)
3086
3087=== modified file 'ubuntu_system_tests/tests/indicators/test_indicator_network.py'
3088--- ubuntu_system_tests/tests/indicators/test_indicator_network.py 2015-10-22 14:58:41 +0000
3089+++ ubuntu_system_tests/tests/indicators/test_indicator_network.py 2016-02-10 11:57:12 +0000
3090@@ -21,8 +21,8 @@
3091 from testtools.matchers import Equals, NotEquals
3092 from testtools import skipUnless
3093
3094+from ubuntu_system_tests.helpers.autopilot.platform import is_wifi_supported
3095 from ubuntu_system_tests.helpers import (
3096- autopilot,
3097 ofono,
3098 radio_killswitch,
3099 network,
3100@@ -49,7 +49,7 @@
3101
3102 class FlightModeTestCase(NetworkIndicatorBase):
3103
3104- @skipUnless(ofono.is_sim_inserted() and autopilot.is_wifi_supported(),
3105+ @skipUnless(ofono.is_sim_inserted() and is_wifi_supported(),
3106 'SIM and Wi-Fi support required.')
3107 def setUp(self):
3108 self.radio_killswitch = self.useFixture(
3109@@ -168,7 +168,7 @@
3110 3. Ensure cellular settings open
3111 """
3112 self.indicator_page.open_cellular_settings()
3113- settings_app = self.get_system_settings_proxy()
3114+ settings_app = system_settings.get_system_settings_proxy()
3115 system_settings.ensure_settings_page_visible(settings_app,
3116 CELLULAR_SETTINGS_PAGE)
3117
3118@@ -179,6 +179,6 @@
3119 3. Ensure Wifi settings open
3120 """
3121 self.indicator_page.open_wifi_settings()
3122- settings_app = self.get_system_settings_proxy()
3123+ settings_app = system_settings.get_system_settings_proxy()
3124 system_settings.ensure_settings_page_visible(settings_app,
3125 WIFI_SETTINGS_PAGE)
3126
3127=== modified file 'ubuntu_system_tests/tests/indicators/test_indicator_sound.py'
3128--- ubuntu_system_tests/tests/indicators/test_indicator_sound.py 2015-09-14 16:31:29 +0000
3129+++ ubuntu_system_tests/tests/indicators/test_indicator_sound.py 2016-02-10 11:57:12 +0000
3130@@ -41,6 +41,6 @@
3131 3. Ensure sound settings open
3132 """
3133 self.indicator_page.open_sound_settings()
3134- settings_app = self.get_system_settings_proxy()
3135+ settings_app = system_settings.get_system_settings_proxy()
3136 system_settings.ensure_settings_page_visible(settings_app,
3137 SOUND_SETTINGS_PAGE)
3138
3139=== modified file 'ubuntu_system_tests/tests/scopes/test_default_scopes.py'
3140--- ubuntu_system_tests/tests/scopes/test_default_scopes.py 2016-01-05 15:28:08 +0000
3141+++ ubuntu_system_tests/tests/scopes/test_default_scopes.py 2016-02-10 11:57:12 +0000
3142@@ -21,7 +21,10 @@
3143 import shutil
3144
3145 from testtools import skipUnless
3146-from ubuntu_system_tests.helpers import autopilot
3147+
3148+from ubuntu_system_tests.helpers.autopilot.platform import (
3149+ get_device_name, get_channel_name
3150+)
3151 from ubuntu_system_tests.helpers import file_system as fs
3152 from ubuntu_system_tests.helpers import scopes
3153 from ubuntu_system_tests.helpers.location import (
3154@@ -59,7 +62,7 @@
3155 def setUp(self):
3156 super().setUp()
3157 logger.info('Running test using channel: {c} and device: {d}'.format(
3158- c=autopilot.get_channel_name(), d=autopilot.get_device_name()))
3159+ c=get_channel_name(), d=get_device_name()))
3160
3161
3162 class ScopeHeadingTest(DefaultScopeTest):
3163
3164=== modified file 'ubuntu_system_tests/tests/scopes/test_photos_scope.py'
3165--- ubuntu_system_tests/tests/scopes/test_photos_scope.py 2016-01-05 15:36:10 +0000
3166+++ ubuntu_system_tests/tests/scopes/test_photos_scope.py 2016-02-10 11:57:12 +0000
3167@@ -22,6 +22,7 @@
3168
3169 from testtools import skipUnless
3170 from ubuntu_system_tests.helpers import file_system as fs
3171+from ubuntu_system_tests.helpers import gallery
3172 from ubuntu_system_tests.helpers import scopes
3173 from ubuntu_system_tests.helpers.scopes import go_to_photos_scope
3174 from ubuntu_system_tests.helpers import timedate
3175@@ -120,7 +121,7 @@
3176 preview.click_open_button()
3177
3178 # The gallery opens
3179- photo_viewer = self.get_gallery_photo_viewer()
3180+ photo_viewer = gallery.get_gallery_photo_viewer()
3181 self.assertIn(local_storage_pic_file_path,
3182 photo_viewer.get_image_source())
3183
3184
3185=== modified file 'ubuntu_system_tests/tests/scopes/test_video_scope.py'
3186--- ubuntu_system_tests/tests/scopes/test_video_scope.py 2016-01-26 18:36:22 +0000
3187+++ ubuntu_system_tests/tests/scopes/test_video_scope.py 2016-02-10 11:57:12 +0000
3188@@ -131,10 +131,10 @@
3189
3190 # Validate the webbrowser is launched by clicking in the play button
3191 preview.play_video()
3192- self.assertTrue(wait_until(self.is_webbrowser_app_running))
3193+ self.assertTrue(wait_until(webbrowser.is_webbrowser_app_running))
3194
3195 # Validate the url opened in the webbrowser is youtube
3196- browser = self.get_webbrowser_app_proxy()
3197+ browser = webbrowser.get_webbrowser_app_proxy()
3198 self.assertIn('youtube', browser.get_current_url())
3199
3200 # Validate the webbrowser was invoked with the correct video id
3201@@ -166,7 +166,7 @@
3202 preview.play_video()
3203
3204 self.assertTrue(wait_until(mediaplayer.is_mediaplayer_running))
3205- media_player = self.get_media_player_proxy()
3206+ media_player = mediaplayer.get_media_player_proxy()
3207 self.assertEqual(fs.get_file_path(test_data.LOCAL_VIDEO_FILE_2),
3208 media_player.get_player().source)
3209
3210
3211=== modified file 'ubuntu_system_tests/tests/test_add_contact.py'
3212--- ubuntu_system_tests/tests/test_add_contact.py 2016-01-22 11:51:00 +0000
3213+++ ubuntu_system_tests/tests/test_add_contact.py 2016-02-10 11:57:12 +0000
3214@@ -24,8 +24,10 @@
3215 from address_book_app.address_book.data import Phone, Contact
3216
3217 from ubuntu_system_tests.tests import base
3218+from ubuntu_system_tests.helpers import addressbook
3219 from ubuntu_system_tests.helpers.addressbook import (
3220 fixture_setup as addressbook_fixtures)
3221+from ubuntu_system_tests.helpers import dialer_app
3222
3223 FIRST_NAME = 'Fulano'
3224 LAST_NAME = 'de Tal'
3225@@ -53,7 +55,7 @@
3226 test_contact_name = (
3227 test_contact.first_name + ' ' + test_contact.last_name)
3228
3229- address_book = self.launch_address_book()
3230+ address_book = addressbook.launch_address_book()
3231
3232 # Add new contact.
3233 contact_editor = address_book.go_to_add_contact()
3234@@ -91,7 +93,7 @@
3235 3. Create a new contact with pre-filled number
3236 4. Ensure the newly saved contact is shown in the contacts list
3237 """
3238- self.dialer_app = self.launch_dialer_app()
3239+ self.dialer_app = dialer_app.launch_dialer_app()
3240 contact_name = '{} {}'.format(FIRST_NAME, LAST_NAME)
3241 self.dialer_app.dialer_page.dial_number_add_new_contact(
3242 TYPED_MOBILE, FORMATTED_MOBILE)
3243
3244=== modified file 'ubuntu_system_tests/tests/test_app_switcher.py'
3245--- ubuntu_system_tests/tests/test_app_switcher.py 2016-01-11 15:03:07 +0000
3246+++ ubuntu_system_tests/tests/test_app_switcher.py 2016-02-10 11:57:12 +0000
3247@@ -18,9 +18,13 @@
3248 # along with this program. If not, see <http://www.gnu.org/licenses/>.
3249 #
3250
3251-from ubuntu_system_tests.helpers import wait_until
3252+from ubuntu_system_tests.helpers import addressbook
3253+from ubuntu_system_tests.helpers import camera
3254 from ubuntu_system_tests.helpers.camera import fixture_setup as camera_fixture
3255+from ubuntu_system_tests.helpers import dialer_app
3256+from ubuntu_system_tests.helpers import messaging
3257 from ubuntu_system_tests.helpers.processes import is_process_running
3258+from ubuntu_system_tests.helpers import wait_until
3259
3260 from ubuntu_system_tests.tests import base
3261
3262@@ -69,10 +73,10 @@
3263 """Launch test applications and open the task switcher
3264 :return: PhoneStage task switcher object.
3265 """
3266- self.launch_dialer_app_from_launcher()
3267- self.launch_messaging_app_from_launcher()
3268- self.launch_address_book_from_launcher()
3269- self.launch_camera_app_from_launcher()
3270+ dialer_app.launch_dialer_app_from_launcher()
3271+ messaging.launch_messaging_app_from_launcher()
3272+ addressbook.launch_address_book_from_launcher()
3273+ camera.launch_camera_app_from_launcher()
3274 stage = self.shell.swipe_to_show_app_switcher()
3275 stage.swipe_to_top()
3276 apps = stage.get_app_window_names()
3277
3278=== modified file 'ubuntu_system_tests/tests/test_bluetooth.py'
3279--- ubuntu_system_tests/tests/test_bluetooth.py 2015-09-07 11:10:31 +0000
3280+++ ubuntu_system_tests/tests/test_bluetooth.py 2016-02-10 11:57:12 +0000
3281@@ -22,6 +22,7 @@
3282
3283 from ubuntu_system_tests.helpers import bluetooth
3284 from ubuntu_system_tests.helpers import indicators
3285+from ubuntu_system_tests.helpers import system_settings
3286 from ubuntu_system_tests.tests import base
3287
3288 BLUETOOTH_INDICATOR = 'indicator-bluetooth'
3289@@ -36,7 +37,7 @@
3290 """ Go to Bluetooth page """
3291 super(BluetoothTestCase, self).setUp()
3292 self.unity_proxy = self.restart_unity()
3293- self.app = self.launch_system_settings()
3294+ self.app = system_settings.launch_system_settings()
3295 self.bluetooth_page = self.app.go_to_bluetooth_page()
3296
3297 def test_discover_bluetooth_devices(self):
3298
3299=== modified file 'ubuntu_system_tests/tests/test_calculator.py'
3300--- ubuntu_system_tests/tests/test_calculator.py 2015-10-30 11:52:23 +0000
3301+++ ubuntu_system_tests/tests/test_calculator.py 2016-02-10 11:57:12 +0000
3302@@ -17,6 +17,7 @@
3303 from autopilot.matchers import Eventually
3304 from testtools.matchers import Equals
3305
3306+from ubuntu_system_tests.helpers import calculator
3307 from ubuntu_system_tests.tests import base
3308
3309
3310@@ -25,7 +26,7 @@
3311 def setUp(self):
3312 super().setUp()
3313 self.unity_proxy = self.restart_unity()
3314- self.calculator = self.launch_calculator_app()
3315+ self.calculator = calculator.launch_calculator_app()
3316
3317 def test_simple_multiplication(self):
3318 """Multiply two numbers."""
3319
3320=== modified file 'ubuntu_system_tests/tests/test_calls.py'
3321--- ubuntu_system_tests/tests/test_calls.py 2016-02-01 15:50:00 +0000
3322+++ ubuntu_system_tests/tests/test_calls.py 2016-02-10 11:57:12 +0000
3323@@ -28,18 +28,21 @@
3324 from testtools.matchers import Equals
3325 from threading import Event
3326
3327+from ubuntu_system_tests.helpers import addressbook
3328 from ubuntu_system_tests.helpers.addressbook import(
3329 Contact,
3330 fixture_setup as address_book_fixture
3331 )
3332+from ubuntu_system_tests.helpers import dialer_app as dialer
3333+from ubuntu_system_tests.helpers.dialer_app import fixture_setup as dialer_fixture_setup # NOQA
3334 from ubuntu_system_tests.helpers import display
3335 from ubuntu_system_tests.helpers import indicators
3336-from ubuntu_system_tests.helpers import ofono
3337-from ubuntu_system_tests.helpers.dialer_app import fixture_setup
3338 from ubuntu_system_tests.helpers.mediaplayer import start_media_player_observer
3339 from ubuntu_system_tests.helpers.messaging.fixture_setup import (
3340 MessagingTestEnvironment)
3341 from ubuntu_system_tests.helpers import network
3342+from ubuntu_system_tests.helpers import ofono
3343+from ubuntu_system_tests.helpers.ofono import fixture_setup as ofono_fixture_setup # NOQA
3344 from ubuntu_system_tests.helpers.power.fixture_setup import (
3345 EnablePowerdFakeSensors)
3346 from ubuntu_system_tests.helpers.indicators import(
3347@@ -49,6 +52,8 @@
3348 from ubuntu_system_tests.helpers.system_settings.fixture_setup import SilentMode # NOQA
3349 from ubuntu_system_tests.helpers.timedate import get_current_utc_time
3350 from ubuntu_system_tests.helpers.vibration import start_vibration_observer
3351+from ubuntu_system_tests.helpers import webbrowser
3352+
3353 from ubuntu_system_tests.tests.base import wait_until
3354 from ubuntu_system_tests.tests.base_telephony import BaseTelephonyTestCase
3355
3356@@ -93,7 +98,7 @@
3357 # enable fake proximity sensors prior to restarting unity8
3358 self.useFixture(EnablePowerdFakeSensors())
3359 super().setUp()
3360- self.useFixture(fixture_setup.DialerTestEnvironment())
3361+ self.useFixture(dialer_fixture_setup.DialerTestEnvironment())
3362 self.useFixture(SilentMode(False))
3363 self.contact_1 = Contact(name=CONTACT_NAME_1,
3364 number=self.get_telephony_service_number1())
3365@@ -236,11 +241,11 @@
3366 """
3367 self.start_notification_observer()
3368 start_time = get_current_utc_time()
3369- address_book = self.launch_address_book()
3370+ address_book = addressbook.launch_address_book()
3371 contacts_page = address_book.get_contact_list_page()
3372 contact = contacts_page.open_contact_by_name(required_contact.name)
3373 contact.call(required_contact.number)
3374- dialer_app = self.get_dialer_app_proxy()
3375+ dialer_app = dialer.get_dialer_app_proxy()
3376 dialer_app.dialer_page.click_call_button()
3377 self.addCleanup(ofono.end_call)
3378 if not wait_until(self.telephony.is_call_active,
3379@@ -387,7 +392,7 @@
3380 time.sleep(1)
3381 call_notifier.start_call()
3382
3383- call_page = self.get_dialer_app_proxy().live_call_page
3384+ call_page = dialer.get_dialer_app_proxy().live_call_page
3385 self._validate_call_started(call_page, self.contact_1.name)
3386 self.assertTrue(display.is_display_on())
3387 self._assert_proximity_sensor()
3388@@ -422,7 +427,7 @@
3389 call_notifier.wait_until_destroyed()
3390
3391 self._get_missed_call_notification(self.contact_1).call()
3392- dialer_page = self.get_dialer_app_proxy().dialer_page
3393+ dialer_page = dialer.get_dialer_app_proxy().dialer_page
3394 self.assertThat(dialer_page.get_entered_phone_number(),
3395 Eventually(Equals(caller_number)))
3396
3397@@ -464,7 +469,7 @@
3398 self.shell.get_passphrase_unlock_screen().unlock(
3399 self.config_stack.get(KEY_DEVICE_PASSWORD))
3400
3401- dialer_page = self.get_dialer_app_proxy().dialer_page
3402+ dialer_page = dialer.get_dialer_app_proxy().dialer_page
3403 self.assertThat(dialer_page.get_entered_phone_number(),
3404 Eventually(Equals(caller_number)))
3405
3406@@ -618,13 +623,13 @@
3407 call_notifier.start_call()
3408 self.addCleanup(ofono.end_call)
3409
3410- call_page = self.get_dialer_app_proxy().live_call_page
3411+ call_page = dialer.get_dialer_app_proxy().live_call_page
3412 self._validate_call_started(call_page, self.contact_1.name)
3413
3414 return call
3415
3416 def _launch_browser_and_browse_page(self, page_url):
3417- browser = self.launch_webbrowser_from_launcher()
3418+ browser = webbrowser.launch_webbrowser_from_launcher()
3419 browser.go_to_url(page_url)
3420 browser.wait_until_page_loaded(page_url)
3421
3422@@ -637,8 +642,8 @@
3423 status=CALL_INPROGRESS)
3424
3425 # End call from the UI once we check everything.
3426- dialer = self.launch_dialer_app_from_launcher()
3427- self._end_call_from_live_screen(dialer)
3428+ dialer_app = dialer.launch_dialer_app_from_launcher()
3429+ self._end_call_from_live_screen(dialer_app)
3430
3431 self._validate_telephony_call(
3432 call['sid'],
3433@@ -701,7 +706,7 @@
3434 4. Open a website and ensure it opens
3435 5. Return to the dialer app and end the call
3436 """
3437- self.useFixture(ofono.fixture_setup.ModemForData(0))
3438+ self.useFixture(ofono_fixture_setup.ModemForData(0))
3439 phone_number = self.get_device_phone_number()
3440 call = self._receive_call(phone_number)
3441 # Disable wifi and enable data connection to browse a website,
3442
3443=== modified file 'ubuntu_system_tests/tests/test_camera.py'
3444--- ubuntu_system_tests/tests/test_camera.py 2015-10-27 17:30:04 +0000
3445+++ ubuntu_system_tests/tests/test_camera.py 2016-02-10 11:57:12 +0000
3446@@ -26,22 +26,24 @@
3447 from testtools import skipUnless
3448 from testtools.matchers import Equals
3449
3450-from ubuntu_system_tests.helpers import autopilot as autopilot_helpers
3451-from ubuntu_system_tests.helpers import device
3452-from ubuntu_system_tests.helpers import file_system as fs
3453-from ubuntu_system_tests.helpers import images
3454-from ubuntu_system_tests.helpers import videos
3455+from ubuntu_system_tests.helpers.autopilot.platform import is_camera_supported
3456 from ubuntu_system_tests.helpers.backup_restore_fixture import (
3457 BackupRestoreFixture)
3458 from ubuntu_system_tests.helpers import camera
3459 from ubuntu_system_tests.helpers.camera.fixture_setup import (
3460 SetCameraAccessRequests)
3461+from ubuntu_system_tests.helpers import device
3462+from ubuntu_system_tests.helpers import file_system as fs
3463+from ubuntu_system_tests.helpers import images
3464+
3465 from ubuntu_system_tests.helpers.location import (
3466- fixture_setup as location_fixture
3467-)
3468+ fixture_setup as location_fixture)
3469 from ubuntu_system_tests.helpers.location.coordinates import EIFFEL_TOWER
3470+from ubuntu_system_tests.helpers import mediaplayer
3471 from ubuntu_system_tests.helpers.unity8.greeter import show_greeter_with_dbus
3472+from ubuntu_system_tests.helpers import videos
3473 from ubuntu_system_tests.helpers import wait_until
3474+
3475 from ubuntu_system_tests.tests import base
3476
3477 logger = logging.getLogger(__name__)
3478@@ -53,7 +55,7 @@
3479
3480 class BaseCameraTestCase(base.BaseUbuntuSystemTestCase):
3481
3482- @skipUnless(autopilot_helpers.is_camera_supported(), 'Camera-app required')
3483+ @skipUnless(is_camera_supported(), 'Camera-app required')
3484 def setUp(self):
3485 """Backup existing images and settings and launch camera-app."""
3486 super().setUp()
3487@@ -64,7 +66,7 @@
3488 self.useFixture(BackupRestoreFixture(fs.DIR_HOME_CAMERA_PICTURES))
3489 self.useFixture(BackupRestoreFixture(fs.DIR_HOME_CAMERA_VIDEOS))
3490 self.useFixture(BackupRestoreFixture(fs.DIR_HOME_CAMERA_THUMBNAILS))
3491- self.camera_app = self.launch_camera_app()
3492+ self.camera_app = camera.launch_camera_app()
3493
3494 def _check_image_not_blank(self, image):
3495 """Check if the taken image is blank or very limited in colours."""
3496@@ -164,7 +166,7 @@
3497 self.camera_app.start_playback()
3498
3499 # Verify the source file in the player is the one recently recorded
3500- media_player = self.get_media_player_proxy()
3501+ media_player = mediaplayer.get_media_player_proxy()
3502 self.assertEqual(fs.FILE_PREFIX + camera.get_recorded_video(),
3503 media_player.get_player().source)
3504
3505
3506=== modified file 'ubuntu_system_tests/tests/test_clock.py'
3507--- ubuntu_system_tests/tests/test_clock.py 2015-12-21 10:57:24 +0000
3508+++ ubuntu_system_tests/tests/test_clock.py 2016-02-10 11:57:12 +0000
3509@@ -25,6 +25,7 @@
3510
3511 from ubuntu_system_tests.helpers.calendar.fixture_setup import (
3512 BackupRestoreCalendarFixture)
3513+from ubuntu_system_tests.helpers import clock
3514 from ubuntu_system_tests.helpers.clock.fixture_setup import (
3515 SetClockAccessRequests)
3516 from ubuntu_system_tests.helpers.location import (
3517@@ -42,7 +43,7 @@
3518 self.useFixture(SetClockAccessRequests(location=True))
3519 self.useFixture(BackupRestoreCalendarFixture())
3520 self.unity_proxy = self.restart_unity()
3521- self.clock = self.launch_clock_app()
3522+ self.clock = clock.launch_clock_app()
3523
3524 def _create_vibration_observer(self):
3525 """ Create observer used to watch for vibration event """
3526
3527=== modified file 'ubuntu_system_tests/tests/test_messaging_sms.py'
3528--- ubuntu_system_tests/tests/test_messaging_sms.py 2016-01-18 10:08:57 +0000
3529+++ ubuntu_system_tests/tests/test_messaging_sms.py 2016-02-10 11:57:12 +0000
3530@@ -26,6 +26,7 @@
3531 Contact,
3532 fixture_setup as address_book_fixture
3533 )
3534+from ubuntu_system_tests.helpers import messaging
3535 from ubuntu_system_tests.helpers.messaging import(
3536 Message,
3537 Search,
3538@@ -39,6 +40,7 @@
3539 from ubuntu_system_tests.helpers.indicators import NotificationsIndicatorPage, NotificationsIndicatorItem # NOQA
3540 from ubuntu_system_tests.helpers.system_settings import SIM_1, SIM_ASK
3541 from ubuntu_system_tests.helpers.uid import b64_uuid
3542+from ubuntu_system_tests.helpers import webbrowser
3543
3544 CONTACT_1 = Contact(name='Imran Khan', number='08151')
3545 CONTACT_2 = Contact(name='John Connor', number='08153')
3546@@ -285,8 +287,8 @@
3547
3548 self.get_messaging_app()
3549 self.click_message_url(domain)
3550- web_browser = self.get_webbrowser_app_proxy()
3551- web_browser.wait_until_page_loaded('{}/'.format(url))
3552+ webbrowser_app = webbrowser.get_webbrowser_app_proxy()
3553+ webbrowser_app.wait_until_page_loaded('{}/'.format(url))
3554
3555 def verify_thread(self, messaging_app, phone_number, message):
3556 """Check that the thread with given number and message exists"""
3557@@ -311,7 +313,7 @@
3558 message_item.wait_until_destroyed()
3559 self.assertThat(lambda: self.shell.is_new_notification_displayed(),
3560 Eventually(Equals(False)))
3561- messaging_app = self.launch_messaging_app_from_launcher()
3562+ messaging_app = messaging.launch_messaging_app_from_launcher()
3563 self.verify_thread(messaging_app, self.contact_1.number, message.body)
3564
3565 @skipUnless(ofono.number_of_sims() > 1, 'More than 1 SIM is required.')
3566
3567=== modified file 'ubuntu_system_tests/tests/test_rotation.py'
3568--- ubuntu_system_tests/tests/test_rotation.py 2016-01-15 16:05:14 +0000
3569+++ ubuntu_system_tests/tests/test_rotation.py 2016-02-10 11:57:12 +0000
3570@@ -19,6 +19,7 @@
3571 #
3572
3573 from ubuntu_system_tests.helpers.system_settings import (
3574+ launch_system_settings,
3575 get_rotation_lock,
3576 set_rotation_lock,
3577 )
3578@@ -41,7 +42,7 @@
3579 self.addCleanup(set_rotation_lock, get_rotation_lock())
3580 set_rotation_lock('false')
3581 self.sensors.set_orientation('top_up')
3582- self.main_view = self.launch_system_settings()
3583+ self.main_view = launch_system_settings()
3584 unity_proxy.ensure_app_loaded()
3585
3586 def _assert_orientation_and_angle(self, orientation, angle):
3587
3588=== modified file 'ubuntu_system_tests/tests/test_sdcard.py'
3589--- ubuntu_system_tests/tests/test_sdcard.py 2016-02-03 18:08:14 +0000
3590+++ ubuntu_system_tests/tests/test_sdcard.py 2016-02-10 11:57:12 +0000
3591@@ -25,6 +25,7 @@
3592
3593 from ubuntu_system_tests.helpers.data import load_test_metadata
3594 from ubuntu_system_tests.helpers import file_system as fs
3595+from ubuntu_system_tests.helpers import gallery
3596 from ubuntu_system_tests.helpers import images
3597 from ubuntu_system_tests.helpers import indicators
3598 from ubuntu_system_tests.helpers import media
3599@@ -171,7 +172,7 @@
3600
3601 mediaplayer.play_video(dst_video)
3602 wait_until(mediaplayer.is_mediaplayer_running)
3603- player = self.get_media_player_proxy()
3604+ player = mediaplayer.get_media_player_proxy()
3605
3606 self.assertTrue(wait_until(player.is_playing))
3607
3608@@ -203,7 +204,7 @@
3609 preview.play_video()
3610
3611 wait_until(mediaplayer.is_mediaplayer_running)
3612- player = self.get_media_player_proxy()
3613+ player = mediaplayer.get_media_player_proxy()
3614
3615 self.assertTrue(wait_until(player.is_playing))
3616
3617@@ -214,11 +215,11 @@
3618 # Prerequisite: Copy picture to the sd card
3619 dst_pic = sdcard.copy_picture(SRC_PICTURE_FILE_1)
3620
3621- gallery = self.launch_gallery_app()
3622- self.assertTrue(gallery.is_image_displayed(dst_pic))
3623+ gallery_app = gallery.launch_gallery_app()
3624+ self.assertTrue(gallery_app.is_image_displayed(dst_pic))
3625
3626- gallery.click_photo(dst_pic)
3627- self.assertTrue(gallery.is_image_in_view(dst_pic))
3628+ gallery_app.click_photo(dst_pic)
3629+ self.assertTrue(gallery_app.is_image_in_view(dst_pic))
3630
3631 @skipUnless(scopes.is_scope_included(scopes.SCOPE_ID_MUSIC), SKIP_REASON)
3632 def test_play_music_from_sd_card_in_music_app(self):
3633@@ -240,7 +241,7 @@
3634 # Play the album in the music app and verify the desired album is
3635 # being reproduced
3636 preview.play_in_music_app()
3637- self.assertTrue(wait_until(self.is_music_app_running, timeout=20))
3638+ self.assertTrue(wait_until(music.is_music_app_running, timeout=20))
3639 self.addCleanup(music.stop_music_app)
3640 song_path = os.path.join(
3641 fs.DIR_MEDIA_ROOT, sdcard.get_sd_card_dir_name(), 'Music',
3642
3643=== modified file 'ubuntu_system_tests/tests/test_settings_wizard.py'
3644--- ubuntu_system_tests/tests/test_settings_wizard.py 2015-10-19 20:30:31 +0000
3645+++ ubuntu_system_tests/tests/test_settings_wizard.py 2016-02-10 11:57:12 +0000
3646@@ -17,8 +17,9 @@
3647 # along with this program. If not, see <http://www.gnu.org/licenses/>
3648
3649 from ubuntu_system_tests.config import get_device_config_stack
3650-from ubuntu_system_tests.helpers.autopilot import is_wifi_supported
3651-from ubuntu_system_tests.helpers.autopilot import is_agps_supported
3652+from ubuntu_system_tests.helpers.autopilot.platform import (
3653+ is_agps_supported, is_wifi_supported
3654+)
3655 from ubuntu_system_tests.helpers.unity8 import settings_wizard
3656 from ubuntu_system_tests.helpers.unity8.settings_wizard import Wizard
3657 from ubuntu_system_tests.helpers import ofono
3658
3659=== modified file 'ubuntu_system_tests/tests/test_sim_pin.py'
3660--- ubuntu_system_tests/tests/test_sim_pin.py 2015-10-08 12:13:55 +0000
3661+++ ubuntu_system_tests/tests/test_sim_pin.py 2016-02-10 11:57:12 +0000
3662@@ -25,6 +25,7 @@
3663
3664 from ubuntu_system_tests.helpers import ofono
3665 from ubuntu_system_tests.helpers.ofono import fixture_setup as ofono_fixture
3666+from ubuntu_system_tests.helpers import system_settings
3667 from ubuntu_system_tests.tests import base
3668
3669
3670@@ -37,7 +38,7 @@
3671 self.useFixture(ofono_fixture.UnlockSims())
3672
3673 self.unity_proxy = self.restart_unity()
3674- self.app = self.launch_system_settings()
3675+ self.app = system_settings.launch_system_settings()
3676
3677 # As per this bug where we're unable to launch the browser from the
3678 # scope after a unity8 reboot.
3679
3680=== modified file 'ubuntu_system_tests/tests/test_system_settings.py'
3681--- ubuntu_system_tests/tests/test_system_settings.py 2016-01-18 13:14:03 +0000
3682+++ ubuntu_system_tests/tests/test_system_settings.py 2016-02-10 11:57:12 +0000
3683@@ -25,6 +25,7 @@
3684 network as network_indicator_helpers
3685 )
3686 from ubuntu_system_tests.helpers import network
3687+from ubuntu_system_tests.helpers import system_settings
3688 from ubuntu_system_tests.tests import base
3689
3690
3691@@ -33,7 +34,7 @@
3692 def setUp(self):
3693 super().setUp()
3694 self.shell = self.restart_unity().main_window
3695- self.system_settings = self.launch_system_settings()
3696+ self.system_settings = system_settings.launch_system_settings()
3697 self.assertTrue(network.is_wifi_connected())
3698
3699 def _disable_mobile_data_if_enabled(self):
3700
3701=== modified file 'ubuntu_system_tests/tests/test_ubuntu_keyboard.py'
3702--- ubuntu_system_tests/tests/test_ubuntu_keyboard.py 2016-01-06 13:19:19 +0000
3703+++ ubuntu_system_tests/tests/test_ubuntu_keyboard.py 2016-02-10 11:57:12 +0000
3704@@ -47,14 +47,14 @@
3705 super().setUp()
3706 self.unity_proxy = self.restart_unity()
3707 self.useFixture(messaging_fixture.SetDefaultSIM())
3708- self.messaging_app = self.launch_messaging_app()
3709+ self.messaging_app = messaging_helpers.launch_messaging_app()
3710
3711 def _focus_message_input_field_to_invoke_keyboard(self):
3712 # Due to some reason, using the proxy object with uitk emulator base,
3713 # causes the Ubuntu Keyboard to misbehave i.e. its auto-capitalization
3714 # settings are reset during the test. Getting the proxy object without
3715 # custom emulator base, solves the issue. --om26er 16-12-2015
3716- messaging_app_raw_proxy = self.get_messaging_app_proxy(
3717+ messaging_app_raw_proxy = messaging_helpers.get_messaging_app_proxy(
3718 base=None)
3719 return messaging_helpers.focus_message_input_field(
3720 messaging_app_raw_proxy, self.messaging_app.pointing_device)
3721@@ -119,7 +119,7 @@
3722 """
3723 osk = UbuntuKeyboard()
3724 osk.type(INITIAL_TEXT)
3725- word_ribbon_list = self.get_ubuntu_keyboard_proxy().word_ribbon_list
3726+ word_ribbon_list = osk_helpers.get_ubuntu_keyboard_proxy().word_ribbon_list # NOQA
3727
3728 suggestions_list = word_ribbon_list.get_suggested_words()
3729 self._assert_words_in_ribbon(suggestions_list, EXPECTED_WORDS)
3730
3731=== modified file 'ubuntu_system_tests/tests/test_with_dialer.py'
3732--- ubuntu_system_tests/tests/test_with_dialer.py 2016-01-12 08:06:11 +0000
3733+++ ubuntu_system_tests/tests/test_with_dialer.py 2016-02-10 11:57:12 +0000
3734@@ -22,6 +22,7 @@
3735
3736 from unity8 import process_helpers as unity_helpers
3737
3738+from ubuntu_system_tests.helpers import dialer_app
3739 from ubuntu_system_tests.tests import base
3740
3741
3742@@ -30,7 +31,7 @@
3743 def setUp(self):
3744 super().setUp()
3745 self.unity = self.restart_unity()
3746- self.dialer_app = self.launch_dialer_app()
3747+ self.dialer_app = dialer_app.launch_dialer_app()
3748
3749 def test_dialer_contacts_view_kept_on_screen_lock(self):
3750 """
3751
3752=== modified file 'ubuntu_system_tests/tests/test_with_webbrowser.py'
3753--- ubuntu_system_tests/tests/test_with_webbrowser.py 2016-01-27 15:40:40 +0000
3754+++ ubuntu_system_tests/tests/test_with_webbrowser.py 2016-02-10 11:57:12 +0000
3755@@ -29,19 +29,21 @@
3756 from ubuntu_keyboard.emulators import keyboard
3757
3758 from ubuntu_system_tests.helpers import autopilot
3759+from ubuntu_system_tests.helpers.data import load_test_metadata
3760 from ubuntu_system_tests.helpers import file_system as fs
3761+from ubuntu_system_tests.helpers import gallery
3762 from ubuntu_system_tests.helpers import images
3763-from ubuntu_system_tests.helpers import wait_until
3764-from ubuntu_system_tests.helpers.data import load_test_metadata
3765+from ubuntu_system_tests.helpers import messaging
3766 from ubuntu_system_tests.helpers.messaging import (
3767 fixture_setup as messaging_fixtures
3768 )
3769-
3770-from ubuntu_system_tests.tests import base_webbrowser
3771+from ubuntu_system_tests.helpers import wait_until
3772 from ubuntu_system_tests.helpers.webbrowser import (
3773 fixture_setup as webbrowser_fixtures
3774 )
3775
3776+from ubuntu_system_tests.tests import base_webbrowser
3777+
3778
3779 logger = logging.getLogger(__name__)
3780 PageUrls = namedtuple('PageUrls', ['entered_url',
3781@@ -281,7 +283,7 @@
3782 self.assertTrue(wait_until(os.path.isfile, downloaded_file))
3783
3784 # Validate the gallery-app is displaying the downloaded image
3785- events_view = self.get_gallery_events_view()
3786+ events_view = gallery.get_gallery_events_view()
3787 self.assertTrue(events_view.is_image_displayed(img.file_name))
3788
3789 # check the displayed image matches the reference image
3790@@ -433,7 +435,7 @@
3791 self.browser.wait_until_page_loaded(test_data.get('ubuntu').actual_url)
3792 self.browser.copy_url_text()
3793
3794- messaging_app = self.launch_messaging_app_from_launcher()
3795+ messaging_app = messaging.launch_messaging_app_from_launcher()
3796 # Apparently the OSK stays visible if the app was switched while
3797 # the keyboard was on screen. Reported: LP: 1505630
3798 keyboard.Keyboard().dismiss()
3799
3800=== modified file 'ubuntu_system_tests/tests/webapps/test_ebay.py'
3801--- ubuntu_system_tests/tests/webapps/test_ebay.py 2016-02-05 13:59:28 +0000
3802+++ ubuntu_system_tests/tests/webapps/test_ebay.py 2016-02-10 11:57:12 +0000
3803@@ -31,7 +31,7 @@
3804
3805 def setUp(self):
3806 super().setUp()
3807- self.web_app = self.launch_ebay_webapp()
3808+ self.web_app = ebay.launch_ebay_webapp()
3809 self.driver = webapp.get_webdriver(self.addCleanup)
3810
3811 def test_open_and_view_content(self):
3812
3813=== modified file 'ubuntu_system_tests/tests/webapps/test_here.py'
3814--- ubuntu_system_tests/tests/webapps/test_here.py 2016-01-14 17:35:52 +0000
3815+++ ubuntu_system_tests/tests/webapps/test_here.py 2016-02-10 11:57:12 +0000
3816@@ -41,7 +41,7 @@
3817 self.useFixture(DummyLocation(*EIFFEL_TOWER))
3818 super().setUp()
3819 self.useFixture(SetLocationAccessRequests(self.LOCATION_APP))
3820- self.webapp = self.launch_here_webapp()
3821+ self.webapp = here.launch_here_webapp()
3822 self.driver = webapp.get_webdriver(self.addCleanup)
3823
3824 def test_retrieve_location(self):

Subscribers

People subscribed via source and target branches

to all changes: