Merge lp:~canonical-platform-qa/ubuntu-calendar-app/fix1351319-swipe_to_get_current_day into lp:ubuntu-calendar-app

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~canonical-platform-qa/ubuntu-calendar-app/fix1351319-swipe_to_get_current_day
Merge into: lp:ubuntu-calendar-app
Diff against target: 315 lines (+83/-68)
4 files modified
YearView.qml (+2/-1)
tests/autopilot/calendar_app/emulators.py (+74/-28)
tests/autopilot/calendar_app/tests/__init__.py (+4/-4)
tests/autopilot/calendar_app/tests/test_yearview.py (+3/-35)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-calendar-app/fix1351319-swipe_to_get_current_day
Reviewer Review Type Date Requested Status
Ubuntu Calendar Developers Pending
Review via email: mp+229355@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-03.

Commit message

On autopilot tests, if the current month does not exist on the year grid, swipe it into view.

To post a comment you must log in.
381. By Leo Arias

Merged with trunk.

382. By Leo Arias

Multiple fixes.

383. By Leo Arias

Fixed the call to swipe.

384. By Leo Arias

Merged with trunk.

385. By Leo Arias

Removed the merge file.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'YearView.qml'
2--- YearView.qml 2014-07-01 16:54:23 +0000
3+++ YearView.qml 2014-08-03 03:40:40 +0000
4@@ -83,9 +83,10 @@
5
6 MonthComponent {
7 id: monthComponent
8+ objectName: "monthComponent" + index
9 showEvents: false
10 currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0)
11-
12+
13 isYearView: true
14 anchors.fill: parent
15 anchors.margins: units.gu(0.5)
16
17=== modified file 'tests/autopilot/calendar_app/emulators.py'
18--- tests/autopilot/calendar_app/emulators.py 2014-07-31 19:39:04 +0000
19+++ tests/autopilot/calendar_app/emulators.py 2014-08-03 03:40:40 +0000
20@@ -16,19 +16,15 @@
21
22 """Calendar app autopilot emulators."""
23
24+import datetime
25 import logging
26 from time import sleep
27
28 import autopilot.logging
29+import ubuntuuitoolkit
30+from autopilot import exceptions
31 from dateutil import tz
32
33-import ubuntuuitoolkit
34-from ubuntuuitoolkit._custom_proxy_objects import _flickable
35-from ubuntuuitoolkit import (
36- emulators as toolkit_emulators,
37- pickers
38-)
39-
40 from calendar_app import data
41
42
43@@ -40,14 +36,7 @@
44 """Exception raised when there are problems with the Calendar."""
45
46
47-# for now we are borrowing the textfield helper for the textarea
48-# once the toolkit has a textarea helper this should be removed
49-# https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1327354
50-class TextArea(toolkit_emulators.TextField):
51- """Autopilot helper for the TextArea component."""
52-
53-
54-class MainView(toolkit_emulators.MainView):
55+class MainView(ubuntuuitoolkit.MainView):
56
57 """An emulator that makes it easy to interact with the calendar-app."""
58
59@@ -127,7 +116,7 @@
60 else:
61 mode_value = 'Years|Months|Days'
62 picker = self.wait_select_single(
63- pickers.DatePicker, mode=mode_value, visible=True)
64+ ubuntuuitoolkit.pickers.DatePicker, mode=mode_value, visible=True)
65 if mode_value == 'Hours|Minutes':
66 picker.pick_time(value)
67 else:
68@@ -221,22 +210,77 @@
69 return local
70
71
72-class YearView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
73+class YearView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
74
75 """Autopilot helper for the Year View page."""
76
77-
78-class WeekView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
79+ def get_selected_day(self):
80+ """Return the selected day.
81+
82+ :returns: A python datetime.date object with the selected day.
83+
84+ """
85+ current_year_grid = self._get_current_year_grid()
86+ for index in range(12):
87+ month_component = self._find_month_component(
88+ current_year_grid, index)
89+ try:
90+ today = month_component.select_single(
91+ 'QQuickItem', isToday=True)
92+ except exceptions.StateNotFoundError:
93+ continue
94+ else:
95+ return datetime.date(
96+ current_year_grid.year, index + 1, today.date)
97+ else:
98+ raise CalendarException(
99+ 'No day is selected on the currently visible year.')
100+
101+ def _get_current_year_grid(self):
102+ path_view_base = self.select_single(
103+ 'PathViewBase', objectName='yearPathView')
104+ return path_view_base.select_single(
105+ ubuntuuitoolkit.QQuickGridView, isCurrentItem=True)
106+
107+ def _find_month_component(self, grid, index):
108+ try:
109+ month = self._get_month_component(index)
110+ except exceptions.StateNotFoundError:
111+ month = self._swipe_to_find_month_component(grid, index)
112+ if month is None:
113+ raise CalendarException('Month {} not found.'.format(index))
114+ else:
115+ return month
116+
117+ def _get_month_component(self, index):
118+ return self.select_single(
119+ 'MonthComponent',
120+ objectName='monthComponent{}'.format(index))
121+
122+ def _swipe_to_find_month_component(self, grid, index):
123+ month = None
124+ grid.swipe_to_top()
125+ while not grid.atYEnd:
126+ try:
127+ month = self._get_month_component(index)
128+ except exceptions.StateNotFoundError:
129+ grid.swipe_to_show_more_below()
130+ else:
131+ break
132+ return month
133+
134+
135+class WeekView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
136
137 """Autopilot helper for the Week View page."""
138
139
140-class MonthView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
141+class MonthView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
142
143 """Autopilot helper for the Year View page."""
144
145
146-class DayView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
147+class DayView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
148
149 """Autopilot helper for the Day View page."""
150
151@@ -369,7 +413,7 @@
152 return day_header
153
154
155-class EventBubble(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
156+class EventBubble(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
157
158 """Autopiot helper for the Event Bubble items."""
159
160@@ -410,7 +454,7 @@
161
162 # override toolkit helper to
163 # workaround bug https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1343916
164-class QQuickFlickable(_flickable.QQuickFlickable):
165+class QQuickFlickable(ubuntuuitoolkit.QQuickFlickable):
166
167 def _slow_drag(self, start_x, stop_x, start_y, stop_y):
168 rate = (self.flickDeceleration + 250) / 350
169@@ -418,7 +462,7 @@
170 self.pointing_device.click()
171
172
173-class NewEvent(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
174+class NewEvent(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
175
176 """Autopilot helper for the New Event page."""
177
178@@ -478,7 +522,8 @@
179 self._ensure_visible_and_write(description_text_area, value)
180
181 def _get_description_text_area(self):
182- return self.select_single(TextArea, objectName='eventDescriptionInput')
183+ return self.select_single(
184+ ubuntuuitoolkit.TextArea, objectName='eventDescriptionInput')
185
186 def _fill_location(self, value):
187 self._ensure_entry_field_visible_and_write('eventLocationInput', value)
188@@ -532,12 +577,12 @@
189 self.pointing_device.click_object(save_button)
190
191
192-class NewEventEntryField(toolkit_emulators.TextField):
193+class NewEventEntryField(ubuntuuitoolkit.TextField):
194
195 """Autopilot helper for the NewEventEntryField component."""
196
197
198-class EventDetails(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
199+class EventDetails(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
200
201 """Autopilot helper for the Event Details page."""
202
203@@ -593,7 +638,8 @@
204 return guests
205
206
207-class DeleteConfirmationDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
208+class DeleteConfirmationDialog(
209+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
210
211 """Autopilot helper for the Delete Confirmation dialog."""
212
213
214=== modified file 'tests/autopilot/calendar_app/tests/__init__.py'
215--- tests/autopilot/calendar_app/tests/__init__.py 2014-06-26 18:10:28 +0000
216+++ tests/autopilot/calendar_app/tests/__init__.py 2014-08-03 03:40:40 +0000
217@@ -28,9 +28,9 @@
218 from autopilot.testcase import AutopilotTestCase
219 from autopilot import logging as autopilot_logging
220
221+import ubuntuuitoolkit
222 from ubuntuuitoolkit import (
223 base,
224- emulators as toolkit_emulators,
225 fixture_setup as toolkit_fixtures
226 )
227
228@@ -83,7 +83,7 @@
229 base.get_qmlscene_launch_command(),
230 self.local_location_qml,
231 app_type='qt',
232- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
233+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
234
235 @autopilot_logging.log_action(logger.info)
236 def launch_test_installed(self):
237@@ -91,13 +91,13 @@
238 base.get_qmlscene_launch_command(),
239 self.installed_location_qml,
240 app_type='qt',
241- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
242+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
243
244 @autopilot_logging.log_action(logger.info)
245 def launch_test_click(self):
246 return self.launch_click_package(
247 "com.ubuntu.calendar",
248- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
249+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
250
251 def _copy_xauthority_file(self, directory):
252 """ Copy .Xauthority file to directory, if it exists in /home
253
254=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
255--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-07-01 20:06:00 +0000
256+++ tests/autopilot/calendar_app/tests/test_yearview.py 2014-08-03 03:40:40 +0000
257@@ -43,10 +43,6 @@
258 return self.year_view.wait_select_single("QQuickGridView",
259 isCurrentItem=True)
260
261- def _get_month_grid(self):
262- current_month = self._get_current_month()
263- return current_month.select_single(objectName="monthGrid")
264-
265 def _change_year(self, direction, how_many=5):
266 current_year = self.year_view.currentYear
267
268@@ -57,21 +53,6 @@
269 lambda: self.year_view.currentYear,
270 Eventually(Equals(current_year + (i * direction))))
271
272- def _get_current_month(self):
273- now = datetime.now()
274- _current_month_name = now.strftime("%B")
275-
276- year_grid = self._get_year_grid()
277- months = year_grid.select_many("MonthComponent")
278-
279- for month in months:
280- _current_month_label = month.select_single(
281- "Label", objectName="monthLabel")
282- if _current_month_name == _current_month_label.text:
283- return month
284-
285- return None
286-
287 def test_current_year_is_default(self):
288 """The current year should be the default shown"""
289 self.assertThat(self.year_view.currentYear,
290@@ -111,22 +92,9 @@
291
292 def test_current_day_is_selected(self):
293 """The current day must be selected."""
294-
295- month_grid = self._get_month_grid()
296-
297- # there could actually be two labels with
298- # the current day: one is the current day of the current month,
299- # the other one is the current day of the previous or next month. Both
300- # shouldn't have the standard white color.
301- current_day_labels = month_grid.select_many(
302- "Label", text=str(datetime.now().day))
303-
304- # probably better to check the surrounding UbuntuShape object,
305- # upgrade when python-autopilot 1.4 will be available (get_parent).
306- for current_day_label in current_day_labels:
307- color = current_day_label.color
308- label_color = (color[0], color[1], color[2], color[3])
309- self.assertThat(label_color, NotEquals((255, 255, 255, 255)))
310+ selected_day = self.year_view.get_selected_day()
311+ self.assertEqual(
312+ selected_day, datetime.date.today())
313
314 def test_show_next_years(self):
315 """It must be possible to show next years by swiping the view."""

Subscribers

People subscribed via source and target branches

to status/vote changes: