Merge lp:~canonical-platform-qa/address-book-app/remove-teardown-ap-tests into lp:address-book-app

Proposed by Christopher Lee
Status: Needs review
Proposed branch: lp:~canonical-platform-qa/address-book-app/remove-teardown-ap-tests
Merge into: lp:address-book-app
Diff against target: 68 lines (+27/-10)
1 file modified
tests/autopilot/address_book_app/tests/__init__.py (+27/-10)
To merge this branch: bzr merge lp:~canonical-platform-qa/address-book-app/remove-teardown-ap-tests
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Vincent Ladeuil (community) Needs Information
Leo Arias (community) Approve
Ubuntu Phablet Team Pending
Review via email: mp+258829@code.launchpad.net

Commit message

Test now uses addCleanup to re-start the OSK.

Description of the change

Test now uses addCleanup to re-start the OSK.
I had an issue where the OSK wasn't started after a test which caused the following tests to fail when they tried to stop an already stopped service.

To post a comment you must log in.
430. By Christopher Lee

User a fixture instead.

431. By Christopher Lee

Oops, forgot to re-raise

Revision history for this message
Leo Arias (elopio) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Vincent Ladeuil (vila) wrote :

See inline question.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
432. By Christopher Lee

Actuall log error message from command call

Revision history for this message
Christopher Lee (veebers) wrote :

> See inline question.
Good point, now logging better details.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Federico Gimenez (fgimenez) wrote :

LGTM

review: Approve

Unmerged revisions

432. By Christopher Lee

Actuall log error message from command call

431. By Christopher Lee

Oops, forgot to re-raise

430. By Christopher Lee

User a fixture instead.

429. By Christopher Lee

Remove need for tearDown using addCleanup

428. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

427. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

426. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/address_book_app/tests/__init__.py'
2--- tests/autopilot/address_book_app/tests/__init__.py 2015-04-14 22:19:01 +0000
3+++ tests/autopilot/address_book_app/tests/__init__.py 2015-05-14 04:42:25 +0000
4@@ -16,6 +16,8 @@
5
6 """address-book-app autopilot tests."""
7
8+import fixtures
9+import logging
10 import os
11 import time
12 import subprocess
13@@ -28,6 +30,30 @@
14 import ubuntuuitoolkit
15 from ubuntuuitoolkit import emulators as toolkit_emulators
16
17+logger = logging.getLogger(__name__)
18+
19+
20+class DisableOnScreenKeyboard(fixtures.Fixture):
21+ """Disable the OSK for the time of the test (Does nothing on desktop)."""
22+
23+ def setUp(self):
24+ super().setUp()
25+ if model() != 'Desktop':
26+ self.toggle_keyboard(state='stop')
27+ self.addCleanup(self.toggle_keyboard, state='start')
28+
29+ def toggle_keyboard(self, state):
30+ try:
31+ subprocess.check_output(
32+ ['/sbin/initctl', state, 'maliit-server'],
33+ stderr=subprocess.STDOUT
34+ )
35+ except subprocess.CalledProcessError as e:
36+ logger.error(
37+ 'Failed to toggle state of keyboard to: {state}\n'
38+ 'Error message: {msg}'.format(state=state, msg=e.output))
39+ raise
40+
41
42 class AddressBookAppTestCase(AutopilotTestCase):
43 """A common test case class that provides several useful methods for
44@@ -45,9 +71,7 @@
45 self.pointing_device = toolkit_emulators.get_pointing_device()
46 super(AddressBookAppTestCase, self).setUp()
47
48- # stop vkb
49- if model() != "Desktop":
50- subprocess.check_call(["/sbin/initctl", "stop", "maliit-server"])
51+ self.useFixture(DisableOnScreenKeyboard())
52
53 if 'AUTOPILOT_APP' in os.environ:
54 self.app_bin = os.environ['AUTOPILOT_APP']
55@@ -86,13 +110,6 @@
56 AddressBookAppTestCase.ARGS = []
57 self.main_window.visible.wait_for(True)
58
59- def tearDown(self):
60- super(AddressBookAppTestCase, self).tearDown()
61-
62- # start the vkb
63- if model() != "Desktop":
64- subprocess.check_call(["/sbin/initctl", "start", "maliit-server"])
65-
66 def launch_test_local(self):
67 return self.launch_test_application(
68 self.app_bin,

Subscribers

People subscribed via source and target branches