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

Proposed by Leo Arias
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 385
Merged at revision: 429
Proposed branch: lp:~canonical-platform-qa/ubuntu-calendar-app/fix1351319-swipe_to_get_current_day
Merge into: lp:ubuntu-calendar-app
Prerequisite: lp:~canonical-platform-qa/ubuntu-calendar-app/fix1341681-new_toolkit_namespace
Diff against target: 179 lines (+68/-40)
3 files modified
YearView.qml (+2/-1)
tests/autopilot/calendar_app/__init__.py (+61/-2)
tests/autopilot/calendar_app/tests/test_yearview.py (+5/-37)
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 Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+229356@code.launchpad.net

This proposal supersedes 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.
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 :

I'd like to see a jenkins run against this

383. By Leo Arias

Fixed the call to swipe.

Revision history for this message
Leo Arias (elopio) wrote :

> I'd like to see a jenkins run against this

It's on its way. I've just confirmed that the test now works on mako.

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 :

Can this apply to other swipe tests in calendar? also note https://code.launchpad.net/~nskaggs/ubuntu-calendar-app/fix-1359167/+merge/233387 which overhauls the tests (gets rid of emulators.py among other things)

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 :

Merge conflicts now since the overhaul. The python3 support landed in another branch; you'll get it when you merge trunk.

review: Needs Fixing
384. By Leo Arias

Merged with trunk.

385. By Leo Arias

Removed the merge file.

Revision history for this message
Leo Arias (elopio) wrote :

> Can this apply to other swipe tests in calendar? also note
> https://code.launchpad.net/~nskaggs/ubuntu-calendar-
> app/fix-1359167/+merge/233387 which overhauls the tests (gets rid of
> emulators.py among other things)

I merged. The tests are running now.
This only applies to swipes on the year view. And we do it only on one tests, as far as I know.

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 :

Thanks for the fix Leo!

review: Approve
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
=== modified file 'YearView.qml'
--- YearView.qml 2014-08-18 16:48:54 +0000
+++ YearView.qml 2014-09-05 15:28:43 +0000
@@ -100,9 +100,10 @@
100100
101 MonthComponent {101 MonthComponent {
102 id: monthComponent102 id: monthComponent
103 objectName: "monthComponent" + index
103 showEvents: false104 showEvents: false
104 currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0)105 currentMonth: new Date(yearView.year, index, 1, 0, 0, 0, 0)
105 106
106 isYearView: true107 isYearView: true
107 anchors.fill: parent108 anchors.fill: parent
108 anchors.margins: units.gu(0.5)109 anchors.margins: units.gu(0.5)
109110
=== modified file 'tests/autopilot/calendar_app/__init__.py'
--- tests/autopilot/calendar_app/__init__.py 2014-09-05 01:20:19 +0000
+++ tests/autopilot/calendar_app/__init__.py 2014-09-05 15:28:43 +0000
@@ -16,14 +16,15 @@
1616
17"""Calendar app autopilot helpers."""17"""Calendar app autopilot helpers."""
1818
19import datetime
19import logging20import logging
20from time import sleep21from time import sleep
2122
22import autopilot.logging23import autopilot.logging
24import ubuntuuitoolkit
25from autopilot import exceptions
23from dateutil import tz26from dateutil import tz
2427
25import ubuntuuitoolkit
26
27from calendar_app import data28from calendar_app import data
2829
2930
@@ -237,6 +238,64 @@
237238
238 """Autopilot helper for the Year View page."""239 """Autopilot helper for the Year View page."""
239240
241 def get_selected_day(self):
242 """Return the selected day.
243
244 :returns: A python datetime.date object with the selected day.
245
246 """
247 current_year_grid = self._get_current_year_grid()
248 for index in range(12):
249 month_component = self._find_month_component(
250 current_year_grid, index)
251 try:
252 today = month_component.select_single(
253 'QQuickItem', isCurrentMonth=True, isToday=True)
254 except exceptions.StateNotFoundError:
255 continue
256 else:
257 return datetime.date(
258 current_year_grid.year, index + 1, today.date)
259 else:
260 raise CalendarException(
261 'No day is selected on the currently visible year.')
262
263 def _get_current_year_grid(self):
264 path_view_base = self.select_single(
265 'PathViewBase', objectName='yearPathView')
266 return path_view_base.select_single(
267 ubuntuuitoolkit.QQuickGridView, isCurrentItem=True)
268
269 def _find_month_component(self, grid, index):
270 try:
271 month = self._get_month_component(grid, index)
272 except exceptions.StateNotFoundError:
273 month = self._swipe_to_find_month_component(grid, index)
274 if month is None:
275 raise CalendarException('Month {} not found.'.format(index))
276 else:
277 return month
278
279 def _get_month_component(self, grid, index):
280 return grid.select_single(
281 'MonthComponent',
282 objectName='monthComponent{}'.format(index))
283
284 def _swipe_to_find_month_component(self, grid, index):
285 month = None
286 grid.swipe_to_top()
287 while not grid.atYEnd:
288 try:
289 month = self._get_month_component(grid, index)
290 except exceptions.StateNotFoundError:
291 # FIXME do not call the private _get_containers.
292 # Reported as bug http://pad.lv/1365674
293 # --elopio - 2014-09-04
294 grid.swipe_to_show_more_below(grid._get_containers())
295 else:
296 break
297 return month
298
240299
241class WeekView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):300class WeekView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
242301
243302
=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-09-04 16:04:37 +0000
+++ tests/autopilot/calendar_app/tests/test_yearview.py 2014-09-05 15:28:43 +0000
@@ -24,7 +24,7 @@
24if sys.version_info < (3,):24if sys.version_info < (3,):
25 range = xrange25 range = xrange
2626
27from datetime import datetime27import datetime
28from autopilot.matchers import Eventually28from autopilot.matchers import Eventually
29from testtools.matchers import Equals, NotEquals29from testtools.matchers import Equals, NotEquals
3030
@@ -41,10 +41,6 @@
41 return self.year_view.wait_select_single("QQuickGridView",41 return self.year_view.wait_select_single("QQuickGridView",
42 isCurrentItem=True)42 isCurrentItem=True)
4343
44 def _get_month_grid(self):
45 current_month = self._get_current_month()
46 return current_month.select_single(objectName="monthGrid")
47
48 def _change_year(self, direction, how_many=5):44 def _change_year(self, direction, how_many=5):
49 current_year = self.year_view.currentYear45 current_year = self.year_view.currentYear
5046
@@ -55,25 +51,10 @@
55 lambda: self.year_view.currentYear,51 lambda: self.year_view.currentYear,
56 Eventually(Equals(current_year + (i * direction))))52 Eventually(Equals(current_year + (i * direction))))
5753
58 def _get_current_month(self):
59 now = datetime.now()
60 _current_month_name = now.strftime("%B")
61
62 year_grid = self._get_year_grid()
63 months = year_grid.select_many("MonthComponent")
64
65 for month in months:
66 _current_month_label = month.select_single(
67 "Label", objectName="monthLabel")
68 if _current_month_name == _current_month_label.text:
69 return month
70
71 return None
72
73 def test_current_year_is_default(self):54 def test_current_year_is_default(self):
74 """The current year should be the default shown"""55 """The current year should be the default shown"""
75 self.assertThat(self.year_view.currentYear,56 self.assertThat(self.year_view.currentYear,
76 Equals(datetime.now().year))57 Equals(datetime.datetime.now().year))
7758
78 def test_selecting_a_month_switch_to_month_view(self):59 def test_selecting_a_month_switch_to_month_view(self):
79 """It must be possible to select a month and open the month view."""60 """It must be possible to select a month and open the month view."""
@@ -109,22 +90,9 @@
10990
110 def test_current_day_is_selected(self):91 def test_current_day_is_selected(self):
111 """The current day must be selected."""92 """The current day must be selected."""
11293 selected_day = self.year_view.get_selected_day()
113 month_grid = self._get_month_grid()94 self.assertEqual(
11495 selected_day, datetime.date.today())
115 # there could actually be two labels with
116 # the current day: one is the current day of the current month,
117 # the other one is the current day of the previous or next month. Both
118 # shouldn't have the standard white color.
119 current_day_labels = month_grid.select_many(
120 "Label", text=str(datetime.now().day))
121
122 # probably better to check the surrounding UbuntuShape object,
123 # upgrade when python-autopilot 1.4 will be available (get_parent).
124 for current_day_label in current_day_labels:
125 color = current_day_label.color
126 label_color = (color[0], color[1], color[2], color[3])
127 self.assertThat(label_color, NotEquals((255, 255, 255, 255)))
12896
129 def test_show_next_years(self):97 def test_show_next_years(self):
130 """It must be possible to show next years by swiping the view."""98 """It must be possible to show next years by swiping the view."""

Subscribers

People subscribed via source and target branches

to status/vote changes: