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

Proposed by Andrea Cerisara
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 163
Merged at revision: 163
Proposed branch: lp:~acerisara/ubuntu-calendar-app/week-view-autopilot
Merge into: lp:ubuntu-calendar-app
Diff against target: 211 lines (+119/-13)
6 files modified
HeaderDateComponent.qml (+1/-0)
WeekView.qml (+1/-0)
calendar.qml (+1/-0)
tests/autopilot/calendar_app/emulators.py (+11/-0)
tests/autopilot/calendar_app/tests/test_weekview.py (+98/-0)
tests/autopilot/calendar_app/tests/test_yearview.py (+7/-13)
To merge this branch: bzr merge lp:~acerisara/ubuntu-calendar-app/week-view-autopilot
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+192952@code.launchpad.net

Commit message

Autopilot tests for the weekly view.

Description of the change

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

Wonderful, thank you!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'HeaderDateComponent.qml'
--- HeaderDateComponent.qml 2013-09-28 09:37:52 +0000
+++ HeaderDateComponent.qml 2013-10-28 21:19:43 +0000
@@ -26,6 +26,7 @@
2626
27 Label{27 Label{
28 id: dateLabel28 id: dateLabel
29 objectName: "dateLabel"
29 text: date.getDate();30 text: date.getDate();
30 fontSize: "large"31 fontSize: "large"
31 horizontalAlignment: Text.AlignHCenter32 horizontalAlignment: Text.AlignHCenter
3233
=== modified file 'WeekView.qml'
--- WeekView.qml 2013-09-28 09:37:52 +0000
+++ WeekView.qml 2013-10-28 21:19:43 +0000
@@ -20,6 +20,7 @@
2020
21 TimeLineHeader{21 TimeLineHeader{
22 id: weekHeader22 id: weekHeader
23 objectName: "weekHeader"
23 type: typeWeek24 type: typeWeek
24 date: weekViewPath.weekStart25 date: weekViewPath.weekStart
25 }26 }
2627
=== modified file 'calendar.qml'
--- calendar.qml 2013-10-22 17:32:19 +0000
+++ calendar.qml 2013-10-28 21:19:43 +0000
@@ -266,6 +266,7 @@
266 }266 }
267 }267 }
268 Tab{268 Tab{
269 objectName: "weekTab"
269 title: i18n.tr("Week")270 title: i18n.tr("Week")
270 page: Page{271 page: Page{
271 anchors.fill: parent272 anchors.fill: parent
272273
=== modified file 'tests/autopilot/calendar_app/emulators.py'
--- tests/autopilot/calendar_app/emulators.py 2013-10-13 18:26:25 +0000
+++ tests/autopilot/calendar_app/emulators.py 2013-10-28 21:19:43 +0000
@@ -28,6 +28,9 @@
28 def get_day_view(self):28 def get_day_view(self):
29 return self.select_single("DayView")29 return self.select_single("DayView")
3030
31 def get_week_view(self):
32 return self.select_single("WeekView")
33
31 def get_label_with_text(self, text, root=None):34 def get_label_with_text(self, text, root=None):
32 if root is None:35 if root is None:
33 root = self36 root = self
@@ -85,3 +88,11 @@
85 x_stop = view.globalRect[0] + view.globalRect[2] * stop88 x_stop = view.globalRect[0] + view.globalRect[2] * stop
8689
87 self.pointing_device.drag(x_start, y_line, x_stop, y_line)90 self.pointing_device.drag(x_start, y_line, x_stop, y_line)
91
92 def get_year(self, component):
93 return int(component.select_single(
94 "Label", objectName="yearLabel").text)
95
96 def get_month_name(self, component):
97 return component.select_single(
98 "Label", objectName="monthLabel").text
8899
=== added file 'tests/autopilot/calendar_app/tests/test_weekview.py'
--- tests/autopilot/calendar_app/tests/test_weekview.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/calendar_app/tests/test_weekview.py 2013-10-28 21:19:43 +0000
@@ -0,0 +1,98 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2013 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8"""
9Calendar app autopilot tests for the week view.
10"""
11
12import calendar
13import datetime
14
15from autopilot.matchers import Eventually
16from testtools.matchers import Equals, NotEquals
17
18from calendar_app.tests import CalendarTestCase
19
20
21class TestWeekView(CalendarTestCase):
22
23 def setUp(self):
24 super(TestWeekView, self).setUp()
25 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
26 self.main_view.switch_to_tab("weekTab")
27
28 self.assertThat(
29 self.main_view.get_week_view, Eventually(NotEquals(None)))
30
31 self.week_view = self.main_view.get_week_view()
32
33 def test_current_month_and_year_is_selected(self):
34 """By default, the week view shows the current month and year."""
35
36 now = datetime.datetime.now()
37
38 expected_year = now.year
39 expected_month_name = now.strftime("%B")
40
41 self.assertThat(self.main_view.get_year(self.week_view),
42 Equals(expected_year))
43
44 self.assertThat(self.main_view.get_month_name(self.week_view),
45 Equals(expected_month_name))
46
47 def test_current_week_is_selected(self):
48 """By default, the week view shows the current week."""
49
50 now = datetime.datetime.now()
51 days = self.get_days_of_week()
52 monday = (now - datetime.timedelta(days=now.weekday())).day
53 current_month_days = calendar.monthrange(now.year, now.month)[1]
54
55 for i in xrange(7):
56 current_day = int(days[i].text)
57 expected_day = (monday + i) % current_month_days
58
59 if (monday + i) == current_month_days:
60 expected_day = current_month_days
61
62 self.assertThat(current_day, Equals(expected_day))
63
64 color = days[i].color
65 # current day is highlighted in white.
66 if(current_day == now.day):
67 label_color = (color[0], color[1], color[2], color[3])
68 self.assertThat(label_color, Equals((255, 255, 255, 255)))
69
70 def test_show_next_weeks(self):
71 """It must be possible to show next weeks by swiping the view."""
72 self.change_week(1)
73
74 def test_show_previous_weeks(self):
75 """It must be possible to show previous weeks by swiping the view."""
76 self.change_week(-1)
77
78 def change_week(self, direction):
79 now = datetime.datetime.now()
80 current_day_start = (now - datetime.timedelta(days=now.weekday()))
81
82 for i in xrange(1, 5):
83 self.main_view.swipe_view(direction, self.week_view, x_pad=0.15)
84 day_start = datetime.datetime.fromtimestamp(
85 self.week_view.dayStart)
86
87 expected_day_start = current_day_start + datetime.timedelta(
88 days=(i * 7 * direction))
89
90 expected_day_start = expected_day_start.replace(
91 hour=0, minute=0, second=0, microsecond=0)
92
93 self.assertThat(day_start, Equals(expected_day_start))
94
95 def get_days_of_week(self):
96 header = self.main_view.select_single(objectName="weekHeader")
97 timeline = header.select_many("TimeLineHeaderComponent")[1]
98 return timeline.select_many("Label", objectName="dateLabel")
099
=== modified file 'tests/autopilot/calendar_app/tests/test_yearview.py'
--- tests/autopilot/calendar_app/tests/test_yearview.py 2013-10-22 17:53:04 +0000
+++ tests/autopilot/calendar_app/tests/test_yearview.py 2013-10-28 21:19:43 +0000
@@ -35,8 +35,8 @@
35 self.assert_current_year_is_default_one(months[0])35 self.assert_current_year_is_default_one(months[0])
3636
37 february = months[1]37 february = months[1]
38 expected_month_name = self.get_month_name(february)38 expected_month_name = self.main_view.get_month_name(february)
39 expected_year = self.get_year(february)39 expected_year = self.main_view.get_year(february)
4040
41 self.pointing_device.click_object(february)41 self.pointing_device.click_object(february)
4242
@@ -47,8 +47,10 @@
47 self.assertThat(month_view.visible, Eventually(Equals(True)))47 self.assertThat(month_view.visible, Eventually(Equals(True)))
48 selected_month = month_view.select_many("MonthComponent")[1]48 selected_month = month_view.select_many("MonthComponent")[1]
4949
50 self.assertThat(self.get_year(selected_month), Equals(expected_year))50 self.assertThat(self.main_view.get_year(selected_month),
51 self.assertThat(self.get_month_name(selected_month),51 Equals(expected_year))
52
53 self.assertThat(self.main_view.get_month_name(selected_month),
52 Equals(expected_month_name))54 Equals(expected_month_name))
5355
54 def test_current_day_is_selected(self):56 def test_current_day_is_selected(self):
@@ -88,17 +90,9 @@
88 selected_year, Equals(current_year + (i * direction)))90 selected_year, Equals(current_year + (i * direction)))
8991
90 def assert_current_year_is_default_one(self, month_component):92 def assert_current_year_is_default_one(self, month_component):
91 self.assertThat(self.get_year(month_component),93 self.assertThat(self.main_view.get_year(month_component),
92 Equals(datetime.now().year))94 Equals(datetime.now().year))
9395
94 def get_year(self, month_component):
95 return int(month_component.select_single(
96 "Label", objectName="yearLabel").text)
97
98 def get_month_name(self, month_component):
99 return month_component.select_single(
100 "Label", objectName="monthLabel").text
101
102 def months_from_selected_year(self):96 def months_from_selected_year(self):
103 # TODO: the component indexed at 1 is the one currently displayed,97 # TODO: the component indexed at 1 is the one currently displayed,
104 # investigate a way to validate this assumption visually.98 # investigate a way to validate this assumption visually.

Subscribers

People subscribed via source and target branches

to status/vote changes: