Merge lp:~acerisara/ubuntu-calendar-app/year-view-autopilot into lp:ubuntu-calendar-app

Proposed by Andrea Cerisara
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 148
Merged at revision: 162
Proposed branch: lp:~acerisara/ubuntu-calendar-app/year-view-autopilot
Merge into: lp:ubuntu-calendar-app
Diff against target: 210 lines (+134/-8)
6 files modified
MonthComponent.qml (+1/-0)
ViewHeader.qml (+2/-0)
calendar.qml (+2/-0)
tests/autopilot/calendar_app/emulators.py (+18/-0)
tests/autopilot/calendar_app/tests/test_monthview.py (+4/-8)
tests/autopilot/calendar_app/tests/test_yearview.py (+107/-0)
To merge this branch: bzr merge lp:~acerisara/ubuntu-calendar-app/year-view-autopilot
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+190832@code.launchpad.net

Commit message

Autopilot tests for yearly view.

Description of the change

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Andrea, this looks great. I like the swipe_view function, with optional xpad. Nicely done. Checking the label color works well enough, and you made it look for non-black which should work out fine for now. As we moved forward we might indeed be able to nail this done a bit more.

review: Approve
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: Approve (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)
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 :

FAILED: Continuous integration, rev:145
http://91.189.93.70:8080/job/ubuntu-calendar-app-ci/176/
Executed test runs:

Click here to trigger a rebuild:
http://91.189.93.70:8080/job/ubuntu-calendar-app-ci/176/rebuild

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)

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 2013-10-16 14:36:51 +0000
3+++ MonthComponent.qml 2013-10-22 17:53:22 +0000
4@@ -64,6 +64,7 @@
5
6 Grid{
7 id: monthGrid
8+ objectName: "monthGrid"
9
10 property int weekCount : 6
11 property var monthStart: root.monthDate.weekStart( Qt.locale().firstDayOfWeek )
12
13=== modified file 'ViewHeader.qml'
14--- ViewHeader.qml 2013-10-09 03:01:45 +0000
15+++ ViewHeader.qml 2013-10-22 17:53:22 +0000
16@@ -12,6 +12,7 @@
17
18 Label{
19 id: monthLabel
20+ objectName: "monthLabel"
21 fontSize: monthLabelFontSize
22 text: Qt.locale().standaloneMonthName(date.getMonth())
23 anchors.leftMargin: units.gu(1)
24@@ -22,6 +23,7 @@
25
26 Label{
27 id: yearLabel
28+ objectName: "yearLabel"
29 fontSize: yearLabelFontSize
30 text: date.getFullYear()
31 anchors.right: parent.right
32
33=== modified file 'calendar.qml'
34--- calendar.qml 2013-10-16 14:15:06 +0000
35+++ calendar.qml 2013-10-22 17:53:22 +0000
36@@ -231,8 +231,10 @@
37 Tabs{
38 id: tabs
39 Tab{
40+ objectName: "yearTab"
41 title: i18n.tr("Year")
42 page: Page{
43+ objectName: "yearPage"
44 anchors.fill: parent
45 tools: commonToolBar
46 YearView{
47
48=== modified file 'tests/autopilot/calendar_app/emulators.py'
49--- tests/autopilot/calendar_app/emulators.py 2013-10-05 07:50:54 +0000
50+++ tests/autopilot/calendar_app/emulators.py 2013-10-22 17:53:22 +0000
51@@ -67,3 +67,21 @@
52
53 def get_time_picker(self):
54 return self.select_single("TimePicker")
55+
56+ def swipe_view(self, direction, view, x_pad=0.35):
57+ """Swipe the given view to left or right.
58+
59+ Args:
60+ direction: if 1 it swipes from right to left, if -1 from
61+ left right.
62+
63+ """
64+
65+ start = (-direction * x_pad) % 1
66+ stop = (direction * x_pad) % 1
67+
68+ y_line = view.globalRect[1] + view.globalRect[3] / 2
69+ x_start = view.globalRect[0] + view.globalRect[2] * start
70+ x_stop = view.globalRect[0] + view.globalRect[2] * stop
71+
72+ self.pointing_device.drag(x_start, y_line, x_stop, y_line)
73
74=== modified file 'tests/autopilot/calendar_app/tests/test_monthview.py'
75--- tests/autopilot/calendar_app/tests/test_monthview.py 2013-10-01 16:15:42 +0000
76+++ tests/autopilot/calendar_app/tests/test_monthview.py 2013-10-22 17:53:22 +0000
77@@ -28,17 +28,13 @@
78
79 def change_month(self, delta):
80 month_view = self.main_view.get_month_view()
81- y_line = month_view.globalRect[1] + month_view.globalRect[3] / 2
82- x_pad = 0.35
83 sign = int(math.copysign(1, delta))
84- start = (-sign * x_pad) % 1
85- stop = (sign * x_pad) % 1
86- x_start = month_view.globalRect[0] + month_view.globalRect[2] * start
87- x_stop = month_view.globalRect[0] + month_view.globalRect[2] * stop
88- for i in range(abs(delta)):
89+
90+ for _ in range(abs(delta)):
91 before = self.get_currentDayStart()
92- self.pointing_device.drag(x_start, y_line, x_stop, y_line)
93+ self.main_view.swipe_view(sign, month_view)
94 after = before + relativedelta(months=sign)
95+
96 self.assertThat(lambda: self.get_currentDayStart().month,
97 Eventually(Equals(after.month)))
98 self.assertThat(lambda: self.get_currentDayStart().year,
99
100=== added file 'tests/autopilot/calendar_app/tests/test_yearview.py'
101--- tests/autopilot/calendar_app/tests/test_yearview.py 1970-01-01 00:00:00 +0000
102+++ tests/autopilot/calendar_app/tests/test_yearview.py 2013-10-22 17:53:22 +0000
103@@ -0,0 +1,107 @@
104+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
105+# Copyright 2013 Canonical
106+#
107+# This program is free software: you can redistribute it and/or modify it
108+# under the terms of the GNU General Public License version 3, as published
109+# by the Free Software Foundation.
110+
111+"""
112+Calendar app autopilot tests for the year view.
113+"""
114+
115+from datetime import datetime
116+
117+from autopilot.matchers import Eventually
118+from testtools.matchers import Equals, NotEquals
119+
120+from calendar_app.tests import CalendarTestCase
121+
122+
123+class TestYearView(CalendarTestCase):
124+
125+ def setUp(self):
126+ super(TestYearView, self).setUp()
127+ self.assertThat(self.main_view.visible, Eventually(Equals(True)))
128+ self.main_view.switch_to_tab("yearTab")
129+ self.assertThat(
130+ self.main_view.get_year_view, Eventually(NotEquals(None)))
131+
132+ self.year_view = self.main_view.get_year_view()
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+ months = self.months_from_selected_year()
138+ self.assert_current_year_is_default_one(months[0])
139+
140+ february = months[1]
141+ expected_month_name = self.get_month_name(february)
142+ expected_year = self.get_year(february)
143+
144+ self.pointing_device.click_object(february)
145+
146+ self.assertThat(
147+ self.main_view.get_month_view, Eventually(NotEquals(None)))
148+
149+ month_view = self.main_view.get_month_view()
150+ self.assertThat(month_view.visible, Eventually(Equals(True)))
151+ selected_month = month_view.select_many("MonthComponent")[1]
152+
153+ self.assertThat(self.get_year(selected_month), Equals(expected_year))
154+ self.assertThat(self.get_month_name(selected_month),
155+ Equals(expected_month_name))
156+
157+ def test_current_day_is_selected(self):
158+ """The current day must be selected."""
159+
160+ months = self.months_from_selected_year()
161+ current_month = months[datetime.now().month - 1]
162+ month_grid = current_month.select_single(objectName="monthGrid")
163+
164+ current_day_label = month_grid.select_single(
165+ "Label", text=str(datetime.now().day))
166+
167+ # probably better to check the surrounding UbuntuShape object,
168+ # upgrade when python-autopilot 1.4 will be available (get_parent).
169+ color = current_day_label.color
170+ label_color = (color[0], color[1], color[2], color[3])
171+
172+ self.assertThat(label_color, NotEquals((255, 255, 255, 255)))
173+
174+ def test_show_next_years(self):
175+ """It must be possible to show next years by swiping the view."""
176+ self.change_year(1)
177+
178+ def test_show_previous_years(self):
179+ """It must be possible to show previous years by swiping the view."""
180+ self.change_year(-1)
181+
182+ def change_year(self, direction, how_many=5):
183+ current_year = datetime.now().year
184+
185+ for i in xrange(1, how_many):
186+ self.main_view.swipe_view(direction, self.year_view, x_pad=0.15)
187+ selected_year = datetime.fromtimestamp(
188+ self.year_view.currentYear).year
189+
190+ self.assertThat(
191+ selected_year, Equals(current_year + (i * direction)))
192+
193+ def assert_current_year_is_default_one(self, month_component):
194+ self.assertThat(self.get_year(month_component),
195+ Equals(datetime.now().year))
196+
197+ def get_year(self, month_component):
198+ return int(month_component.select_single(
199+ "Label", objectName="yearLabel").text)
200+
201+ def get_month_name(self, month_component):
202+ return month_component.select_single(
203+ "Label", objectName="monthLabel").text
204+
205+ def months_from_selected_year(self):
206+ # TODO: the component indexed at 1 is the one currently displayed,
207+ # investigate a way to validate this assumption visually.
208+
209+ year_grid = self.year_view.select_many("QQuickGridView")[1]
210+ return year_grid.select_many("MonthComponent")

Subscribers

People subscribed via source and target branches

to status/vote changes: