Merge lp:~kissiel/checkbox/autopilot-infrastructure into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Maciej Kisielewski
Approved revision: 3637
Merged at revision: 3624
Proposed branch: lp:~kissiel/checkbox/autopilot-infrastructure
Merge into: lp:checkbox
Diff against target: 460 lines (+108/-136)
15 files modified
checkbox-touch/Makefile (+2/-1)
checkbox-touch/README.rst (+1/-1)
checkbox-touch/build-me (+3/-2)
checkbox-touch/checkbox-touch.qml (+34/-17)
checkbox-touch/checkbox-touch.qmlproject (+1/-1)
checkbox-touch/components/CheckboxTouchApplication.qml (+4/-4)
checkbox-touch/py/checkbox_touch.py (+19/-6)
checkbox-touch/tests/autopilot/autopilot-provider/jobs/autopilot.pxu (+7/-0)
checkbox-touch/tests/autopilot/autopilot-provider/manage.py (+21/-0)
checkbox-touch/tests/autopilot/checkbox_touch/__init__.py (+1/-0)
checkbox-touch/tests/autopilot/checkbox_touch/test_checkbox_touch.py (+12/-0)
checkbox-touch/tests/autopilot/checkbox_touch/test_latch_button.py (+0/-16)
checkbox-touch/tests/autopilot/checkbox_touch/test_manual_intro_page.py (+0/-35)
checkbox-touch/tests/autopilot/checkbox_touch/test_resume_session_screen.py (+0/-52)
checkbox-touch/tests/autopilot/run (+3/-1)
To merge this branch: bzr merge lp:~kissiel/checkbox/autopilot-infrastructure
Reviewer Review Type Date Requested Status
Maciej Kisielewski Approve
Review via email: mp+253880@code.launchpad.net

Description of the change

This MR replaces https://code.launchpad.net/~kissiel/checkbox/autopilot-testing/+merge/253774 as the previous one failed to be auto-merged by tarmac.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Self-approving. This was already reviewed here: https://code.launchpad.net/~kissiel/checkbox/autopilot-testing/+merge/253774

If this doesn't land, it means that tarmac is seriously borked.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-touch/Makefile'
2--- checkbox-touch/Makefile 2014-08-11 14:20:37 +0000
3+++ checkbox-touch/Makefile 2015-03-23 21:22:52 +0000
4@@ -11,6 +11,7 @@
5 all:
6
7 autopilot:
8+ ./get-libs
9 chmod +x tests/autopilot/run
10 tests/autopilot/run
11
12@@ -18,5 +19,5 @@
13 qmltestrunner -input tests/unit
14
15 run:
16- /usr/bin/qmlscene $@ main.qml
17+ /usr/bin/qmlscene $@ checkbox-touch.qml
18
19
20=== modified file 'checkbox-touch/README.rst'
21--- checkbox-touch/README.rst 2014-12-03 15:05:34 +0000
22+++ checkbox-touch/README.rst 2015-03-23 21:22:52 +0000
23@@ -56,7 +56,7 @@
24 Running Checkbox-Touch on a desktop
25 -----------------------------------
26
27-To run on a desktop run `qmlscene main.qml`
28+To run on a desktop run `qmlscene checkbox-touch.qml`
29 Note: Make sure you've ran `./get-libs` first.
30
31
32
33=== modified file 'checkbox-touch/build-me'
34--- checkbox-touch/build-me 2015-03-13 14:21:40 +0000
35+++ checkbox-touch/build-me 2015-03-23 21:22:52 +0000
36@@ -80,7 +80,8 @@
37 "_comment": "file generated automatically with {0}"
38 .format(parser.prog),
39 "revision": get_revision_string(),
40- "testplan": args.testplan
41+ "testplan": args.testplan,
42+ "providersDir": "providers"
43 }
44 settings_file = open('settings.json', 'w')
45 settings_file.write(json.dumps(settings, sort_keys=True, indent=4))
46@@ -115,7 +116,7 @@
47 [Desktop Entry]
48 Name=Checkbox
49 Comment=System testing utility for Ubuntu
50- Exec=qmlscene {import_options} $@ main.qml
51+ Exec=qmlscene {import_options} $@ checkbox-touch.qml
52 Icon=checkbox-touch.svg
53 Terminal=false
54 Type=Application
55
56=== removed symlink 'checkbox-touch/checkbox-touch.qml'
57=== target was u'preview.qml'
58=== renamed file 'checkbox-touch/main.qml' => 'checkbox-touch/checkbox-touch.qml'
59--- checkbox-touch/main.qml 2015-02-09 14:19:48 +0000
60+++ checkbox-touch/checkbox-touch.qml 2015-03-23 21:22:52 +0000
61@@ -57,24 +57,41 @@
62 property var appSettings: {
63 "applicationName" : applicationName,
64 "revision": "unknown revision",
65- "testplan": ""
66+ "testplan": "",
67+ "providersDir": "providers"
68+ }
69+
70+ Arguments {
71+ id: args
72+ Argument {
73+ name: "autopilot"
74+ help: i18n.tr("Run Checkbox-Touch in autopilot-testing mode")
75+ required: false
76+ }
77 }
78
79 Component.onCompleted: {
80- var xhr = new XMLHttpRequest;
81- xhr.open("GET", "settings.json");
82- xhr.onreadystatechange = function() {
83- if (xhr.readyState == XMLHttpRequest.DONE) {
84- try {
85- appSettings = JSON.parse(xhr.responseText);
86- } catch (x) {
87- // if we cannot parse settings.json, we should leave
88- // deafult values of appSettings
89- console.log("Could not parse settings.json. Using default values")
90+ if (args.values["autopilot"]) {
91+ // autopilot-testing mode
92+ appSettings["testplan"] = "2015.com.canonical.certification::checkbox-touch-autopilot"
93+ appSettings["providersDir"] = "tests/autopilot/autopilot-provider"
94+ } else {
95+ // normal execution - load settings.json file
96+ var xhr = new XMLHttpRequest;
97+ xhr.open("GET", "settings.json");
98+ xhr.onreadystatechange = function() {
99+ if (xhr.readyState == XMLHttpRequest.DONE) {
100+ try {
101+ appSettings = JSON.parse(xhr.responseText);
102+ } catch (x) {
103+ // if we cannot parse settings.json, we should leave
104+ // deafult values of appSettings
105+ console.log("Could not parse settings.json. Using default values")
106+ }
107 }
108 }
109+ xhr.send();
110 }
111- xhr.send();
112 }
113
114
115@@ -115,7 +132,7 @@
116 "checkbox_touch" : applicationVersion,
117 "plainbox" : plainboxVersion
118 };
119- resumeOrStartSession();
120+ resumeOrStartSession(appSettings["providersDir"]);
121 }
122 onSessionReady: {
123 welcomePage.enableButton()
124@@ -223,7 +240,7 @@
125 onRestartSession: {
126 pageStack.clear();
127 pageStack.push(welcomePage);
128- app.startSession();
129+ app.startSession(appSettings["providersDir"]);
130 }
131 }
132
133@@ -310,10 +327,10 @@
134 } else {
135 if (result.errors_encountered) {
136 ErrorLogic.showError(mainView, i18n.tr("Could not resume session."),
137- app.startSession(),
138+ app.startSession(appSettings["providersDir"]),
139 i18n.tr("Start new session"));
140 } else {
141- app.startSession();
142+ app.startSession(appSettings["providersDir"]);
143 }
144 }
145 });
146@@ -363,7 +380,7 @@
147 resultsPage.endTesting.connect(function() {
148 pageStack.clear();
149 app.clearSession(function() {
150- app.startSession();
151+ app.startSession(appSettings["providersDir"]);
152 pageStack.push(welcomePage);
153 });
154 });
155
156=== modified file 'checkbox-touch/checkbox-touch.qmlproject'
157--- checkbox-touch/checkbox-touch.qmlproject 2014-08-12 18:58:43 +0000
158+++ checkbox-touch/checkbox-touch.qmlproject 2015-03-23 21:22:52 +0000
159@@ -1,7 +1,7 @@
160 import QmlProject 1.1
161
162 Project {
163- mainFile: "main.qml"
164+ mainFile: "checkbox-touch.qml"
165
166 /* Include .qml, .js, and image files from current directory and subdirectories */
167 QmlFiles {
168
169=== modified file 'checkbox-touch/components/CheckboxTouchApplication.qml'
170--- checkbox-touch/components/CheckboxTouchApplication.qml 2015-03-13 14:21:45 +0000
171+++ checkbox-touch/components/CheckboxTouchApplication.qml 2015-03-23 21:22:52 +0000
172@@ -44,16 +44,16 @@
173 // Starts session in plainbox and runs all necessary setup actions.
174 // Calling this function will signal sessionReady() once it's finished
175 // doing setup.
176- function startSession() {
177- request("start_session", [], function(result) {
178+ function startSession(providersDir) {
179+ request("start_session", [providersDir], function(result) {
180 sessionDir = result['session_dir'];
181 sessionReady();
182 }, function(error) {
183 console.error("Unable to start session: " + error);
184 });
185 }
186- function resumeSession(rerunLastTest, continuation) {
187- request("resume_session", [rerunLastTest], function(result) {
188+ function resumeSession(rerunLastTest, providersDir, continuation) {
189+ request("resume_session", [rerunLastTest, providersDir], function(result) {
190 if (!result["session_id"]) {
191 pageStack.pop();
192 ErrorLogic.showError(mainView,
193
194=== modified file 'checkbox-touch/py/checkbox_touch.py'
195--- checkbox-touch/py/checkbox_touch.py 2015-03-13 14:21:45 +0000
196+++ checkbox-touch/py/checkbox_touch.py 2015-03-23 21:22:52 +0000
197@@ -351,7 +351,7 @@
198 }
199
200 @view
201- def start_session(self):
202+ def start_session(self, providers_dir):
203 if self.manager is not None:
204 _logger.warning("start_session() should not be called twice!")
205 else:
206@@ -360,7 +360,7 @@
207 self.manager.add_local_device_context()
208 self.context = self.manager.default_device_context
209 # Add some all providers into the context
210- for provider in self._get_default_providers():
211+ for provider in self._get_default_providers(providers_dir):
212 self.context.add_provider(provider)
213 # Fill in the meta-data
214 self.context.state.metadata.app_id = 'checkbox-touch'
215@@ -386,9 +386,10 @@
216 }
217
218 @view
219- def resume_session(self, rerun_last_test):
220+ def resume_session(self, rerun_last_test, providers_dir):
221 all_units = list(itertools.chain(
222- *[p.unit_list for p in self._get_default_providers()]))
223+ *[p.unit_list for p in self._get_default_providers(
224+ providers_dir)]))
225 try:
226 self.manager = SessionManager.load_session(
227 all_units, self.resume_candidate_storage)
228@@ -772,12 +773,24 @@
229 self.session_storage_repo = SessionStorageRepository(
230 self._get_app_cache_directory())
231
232- def _get_default_providers(self):
233+ def _get_default_providers(self, providers_dir):
234+ """
235+ Get providers
236+
237+ :param providers_dir:
238+ Path within application tree from which to load providers
239+ :returns:
240+ list of loaded providers
241+ """
242 all_providers.load()
243 provider_list = all_providers.get_all_plugin_objects()
244 # when running on ubuntu-touch device, APP_DIR env var is present
245 # and points to touch application top directory
246- path = os.path.join(os.path.expandvars('$APP_DIR'), 'providers')
247+ app_root_dir = os.path.normpath(os.getenv(
248+ 'APP_DIR', os.path.join(os.path.dirname(__file__), '..')))
249+ path = os.path.join(app_root_dir,
250+ os.path.normpath(providers_dir))
251+ _logger.info("Loading all providers from %s", path)
252 if os.path.exists(path):
253 embedded_providers = EmbeddedProvider1PlugInCollection(path)
254 provider_list += embedded_providers.get_all_plugin_objects()
255
256=== added directory 'checkbox-touch/tests/autopilot/autopilot-provider'
257=== added directory 'checkbox-touch/tests/autopilot/autopilot-provider/jobs'
258=== added file 'checkbox-touch/tests/autopilot/autopilot-provider/jobs/autopilot.pxu'
259--- checkbox-touch/tests/autopilot/autopilot-provider/jobs/autopilot.pxu 1970-01-01 00:00:00 +0000
260+++ checkbox-touch/tests/autopilot/autopilot-provider/jobs/autopilot.pxu 2015-03-23 21:22:52 +0000
261@@ -0,0 +1,7 @@
262+unit: test plan
263+_description:
264+ Test plan that should be default one run by autopilot.
265+id: checkbox-touch-autopilot
266+_name: Checkbox-Touch autpoilot self-test
267+estimated_duration: 60
268+include: autopilot/.*
269
270=== added file 'checkbox-touch/tests/autopilot/autopilot-provider/manage.py'
271--- checkbox-touch/tests/autopilot/autopilot-provider/manage.py 1970-01-01 00:00:00 +0000
272+++ checkbox-touch/tests/autopilot/autopilot-provider/manage.py 2015-03-23 21:22:52 +0000
273@@ -0,0 +1,21 @@
274+#!/usr/bin/env python3
275+from plainbox.provider_manager import setup, N_
276+
277+# You can inject other stuff here but please don't go overboard.
278+#
279+# In particular, if you need comprehensive compilation support to get
280+# your bin/ populated then please try to discuss that with us in the
281+# upstream project IRC channel #checkbox on irc.freenode.net.
282+
283+# NOTE: one thing that you could do here, that makes a lot of sense,
284+# is to compute version somehow. This may vary depending on the
285+# context of your provider. Future version of PlainBox will offer git,
286+# bzr and mercurial integration using the versiontools library
287+# (optional)
288+
289+setup(
290+ name='2015.com.canonical.certification:autopilot-touch',
291+ version="1.0",
292+ description=N_("The 2015.com.canonical.certification:autopilot-touch provider"),
293+ gettext_domain="2015_com_canonical_certification_autopilot-touch",
294+)
295\ No newline at end of file
296
297=== modified file 'checkbox-touch/tests/autopilot/checkbox_touch/__init__.py'
298--- checkbox-touch/tests/autopilot/checkbox_touch/__init__.py 2014-08-11 12:36:57 +0000
299+++ checkbox-touch/tests/autopilot/checkbox_touch/__init__.py 2015-03-23 21:22:52 +0000
300@@ -47,6 +47,7 @@
301 base.get_qmlscene_launch_command(),
302 '-I' + _get_module_include_path(),
303 app_qml_source_location,
304+ '--autopilot',
305 app_type='qt',
306 emulator_base=emulators.UbuntuUIToolkitEmulatorBase)
307 else:
308
309=== added file 'checkbox-touch/tests/autopilot/checkbox_touch/test_checkbox_touch.py'
310--- checkbox-touch/tests/autopilot/checkbox_touch/test_checkbox_touch.py 1970-01-01 00:00:00 +0000
311+++ checkbox-touch/tests/autopilot/checkbox_touch/test_checkbox_touch.py 2015-03-23 21:22:52 +0000
312@@ -0,0 +1,12 @@
313+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
314+
315+from testtools.matchers import Equals
316+from autopilot.matchers import Eventually
317+
318+import checkbox_touch
319+
320+class TestCheckboxTouch(checkbox_touch.ClickAppTestCase):
321+ """Test checking if app launches"""
322+ def test_launches(self):
323+ main_view = self.app.select_single(objectName='mainView')
324+ self.assertThat(main_view.visible, Eventually(Equals(True)))
325
326=== removed file 'checkbox-touch/tests/autopilot/checkbox_touch/test_latch_button.py'
327--- checkbox-touch/tests/autopilot/checkbox_touch/test_latch_button.py 2014-09-11 08:09:35 +0000
328+++ checkbox-touch/tests/autopilot/checkbox_touch/test_latch_button.py 1970-01-01 00:00:00 +0000
329@@ -1,16 +0,0 @@
330-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
331-
332-from testtools.matchers import Equals
333-
334-import checkbox_touch
335-
336-
337-class LatchButtonTestCase(checkbox_touch.ClickAppTestCase):
338- """Tests for the LatchButton component"""
339- def test_latching(self):
340- latch_button = self.app.select_single(objectName="latchButton")
341- latch_button.swipe_into_view()
342- signal = latch_button.watch_signal("latchedClicked()")
343- self.pointing_device.click_object(latch_button)
344- self.pointing_device.click_object(latch_button) # click again!
345- self.assertThat(signal.num_emissions, Equals(1))
346
347=== removed file 'checkbox-touch/tests/autopilot/checkbox_touch/test_manual_intro_page.py'
348--- checkbox-touch/tests/autopilot/checkbox_touch/test_manual_intro_page.py 2014-09-11 08:09:35 +0000
349+++ checkbox-touch/tests/autopilot/checkbox_touch/test_manual_intro_page.py 1970-01-01 00:00:00 +0000
350@@ -1,35 +0,0 @@
351-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
352-
353-from testtools.matchers import Equals
354-
355-import checkbox_touch
356-
357-
358-class ManualIntroPageTestCase(checkbox_touch.ClickAppTestCase):
359- """Tests for the Intro page to Manual test"""
360-
361- def setUp(self):
362- super(ManualIntroPageTestCase, self).setUp()
363- # open ManualIntroPage by clicking on 'Manual test page' butotn
364- button = self.main_view.select_single(
365- objectName='manualIntroPageButton')
366- self.pointing_device.click_object(button)
367- self.page = self.app.select_single(objectName='manualIntroPage')
368-
369- def test_default_content(self):
370- self.assertThat(self.page.title, Equals('Test Description'))
371-
372- def test_continue_button(self):
373- continue_button = self.page.select_single(objectName='continueButton')
374- self.assertThat(continue_button.text, Equals('Continue'))
375- signal = self.page.watch_signal('continueClicked()')
376- self.pointing_device.click_object(continue_button)
377- self.assertThat(signal.was_emitted, Equals(True))
378-
379- def test_goes_to_verification(self):
380- continue_button = self.page.select_single(objectName='continueButton')
381- self.pointing_device.click_object(continue_button)
382- next_page = self.app.select_single(objectName='testVerificationPage')
383- self.assertThat(next_page.title, Equals('Verification'))
384- page_stack = self.main_view.select_single(objectName='pageStack')
385- self.assertThat(page_stack.depth, Equals(3))
386
387=== removed file 'checkbox-touch/tests/autopilot/checkbox_touch/test_resume_session_screen.py'
388--- checkbox-touch/tests/autopilot/checkbox_touch/test_resume_session_screen.py 2014-09-11 08:09:35 +0000
389+++ checkbox-touch/tests/autopilot/checkbox_touch/test_resume_session_screen.py 1970-01-01 00:00:00 +0000
390@@ -1,52 +0,0 @@
391-# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
392-
393-"""Tests for the Hello World"""
394-
395-from testtools.matchers import Equals
396-
397-import checkbox_touch
398-
399-
400-class ResumeSessionScreenTestCase(checkbox_touch.ClickAppTestCase):
401- """Tests for resume session screen"""
402-
403- def setUp(self):
404- super(ResumeSessionScreenTestCase, self).setUp()
405- # click "resume session page"
406- button = self.main_view.select_single(
407- objectName='resumeSessionPageButton')
408- self.pointing_device.click_object(button)
409- self.page = self.app.select_single(objectName='resumeSessionPage')
410-
411- def test_default_content(self):
412- self.assertThat(self.page.title, Equals('Resume session'))
413- button_texts = [('rerunButtonLabel', 'Rerun last'),
414- ('continueButtonLabel', 'Continue'),
415- ('restartButtonLabel', 'Restart')]
416- for obj_name, text in button_texts:
417- obj = self.main_view.select_single(objectName=obj_name)
418- self.assertThat(obj.text, Equals(text))
419-
420- def test_signal_rerun_last(self):
421- signal_watcher = self.page.watch_signal('rerunLast()')
422- button = self.main_view.select_single(objectName='rerunButton')
423- self.pointing_device.click_object(button)
424- self.assertThat(signal_watcher.was_emitted, Equals(True))
425- page_stack = self.main_view.select_single(objectName='pageStack')
426- self.assertThat(page_stack.depth, Equals(1))
427-
428- def test_signal_continue_session(self):
429- signal_watcher = self.page.watch_signal('continueSession()')
430- button = self.main_view.select_single(objectName='continueButton')
431- self.pointing_device.click_object(button)
432- self.assertThat(signal_watcher.was_emitted, Equals(True))
433- page_stack = self.main_view.select_single(objectName='pageStack')
434- self.assertThat(page_stack.depth, Equals(1))
435-
436- def test_signal_restart_session(self):
437- signal_watcher = self.page.watch_signal('restartSession()')
438- button = self.main_view.select_single(objectName='restartButton')
439- self.pointing_device.click_object(button)
440- self.assertThat(signal_watcher.was_emitted, Equals(True))
441- page_stack = self.main_view.select_single(objectName='pageStack')
442- self.assertThat(page_stack.depth, Equals(1))
443
444=== modified file 'checkbox-touch/tests/autopilot/run'
445--- checkbox-touch/tests/autopilot/run 2014-08-11 12:36:57 +0000
446+++ checkbox-touch/tests/autopilot/run 2015-03-23 21:22:52 +0000
447@@ -2,11 +2,13 @@
448
449 if [[ -z `which autopilot` ]]; then
450 echo "Autopilot is not installed. Skip"
451- exit
452+ exit 1
453 fi
454
455 SCRIPTPATH=`dirname $0`
456 pushd ${SCRIPTPATH}
457 autopilot run checkbox_touch
458+ret=$?
459 popd
460+exit $ret
461

Subscribers

People subscribed via source and target branches