Merge lp:~nskaggs/ubuntu-calendar-app/yearview-tweaks into lp:ubuntu-calendar-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Leo Arias
Approved revision: 347
Merged at revision: 339
Proposed branch: lp:~nskaggs/ubuntu-calendar-app/yearview-tweaks
Merge into: lp:ubuntu-calendar-app
Diff against target: 512 lines (+164/-110)
9 files modified
DayView.qml (+5/-5)
MonthView.qml (+2/-1)
WeekView.qml (+8/-7)
YearView.qml (+8/-7)
tests/autopilot/calendar_app/emulators.py (+93/-25)
tests/autopilot/calendar_app/tests/test_dayview.py (+2/-6)
tests/autopilot/calendar_app/tests/test_monthview.py (+2/-6)
tests/autopilot/calendar_app/tests/test_weekview.py (+2/-6)
tests/autopilot/calendar_app/tests/test_yearview.py (+42/-47)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calendar-app/yearview-tweaks
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+225208@code.launchpad.net

Commit message

Fixes for #1335241 and some test cleanup

Description of the change

Fixes for #1335241 and some test cleanup

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

You'll notice some qml tweaks to objectnames and id's. Just trying to standardize naming.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
345. By Nicholas Skaggs

flake8 fixes

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
346. By Nicholas Skaggs

fix objectname

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This is ready; waiting for someone to approve and merge. I'd like to tweak the tests more but don't want to hold trunk merges.

347. By Nicholas Skaggs

one more objectname correction :-)

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
Leo Arias (elopio) wrote :

Thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DayView.qml'
2--- DayView.qml 2014-05-31 04:38:48 +0000
3+++ DayView.qml 2014-07-02 02:06:44 +0000
4@@ -5,8 +5,8 @@
5 import "ViewType.js" as ViewType
6
7 Page{
8- id: root
9- objectName: "DayView"
10+ id: dayViewPage
11+ objectName: "dayViewPage"
12
13 property var currentDay: new Date()
14 property bool isCurrentPage: false
15@@ -42,7 +42,7 @@
16
17 PathViewBase{
18 id: dayViewPath
19- objectName: "DayViewPathBase"
20+ objectName: "dayViewPath"
21
22 property var startDay: currentDay
23 //This is used to scroll all view together when currentItem scrolls
24@@ -83,9 +83,9 @@
25 isActive: true
26
27 Connections{
28- target: root
29+ target: dayViewPage
30 onIsCurrentPageChanged:{
31- if(root.isCurrentPage){
32+ if(dayViewPage.isCurrentPage){
33 timeLineView.scrollToCurrentTime();
34 }
35 }
36
37=== modified file 'MonthView.qml'
38--- MonthView.qml 2014-04-26 03:54:09 +0000
39+++ MonthView.qml 2014-07-02 02:06:44 +0000
40@@ -5,7 +5,7 @@
41
42 Page {
43 id: monthViewPage
44- objectName: "MonthView"
45+ objectName: "monthViewPage"
46
47 property var currentMonth: DateExt.today();
48
49@@ -15,6 +15,7 @@
50
51 PathViewBase{
52 id: monthViewPath
53+ objectName: "monthViewPath"
54
55 property var startMonth: currentMonth;
56
57
58=== modified file 'WeekView.qml'
59--- WeekView.qml 2014-05-31 04:38:48 +0000
60+++ WeekView.qml 2014-07-02 02:06:44 +0000
61@@ -5,7 +5,9 @@
62 import "ViewType.js" as ViewType
63
64 Page{
65- id: root
66+ id: weekViewPage
67+ objectName: "weekViewPage"
68+
69 property var dayStart: new Date();
70 property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
71 property bool isCurrentPage: false
72@@ -15,8 +17,6 @@
73 Keys.forwardTo: [weekViewPath]
74
75 Column {
76- objectName: "WeekView"
77-
78 anchors.fill: parent
79 anchors.top: parent.top
80 anchors.topMargin: units.gu(1.5)
81@@ -35,15 +35,16 @@
82 date: firstDay
83
84 onDateSelected: {
85- root.dateSelected(date);
86+ weekViewPage.dateSelected(date);
87 }
88 }
89
90 PathViewBase{
91 id: weekViewPath
92+ objectName: "weekViewPath"
93
94 width: parent.width
95- height: root.height - weekViewPath.y
96+ height: weekViewPage.height - weekViewPath.y
97
98 //This is used to scroll all view together when currentItem scrolls
99 property var childContentY;
100@@ -79,9 +80,9 @@
101 startDay: firstDay.addDays( weekViewPath.indexType(index) * 7)
102
103 Connections{
104- target: root
105+ target: weekViewPage
106 onIsCurrentPageChanged:{
107- if(root.isCurrentPage){
108+ if(weekViewPage.isCurrentPage){
109 timeLineView.scrollToCurrentTime();
110 }
111 }
112
113=== modified file 'YearView.qml'
114--- YearView.qml 2014-04-26 03:54:09 +0000
115+++ YearView.qml 2014-07-02 02:06:44 +0000
116@@ -4,15 +4,16 @@
117 import "dateExt.js" as DateExt
118 Page {
119 id: yearViewPage
120+ objectName: "yearViewPage"
121
122 property int currentYear: DateExt.today().getFullYear();
123 signal monthSelected(var date);
124
125- Keys.forwardTo: [pathView]
126+ Keys.forwardTo: [yearPathView]
127
128 PathViewBase {
129- id: pathView
130- objectName: "YearView"
131+ id: yearPathView
132+ objectName: "yearPathView"
133
134 anchors.fill: parent
135
136@@ -27,11 +28,11 @@
137 delegate: GridView{
138 id: yearView
139 clip: true
140- focus: index == pathView.currentIndex
141+ focus: index == yearPathView.currentIndex
142
143 property int scrollMonth: 0;
144- property bool isCurrentItem: index == pathView.currentIndex
145- property int year: (yearViewPage.currentYear + pathView.indexType(index))
146+ property bool isCurrentItem: index == yearPathView.currentIndex
147+ property int year: (yearViewPage.currentYear + yearPathView.indexType(index))
148
149 width: parent.width
150 height: parent.height
151@@ -57,7 +58,7 @@
152 }
153
154 Connections{
155- target: pathView
156+ target: yearPathView
157 onScrollUp: {
158 scrollMonth -= 2;
159 if(scrollMonth < 0) {
160
161=== modified file 'tests/autopilot/calendar_app/emulators.py'
162--- tests/autopilot/calendar_app/emulators.py 2014-06-27 16:55:22 +0000
163+++ tests/autopilot/calendar_app/emulators.py 2014-07-02 02:06:44 +0000
164@@ -51,6 +51,48 @@
165 """An emulator that makes it easy to interact with the calendar-app."""
166
167 @autopilot.logging.log_action(logger.info)
168+ def go_to_month_view(self):
169+ """Open the month view.
170+
171+ :return: The Month View page.
172+
173+ """
174+ month_tab = self.select_single('Tab', objectName='monthTab')
175+ if not month_tab.visible:
176+ self.switch_to_tab('monthTab')
177+ else:
178+ logger.debug('The month View page is already opened.')
179+ return self.get_month_view(month_tab)
180+
181+ @autopilot.logging.log_action(logger.info)
182+ def go_to_week_view(self):
183+ """Open the week view.
184+
185+ :return: The Week View page.
186+
187+ """
188+ week_tab = self.select_single('Tab', objectName='weekTab')
189+ if not week_tab.visible:
190+ self.switch_to_tab('weekTab')
191+ else:
192+ logger.debug('The week View page is already opened.')
193+ return self.get_week_view(week_tab)
194+
195+ @autopilot.logging.log_action(logger.info)
196+ def go_to_year_view(self):
197+ """Open the year view.
198+
199+ :return: The Year View page.
200+
201+ """
202+ year_tab = self.select_single('Tab', objectName='yearTab')
203+ if not year_tab.visible:
204+ self.switch_to_tab('yearTab')
205+ else:
206+ logger.debug('The Year View page is already opened.')
207+ return self.get_year_view(year_tab)
208+
209+ @autopilot.logging.log_action(logger.info)
210 def go_to_day_view(self):
211 """Open the day view.
212
213@@ -62,7 +104,7 @@
214 self.switch_to_tab('dayTab')
215 else:
216 logger.debug('The Day View page is already opened.')
217- return day_tab.select_single(DayView, objectName='DayView')
218+ return self.get_day_view(day_tab)
219
220 @autopilot.logging.log_action(logger.info)
221 def go_to_new_event(self):
222@@ -92,20 +134,31 @@
223 # close picker
224 self.pointing_device.click_object(field)
225
226- def get_event_view(self):
227- return self.wait_select_single("EventView")
228-
229- def get_month_view(self):
230- return self.wait_select_single("MonthView")
231-
232- def get_year_view(self):
233- return self.wait_select_single("YearView")
234-
235- def get_day_view(self):
236- return self.wait_select_single("DayView")
237-
238- def get_week_view(self):
239- return self.wait_select_single("WeekView")
240+ def get_event_view(self, parent_object=None):
241+ if parent_object is None:
242+ parent_object = self
243+ return parent_object.select_single("EventView")
244+
245+ def get_month_view(self, parent_object=None):
246+ if parent_object is None:
247+ parent_object = self
248+ return parent_object.select_single(MonthView,
249+ objectName='monthViewPage')
250+
251+ def get_year_view(self, parent_object=None):
252+ if parent_object is None:
253+ parent_object = self
254+ return parent_object.select_single(YearView, objectName='yearViewPage')
255+
256+ def get_day_view(self, parent_object=None):
257+ if parent_object is None:
258+ parent_object = self
259+ return parent_object.select_single(DayView, objectName='dayViewPage')
260+
261+ def get_week_view(self, parent_object=None):
262+ if parent_object is None:
263+ parent_object = self
264+ return parent_object.select_single(WeekView, objectName='weekViewPage')
265
266 def get_label_with_text(self, text, root=None):
267 if root is None:
268@@ -116,6 +169,14 @@
269 else:
270 return None
271
272+ def get_year(self, component):
273+ return int(component.wait_select_single(
274+ "Label", objectName="yearLabel").text)
275+
276+ def get_month_name(self, component):
277+ return component.wait_select_single(
278+ "Label", objectName="monthLabel").text
279+
280 def safe_swipe_view(self, direction, view, date):
281 """
282 direction: direction to swip
283@@ -153,20 +214,27 @@
284
285 self.pointing_device.drag(x_start, y_line, x_stop, y_line)
286
287- def get_year(self, component):
288- return int(component.wait_select_single(
289- "Label", objectName="yearLabel").text)
290-
291- def get_month_name(self, component):
292- return component.wait_select_single(
293- "Label", objectName="monthLabel").text
294-
295 def to_local_date(self, date):
296 utc = date.replace(tzinfo=tz.tzutc())
297 local = utc.astimezone(tz.tzlocal())
298 return local
299
300
301+class YearView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
302+
303+ """Autopilot helper for the Year View page."""
304+
305+
306+class WeekView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
307+
308+ """Autopilot helper for the Week View page."""
309+
310+
311+class MonthView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
312+
313+ """Autopilot helper for the Year View page."""
314+
315+
316 class DayView(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
317
318 """Autopilot helper for the Day View page."""
319@@ -308,7 +376,7 @@
320 self._fill_form(event_information)
321 self._save()
322 return self.get_root_instance().select_single(
323- DayView, objectName='DayView')
324+ DayView, objectName='dayViewPage')
325
326 @autopilot.logging.log_action(logger.debug)
327 def _fill_form(self, event_information):
328@@ -404,7 +472,7 @@
329 DeleteConfirmationDialog, objectName='deleteConfirmationDialog')
330 delete_confirmation_dialog.confirm_deletion()
331
332- return root.select_single(DayView, objectName='DayView')
333+ return root.select_single(DayView, objectName='dayViewPage')
334
335 def get_event_information(self):
336 """Return the information of the event."""
337
338=== modified file 'tests/autopilot/calendar_app/tests/test_dayview.py'
339--- tests/autopilot/calendar_app/tests/test_dayview.py 2014-06-26 18:10:28 +0000
340+++ tests/autopilot/calendar_app/tests/test_dayview.py 2014-07-02 02:06:44 +0000
341@@ -37,12 +37,8 @@
342 def setUp(self):
343 super(TestDayView, self).setUp()
344 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
345- self.main_view.switch_to_tab("dayTab")
346-
347- self.assertThat(
348- self.main_view.get_day_view, Eventually(NotEquals(None)))
349-
350- self.day_view = self.main_view.get_day_view()
351+
352+ self.day_view = self.main_view.go_to_day_view()
353
354 def test_current_month_and_year_is_selected(self):
355 """By default, the day view shows the current month and year."""
356
357=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
358--- tests/autopilot/calendar_app/tests/test_monthview.py 2014-06-26 18:10:28 +0000
359+++ tests/autopilot/calendar_app/tests/test_monthview.py 2014-07-02 02:06:44 +0000
360@@ -34,12 +34,8 @@
361 def setUp(self):
362 super(TestMonthView, self).setUp()
363 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
364- self.main_view.switch_to_tab("monthTab")
365-
366- self.assertThat(
367- self.main_view.get_month_view, Eventually(NotEquals(None)))
368-
369- self.month_view = self.main_view.get_month_view()
370+
371+ self.month_view = self.main_view.go_to_month_view()
372
373 def _change_month(self, delta):
374 month_view = self.main_view.get_month_view()
375
376=== modified file 'tests/autopilot/calendar_app/tests/test_weekview.py'
377--- tests/autopilot/calendar_app/tests/test_weekview.py 2014-06-26 18:10:28 +0000
378+++ tests/autopilot/calendar_app/tests/test_weekview.py 2014-07-02 02:06:44 +0000
379@@ -39,12 +39,8 @@
380 def setUp(self):
381 super(TestWeekView, self).setUp()
382 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
383- self.main_view.switch_to_tab("weekTab")
384-
385- self.assertThat(
386- self.main_view.get_week_view, Eventually(NotEquals(None)))
387-
388- self.week_view = self.main_view.get_week_view()
389+
390+ self.week_view = self.main_view.go_to_week_view()
391
392 def _change_week(self, direction):
393 first_dow = self._get_first_day_of_week()
394
395=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
396--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-06-26 18:10:28 +0000
397+++ tests/autopilot/calendar_app/tests/test_yearview.py 2014-07-02 02:06:44 +0000
398@@ -36,28 +36,55 @@
399 def setUp(self):
400 super(TestYearView, self).setUp()
401 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
402- self.main_view.switch_to_tab("yearTab")
403- self.assertThat(
404- self.main_view.get_year_view, Eventually(NotEquals(None)))
405-
406- self.year_view = self.main_view.get_year_view()
407-
408- def _get_current_year(self):
409- return self.year_view.select_single("QQuickGridView",
410- isCurrentItem=True)
411+
412+ self.year_view = self.main_view.go_to_year_view()
413+
414+ def _get_year_grid(self):
415+ return self.year_view.wait_select_single("QQuickGridView",
416+ isCurrentItem=True)
417+
418+ def _get_month_grid(self):
419+ current_month = self._get_current_month()
420+ return current_month.select_single(objectName="monthGrid")
421+
422+ def _change_year(self, direction, how_many=5):
423+ current_year = self.year_view.currentYear
424+
425+ for i in range(1, how_many):
426+ self.main_view.swipe_view(direction, self.year_view)
427+
428+ self.assertThat(
429+ lambda: self.year_view.currentYear,
430+ Eventually(Equals(current_year + (i * direction))))
431+
432+ def _get_current_month(self):
433+ now = datetime.now()
434+ _current_month_name = now.strftime("%B")
435+
436+ year_grid = self._get_year_grid()
437+ months = year_grid.select_many("MonthComponent")
438+
439+ for month in months:
440+ _current_month_label = month.select_single(
441+ "Label", objectName="monthLabel")
442+ if _current_month_name == _current_month_label.text:
443+ return month
444+
445+ return None
446+
447+ def test_current_year_is_default(self):
448+ """The current year should be the default shown"""
449+ self.assertThat(self.year_view.currentYear,
450+ Equals(datetime.now().year))
451
452 def test_selecting_a_month_switch_to_month_view(self):
453 """It must be possible to select a month and open the month view."""
454
455 # TODO: the component indexed at 1 is the one currently displayed,
456 # investigate a way to validate this assumption visually.
457- year_grid = self._get_current_year()
458- self.assertThat(year_grid, NotEquals(None))
459+ year_grid = self._get_year_grid()
460 months = year_grid.select_many("MonthComponent")
461 months.sort(key=lambda month: month.currentMonth)
462- # check that current year is the default
463- self.assertThat(self.main_view.get_year(months[0]),
464- Equals(datetime.now().year))
465
466 february = months[1]
467 expected_month_name = self.main_view.get_month_name(february)
468@@ -85,8 +112,7 @@
469 def test_current_day_is_selected(self):
470 """The current day must be selected."""
471
472- _current_month = self._current_month()
473- month_grid = _current_month.select_single(objectName="monthGrid")
474+ month_grid = self._get_month_grid()
475
476 # there could actually be two labels with
477 # the current day: one is the current day of the current month,
478@@ -109,34 +135,3 @@
479 def test_show_previous_years(self):
480 """It must be possible to show previous years by swiping the view."""
481 self._change_year(-1)
482-
483- def _change_year(self, direction, how_many=5):
484- current_year = datetime.now().year
485-
486- for i in range(1, how_many):
487- self.main_view.swipe_view(direction, self.year_view)
488-
489- self.assertThat(
490- lambda: self.year_view.currentYear,
491- Eventually(Equals(current_year + (i * direction))))
492-
493- def _current_month(self):
494- now = datetime.now()
495- _current_month_name = now.strftime("%B")
496-
497- # for months after June, we must scroll down the page to have
498- # the month components loaded in the view.
499- if now.month > 6:
500- self.page.drag_page_up()
501-
502- year_grid = self._get_current_year()
503- self.assertThat(year_grid, NotEquals(None))
504- months = year_grid.select_many("MonthComponent")
505-
506- for month in months:
507- _current_month_label = month.select_single(
508- "Label", objectName="monthLabel")
509- if _current_month_name == _current_month_label.text:
510- return month
511-
512- return None

Subscribers

People subscribed via source and target branches

to status/vote changes: