Merge lp:~canonical-platform-qa/qtcreator-plugin-ubuntu/update_simpleui_autopilot_launch into lp:qtcreator-plugin-ubuntu

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/qtcreator-plugin-ubuntu/update_simpleui_autopilot_launch
Merge into: lp:qtcreator-plugin-ubuntu
Prerequisite: lp:~canonical-platform-qa/qtcreator-plugin-ubuntu/update_simpleui_qttest-2
Diff against target: 167 lines (+58/-53)
3 files modified
share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/__init__.py (+51/-46)
share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/test_main.py (+6/-6)
share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/run (+1/-1)
To merge this branch: bzr merge lp:~canonical-platform-qa/qtcreator-plugin-ubuntu/update_simpleui_autopilot_launch
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+247243@code.launchpad.net

This proposal has been superseded by a proposal from 2015-02-04.

Commit message

Updated the autopilot test template.

To post a comment you must log in.
360. By Leo Arias

Reverted the changelog change.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
361. By Leo Arias

Merged with prerequisite.

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

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/__init__.py'
2--- share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/__init__.py 2015-02-04 17:44:44 +0000
3+++ share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/__init__.py 2015-02-04 17:44:44 +0000
4@@ -1,18 +1,18 @@
5 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6
7-"""Ubuntu Touch App autopilot tests."""
8+"""Ubuntu Touch App Autopilot tests."""
9
10 import os
11-import subprocess
12-
13-from autopilot import input, platform
14+
15+import ubuntuuitoolkit
16+
17+from autopilot import introspection
18 from autopilot.matchers import Eventually
19 from testtools.matchers import Equals
20-from ubuntuuitoolkit import base, emulators
21-
22-
23-def _get_module_include_path():
24- return os.path.join(get_path_to_source_root(), 'modules')
25+from ubuntuuitoolkit import base
26+
27+
28+PACKAGE_ID = '%ProjectName:l%.%ClickDomain:l%'
29
30
31 def get_path_to_source_root():
32@@ -21,51 +21,56 @@
33 os.path.dirname(__file__), '..', '..', '..', '..'))
34
35
36+class ApplicationCustomProxyObject(
37+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
38+
39+ """Autopilot custom proxy object for the app."""
40+
41+ @classmethod
42+ def validate_dbus_object(cls, path, state):
43+ application_name = PACKAGE_ID
44+ name = introspection.get_classname_from_path(path)
45+ if str(name) == application_name:
46+ if state['applicationName'][1] == application_name:
47+ return True
48+ return False
49+
50+ @property
51+ def main_view(self):
52+ return self.select_single(ubuntuuitoolkit.MainView)
53+
54+
55 class ClickAppTestCase(base.UbuntuUIToolkitAppTestCase):
56+
57 """Common test case that provides several useful methods for the tests."""
58
59- package_id = '' # TODO
60- app_name = '%ProjectName%'
61-
62- def setUp(self):
63- super(ClickAppTestCase, self).setUp()
64- self.pointing_device = input.Pointer(self.input_device_class.create())
65- self.launch_application()
66-
67- self.assertThat(self.main_view.visible, Eventually(Equals(True)))
68+ project_name = '%ProjectName%'
69
70 def launch_application(self):
71- if platform.model() == 'Desktop':
72- self._launch_application_from_desktop()
73- else:
74- self._launch_application_from_phablet()
75-
76- def _launch_application_from_desktop(self):
77 app_qml_source_location = self._get_app_qml_source_path()
78 if os.path.exists(app_qml_source_location):
79- self.app = self.launch_test_application(
80- base.get_qmlscene_launch_command(),
81- '-I' + _get_module_include_path(),
82- app_qml_source_location,
83- app_type='qt',
84- emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
85+ app = self._launch_application_from_source(
86+ app_qml_source_location)
87 else:
88- raise NotImplementedError(
89- "On desktop we can't install click packages yet, so we can "
90- "only run from source.")
91+ app = self._launch_installed_application()
92+
93+ self.assertThat(app.main_view.visible, Eventually(Equals(True)))
94+ return app
95
96 def _get_app_qml_source_path(self):
97 qml_file_name = 'Main.qml'
98- return os.path.join(self._get_path_to_app_source(), qml_file_name)
99-
100- def _get_path_to_app_source(self):
101- return os.path.join(get_path_to_source_root(), self.app_name)
102-
103- def _launch_application_from_phablet(self):
104- # On phablet, we only run the tests against the installed click
105- # package.
106- self.app = self.launch_click_package(self.pacakge_id, self.app_name)
107-
108- @property
109- def main_view(self):
110- return self.app.select_single(emulators.MainView)
111+ return os.path.join(self._get_path_to_project_source(), qml_file_name)
112+
113+ def _get_path_to_project_source(self):
114+ return os.path.join(get_path_to_source_root(), self.project_name)
115+
116+ def _launch_application_from_source(self, app_qml_source_location):
117+ return self.launch_test_application(
118+ base.get_qmlscene_launch_command(),
119+ app_qml_source_location,
120+ app_type='qt',
121+ emulator_base=ApplicationCustomProxyObject)
122+
123+ def _launch_installed_application(self):
124+ return self.launch_click_package(
125+ PACKAGE_ID, emulator_base=ApplicationCustomProxyObject)
126
127=== modified file 'share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/test_main.py'
128--- share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/test_main.py 2015-01-28 09:59:55 +0000
129+++ share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/displayName/test_main.py 2015-02-04 17:44:44 +0000
130@@ -2,8 +2,6 @@
131
132 """Tests for the Hello World"""
133
134-import os
135-
136 from autopilot.matchers import Eventually
137 from testtools.matchers import Equals
138
139@@ -14,11 +12,13 @@
140 """Generic tests for the Hello World"""
141
142 def test_initial_label(self):
143- label = self.main_view.select_single(objectName='label')
144+ app = self.launch_application()
145+ label = app.main_view.select_single(objectName='label')
146 self.assertThat(label.text, Equals('Hello..'))
147
148 def test_click_button_should_update_label(self):
149- button = self.main_view.select_single(objectName='button')
150- self.pointing_device.click_object(button)
151- label = self.main_view.select_single(objectName='label')
152+ app = self.launch_application()
153+ button = app.main_view.select_single(objectName='button')
154+ app.pointing_device.click_object(button)
155+ label = app.main_view.select_single(objectName='label')
156 self.assertThat(label.text, Eventually(Equals('..world!')))
157
158=== modified file 'share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/run'
159--- share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/run 2015-01-28 09:59:55 +0000
160+++ share/qtcreator/templates/wizards/ubuntu/simple-app-qmlproject/tests/autopilot/run 2015-02-04 17:44:44 +0000
161@@ -7,5 +7,5 @@
162
163 SCRIPTPATH=`dirname $0`
164 pushd ${SCRIPTPATH}
165-autopilot run %ProjectName%
166+autopilot3 run %ProjectName%
167 popd

Subscribers

People subscribed via source and target branches