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
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-12 17:46:04 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-09-05 02:57:23 +0000
@@ -21,12 +21,13 @@
2121
22import os.path22import os.path
23import os23import os
24import shutil
2425
25from autopilot.input import Mouse, Touch, Pointer26from autopilot.input import Mouse, Touch, Pointer
26from autopilot.platform import model27from autopilot.platform import model
27from autopilot.testcase import AutopilotTestCase28from autopilot.testcase import AutopilotTestCase
28from autopilot.matchers import Eventually29from autopilot.matchers import Eventually
29from testtools.matchers import GreaterThan30from testtools.matchers import GreaterThan, Equals
3031
31from ubuntuuitoolkit import emulators as toolkit_emulators32from ubuntuuitoolkit import emulators as toolkit_emulators
32from ubuntu_clock_app import emulators33from ubuntu_clock_app import emulators
@@ -43,10 +44,16 @@
43 scenarios = [('with touch', dict(input_device_class=Touch))]44 scenarios = [('with touch', dict(input_device_class=Touch))]
4445
45 local_location = "../../ubuntu-clock-app.qml"46 local_location = "../../ubuntu-clock-app.qml"
47 sqlite_dir = os.path.expanduser(
48 "~/.local/share/Qt Project/QtQmlViewer/QML/OfflineStorage/Databases")
49 backup_dir = sqlite_dir + ".backup"
4650
47 def setUp(self):51 def setUp(self):
48 self.pointing_device = Pointer(self.input_device_class.create())52 self.pointing_device = Pointer(self.input_device_class.create())
49 super(ClockAppTestCase, self).setUp()53 super(ClockAppTestCase, self).setUp()
54 self.temp_move_sqlite_db()
55 self.addCleanup(self.restore_sqlite_db)
56
50 if os.path.exists(self.local_location):57 if os.path.exists(self.local_location):
51 self.launch_test_local()58 self.launch_test_local()
52 else:59 else:
@@ -68,6 +75,31 @@
68 app_type='qt',75 app_type='qt',
69 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)76 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
7077
78 def temp_move_sqlite_db(self):
79 if os.path.exists(self.sqlite_dir):
80 shutil.move(self.sqlite_dir, self.backup_dir)
81 self.assertThat(
82 lambda: os.path.exists(self.backup_dir),
83 Eventually(Equals(True)))
84
85 def restore_sqlite_db(self):
86 if os.path.exists(self.backup_dir) and os.path.exists(self.sqlite_dir):
87 shutil.rmtree(self.sqlite_dir)
88 self.assertThat(
89 lambda: os.path.exists(self.sqlite_dir),
90 Eventually(Equals(False)))
91 shutil.move(self.backup_dir, self.sqlite_dir)
92 self.assertTrue(
93 lambda: os.path.exists(self.sqlite_dir),
94 Eventually(Equals(True)))
95 elif os.path.exists(self.backup_dir):
96 shutil.move(self.backup_dir, self.sqlite_dir)
97 self.assertTrue(
98 lambda: os.path.exists(self.sqlite_dir),
99 Eventually(Equals(True)))
100 else:
101 pass
102
71 @property103 @property
72 def main_view(self):104 def main_view(self):
73 return self.app.select_single(emulators.MainView)105 return self.app.select_single(emulators.MainView)
74106
=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-02 19:39:34 +0000
+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-09-05 02:57:23 +0000
@@ -89,16 +89,14 @@
89 self.pointing_device.click_object(add_preset_button)89 self.pointing_device.click_object(add_preset_button)
9090
91 # Write in the label91 # Write in the label
92 if model() != "Desktop":92 self.drag_page_up_to_show_input_box()
93 self.drag_page_up_to_show_input_box()
94 self.assertThat(self.main_view.get_timer_name_preset, Eventually(Not(Is(None))))93 self.assertThat(self.main_view.get_timer_name_preset, Eventually(Not(Is(None))))
95 label = self.select_name_preset_label() 94 label = self.select_name_preset_label()
96 self.assertThat(label.focus, Eventually(Equals(True)))95 self.assertThat(label.focus, Eventually(Equals(True)))
97 self.keyboard.type("test")96 self.keyboard.type("test")
98 self.assertThat(label.text, Eventually(Equals("test")))97 self.assertThat(label.text, Eventually(Equals("test")))
9998
100 if model() != "Desktop":99 self.drag_page_down_to_previous_state()
101 self.drag_page_down_to_previous_state()
102100
103 # Set hour101 # Set hour
104 self.assertThat(self.main_view.get_timer_hour_hand, Eventually(Not(Is(None))))102 self.assertThat(self.main_view.get_timer_hour_hand, Eventually(Not(Is(None))))
@@ -113,12 +111,14 @@
113111
114 # Press "Save" toolbar button112 # Press "Save" toolbar button
115 self.assertThat(self.main_view.get_toolbar_timer_save_preset_button, Eventually(Not(Is(None))))113 self.assertThat(self.main_view.get_toolbar_timer_save_preset_button, Eventually(Not(Is(None))))
116 save_preset_button = self.main_view.get_toolbar_timer_save_preset_button()
117 self.pointing_device.click_object(save_preset_button)
118114
119 # Check if the preset has been saved115 #make sure preset is saved, and shows up properly
120 self.assertThat(self.main_view.get_num_of_presets,116 timeout = 0
121 Eventually(Equals(num_of_presets_old+1)))117 while self.main_view.get_num_of_presets() != num_of_presets_old+1 and timeout < 10:
118 save_preset_button = self.main_view.get_toolbar_timer_save_preset_button()
119 self.pointing_device.click_object(save_preset_button)
120 sleep(1)
121 timeout += 1
122122
123 def test_delete_preset(self):123 def test_delete_preset(self):
124 """Test if the swipe of a preset deletes it"""124 """Test if the swipe of a preset deletes it"""
@@ -129,17 +129,17 @@
129 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))129 self.assertThat(self.main_view.get_num_of_presets, Eventually(Not(Is(None))))
130 num_of_presets_old = self.main_view.get_num_of_presets()130 num_of_presets_old = self.main_view.get_num_of_presets()
131 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))131 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))
132 first_preset = self.main_view.get_first_preset_list_item()132
133133 self.drag_page_up_to_show_input_box()
134 if model() != "Desktop":134
135 self.drag_page_up_to_show_input_box()
136 # Delete the preset135 # Delete the preset
137 x, y, w, h = first_preset.globalRect136 timeout = 0
138 tx = x + (w / 8)
139 ty = y + (h / 2)
140 timeout = 0
141 while self.main_view.get_num_of_presets() != num_of_presets_old-1 and timeout < 10:137 while self.main_view.get_num_of_presets() != num_of_presets_old-1 and timeout < 10:
142 self.pointing_device.drag(tx, ty, w - w / 8, ty) 138 first_preset = self.main_view.get_first_preset_list_item()
139 x, y, w, h = first_preset.globalRect
140 tx = x + (w / 8)
141 ty = y + (h / 2)
142 self.pointing_device.drag(tx, ty, w - w / 8, ty)
143 sleep(1)143 sleep(1)
144 timeout += 1144 timeout += 1
145145
@@ -156,12 +156,11 @@
156 # Click to select the preset156 # Click to select the preset
157 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))157 self.assertThat(self.main_view.get_first_preset_list_item, Eventually(Not(Is(None))))
158 first_preset = self.main_view.get_first_preset_list_item()158 first_preset = self.main_view.get_first_preset_list_item()
159 if model() != "Desktop":159
160 self.drag_page_up_to_show_input_box()160 self.drag_page_up_to_show_input_box()
161 self.pointing_device.click_object(first_preset)161 self.pointing_device.click_object(first_preset)
162162
163 if model() != "Desktop":163 self.drag_page_down_to_previous_state()
164 self.drag_page_down_to_previous_state()
165164
166 # Click to start the preset165 # Click to start the preset
167 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))166 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))
@@ -171,7 +170,7 @@
171 self.pointing_device.click_object(label)170 self.pointing_device.click_object(label)
172 sleep(1)171 sleep(1)
173 timeout += 1172 timeout += 1
174 173
175 # Check if timer is started174 # Check if timer is started
176 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))175 self.assertThat(self.main_view.get_label_timer, Eventually(Not(Is(None))))
177 label_timer = self.main_view.get_label_timer()176 label_timer = self.main_view.get_label_timer()

Subscribers

People subscribed via source and target branches