Merge lp:~carla-sella/ubuntu-calendar-app/dayview-test-default-view into lp:ubuntu-calendar-app
- dayview-test-default-view
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Nicholas Skaggs | ||||
Approved revision: | 610 | ||||
Merged at revision: | 624 | ||||
Proposed branch: | lp:~carla-sella/ubuntu-calendar-app/dayview-test-default-view | ||||
Merge into: | lp:ubuntu-calendar-app | ||||
Diff against target: |
216 lines (+120/-17) 3 files modified
HeaderDateComponent.qml (+1/-0) tests/autopilot/calendar_app/__init__.py (+72/-13) tests/autopilot/calendar_app/tests/test_dayview.py (+47/-4) |
||||
To merge this branch: | bzr merge lp:~carla-sella/ubuntu-calendar-app/dayview-test-default-view | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Nicholas Skaggs | Pending | ||
Review via email: mp+253760@code.launchpad.net |
Commit message
Autopilot test for Calendar app
Description of the change
Dayview: test default view.
Carla Sella (carla-sella) wrote : | # |
Carla Sella (carla-sella) wrote : | # |
Should be ok now.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:607
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 608. By Carla Sella
-
Fixed identation errror.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:608
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Carla Sella (carla-sella) wrote : | # |
Reported bug #1435542 as in Italy Sunday is the first day of the week and yesterday, 22nd March the week number was 12 and not 11, so this test failed, but should not have:
Traceback (most recent call last):
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
raise mismatch_error
testtools.
Carla Sella (carla-sella) wrote : | # |
I found out why the test is failing only on Sundays.
If you look at the screenshot:
https:/
You can see how the days in Calendar app are displayed, Sunday is together with Saturday and Friday on the same page where there is the W13 week number label, but friday and saturday are W13 while sunday is W14.
That means that, for instance sunday 5 april is displayed on W13 but is
W14 instead.
So the test fails if you are testing on sunday 5 april because I am checking day label and day of week label are correct, the label is correct for two day but not for the third only in pages displaying Friday, Saturday and Sunday together.
So the question is: what should I do if the day I am testing on is a Sunday, this test will always fail on Sundays as Sundays are already on a next week number-
I can verify that if the day I am testing on is a Sunday I have to subtact 1 to week number, but not sure this is what you want me to do.
Carla
- 609. By Carla Sella
-
Added test_today_button.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:609
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Kunal Parmar (pkunal-parmar) wrote : | # |
> I found out why the test is failing only on Sundays.
> If you look at the screenshot:
>
> https:/
>
> You can see how the days in Calendar app are displayed, Sunday is together
> with Saturday and Friday on the same page where there is the W13 week number
> label, but friday and saturday are W13 while sunday is W14.
> That means that, for instance sunday 5 april is displayed on W13 but is
> W14 instead.
> So the test fails if you are testing on sunday 5 april because I am checking
> day label and day of week label are correct, the label is correct for two day
> but not for the third only in pages displaying Friday, Saturday and Sunday
> together.
>
> So the question is: what should I do if the day I am testing on is a Sunday,
> this test will always fail on Sundays as Sundays are already on a next week
> number-
>
> I can verify that if the day I am testing on is a Sunday I have to subtact 1
> to week number, but not sure this is what you want me to do.
>
> Carla
Hello Carla,
There seem some issue with logic how we calculate week numer from date.
Date.prototype.
var date = this.weekStart(
This is function used, in dateext.js, and looks like week's start day here is hard coded.
I gave you a branch where I resolved this issue, that patch calculate week number by taking in account what is week start day.
Please check with that branch as well.
Carla Sella (carla-sella) wrote : | # |
Hello Kunal,
I merged your branch into mine. It works if I run this test on a Sunday (for instance Sun 5th April), but fails if I run it on the 31st of March for instance, I get this errror:
Traceback (most recent call last):
File "/home/
self.
File "/usr/lib/
self.
File "/usr/lib/
raise mismatch_error
testtools.
Kunal Parmar (pkunal-parmar) wrote : | # |
> Hello Kunal,
> I merged your branch into mine. It works if I run this test on a Sunday (for
> instance Sun 5th April), but fails if I run it on the 31st of March for
> instance, I get this errror:
>
> Traceback (most recent call last):
> File "/home/
> view/tests/
> test_default_view
> self.day_
> File "/usr/lib/
> assertEqual
> self.assertThat
> File "/usr/lib/
> assertThat
> raise mismatch_error
> testtools.
Hello Carla,
I read python strftime doc. As per it, week start from 00 and end at 53. As per our implementation it start from 1 and end at 54.
Also we need to check what is locale set as per that we should use %U or %W.
I referred this link https:/
- 610. By Carla Sella
-
Fixed cheching week number.
Carla Sella (carla-sella) wrote : | # |
To me looks like using %W instead of %U fixes the issue, but I am not sure. Maybe someone can double check ?
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:610
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
%W can work, so long as we assume a Monday as first day of the week locale.
Preview Diff
1 | === modified file 'HeaderDateComponent.qml' |
2 | --- HeaderDateComponent.qml 2014-11-04 18:32:16 +0000 |
3 | +++ HeaderDateComponent.qml 2015-04-06 16:51:08 +0000 |
4 | @@ -39,6 +39,7 @@ |
5 | |
6 | Column { |
7 | id: dateContainer |
8 | + objectName: "dateContainer" |
9 | |
10 | width: dayLabel.paintedWidth |
11 | spacing: units.gu(0.2) |
12 | |
13 | === modified file 'tests/autopilot/calendar_app/__init__.py' |
14 | --- tests/autopilot/calendar_app/__init__.py 2015-03-07 10:14:46 +0000 |
15 | +++ tests/autopilot/calendar_app/__init__.py 2015-04-06 16:51:08 +0000 |
16 | @@ -28,6 +28,7 @@ |
17 | from testtools.matchers import GreaterThan |
18 | |
19 | from calendar_app import data |
20 | +from datetime import date |
21 | |
22 | |
23 | logger = logging.getLogger(__name__) |
24 | @@ -275,6 +276,10 @@ |
25 | local = utc.astimezone(tz.tzlocal()) |
26 | return local |
27 | |
28 | + def press_header_todaybutton(self): |
29 | + header = self.get_header() |
30 | + header.click_action_button('todaybutton') |
31 | + |
32 | |
33 | class YearView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase): |
34 | |
35 | @@ -583,27 +588,81 @@ |
36 | return event_details_page.edit() |
37 | |
38 | @autopilot.logging.log_action(logger.info) |
39 | - def get_day_header(self, day=None): |
40 | + def get_timeline_header_component(self, day): |
41 | """Return the dayheader for a given day. If no day is given, |
42 | return the current day. |
43 | |
44 | - :param day: A datetime object matching the header |
45 | + :param day: day in date(year, month, day) format |
46 | :return: The day header object |
47 | """ |
48 | if day: |
49 | headers = self.select_many('TimeLineHeaderComponent') |
50 | for header in headers: |
51 | - if header.startDay.datetime == day: |
52 | - day_header = header |
53 | - break |
54 | - else: |
55 | - # just grab the current day |
56 | - day_header = self.wait_select_single( |
57 | - 'TimeLineHeaderComponent', isCurrentItem=True) |
58 | - |
59 | - if not(day_header): |
60 | - raise CalendarException('Day Header not found for %s' % day) |
61 | - return day_header |
62 | + header_date = date(header.startDay.datetime.year, |
63 | + header.startDay.datetime.month, |
64 | + header.startDay.datetime.day) |
65 | + if header_date == day: |
66 | + return header |
67 | + |
68 | + else: |
69 | + raise CalendarException('Day Header not found for %s' % day) |
70 | + |
71 | + @autopilot.logging.log_action(logger.info) |
72 | + def get_timeline_header(self, day): |
73 | + """Return the dayheader for a given day. If no day is given, |
74 | + return the current day. |
75 | + |
76 | + :param day: day in date(year, month, day) format |
77 | + :return: The day header object |
78 | + """ |
79 | + if day: |
80 | + headers = self.select_many('TimeLineHeader') |
81 | + for header in headers: |
82 | + header_date = date(header.startDay.datetime.year, |
83 | + header.startDay.datetime.month, |
84 | + header.startDay.datetime.day) |
85 | + if header_date == day: |
86 | + return header |
87 | + |
88 | + else: |
89 | + raise CalendarException('Day Header not found for %s' % day) |
90 | + |
91 | + @autopilot.logging.log_action(logger.info) |
92 | + def get_daylabel(self, today): |
93 | + current_day_header = self.get_timeline_header_component(today) |
94 | + return current_day_header.wait_select_single( |
95 | + 'Label', objectName='dayLabel') |
96 | + |
97 | + @autopilot.logging.log_action(logger.info) |
98 | + def get_datelabel(self, today): |
99 | + current_day_header = self.get_timeline_header_component(today) |
100 | + return current_day_header.wait_select_single( |
101 | + 'Label', objectName='dateLabel') |
102 | + |
103 | + @autopilot.logging.log_action(logger.info) |
104 | + def get_weeknumer(self, today): |
105 | + current_day_header = self.get_timeline_header(today) |
106 | + return current_day_header.wait_select_single( |
107 | + 'Label', objectName='weeknumber') |
108 | + |
109 | + @autopilot.logging.log_action(logger.info) |
110 | + def get_scrollHour(self): |
111 | + return self.wait_select_single( |
112 | + 'TimeLineBaseComponent', objectName='DayComponent-0').scrollHour |
113 | + |
114 | + @autopilot.logging.log_action(logger.info) |
115 | + def check_loading_spinnger(self): |
116 | + timelinebasecomponent = self.get_active_timelinebasecomponent() |
117 | + loading_spinner = timelinebasecomponent.wait_select_single( |
118 | + "ActivityIndicator") |
119 | + loading_spinner.running.wait_for(False) |
120 | + |
121 | + @autopilot.logging.log_action(logger.info) |
122 | + def get_active_timelinebasecomponent(self): |
123 | + timelinebase_components = self.select_many(("TimeLineBaseComponent")) |
124 | + for component in timelinebase_components: |
125 | + if component.isActive: |
126 | + return component |
127 | |
128 | |
129 | class AgendaView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase): |
130 | |
131 | === modified file 'tests/autopilot/calendar_app/tests/test_dayview.py' |
132 | --- tests/autopilot/calendar_app/tests/test_dayview.py 2014-10-08 00:44:20 +0000 |
133 | +++ tests/autopilot/calendar_app/tests/test_dayview.py 2015-04-06 16:51:08 +0000 |
134 | @@ -19,6 +19,7 @@ |
135 | """ |
136 | |
137 | import datetime |
138 | +import calendar |
139 | |
140 | # from __future__ import range |
141 | # (python3's range, is same as python2's xrange) |
142 | @@ -30,6 +31,7 @@ |
143 | from testtools.matchers import Equals, NotEquals |
144 | |
145 | from calendar_app.tests import CalendarAppTestCase |
146 | +from datetime import date |
147 | |
148 | |
149 | class TestDayView(CalendarAppTestCase): |
150 | @@ -38,15 +40,44 @@ |
151 | super(TestDayView, self).setUp() |
152 | self.day_view = self.app.main_view.go_to_day_view() |
153 | |
154 | - def test_current_month_and_year_is_selected(self): |
155 | - """By default, the day view shows the current month and year.""" |
156 | + def test_default_view(self): |
157 | + """By default, the day view shows the current month year and |
158 | + today's date. |
159 | + The day should be scrolled to the current time |
160 | + """ |
161 | |
162 | now = datetime.datetime.now() |
163 | + today = date(now.year, now.month, now.day) |
164 | + day_view_currentDay = self.day_view.currentDay |
165 | + |
166 | + day_view_currentDay_date = \ |
167 | + date(day_view_currentDay.year, |
168 | + day_view_currentDay.month, |
169 | + day_view_currentDay.day) |
170 | |
171 | expected_month_name_year = now.strftime("%B %Y") |
172 | |
173 | - self.assertThat(self.app.main_view.get_month_year(self.day_view), |
174 | - Equals(expected_month_name_year)) |
175 | + # Checking today's date is correct |
176 | + self.assertEquals(day_view_currentDay_date, today) |
177 | + |
178 | + # Checking month and year in header are correct |
179 | + self.assertEquals( |
180 | + self.app.main_view.get_month_year(self.day_view), |
181 | + expected_month_name_year) |
182 | + |
183 | + # Checking day label and day of week label are correct |
184 | + self.assertEquals( |
185 | + self.day_view.get_daylabel(today).text, |
186 | + calendar.day_abbr[now.weekday()]) |
187 | + self.assertEquals( |
188 | + self.day_view.get_datelabel(today).text, str(now.day)) |
189 | + |
190 | + # Checking week number is correct |
191 | + self.assertEquals( |
192 | + self.day_view.get_weeknumer(today).text, 'W' + now.strftime("%W")) |
193 | + |
194 | + # Check day is scrolled to the current time |
195 | + self.assertEquals(self.day_view.get_scrollHour(), now.hour) |
196 | |
197 | def test_show_next_days(self): |
198 | """It must be possible to show next days by swiping the view.""" |
199 | @@ -56,6 +87,18 @@ |
200 | """It must be possible to show previous days by swiping the view.""" |
201 | self._change_days(-1) |
202 | |
203 | + def test_today_button(self): |
204 | + now = datetime.datetime.now() |
205 | + today = date(now.year, now.month, now.day) |
206 | + self._change_days(1) |
207 | + self.app.main_view.press_header_todaybutton() |
208 | + self.day_view.check_loading_spinnger() |
209 | + |
210 | + current_day = self.day_view.get_active_timelinebasecomponent().startDay |
211 | + new_today = date(current_day.year, current_day.month, current_day.day) |
212 | + |
213 | + self.assertEquals(today, new_today) |
214 | + |
215 | def _change_days(self, direction): |
216 | firstday = self.day_view.currentDay.datetime |
217 |
Still need to verify that the day should be scrolled to the current time.