Merge lp:~om26er/ubuntu-calculator-app/fix_start_stop_OSK into lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk

Proposed by Omer Akram
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 169
Merged at revision: 169
Proposed branch: lp:~om26er/ubuntu-calculator-app/fix_start_stop_OSK
Merge into: lp:~ubuntu-calculator-dev/ubuntu-calculator-app/old_trunk
Diff against target: 86 lines (+37/-12)
2 files modified
tests/autopilot/ubuntu_calculator_app/tests/__init__.py (+19/-12)
tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py (+18/-0)
To merge this branch: bzr merge lp:~om26er/ubuntu-calculator-app/fix_start_stop_OSK
Reviewer Review Type Date Requested Status
Mihir Soni Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+188264@code.launchpad.net

Commit message

Improves the start/stop of OSK during autopilot test run. Handle a condition where interrupting the test run (ctrl+c) would result in not being able to run the test suite again.

Description of the change

Improves the start/stop of OSK during autopilot test run. Handle a condition where interrupting the test run (ctrl+c) would result in not being able to run the test suite again.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mihir Soni (mihirsoni) wrote :

Looks good..:)

Thanks for your time

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/__init__.py'
2--- tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-09-27 16:31:05 +0000
3+++ tests/autopilot/ubuntu_calculator_app/tests/__init__.py 2013-09-30 06:41:52 +0000
4@@ -45,13 +45,6 @@
5 self.temp_move_sqlite_db()
6 self.addCleanup(self.restore_sqlite_db)
7
8- #turn off the OSK so it doesn't block screen elements
9- if model() != 'Desktop':
10- os.system("stop maliit-server")
11- #adding cleanup step seems to restart service immeadiately
12- #disabling for now
13- #self.addCleanup(os.system("start maliit-server"))
14-
15 if os.path.exists(self.local_location):
16 self.launch_test_local()
17 elif os.path.exists(self.installed_location):
18@@ -81,11 +74,25 @@
19 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
20
21 def temp_move_sqlite_db(self):
22- if os.path.exists(self.sqlite_dir):
23- shutil.move(self.sqlite_dir, self.backup_dir)
24- self.assertThat(
25- lambda: os.path.exists(self.backup_dir),
26- Eventually(Equals(True)))
27+ if os.path.exists(self.sqlite_dir) and os.path.exists(self.backup_dir):
28+ # In case the test suite was interrupted (ctrl+c) it may not run
29+ # again because there is already a backup dir, so we make sure to
30+ # delete it.
31+ shutil.rmtree(self.backup_dir)
32+ self.assertThat(
33+ lambda: os.path.exists(self.backup_dir),
34+ Eventually(Equals(False)))
35+ shutil.move(self.sqlite_dir, self.backup_dir)
36+ self.assertThat(
37+ lambda: os.path.exists(self.backup_dir),
38+ Eventually(Equals(True)))
39+ elif os.path.exists(self.sqlite_dir):
40+ shutil.move(self.sqlite_dir, self.backup_dir)
41+ self.assertThat(
42+ lambda: os.path.exists(self.backup_dir),
43+ Eventually(Equals(True)))
44+ else:
45+ pass
46
47 def restore_sqlite_db(self):
48 if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):
49
50=== modified file 'tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py'
51--- tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py 2013-09-24 19:51:16 +0000
52+++ tests/autopilot/ubuntu_calculator_app/tests/test_simple_page.py 2013-09-30 06:41:52 +0000
53@@ -20,8 +20,10 @@
54
55 from testtools.matchers import Equals
56 from autopilot.matchers import Eventually
57+from autopilot.platform import model
58
59 from ubuntu_calculator_app.tests import CalculatorTestCase
60+import subprocess
61
62
63 class TestSimplePage(CalculatorTestCase):
64@@ -29,6 +31,22 @@
65 def setUp(self):
66 super(TestSimplePage, self).setUp()
67
68+ @classmethod
69+ def setUpClass(cls):
70+ if model() != "Desktop":
71+ try:
72+ subprocess.check_call(["stop", "-q", "maliit-server"])
73+ except subprocess.CalledProcessError:
74+ pass
75+
76+ @classmethod
77+ def tearDownClass(cls):
78+ if model() != "Desktop":
79+ try:
80+ subprocess.check_call(["start", "-q", "maliit-server"])
81+ except subprocess.CalledProcessError:
82+ pass
83+
84 def test_operation_after_clear(self):
85 """ Test that after clearing one calculation, the next is still correct
86 (bug #1164973).

Subscribers

People subscribed via source and target branches