Merge lp:~carla-sella/ubuntu-calendar-app/calendar-management-tests into lp:ubuntu-calendar-app

Proposed by Carla Sella
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 632
Merged at revision: 630
Proposed branch: lp:~carla-sella/ubuntu-calendar-app/calendar-management-tests
Merge into: lp:ubuntu-calendar-app
Diff against target: 265 lines (+167/-1)
5 files modified
CalendarChoicePopup.qml (+6/-1)
ColorPickerDialog.qml (+2/-0)
EventActions.qml (+1/-0)
tests/autopilot/calendar_app/__init__.py (+76/-0)
tests/autopilot/calendar_app/tests/test_management.py (+82/-0)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-calendar-app/calendar-management-tests
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+256202@code.launchpad.net

Commit message

New Calendar App management tests.

Description of the change

New Calendar App management tests.

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 :

Looks good. A few comments, including requests for more tests (can't help myself!). I wouldn't hold this for the test enhancements, but I'd like to see the other issues fixed.

review: Needs Fixing
632. By Carla Sella

Implemented improvements asked by Nicholas.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

LGTM!

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
1=== modified file 'CalendarChoicePopup.qml'
2--- CalendarChoicePopup.qml 2014-11-08 11:26:37 +0000
3+++ CalendarChoicePopup.qml 2015-04-17 19:50:54 +0000
4@@ -24,7 +24,7 @@
5
6 Page {
7 id: root
8-
9+ objectName: "calendarchoicepopup"
10 property var model;
11
12 signal collectionUpdated();
13@@ -67,6 +67,7 @@
14 width: aadCalendar.width
15 Button {
16 id:aadCalendar
17+ objectName: "aadCalendar"
18 text: i18n.tr("Add new Calendar")
19 anchors.top :parent.top
20 anchors.topMargin:units.gu(2)
21@@ -80,9 +81,11 @@
22 model : root.model.getCollections();
23 delegate: ListItem.Standard {
24 id: delegateComp
25+ objectName: "calendarItem"
26
27 Rectangle {
28 id: calendarColorCode
29+ objectName: "calendarColorCode"
30
31 width: parent.height - units.gu(2)
32 height: width
33@@ -111,6 +114,7 @@
34 }
35
36 Label{
37+ objectName: "calendarName"
38 text: modelData.name
39 elide: Text.ElideRight
40 opacity: checkBox.checked ? 1.0 : 0.8
41@@ -125,6 +129,7 @@
42
43 control: CheckBox {
44 id: checkBox
45+ objectName: "checkBox"
46 checked: modelData.extendedMetaData("collection-selected")
47 enabled: !root.isInEditMode
48 onCheckedChanged: {
49
50=== modified file 'ColorPickerDialog.qml'
51--- ColorPickerDialog.qml 2014-09-19 08:46:30 +0000
52+++ ColorPickerDialog.qml 2015-04-17 19:50:54 +0000
53@@ -21,6 +21,7 @@
54
55 Dialog {
56 id: root
57+ objectName: "colorPickerDialog"
58 title: i18n.tr("Select Color")
59 signal accepted(var color)
60 signal rejected()
61@@ -34,6 +35,7 @@
62 Repeater{
63 model: ["#2C001E","#333333","#DD4814","#DF382C","#EFB73E","#19B6EE","#38B44A","#001F5C"];
64 delegate:Rectangle{
65+ objectName: "color" + index
66 width: parent.width/5
67 height: width
68 color: modelData
69
70=== modified file 'EventActions.qml'
71--- EventActions.qml 2015-03-20 14:25:01 +0000
72+++ EventActions.qml 2015-04-17 19:50:54 +0000
73@@ -55,6 +55,7 @@
74
75 Action{
76 id: _showCalendarAction
77+ objectName: "calendarsbutton"
78 iconName: "calendar"
79 text: i18n.tr("Calendars")
80 onTriggered: {
81
82=== modified file 'tests/autopilot/calendar_app/__init__.py'
83--- tests/autopilot/calendar_app/__init__.py 2015-04-10 19:33:42 +0000
84+++ tests/autopilot/calendar_app/__init__.py 2015-04-17 19:50:54 +0000
85@@ -142,6 +142,18 @@
86 header.click_action_button('neweventbutton')
87 return self.wait_select_single(NewEvent, objectName='newEventPage')
88
89+ @autopilot.logging.log_action(logger.info)
90+ def go_to_calendar_choice_popup(self):
91+ """Open the calendar chioce popup.
92+
93+ :return: CalendaChoicePopup.
94+
95+ """
96+ header = self.get_header()
97+ header.click_action_button('calendarsbutton')
98+ return self.wait_select_single(
99+ CalendarChoicePopup, objectName="calendarchoicepopup")
100+
101 def set_picker(self, field, mode, value):
102 # open picker
103 self.pointing_device.click_object(field)
104@@ -285,6 +297,16 @@
105 header = self.get_header()
106 header.click_action_button('todaybutton')
107
108+ @autopilot.logging.log_action(logger.info)
109+ def get_color_picker_dialog(self):
110+ return self.wait_select_single(
111+ "ColorPickerDialog", objectName="colorPickerDialog")
112+
113+ @autopilot.logging.log_action(logger.info)
114+ def press_header_custombackbutton(self):
115+ header = self.get_header()
116+ header.click_custom_back_button()
117+
118
119 class YearView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
120
121@@ -1003,3 +1025,57 @@
122 delete_button = self.select_single(
123 'Button', objectName='deleteEventButton')
124 self.pointing_device.click_object(delete_button)
125+
126+
127+class CalendarChoicePopup(
128+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
129+
130+ """Autopilot helper for the Calendar Choice Popup."""
131+
132+ @autopilot.logging.log_action(logger.debug)
133+ def press_check_box_button(self):
134+ """ press check box button to select or unselect it """
135+ calendar = self._get_calendar()
136+ check_box = calendar.wait_select_single(
137+ "CheckBox", objectName="checkBox")
138+ self.pointing_device.click_object(check_box)
139+ check_box.checked.wait_for(False)
140+
141+ def _get_calendar(self):
142+ calendarItems = self.select_many("Standard", objectName="calendarItem")
143+ for item in calendarItems:
144+ if item.select_single(
145+ "Label", objectName="calendarName").text == "Personal":
146+ return item
147+
148+ @autopilot.logging.log_action(logger.debug)
149+ def get_checkbox_status(self):
150+ """ press check box button to select or unselect it """
151+ calendar = self._get_calendar()
152+ return calendar.wait_select_single(
153+ "CheckBox", objectName="checkBox").checked
154+
155+ @autopilot.logging.log_action(logger.debug)
156+ def get_calendar_color(self):
157+ """ get calendar color """
158+ calendar = self._get_calendar()
159+ return calendar.select_single(
160+ "QQuickRectangle", objectName="calendarColorCode").color
161+
162+ @autopilot.logging.log_action(logger.debug)
163+ def open_color_picker_dialog(self):
164+ """ press color rectangle to open calendar color picker"""
165+ calendar = self._get_calendar()
166+ color_rectangle = calendar.wait_select_single(
167+ "QQuickRectangle", objectName="calendarColorCode")
168+ self.pointing_device.click_object(color_rectangle)
169+
170+
171+class ColorPickerDialog(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
172+ """Autopilot helper for the Color Picker Dialog."""
173+
174+ @autopilot.logging.log_action(logger.debug)
175+ def change_calendar_color(self, new_color):
176+ new_color_circle = self.wait_select_single(
177+ "QQuickRectangle", objectName=new_color)
178+ self.pointing_device.click_object(new_color_circle)
179
180=== added file 'tests/autopilot/calendar_app/tests/test_management.py'
181--- tests/autopilot/calendar_app/tests/test_management.py 1970-01-01 00:00:00 +0000
182+++ tests/autopilot/calendar_app/tests/test_management.py 2015-04-17 19:50:54 +0000
183@@ -0,0 +1,82 @@
184+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
185+#
186+# Copyright (C) 2013, 2014 Canonical Ltd
187+#
188+# This program is free software: you can redistribute it and/or modify
189+# it under the terms of the GNU General Public License version 3 as
190+# published by the Free Software Foundation.
191+#
192+# This program is distributed in the hope that it will be useful,
193+# but WITHOUT ANY WARRANTY; without even the implied warranty of
194+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
195+# GNU General Public License for more details.
196+#
197+# You should have received a copy of the GNU General Public License
198+# along with this program. If not, see <http://www.gnu.org/licenses/>.
199+
200+"""
201+Calendar app autopilot tests calendar management.
202+"""
203+
204+
205+from testtools.matchers import NotEquals, Equals
206+from autopilot.matchers import Eventually
207+
208+from calendar_app import data
209+
210+from calendar_app.tests import CalendarAppTestCaseWithVcard
211+
212+
213+class TestManagement(CalendarAppTestCaseWithVcard):
214+
215+ def test_change_calendar_color(self):
216+ """ Test changing calendar color """
217+ calendar_choice_popup = \
218+ self.app.main_view.go_to_calendar_choice_popup()
219+ original_calendar_color = \
220+ calendar_choice_popup.get_calendar_color()
221+ calendar_choice_popup.open_color_picker_dialog()
222+ colorPickerDialog = self.app.main_view.get_color_picker_dialog()
223+ colorPickerDialog.change_calendar_color("color6")
224+
225+ final_calendar_color = \
226+ calendar_choice_popup.get_calendar_color()
227+
228+ self.assertThat(
229+ original_calendar_color, NotEquals(final_calendar_color))
230+
231+ def test_unselect_calendar(self):
232+ """ Test unselecting calendar
233+
234+ First adding an Event to then check it no longer appears after
235+ deselecting the Personal calendar """
236+ test_event = data.Event.make_unique()
237+ new_event_page = self.app.main_view.go_to_new_event()
238+ new_event_page.add_event(test_event)
239+
240+ self.assertThat(lambda: self._event_exists(test_event.name),
241+ Eventually(Equals(True)))
242+
243+ calendar_choice_popup = \
244+ self.app.main_view.go_to_calendar_choice_popup()
245+ original_checbox_status = \
246+ calendar_choice_popup.get_checkbox_status()
247+ calendar_choice_popup.press_check_box_button()
248+
249+ self.assertThat(
250+ original_checbox_status,
251+ NotEquals(calendar_choice_popup.get_checkbox_status()))
252+
253+ self.app.main_view.press_header_custombackbutton()
254+ self.app.main_view.go_to_day_view()
255+
256+ self.assertThat(lambda: self._event_exists(test_event.name),
257+ Eventually(Equals(False)))
258+
259+ def _event_exists(self, event_name):
260+ try:
261+ day_view = self.app.main_view.go_to_day_view()
262+ day_view.get_event(event_name, True)
263+ except Exception:
264+ return False
265+ return True

Subscribers

People subscribed via source and target branches

to status/vote changes: