Merge lp:~om26er/ubuntu-clock-app/fix_autopilot_on_touch into lp:ubuntu-clock-app/saucy

Proposed by Omer Akram
Status: Rejected
Rejected by: Nicholas Skaggs
Proposed branch: lp:~om26er/ubuntu-clock-app/fix_autopilot_on_touch
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 191 lines (+74/-27)
4 files modified
tests/autopilot/ubuntu_clock_app/emulators/main_window.py (+9/-0)
tests/autopilot/ubuntu_clock_app/tests/__init__.py (+1/-1)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+62/-25)
timer/TimerPage.qml (+2/-1)
To merge this branch: bzr merge lp:~om26er/ubuntu-clock-app/fix_autopilot_on_touch
Reviewer Review Type Date Requested Status
Nicholas Skaggs Pending
Ubuntu Clock Developers Pending
Review via email: mp+178443@code.launchpad.net

Commit message

fix autopilot tests on touch

Description of the change

autopilot tests are failing on touch devices, this branch fixes that. Also "NewTabBar" is now "TabBar" it seems to re-named that in autopilot tests as tests were failing on the desktop as well.

To post a comment you must log in.
163. By Omer Akram

fix

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Nice! Just need some small house cleaning.

Can you add comments to what these emulator function do. Sort of like "Returns the number of presets in the timer list view".

9 + def get_num_of_presets(self):
10 + time_page = self.app.select_single("TimerPage")
11 + return time_page.select_single("QQuickListView").count
12 +
13 + def get_first_preset_list_item(self):
14 + return self.app.select_single("Standard", objectName="preset0")

I think here you meant "timer_page" instead of "time_page"

9 + def get_num_of_presets(self):
10 + time_page = self.app.select_single("TimerPage")
11 + return time_page.select_single("QQuickListView").count

I think the show_toolbar should be replaced with the new emulator functions which landed in the SDK itself. It was implemented by elopio (irc) where the SDK provides common emulator functions such as show/hide toolbar, switch tabs etc. If you want you can implement this in this MP or otherwise take care of this in a latter commit.

43 def show_toolbar(self):
44 - toolbar_timer = self.main_window.get_toolbar_timer()
45 -
46 - x, y, w, h = toolbar_timer.globalRect
47 - tx = x + (w / 2)
48 - ty = y - (h / 2)
49 -
50 - self.pointing_device.drag(tx, ty + (h / 3), tx, ty - h)
51 + toolbar = self.app.select_single("Toolbar")
52 +
53 + x, y, w, h = toolbar.globalRect
54 + tx = x + (w / 2)
55 + ty = y + (h - (h / 8))
56 +
57 + self.pointing_device.drag(tx, ty, tx, ty - h)
58 + self.assertThat(toolbar.animating, Eventually(Equals(False)))
59 + self.assertThat(toolbar.state, Eventually(Equals("spread")))

Otherwise it all looks good.

164. By Omer Akram

fix per suggestions

Revision history for this message
Omer Akram (om26er) wrote :

> Nice! Just need some small house cleaning.
>
> Can you add comments to what these emulator function do. Sort of like "Returns
> the number of presets in the timer list view".
>
> 9 + def get_num_of_presets(self):
> 10 + time_page = self.app.select_single("TimerPage")
> 11 + return time_page.select_single("QQuickListView").count
> 12 +
> 13 + def get_first_preset_list_item(self):
> 14 + return self.app.select_single("Standard", objectName="preset0")
>
> I think here you meant "timer_page" instead of "time_page"
>
> 9 + def get_num_of_presets(self):
> 10 + time_page = self.app.select_single("TimerPage")
> 11 + return time_page.select_single("QQuickListView").count
>
> I think the show_toolbar should be replaced with the new emulator functions
> which landed in the SDK itself. It was implemented by elopio (irc) where the
> SDK provides common emulator functions such as show/hide toolbar, switch tabs
> etc. If you want you can implement this in this MP or otherwise take care of
> this in a latter commit.
>
> 43 def show_toolbar(self):
> 44 - toolbar_timer = self.main_window.get_toolbar_timer()
> 45 -
> 46 - x, y, w, h = toolbar_timer.globalRect
> 47 - tx = x + (w / 2)
> 48 - ty = y - (h / 2)
> 49 -
> 50 - self.pointing_device.drag(tx, ty + (h / 3), tx, ty - h)
> 51 + toolbar = self.app.select_single("Toolbar")
> 52 +
> 53 + x, y, w, h = toolbar.globalRect
> 54 + tx = x + (w / 2)
> 55 + ty = y + (h - (h / 8))
> 56 +
> 57 + self.pointing_device.drag(tx, ty, tx, ty - h)
> 58 + self.assertThat(toolbar.animating, Eventually(Equals(False)))
> 59 + self.assertThat(toolbar.state, Eventually(Equals("spread")))
>
> Otherwise it all looks good.

Done. The use of ubuntusdk emulators will be done later.

165. By Omer Akram

fix

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Everything in here is now in my branch, plus more asserts and other fixes;

https://code.launchpad.net/~nskaggs/ubuntu-clock-app/fix-autopilot-tests/+merge/178864

Unmerged revisions

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/emulators/main_window.py'
2--- tests/autopilot/ubuntu_clock_app/emulators/main_window.py 2013-07-14 22:16:59 +0000
3+++ tests/autopilot/ubuntu_clock_app/emulators/main_window.py 2013-08-07 13:42:28 +0000
4@@ -101,3 +101,12 @@
5 def get_label_timer(self):
6 """Return the label with the timer countdown"""
7 return self.app.select_single("Label", objectName="labelTimer")
8+
9+ def get_num_of_presets(self):
10+ """Returns the number of presets in the timer page."""
11+ timer_page = self.app.select_single("TimerPage")
12+ return timer_page.select_single("QQuickListView").count
13+
14+ def get_first_preset_list_item(self):
15+ """Returns the first preset list item in the timer page."""
16+ return self.app.select_single("Standard", objectName="preset0")
17
18=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
19--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-07-13 23:36:30 +0000
20+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2013-08-07 13:42:28 +0000
21@@ -66,7 +66,7 @@
22 app_type='qt')
23
24 def get_tabs(self):
25- return self.app.select_single("NewTabBar")
26+ return self.app.select_single("TabBar")
27
28 def move_to_stopwatch_tab(self):
29 tabs_bar = self.get_tabs()
30
31=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
32--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-07-14 22:16:59 +0000
33+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2013-08-07 13:42:28 +0000
34@@ -22,6 +22,7 @@
35
36 from testtools.matchers import Equals, NotEquals
37 from autopilot.matchers import Eventually
38+from autopilot.platform import model
39
40 from ubuntu_clock_app.tests import ClockAppTestCase
41
42@@ -41,13 +42,40 @@
43 self.assertThat(CurrentTab.title, Eventually(Equals("Timer")))
44
45 def show_toolbar(self):
46- toolbar_timer = self.main_window.get_toolbar_timer()
47-
48- x, y, w, h = toolbar_timer.globalRect
49- tx = x + (w / 2)
50- ty = y - (h / 2)
51-
52- self.pointing_device.drag(tx, ty + (h / 3), tx, ty - h)
53+ toolbar = self.app.select_single("Toolbar")
54+
55+ x, y, w, h = toolbar.globalRect
56+ tx = x + (w / 2)
57+ ty = y + (h - (h / 8))
58+
59+ self.pointing_device.drag(tx, ty, tx, ty - h)
60+ self.assertThat(toolbar.animating, Eventually(Equals(False)))
61+ self.assertThat(toolbar.state, Eventually(Equals("spread")))
62+
63+ def drag_page_up_to_show_input_box(self):
64+ timer_page = self.app.select_single("TimerPage")
65+
66+ x, y, w, h = timer_page.globalRect
67+ tx = x + (w / 2)
68+ ty = y + (h / 2)
69+
70+ self.pointing_device.drag(tx, ty, tx, ty - h / 2)
71+ self.assertThat(
72+ timer_page.select_single("AnimationContainer").moving,
73+ Eventually(Equals(False)))
74+
75+ def drag_page_down_to_previous_state(self):
76+ timer_page = self.app.select_single("TimerPage")
77+
78+ x, y, w, h = timer_page.globalRect
79+ tx = x + (w / 2)
80+ ty = y + (h / 2)
81+
82+ self.pointing_device.drag(tx, ty, tx, ty + h / 2)
83+ self.assertThat(
84+ timer_page.select_single("AnimationContainer").moving,
85+ Eventually(Equals(False)))
86+
87
88 def test_add_preset(self):
89 """Test to check if button to add a preset working"""
90@@ -59,10 +87,16 @@
91 add_preset_button = self.main_window.get_toolbar_timer_add_preset_button()
92 self.pointing_device.click_object(add_preset_button)
93
94- # Write in the label
95+ # Write in the label
96+ if model() != "Desktop":
97+ self.drag_page_up_to_show_input_box()
98 label = self.main_window.get_timer_name_preset()
99 self.pointing_device.click_object(label)
100 self.keyboard.type("test")
101+ self.assertThat(label.text, Eventually(Equals("test")))
102+
103+ if model() != "Desktop":
104+ self.drag_page_down_to_previous_state()
105
106 # Set hour
107 hour = self.main_window.get_timer_hour_hand()
108@@ -71,16 +105,14 @@
109 ty = y + (h / 2)
110 self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
111
112+ num_of_presets_old = int(self.main_window.get_num_of_presets())
113 # Press "Done" button
114 label = self.main_window.get_timer_clock_center_label()
115 self.pointing_device.click_object(label)
116
117 # Check if the preset has been saved
118- preset_text_label = self.main_window.get_preset_label_text()
119- preset_timer_label = self.main_window.get_preset_label_timer()
120-
121- self.assertThat(preset_text_label.text, Eventually(Equals("test")))
122- self.assertThat(preset_timer_label.text, Eventually(Equals("23:00:00")))
123+ self.assertThat(self.main_window.get_num_of_presets(),
124+ Eventually(Equals(num_of_presets_old+1)))
125
126 def test_delete_preset(self):
127 """Test if the swipe of a preset deletes it"""
128@@ -88,19 +120,20 @@
129 # Create a new preset
130 self.test_add_preset()
131
132- # Get the label of test and its id
133- preset_text_label = self.main_window.get_preset_label_text()
134- preset_text_label_id = preset_text_label.id
135+ num_of_presets_old = int(self.main_window.get_num_of_presets())
136+ first_preset = self.main_window.get_first_preset_list_item()
137
138- # Delete the preset
139- x, y, w, h = preset_text_label.globalRect
140- tx = x + (w / 2)
141+ if model() != "Desktop":
142+ self.drag_page_up_to_show_input_box()
143+ # Delete the preset
144+ x, y, w, h = first_preset.globalRect
145+ tx = x + (w / 8)
146 ty = y + (h / 2)
147- self.pointing_device.drag(tx - w, ty, tx + 10 * w , ty)
148+ self.pointing_device.drag(tx, ty, w - w / 8, ty)
149
150 # Check has been deleted
151- label = lambda: self.main_window.get_object_by_id('Label', preset_text_label_id)
152- self.assertThat(label, Eventually(Equals(None)))
153+ self.assertThat(self.main_window.get_num_of_presets(),
154+ Eventually(Equals(num_of_presets_old-1)))
155
156 def test_run_preset(self):
157 """Tests if a preset can runs"""
158@@ -109,10 +142,14 @@
159 self.test_add_preset()
160
161 # Click to select the preset
162- preset_text_label = self.main_window.get_preset_label_text()
163- self.pointing_device.click_object(preset_text_label)
164+ first_preset = self.main_window.get_first_preset_list_item()
165+ if model() != "Desktop":
166+ self.drag_page_up_to_show_input_box()
167+ self.pointing_device.click_object(first_preset)
168
169- # Click to start the preset
170+ if model() != "Desktop":
171+ self.drag_page_down_to_previous_state()
172+ # Click to start the preset
173 label = self.main_window.get_timer_clock_center_label()
174 self.pointing_device.click_object(label)
175
176
177=== modified file 'timer/TimerPage.qml'
178--- timer/TimerPage.qml 2013-07-25 15:02:06 +0000
179+++ timer/TimerPage.qml 2013-08-07 13:42:28 +0000
180@@ -217,9 +217,10 @@
181 currentIndex: -1
182
183 delegate: ListItem.Standard {
184+ objectName: "preset" + index
185 Label {
186 id: presetTextLabel // Needs by autopilot
187- objectName: "presetTextLabel"
188+ objectName: "presetTextLabel" + index
189 fontSize: "large";
190 text: label
191 anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(3) }

Subscribers

People subscribed via source and target branches