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

Proposed by Nicholas Skaggs
Status: Superseded
Proposed branch: lp:~nskaggs/ubuntu-calendar-app/fix-yearview
Merge into: lp:ubuntu-calendar-app
Prerequisite: lp:~pkunal-parmar/ubuntu-calendar-app/YearView-curmonth-scroll
Diff against target: 193 lines (+80/-75)
2 files modified
tests/autopilot/calendar_app/__init__.py (+55/-16)
tests/autopilot/calendar_app/tests/test_yearview.py (+25/-59)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-calendar-app/fix-yearview
Reviewer Review Type Date Requested Status
Ubuntu Calendar Developers Pending
Review via email: mp+236437@code.launchpad.net

Commit message

Resolves Bug #1351663

Description of the change

Resolves Bug #1351663

To post a comment you must log in.
404. By Nicholas Skaggs

remove locale setting

405. By Nicholas Skaggs

fix flake8

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/calendar_app/__init__.py'
2--- tests/autopilot/calendar_app/__init__.py 2014-09-23 15:09:07 +0000
3+++ tests/autopilot/calendar_app/__init__.py 2014-09-29 23:23:54 +0000
4@@ -245,24 +245,56 @@
5 def get_selected_day(self):
6 """Return the selected day.
7
8- :returns: A python datetime.date object with the selected day.
9+ :returns: A today calendar object
10
11 """
12- current_year_grid = self._get_current_year_grid()
13- for index in range(12):
14- month_component = self._find_month_component(
15- current_year_grid, index)
16- try:
17- today = month_component.select_single(
18- 'QQuickItem', isCurrentMonth=True, isToday=True)
19- except exceptions.StateNotFoundError:
20- continue
21- else:
22- return datetime.date(
23- current_year_grid.year, index + 1, today.date)
24- else:
25+ month = self.get_selected_month()
26+ try:
27+ today = month.select_single(
28+ 'QQuickItem', isCurrentMonth=True, isToday=True)
29+ except exceptions.StateNotFoundError:
30 raise CalendarException(
31- 'No day is selected on the currently visible year.')
32+ 'No day is selected on the currently visible year.')
33+ else:
34+ return today
35+
36+ def get_selected_month(self):
37+ """Return the selected month.
38+
39+ :returns: A month calendar object
40+
41+ """
42+ current_year_grid = self._get_current_year_grid()
43+ return self._get_month_component(current_year_grid, current_year_grid.scrollMonth)
44+
45+ def get_day(self, monthNumber, dayNumber):
46+ """Return the day object.
47+ :param monthNumber the numeric month to get
48+ :param dayNumber the numeric day to get
49+ :returns: A month calendar object
50+
51+ """
52+ month = self.get_month(monthNumber)
53+
54+ try:
55+ day = month.select_single('QQuickItem', date=dayNumber)
56+ except exceptions.StateNotFoundError:
57+ raise CalendarException('%s not found in %s' % (
58+ dayNumber, monthNumber))
59+ else:
60+ return today
61+
62+
63+ def get_month(self, monthNumber):
64+ """Return the month object.
65+ :param monthNumber the numeric month to get
66+ :returns: A month calendar object
67+
68+ """
69+ current_year_grid = self._get_current_year_grid()
70+ # the monthcomponents start at zero, thus subtract 1 to get month
71+ return self._find_month_component(current_year_grid, monthNumber - 1)
72+
73
74 def _get_current_year_grid(self):
75 path_view_base = self.select_single(
76@@ -308,7 +340,14 @@
77
78 class MonthView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
79
80- """Autopilot helper for the Year View page."""
81+ """Autopilot helper for the Month View page."""
82+
83+ def get_current_month(self):
84+ return self.select_single('MonthComponent', isCurrentItem=True)
85+
86+ def get_current_month_name(self):
87+ return self.get_current_month().select_single('Label',
88+ objectName='monthLabel').text
89
90
91 class DayView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
92
93=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
94--- tests/autopilot/calendar_app/tests/test_yearview.py 2014-09-29 23:23:54 +0000
95+++ tests/autopilot/calendar_app/tests/test_yearview.py 2014-09-29 23:23:54 +0000
96@@ -52,72 +52,38 @@
97 lambda: self.year_view.currentYear,
98 Eventually(Equals(current_year + (i * direction))))
99
100- def _flick_view_up(self, view):
101- """Swipe the given view to bottom to up"""
102-
103- start = (0.15) % 1
104- stop = (-0.15) % 1
105-
106- x_line = view.globalRect[0] + view.globalRect[2] / 2
107- y_start = view.globalRect[1] + view.globalRect[3] * start
108- y_stop = view.globalRect[1] + view.globalRect[3] * stop
109-
110- self.pointing_device.drag(x_line, y_start, x_line, y_stop)
111-
112- def _flick_view(self, view):
113- """Swipe the given view to bottom to up"""
114- counter = 0
115- # try up to 3 times to swipe
116- while counter < 3:
117- self._flick_view_up(view)
118- sleep(1)
119- counter += 1
120-
121- def test_current_year_is_default(self):
122- """The current year should be the default shown"""
123- self.assertThat(self.year_view.currentYear,
124- Equals(datetime.datetime.now().year))
125+ def test_default_view(self):
126+ """The current year should be the default shown
127+ and the current month should be visible. In addition
128+ the current day should be selected"""
129+ date = datetime.datetime.now()
130+ self.assertEqual(self.year_view.currentYear, date.year)
131+ self.assertEqual(self.year_view.get_selected_month().currentMonth.datetime.month, date.month)
132+ self.assertEqual(self.year_view.get_selected_day().date, date.day)
133
134 def test_selecting_a_month_switch_to_month_view(self):
135 """It must be possible to select a month and open the month view."""
136
137- # TODO: the component indexed at 1 is the one currently displayed,
138- # investigate a way to validate this assumption visually.
139- year_grid = self._get_year_grid()
140- months = year_grid.select_many("MonthComponent")
141- months.sort(key=lambda month: month.currentMonth)
142-
143- # Swiping view vertically enought time to make sure January is visible
144- self._flick_view(self.year_view)
145-
146- february = months[1]
147- expected_month_name = self.app.main_view.get_month_name(february)
148- expected_year = self.app.main_view.get_year(february)
149-
150- self.app.pointing_device.click_object(february)
151-
152- self.assertThat(
153- self.app.main_view.get_month_view, Eventually(NotEquals(None)))
154-
155+ # click the select month
156+ month = self.year_view.get_selected_month()
157+ expected_year = self.year_view.currentYear
158+ expected_month = month.currentMonth.datetime.month
159+ expected_month_name = month.select_single('Label',
160+ objectName = 'monthLabel').text
161+
162+ self.app.pointing_device.click_object(month)
163+
164+ # confirm month transition
165 month_view = self.app.main_view.get_month_view()
166 self.assertThat(month_view.visible, Eventually(Equals(True)))
167
168- selected_month = month_view.select_single("MonthComponent",
169- isCurrentItem=True)
170-
171- self.assertThat(selected_month, NotEquals(None))
172-
173- self.assertThat(self.app.main_view.get_year(selected_month),
174- Equals(expected_year))
175-
176- self.assertThat(self.app.main_view.get_month_name(selected_month),
177- Equals(expected_month_name))
178-
179- def test_current_day_is_selected(self):
180- """The current day must be selected."""
181- selected_day = self.year_view.get_selected_day()
182- self.assertEqual(
183- selected_day, datetime.date.today())
184+ self.assertEquals(month_view.currentMonth.datetime.year,
185+ expected_year)
186+
187+ self.assertEquals(month_view.currentMonth.datetime.month,
188+ expected_month)
189+
190+ self.assertEquals(month_view.get_current_month_name(), expected_month_name)
191
192 def test_show_next_years(self):
193 """It must be possible to show next years by swiping the view."""

Subscribers

People subscribed via source and target branches

to status/vote changes: