Merge lp:~carla-sella/ubuntu-calendar-app/current-day-month-year-selected into lp:ubuntu-calendar-app

Proposed by Carla Sella
Status: Merged
Approved by: Carla Sella
Approved revision: 602
Merged at revision: 603
Proposed branch: lp:~carla-sella/ubuntu-calendar-app/current-day-month-year-selected
Merge into: lp:ubuntu-calendar-app
Diff against target: 117 lines (+59/-0)
4 files modified
MonthComponent.qml (+2/-0)
MonthView.qml (+1/-0)
tests/autopilot/calendar_app/__init__.py (+16/-0)
tests/autopilot/calendar_app/tests/test_monthview.py (+40/-0)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-calendar-app/current-day-month-year-selected
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+251387@code.launchpad.net

Commit message

Autopilot test for Calendar App.

Description of the change

Updating monthview test suite.

To post a comment you must log in.
Revision history for this message
Carla Sella (carla-sella) wrote :

Added test_current_day_month_and_year_is_selected.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
598. By Carla Sella <email address hidden>

Fixed datetime errors.

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
Nicholas Skaggs (nskaggs) wrote :

A couple tweaks suggested :-)

review: Needs Fixing
599. By Carla Sella

Fixed get_current_selected_day.

Revision history for this message
Carla Sella (carla-sella) wrote :

Nicholas: found a way to fix get_current_selected_day() so that the item returned is one ant the right one.

Revision history for this message
Carla Sella (carla-sella) wrote :

Still have to do the "assert the days of the week are correct for the locale (starting with sunday, saturday, monday depending)"

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

Added test_days_of_week_are_correct.

Revision history for this message
Carla Sella (carla-sella) wrote :

This mp should be complete now.

601. By Carla Sella

Fixed pep8 and pyflakes.

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: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Minor comments. Feel free to merge once addressed.

review: Approve
602. By Carla Sella

Adde modifications as Nicholas' notes.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'MonthComponent.qml'
2--- MonthComponent.qml 2014-11-29 09:40:53 +0000
3+++ MonthComponent.qml 2015-03-06 21:34:27 +0000
4@@ -148,6 +148,7 @@
5
6 Row{
7 id: dayLabelRow
8+ objectName: "dayLabelRow" + index
9
10 property int dayWidth: width / 7;
11
12@@ -230,6 +231,7 @@
13
14 Label{
15 id: weekDay
16+ objectName: "weekDay" + index
17 width: parent.dayWidth
18 property var day :Qt.locale().standaloneDayName(( Qt.locale().firstDayOfWeek + index), Locale.ShortFormat)
19 text: isYearView ? day.charAt(0) : day;
20
21=== modified file 'MonthView.qml'
22--- MonthView.qml 2015-02-18 19:27:20 +0000
23+++ MonthView.qml 2015-03-06 21:34:27 +0000
24@@ -50,6 +50,7 @@
25 ]
26
27 contents: Label {
28+ objectName:"monthYearLabel"
29 fontSize: "x-large"
30 // TRANSLATORS: this is a time formatting string,
31 // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
32
33=== modified file 'tests/autopilot/calendar_app/__init__.py'
34--- tests/autopilot/calendar_app/__init__.py 2015-02-26 21:11:03 +0000
35+++ tests/autopilot/calendar_app/__init__.py 2015-03-06 21:34:27 +0000
36@@ -435,10 +435,26 @@
37 def get_current_month(self):
38 return self.select_single('MonthComponent', isCurrentItem=True)
39
40+ @autopilot.logging.log_action(logger.info)
41 def get_current_month_name(self):
42 month = self.get_current_month()
43 return month.currentMonth.datetime.strftime("%B")
44
45+ @autopilot.logging.log_action(logger.info)
46+ def get_current_selected_day(self):
47+ today_days = self.select_many(
48+ 'MonthComponentDateDelegate', isToday=True)
49+ for item in today_days:
50+ if item.isCurrentMonth:
51+ return item
52+
53+ @autopilot.logging.log_action(logger.info)
54+ def get_day_label(self, day):
55+ days_row = self.select_single(
56+ 'QQuickRow', objectName='dayLabelRow0')
57+ return days_row.select_single(
58+ 'Label', objectName='weekDay{}'.format(day))
59+
60
61 class DayView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
62
63
64=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
65--- tests/autopilot/calendar_app/tests/test_monthview.py 2014-09-04 16:04:37 +0000
66+++ tests/autopilot/calendar_app/tests/test_monthview.py 2015-03-06 21:34:27 +0000
67@@ -22,6 +22,7 @@
68 from testtools.matchers import Equals, NotEquals
69
70 import math
71+import calendar
72
73 from calendar_app.tests import CalendarAppTestCase
74
75@@ -96,3 +97,42 @@
76
77 def test_monthview_go_to_today_prev_year(self):
78 self._go_to_today(-12)
79+
80+ def test_current_day_month_and_year_is_selected(self):
81+ """
82+ By default, the month view shows the current day, month and year.
83+ """
84+ now = datetime.now()
85+ expected_month_name_year = now.strftime("%B %Y")
86+
87+ self.assertThat(self.app.main_view.get_month_year(self.month_view),
88+ Equals(expected_month_name_year))
89+
90+ expected_day = str(int(now.strftime("%d")))
91+ selected_day = self.month_view.get_current_selected_day()
92+
93+ self.assertEquals(
94+ selected_day.select_single('Label').text, expected_day)
95+
96+ def test_days_of_week_are_correct(self):
97+ """
98+ Verify that days of week are correct for the locale
99+ """
100+ first_week_day = calendar.day_abbr[calendar.firstweekday()]
101+ day_0_label = self.month_view.get_day_label(0).day
102+ day_1_label = self.month_view.get_day_label(1).day
103+ day_2_label = self.month_view.get_day_label(2).day
104+ day_3_label = self.month_view.get_day_label(3).day
105+ day_4_label = self.month_view.get_day_label(4).day
106+ day_5_label = self.month_view.get_day_label(5).day
107+ day_6_label = self.month_view.get_day_label(6).day
108+
109+ self.assertEquals(day_0_label, first_week_day)
110+
111+ self.assertEquals(calendar.day_abbr[calendar.MONDAY], day_0_label)
112+ self.assertEquals(calendar.day_abbr[calendar.TUESDAY], day_1_label)
113+ self.assertEquals(calendar.day_abbr[calendar.WEDNESDAY], day_2_label)
114+ self.assertEquals(calendar.day_abbr[calendar.THURSDAY], day_3_label)
115+ self.assertEquals(calendar.day_abbr[calendar.FRIDAY], day_4_label)
116+ self.assertEquals(calendar.day_abbr[calendar.SATURDAY], day_5_label)
117+ self.assertEquals(calendar.day_abbr[calendar.SUNDAY], day_6_label)

Subscribers

People subscribed via source and target branches

to status/vote changes: