Merge lp:~elopio/qtcreator-plugin-ubuntu/update_tabs_autopilot_template into lp:qtcreator-plugin-ubuntu

Proposed by Leo Arias on 2014-07-02
Status: Work in progress
Proposed branch: lp:~elopio/qtcreator-plugin-ubuntu/update_tabs_autopilot_template
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 366 lines (+105/-164)
8 files modified
share/qtcreator/templates/wizards/ubuntu/projectypes.json (+1/-4)
share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/displayName/__init__.py (+3/-8)
share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/run (+3/-3)
share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/__init__.py (+57/-122)
share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/__init__.py (+0/-1)
share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/test_main.py (+0/-23)
share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/test_main.py (+38/-0)
share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/run (+3/-3)
To merge this branch: bzr merge lp:~elopio/qtcreator-plugin-ubuntu/update_tabs_autopilot_template
Reviewer Review Type Date Requested Status
Zoltan Balogh (community) 2014-07-02 Needs Fixing on 2014-07-07
PS Jenkins bot continuous-integration Approve on 2014-07-03
Josh Arenson (community) Needs Fixing on 2014-07-03
Review via email: mp+225256@code.launchpad.net

Commit Message

Updated the tabs autopilot template to be more similar to the one of the simple app.

To post a comment you must log in.
Josh Arenson (josharenson) wrote :

This works nicely if you create an "App With Tabbed UI", but doesn't work if you create an "App With QML Extension Library" (which is an just app with a tabbed ui and a backend library). Was this intended?

review: Needs Information
Josh Arenson (josharenson) wrote :

149 + self.app = self.launch_click_package(self.pacakge_id, self.app_name)

"package" is spelled incorrectly.

review: Needs Fixing
Leo Arias (elopio) wrote :

> 149 + self.app = self.launch_click_package(self.pacakge_id,
> self.app_name)
>
> "package" is spelled incorrectly.

Nice catch, I've fixed it. That means we need to test this also on the phone :'(

Leo Arias (elopio) wrote :

> This works nicely if you create an "App With Tabbed UI", but doesn't work if
> you create an "App With QML Extension Library" (which is an just app with a
> tabbed ui and a backend library). Was this intended?

Well, that's a different template that needs the same treatment.
I'll report the bug, because this week I won't have time to do it.

Josh Arenson (josharenson) :
review: Needs Fixing
Zoltan Balogh (bzoltan) wrote :

OK

review: Approve
Zoltan Balogh (bzoltan) wrote :

The new project wizzard will conflict with this MR, so it is better to wait for the wizzard MR to land.

review: Needs Fixing

Unmerged revisions

194. By Leo Arias on 2014-07-03

Fixed get_path_to_source_root.

193. By Leo Arias on 2014-07-02

Fixed typo.

192. By Leo Arias on 2014-07-02

Finished the updates on the tabbs sample app.

191. By Leo Arias on 2014-07-02

Initial changes to the tabs project autopilot template.

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/projectypes.json'
2--- share/qtcreator/templates/wizards/ubuntu/projectypes.json 2014-05-27 08:58:10 +0000
3+++ share/qtcreator/templates/wizards/ubuntu/projectypes.json 2014-07-03 00:47:32 +0000
4@@ -88,13 +88,10 @@
5 "fileName": "tests/autopilot/run"
6 },
7 {
8- "fileName": "tests/autopilot/displayName/main/test_main.py"
9+ "fileName": "tests/autopilot/displayName/test_main.py"
10 },
11 {
12 "fileName": "tests/autopilot/displayName/__init__.py"
13- },
14- {
15- "fileName": "tests/autopilot/displayName/main/__init__.py"
16 }
17 ]
18 },
19
20=== modified file 'share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/displayName/__init__.py'
21--- share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/displayName/__init__.py 2013-10-25 05:05:39 +0000
22+++ share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/displayName/__init__.py 2014-07-03 00:47:32 +0000
23@@ -3,7 +3,6 @@
24 """Ubuntu Touch App autopilot tests."""
25
26 import os
27-import subprocess
28
29 from autopilot import input, platform
30 from autopilot.matchers import Eventually
31@@ -17,8 +16,7 @@
32
33 def get_path_to_source_root():
34 return os.path.abspath(
35- os.path.join(
36- os.path.dirname(__file__), '..', '..', '..', '..'))
37+ os.path.join(os.path.dirname(__file__), '..', '..', '..'))
38
39
40 class ClickAppTestCase(base.UbuntuUIToolkitAppTestCase):
41@@ -56,15 +54,12 @@
42
43 def _get_app_qml_source_path(self):
44 qml_file_name = '{0}.qml'.format(self.app_name)
45- return os.path.join(self._get_path_to_app_source(), qml_file_name)
46-
47- def _get_path_to_app_source(self):
48- return os.path.join(get_path_to_source_root(), self.app_name)
49+ return os.path.join(get_path_to_source_root(), qml_file_name)
50
51 def _launch_application_from_phablet(self):
52 # On phablet, we only run the tests against the installed click
53 # package.
54- self.app = self.launch_click_package(self.pacakge_id, self.app_name)
55+ self.app = self.launch_click_package(self.package_id, self.app_name)
56
57 @property
58 def main_view(self):
59
60=== modified file 'share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/run'
61--- share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/run 2013-08-08 07:26:20 +0000
62+++ share/qtcreator/templates/wizards/ubuntu/simple/tests/autopilot/run 2014-07-03 00:47:32 +0000
63@@ -1,11 +1,11 @@
64 #!/bin/bash
65
66-if [[ -z `which autopilot` ]]; then
67- echo "Autopilot is not installed. Skip"
68+if [[ -z `which autopilot3` ]]; then
69+ echo "python3-autopilot is not installed. Skip"
70 exit
71 fi
72
73 SCRIPTPATH=`dirname $0`
74 pushd ${SCRIPTPATH}
75-autopilot run %DISPLAYNAME%
76+autopilot3 run %DISPLAYNAME%
77 popd
78
79=== modified file 'share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/__init__.py'
80--- share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/__init__.py 2013-08-08 07:26:20 +0000
81+++ share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/__init__.py 2014-07-03 00:47:32 +0000
82@@ -2,130 +2,65 @@
83
84 """Ubuntu Touch App autopilot tests."""
85
86-from os import remove
87-import os.path
88-from tempfile import mktemp
89-import subprocess
90+import os
91
92-from autopilot.input import Mouse, Touch, Pointer
93+from autopilot import input, platform
94 from autopilot.matchers import Eventually
95-from autopilot.platform import model
96-from testtools.matchers import Is, Not, Equals
97-from autopilot.testcase import AutopilotTestCase
98-
99-def get_module_include_path():
100+from testtools.matchers import Equals
101+from ubuntuuitoolkit import base, emulators
102+
103+
104+def _get_module_include_path():
105+ return os.path.join(get_path_to_source_root(), 'modules')
106+
107+
108+def get_path_to_source_root():
109 return os.path.abspath(
110- os.path.join(
111- os.path.dirname(__file__),
112- '..',
113- '..',
114- '..',
115- '..',
116- 'modules')
117- )
118-
119-
120-class UbuntuTouchAppTestCase(AutopilotTestCase):
121- """A common test case class that provides several useful methods for the tests."""
122-
123- if model() == 'Desktop':
124- scenarios = [
125- ('with mouse', dict(input_device_class=Mouse))
126- ]
127- else:
128- scenarios = [
129- ('with touch', dict(input_device_class=Touch))
130- ]
131+ os.path.join(os.path.dirname(__file__), '..', '..', '..'))
132+
133+
134+class ClickAppTestCase(base.UbuntuUIToolkitAppTestCase):
135+ """Common test case that provides several useful methods for the tests."""
136+
137+ package_id = '' # TODO
138+ app_name = '%DISPLAYNAME%'
139+
140+ def setUp(self):
141+ super(ClickAppTestCase, self).setUp()
142+ self.pointing_device = input.Pointer(self.input_device_class.create())
143+ self.launch_application()
144+
145+ self.assertThat(self.main_view.visible, Eventually(Equals(True)))
146+
147+ def launch_application(self):
148+ if platform.model() == 'Desktop':
149+ self._launch_application_from_desktop()
150+ else:
151+ self._launch_application_from_phablet()
152+
153+ def _launch_application_from_desktop(self):
154+ app_qml_source_location = self._get_app_qml_source_path()
155+ if os.path.exists(app_qml_source_location):
156+ self.app = self.launch_test_application(
157+ base.get_qmlscene_launch_command(),
158+ '-I' + _get_module_include_path(),
159+ app_qml_source_location,
160+ app_type='qt',
161+ emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
162+ else:
163+ raise NotImplementedError(
164+ "On desktop we can't install click packages yet, so we can "
165+ "only run from source.")
166+
167+ def _get_app_qml_source_path(self):
168+ qml_file_name = '{0}.qml'.format(self.app_name)
169+ return os.path.join(get_path_to_source_root(), qml_file_name)
170+
171+ def _launch_application_from_phablet(self):
172+ # On phablet, we only run the tests against the installed click
173+ # package.
174+ self.app = self.launch_click_package(self.package_id, self.app_name)
175
176 @property
177- def main_window(self):
178- return MainWindow(self.app)
179-
180-
181- def setUp(self):
182- self.pointing_device = Pointer(self.input_device_class.create())
183- super(UbuntuTouchAppTestCase, self).setUp()
184- self.launch_test_qml()
185-
186-
187- def launch_test_qml(self):
188- # If the test class has defined a 'test_qml' class attribute then we
189- # write it to disk and launch it inside the QML Scene. If not, then we
190- # silently do nothing (presumably the test has something else planned).
191- arch = subprocess.check_output(["dpkg-architecture",
192- "-qDEB_HOST_MULTIARCH"]).strip()
193- if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring):
194- qml_path = mktemp(suffix='.qml')
195- open(qml_path, 'w').write(self.test_qml)
196- self.addCleanup(remove, qml_path)
197-
198- self.app = self.launch_test_application(
199- "/usr/lib/" + arch + "/qt5/bin/qmlscene",
200- "-I", get_module_include_path(),
201- qml_path,
202- app_type='qt')
203-
204- if hasattr(self, 'test_qml_file') and isinstance(self.test_qml_file, basestring):
205- qml_path = self.test_qml_file
206- self.app = self.launch_test_application(
207- "/usr/lib/" + arch + "/qt5/bin/qmlscene",
208- "-I", get_module_include_path(),
209- qml_path,
210- app_type='qt')
211-
212- self.assertThat(self.get_qml_view().visible, Eventually(Equals(True)))
213-
214-
215- def get_qml_view(self):
216- """Get the main QML view"""
217-
218- return self.app.select_single("QQuickView")
219-
220- def get_mainview(self):
221- """Get the QML MainView"""
222-
223- mainView = self.app.select_single("MainView")
224- self.assertThat(mainView, Not(Is(None)))
225- return mainView
226-
227-
228- def get_object(self,objectName):
229- """Get a object based on the objectName"""
230-
231- obj = self.app.select_single(objectName=objectName)
232- self.assertThat(obj, Not(Is(None)))
233- return obj
234-
235-
236- def mouse_click(self,objectName):
237- """Move mouse on top of the object and click on it"""
238-
239- obj = self.get_object(objectName)
240- self.pointing_device.move_to_object(obj)
241- self.pointing_device.click()
242-
243-
244- def mouse_press(self,objectName):
245- """Move mouse on top of the object and press mouse button (without releasing it)"""
246-
247- obj = self.get_object(objectName)
248- self.pointing_device.move_to_object(obj)
249- self.pointing_device.press()
250-
251-
252- def mouse_release(self):
253- """Release mouse button"""
254-
255- self.pointing_device.release()
256-
257-
258- def type_string(self, string):
259- """Type a string with keyboard"""
260-
261- self.keyboard.type(string)
262-
263-
264- def type_key(self, key):
265- """Type a single key with keyboard"""
266-
267- self.keyboard.key(key)
268+ def main_view(self):
269+ return self.app.select_single(emulators.MainView)
270
271=== removed directory 'share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main'
272=== removed file 'share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/__init__.py'
273--- share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/__init__.py 2013-08-08 07:26:20 +0000
274+++ share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/__init__.py 1970-01-01 00:00:00 +0000
275@@ -1,1 +0,0 @@
276-""" A main.qml test suite """
277
278=== removed file 'share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/test_main.py'
279--- share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/test_main.py 2013-08-08 07:26:20 +0000
280+++ share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/main/test_main.py 1970-01-01 00:00:00 +0000
281@@ -1,23 +0,0 @@
282-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
283-
284-"""Tests for the Hello World"""
285-
286-from autopilot.matchers import Eventually
287-from textwrap import dedent
288-from testtools.matchers import Is, Not, Equals
289-from testtools import skip
290-import os
291-from %DISPLAYNAME% import UbuntuTouchAppTestCase
292-
293-
294-class MainTests(UbuntuTouchAppTestCase):
295- """Generic tests for the Hello World"""
296-
297- test_qml_file = "%s/%s.qml" % (os.path.dirname(os.path.realpath(__file__)),"../../../../%DISPLAYNAME%")
298-
299- def test_0_can_select_mainView(self):
300- """Must be able to select the mainview."""
301-
302- mainView = self.get_mainview()
303- self.assertThat(mainView.visible,Eventually(Equals(True)))
304-
305
306=== added file 'share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/test_main.py'
307--- share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/test_main.py 1970-01-01 00:00:00 +0000
308+++ share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/displayName/test_main.py 2014-07-03 00:47:32 +0000
309@@ -0,0 +1,38 @@
310+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
311+
312+"""Tests for the Hello World"""
313+
314+import os
315+
316+from autopilot.matchers import Eventually
317+from testtools.matchers import Equals
318+
319+import %DISPLAYNAME%
320+
321+
322+class MainViewTestCase(%DISPLAYNAME%.ClickAppTestCase):
323+
324+ """Generic tests for the Hello World with tabs."""
325+
326+ def setUp(self):
327+ super(MainViewTestCase, self).setUp()
328+ self.hello_tab_label = self.main_view.select_single(
329+ objectName='helloTab_label')
330+ self.world_tab_label = self.main_view.select_single(
331+ objectName='worldTab_label')
332+
333+ def test_initial_tab_must_be_hello(self):
334+ self.assertTrue(self.hello_tab_label.visible)
335+ self.assertThat(
336+ self.hello_tab_label.text,
337+ Equals('You can change the Tab from Page title above.'))
338+ self.assertFalse(self.world_tab_label.visible)
339+
340+ def test_go_to_world_tab_must_make_it_visible(self):
341+ self.main_view.switch_to_tab('worldTab')
342+ self.assertTrue(self.world_tab_label.visible)
343+ self.assertThat(
344+ self.world_tab_label.text,
345+ Equals('Swipe from bottom to up to reveal the toolbar.'))
346+ self.assertFalse(self.hello_tab_label.visible)
347+
348
349=== modified file 'share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/run'
350--- share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/run 2013-08-08 07:26:20 +0000
351+++ share/qtcreator/templates/wizards/ubuntu/tabs/tests/autopilot/run 2014-07-03 00:47:32 +0000
352@@ -1,11 +1,11 @@
353 #!/bin/bash
354
355-if [[ -z `which autopilot` ]]; then
356- echo "Autopilot is not installed. Skip"
357+if [[ -z `which autopilot3` ]]; then
358+ echo "python3-autopilot is not installed. Skip"
359 exit
360 fi
361
362 SCRIPTPATH=`dirname $0`
363 pushd ${SCRIPTPATH}
364-autopilot run %DISPLAYNAME%
365+autopilot3 run %DISPLAYNAME%
366 popd

Subscribers

People subscribed via source and target branches

to all changes: