1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
"""Ubuntu Touch App autopilot tests."""
8
from autopilot import input, platform
9
from autopilot.matchers import Eventually
10
from testtools.matchers import Equals
11
from ubuntuuitoolkit import base, emulators
14
def _get_module_include_path():
15
return os.path.join(get_path_to_source_root(), 'modules')
18
def get_path_to_source_root():
19
return os.path.abspath(
21
os.path.dirname(__file__), '..', '..', '..', '..'))
24
class ClickAppTestCase(base.UbuntuUIToolkitAppTestCase):
25
"""Common test case that provides several useful methods for the tests."""
27
package_id = '' # TODO
28
app_name = 'screen_size'
31
super(ClickAppTestCase, self).setUp()
32
self.pointing_device = input.Pointer(self.input_device_class.create())
33
self.launch_application()
35
self.assertThat(self.main_view.visible, Eventually(Equals(True)))
37
def launch_application(self):
38
if platform.model() == 'Desktop':
39
self._launch_application_from_desktop()
41
self._launch_application_from_phablet()
43
def _launch_application_from_desktop(self):
44
app_qml_source_location = self._get_app_qml_source_path()
45
if os.path.exists(app_qml_source_location):
46
self.app = self.launch_test_application(
47
base.get_qmlscene_launch_command(),
48
'-I' + _get_module_include_path(),
49
app_qml_source_location,
51
emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
53
raise NotImplementedError(
54
"On desktop we can't install click packages yet, so we can "
55
"only run from source.")
57
def _get_app_qml_source_path(self):
58
qml_file_name = '{0}.qml'.format(self.app_name)
59
return os.path.join(self._get_path_to_app_source(), qml_file_name)
61
def _get_path_to_app_source(self):
62
return os.path.join(get_path_to_source_root(), self.app_name)
64
def _launch_application_from_phablet(self):
65
# On phablet, we only run the tests against the installed click
67
self.app = self.launch_click_package(self.pacakge_id, self.app_name)
71
return self.app.select_single(emulators.MainView)