Merge lp:~nskaggs/ubuntu-clock-app/ap-cleanups into lp:ubuntu-clock-app/saucy

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 183
Merged at revision: 181
Proposed branch: lp:~nskaggs/ubuntu-clock-app/ap-cleanups
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 163 lines (+56/-25)
2 files modified
tests/autopilot/ubuntu_clock_app/tests/__init__.py (+33/-1)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+23/-24)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-clock-app/ap-cleanups
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+184000@code.launchpad.net

Commit message

correct timing loop to account for moving presets
add db cleanup before each test run

Description of the change

Fix the current bug with autopilot tests and add db cleanups before each test

http://reports.qa.ubuntu.com/smokeng/saucy/image/3966/ubuntu-clock-app-autopilot/

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
183. By Nicholas Skaggs

add loop for save button timing, remove "desktop" specific code so test runs uniformly across devices

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Continuous integration, rev:183
http://91.189.93.70:8080/job/ubuntu-clock-app-ci/11/
Executed test runs:

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-clock-app-ci/11/rebuild

review: Needs Fixing (continuous-integration)
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
2--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-12 17:46:04 +0000
3+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-09-05 02:57:23 +0000
4@@ -21,12 +21,13 @@
5
6 import os.path
7 import os
8+import shutil
9
10 from autopilot.input import Mouse, Touch, Pointer
11 from autopilot.platform import model
12 from autopilot.testcase import AutopilotTestCase
13 from autopilot.matchers import Eventually
14-from testtools.matchers import GreaterThan
15+from testtools.matchers import GreaterThan, Equals
16
17 from ubuntuuitoolkit import emulators as toolkit_emulators
18 from ubuntu_clock_app import emulators
19@@ -43,10 +44,16 @@
20 scenarios = [('with touch', dict(input_device_class=Touch))]
21
22 local_location = "../../ubuntu-clock-app.qml"
23+ sqlite_dir = os.path.expanduser(
24+ "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases")
25+ backup_dir = sqlite_dir + ".backup"
26
27 def setUp(self):
28 self.pointing_device = Pointer(self.input_device_class.create())
29 super(ClockAppTestCase, self).setUp()
30+ self.temp_move_sqlite_db()
31+ self.addCleanup(self.restore_sqlite_db)
32+
33 if os.path.exists(self.local_location):
34 self.launch_test_local()
35 else:
36@@ -68,6 +75,31 @@
37 app_type='qt',
38 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
39
40+ def temp_move_sqlite_db(self):
41+ if os.path.exists(self.sqlite_dir):
42+ shutil.move(self.sqlite_dir, self.backup_dir)
43+ self.assertThat(
44+ lambda: os.path.exists(self.backup_dir),
45+ Eventually(Equals(True)))
46+
47+ def restore_sqlite_db(self):
48+ if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):
49+ shutil.rmtree(self.sqlite_dir)
50+ self.assertThat(
51+ lambda: os.path.exists(self.sqlite_dir),
52+ Eventually(Equals(False)))
53+ shutil.move(self.backup_dir, self.sqlite_dir)
54+ self.assertTrue(
55+ lambda: os.path.exists(self.sqlite_dir),
56+ Eventually(Equals(True)))
57+ elif os.path.exists(self.backup_dir):
58+ shutil.move(self.backup_dir, self.sqlite_dir)
59+ self.assertTrue(
60+ lambda: os.path.exists(self.sqlite_dir),
61+ Eventually(Equals(True)))
62+ else:
63+ pass
64+
65 @property
66 def main_view(self):
67 return self.app.select_single(emulators.MainView)
68
69=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
70--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-02 19:39:34 +0000
71+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-05 02:57:23 +0000
72@@ -89,16 +89,14 @@
73 self.pointing_device.click_object(add_preset_button)
74
75 # Write in the label
76- if model() != "Desktop":
77- self.drag_page_up_to_show_input_box()
78+ self.drag_page_up_to_show_input_box()
79 self.assertThat(self.main_view.get_timer_name_preset, Eventually(Not(Is(None))))
80- label = self.select_name_preset_label()
81+ label = self.select_name_preset_label()
82 self.assertThat(label.focus, Eventually(Equals(True)))
83 self.keyboard.type("test")
84 self.assertThat(label.text, Eventually(Equals("test")))
85
86- if model() != "Desktop":
87- self.drag_page_down_to_previous_state()
88+ self.drag_page_down_to_previous_state()
89
90 # Set hour
91 self.assertThat(self.main_view.get_timer_hour_hand, Eventually(Not(Is(None))))
92@@ -113,12 +111,14 @@
93
94 # Press "Save" toolbar button
95 self.assertThat(self.main_view.get_toolbar_timer_save_preset_button, Eventually(Not(Is(None))))
96- save_preset_button = self.main_view.get_toolbar_timer_save_preset_button()
97- self.pointing_device.click_object(save_preset_button)
98
99- # Check if the preset has been saved
100- self.assertThat(self.main_view.get_num_of_presets,
101- Eventually(Equals(num_of_presets_old+1)))
102+ #make sure preset is saved, and shows up properly
103+ timeout = 0
104+ while self.main_view.get_num_of_presets() != num_of_presets_old+1 and timeout < 10:
105+ save_preset_button = self.main_view.get_toolbar_timer_save_preset_button()
106+ self.pointing_device.click_object(save_preset_button)
107+ sleep(1)
108+ timeout += 1
109
110 def test_delete_preset(self):
111 """Test if the swipe of a preset deletes it"""
112@@ -129,17 +129,17 @@
113 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))
114 num_of_presets_old = self.main_view.get_num_of_presets()
115 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))
116- first_preset = self.main_view.get_first_preset_list_item()
117-
118- if model() != "Desktop":
119- self.drag_page_up_to_show_input_box()
120+
121+ self.drag_page_up_to_show_input_box()
122+
123 # Delete the preset
124- x, y, w, h = first_preset.globalRect
125- tx = x + (w / 8)
126- ty = y + (h / 2)
127- timeout = 0
128+ timeout = 0
129 while self.main_view.get_num_of_presets() != num_of_presets_old-1 and timeout < 10:
130- self.pointing_device.drag(tx, ty, w - w / 8, ty)
131+ first_preset = self.main_view.get_first_preset_list_item()
132+ x, y, w, h = first_preset.globalRect
133+ tx = x + (w / 8)
134+ ty = y + (h / 2)
135+ self.pointing_device.drag(tx, ty, w - w / 8, ty)
136 sleep(1)
137 timeout += 1
138
139@@ -156,12 +156,11 @@
140 # Click to select the preset
141 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))
142 first_preset = self.main_view.get_first_preset_list_item()
143- if model() != "Desktop":
144- self.drag_page_up_to_show_input_box()
145+
146+ self.drag_page_up_to_show_input_box()
147 self.pointing_device.click_object(first_preset)
148
149- if model() != "Desktop":
150- self.drag_page_down_to_previous_state()
151+ self.drag_page_down_to_previous_state()
152
153 # Click to start the preset
154 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))
155@@ -171,7 +170,7 @@
156 self.pointing_device.click_object(label)
157 sleep(1)
158 timeout += 1
159-
160+
161 # Check if timer is started
162 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))
163 label_timer = self.main_view.get_label_timer()

Subscribers

People subscribed via source and target branches