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
=== modified file 'CalendarChoicePopup.qml'
--- CalendarChoicePopup.qml 2014-11-08 11:26:37 +0000
+++ CalendarChoicePopup.qml 2015-04-17 19:50:54 +0000
@@ -24,7 +24,7 @@
2424
25Page {25Page {
26 id: root26 id: root
2727 objectName: "calendarchoicepopup"
28 property var model;28 property var model;
2929
30 signal collectionUpdated();30 signal collectionUpdated();
@@ -67,6 +67,7 @@
67 width: aadCalendar.width67 width: aadCalendar.width
68 Button {68 Button {
69 id:aadCalendar69 id:aadCalendar
70 objectName: "aadCalendar"
70 text: i18n.tr("Add new Calendar")71 text: i18n.tr("Add new Calendar")
71 anchors.top :parent.top72 anchors.top :parent.top
72 anchors.topMargin:units.gu(2)73 anchors.topMargin:units.gu(2)
@@ -80,9 +81,11 @@
80 model : root.model.getCollections();81 model : root.model.getCollections();
81 delegate: ListItem.Standard {82 delegate: ListItem.Standard {
82 id: delegateComp83 id: delegateComp
84 objectName: "calendarItem"
8385
84 Rectangle {86 Rectangle {
85 id: calendarColorCode87 id: calendarColorCode
88 objectName: "calendarColorCode"
8689
87 width: parent.height - units.gu(2)90 width: parent.height - units.gu(2)
88 height: width91 height: width
@@ -111,6 +114,7 @@
111 }114 }
112115
113 Label{116 Label{
117 objectName: "calendarName"
114 text: modelData.name118 text: modelData.name
115 elide: Text.ElideRight119 elide: Text.ElideRight
116 opacity: checkBox.checked ? 1.0 : 0.8120 opacity: checkBox.checked ? 1.0 : 0.8
@@ -125,6 +129,7 @@
125129
126 control: CheckBox {130 control: CheckBox {
127 id: checkBox131 id: checkBox
132 objectName: "checkBox"
128 checked: modelData.extendedMetaData("collection-selected")133 checked: modelData.extendedMetaData("collection-selected")
129 enabled: !root.isInEditMode134 enabled: !root.isInEditMode
130 onCheckedChanged: {135 onCheckedChanged: {
131136
=== modified file 'ColorPickerDialog.qml'
--- ColorPickerDialog.qml 2014-09-19 08:46:30 +0000
+++ ColorPickerDialog.qml 2015-04-17 19:50:54 +0000
@@ -21,6 +21,7 @@
2121
22Dialog {22Dialog {
23 id: root23 id: root
24 objectName: "colorPickerDialog"
24 title: i18n.tr("Select Color")25 title: i18n.tr("Select Color")
25 signal accepted(var color)26 signal accepted(var color)
26 signal rejected()27 signal rejected()
@@ -34,6 +35,7 @@
34 Repeater{35 Repeater{
35 model: ["#2C001E","#333333","#DD4814","#DF382C","#EFB73E","#19B6EE","#38B44A","#001F5C"];36 model: ["#2C001E","#333333","#DD4814","#DF382C","#EFB73E","#19B6EE","#38B44A","#001F5C"];
36 delegate:Rectangle{37 delegate:Rectangle{
38 objectName: "color" + index
37 width: parent.width/539 width: parent.width/5
38 height: width40 height: width
39 color: modelData41 color: modelData
4042
=== modified file 'EventActions.qml'
--- EventActions.qml 2015-03-20 14:25:01 +0000
+++ EventActions.qml 2015-04-17 19:50:54 +0000
@@ -55,6 +55,7 @@
5555
56 Action{56 Action{
57 id: _showCalendarAction57 id: _showCalendarAction
58 objectName: "calendarsbutton"
58 iconName: "calendar"59 iconName: "calendar"
59 text: i18n.tr("Calendars")60 text: i18n.tr("Calendars")
60 onTriggered: {61 onTriggered: {
6162
=== modified file 'tests/autopilot/calendar_app/__init__.py'
--- tests/autopilot/calendar_app/__init__.py 2015-04-10 19:33:42 +0000
+++ tests/autopilot/calendar_app/__init__.py 2015-04-17 19:50:54 +0000
@@ -142,6 +142,18 @@
142 header.click_action_button('neweventbutton')142 header.click_action_button('neweventbutton')
143 return self.wait_select_single(NewEvent, objectName='newEventPage')143 return self.wait_select_single(NewEvent, objectName='newEventPage')
144144
145 @autopilot.logging.log_action(logger.info)
146 def go_to_calendar_choice_popup(self):
147 """Open the calendar chioce popup.
148
149 :return: CalendaChoicePopup.
150
151 """
152 header = self.get_header()
153 header.click_action_button('calendarsbutton')
154 return self.wait_select_single(
155 CalendarChoicePopup, objectName="calendarchoicepopup")
156
145 def set_picker(self, field, mode, value):157 def set_picker(self, field, mode, value):
146 # open picker158 # open picker
147 self.pointing_device.click_object(field)159 self.pointing_device.click_object(field)
@@ -285,6 +297,16 @@
285 header = self.get_header()297 header = self.get_header()
286 header.click_action_button('todaybutton')298 header.click_action_button('todaybutton')
287299
300 @autopilot.logging.log_action(logger.info)
301 def get_color_picker_dialog(self):
302 return self.wait_select_single(
303 "ColorPickerDialog", objectName="colorPickerDialog")
304
305 @autopilot.logging.log_action(logger.info)
306 def press_header_custombackbutton(self):
307 header = self.get_header()
308 header.click_custom_back_button()
309
288310
289class YearView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):311class YearView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
290312
@@ -1003,3 +1025,57 @@
1003 delete_button = self.select_single(1025 delete_button = self.select_single(
1004 'Button', objectName='deleteEventButton')1026 'Button', objectName='deleteEventButton')
1005 self.pointing_device.click_object(delete_button)1027 self.pointing_device.click_object(delete_button)
1028
1029
1030class CalendarChoicePopup(
1031 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
1032
1033 """Autopilot helper for the Calendar Choice Popup."""
1034
1035 @autopilot.logging.log_action(logger.debug)
1036 def press_check_box_button(self):
1037 """ press check box button to select or unselect it """
1038 calendar = self._get_calendar()
1039 check_box = calendar.wait_select_single(
1040 "CheckBox", objectName="checkBox")
1041 self.pointing_device.click_object(check_box)
1042 check_box.checked.wait_for(False)
1043
1044 def _get_calendar(self):
1045 calendarItems = self.select_many("Standard", objectName="calendarItem")
1046 for item in calendarItems:
1047 if item.select_single(
1048 "Label", objectName="calendarName").text == "Personal":
1049 return item
1050
1051 @autopilot.logging.log_action(logger.debug)
1052 def get_checkbox_status(self):
1053 """ press check box button to select or unselect it """
1054 calendar = self._get_calendar()
1055 return calendar.wait_select_single(
1056 "CheckBox", objectName="checkBox").checked
1057
1058 @autopilot.logging.log_action(logger.debug)
1059 def get_calendar_color(self):
1060 """ get calendar color """
1061 calendar = self._get_calendar()
1062 return calendar.select_single(
1063 "QQuickRectangle", objectName="calendarColorCode").color
1064
1065 @autopilot.logging.log_action(logger.debug)
1066 def open_color_picker_dialog(self):
1067 """ press color rectangle to open calendar color picker"""
1068 calendar = self._get_calendar()
1069 color_rectangle = calendar.wait_select_single(
1070 "QQuickRectangle", objectName="calendarColorCode")
1071 self.pointing_device.click_object(color_rectangle)
1072
1073
1074class ColorPickerDialog(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
1075 """Autopilot helper for the Color Picker Dialog."""
1076
1077 @autopilot.logging.log_action(logger.debug)
1078 def change_calendar_color(self, new_color):
1079 new_color_circle = self.wait_select_single(
1080 "QQuickRectangle", objectName=new_color)
1081 self.pointing_device.click_object(new_color_circle)
10061082
=== added file 'tests/autopilot/calendar_app/tests/test_management.py'
--- tests/autopilot/calendar_app/tests/test_management.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/calendar_app/tests/test_management.py 2015-04-17 19:50:54 +0000
@@ -0,0 +1,82 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013, 2014 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""
18Calendar app autopilot tests calendar management.
19"""
20
21
22from testtools.matchers import NotEquals, Equals
23from autopilot.matchers import Eventually
24
25from calendar_app import data
26
27from calendar_app.tests import CalendarAppTestCaseWithVcard
28
29
30class TestManagement(CalendarAppTestCaseWithVcard):
31
32 def test_change_calendar_color(self):
33 """ Test changing calendar color """
34 calendar_choice_popup = \
35 self.app.main_view.go_to_calendar_choice_popup()
36 original_calendar_color = \
37 calendar_choice_popup.get_calendar_color()
38 calendar_choice_popup.open_color_picker_dialog()
39 colorPickerDialog = self.app.main_view.get_color_picker_dialog()
40 colorPickerDialog.change_calendar_color("color6")
41
42 final_calendar_color = \
43 calendar_choice_popup.get_calendar_color()
44
45 self.assertThat(
46 original_calendar_color, NotEquals(final_calendar_color))
47
48 def test_unselect_calendar(self):
49 """ Test unselecting calendar
50
51 First adding an Event to then check it no longer appears after
52 deselecting the Personal calendar """
53 test_event = data.Event.make_unique()
54 new_event_page = self.app.main_view.go_to_new_event()
55 new_event_page.add_event(test_event)
56
57 self.assertThat(lambda: self._event_exists(test_event.name),
58 Eventually(Equals(True)))
59
60 calendar_choice_popup = \
61 self.app.main_view.go_to_calendar_choice_popup()
62 original_checbox_status = \
63 calendar_choice_popup.get_checkbox_status()
64 calendar_choice_popup.press_check_box_button()
65
66 self.assertThat(
67 original_checbox_status,
68 NotEquals(calendar_choice_popup.get_checkbox_status()))
69
70 self.app.main_view.press_header_custombackbutton()
71 self.app.main_view.go_to_day_view()
72
73 self.assertThat(lambda: self._event_exists(test_event.name),
74 Eventually(Equals(False)))
75
76 def _event_exists(self, event_name):
77 try:
78 day_view = self.app.main_view.go_to_day_view()
79 day_view.get_event(event_name, True)
80 except Exception:
81 return False
82 return True

Subscribers

People subscribed via source and target branches

to status/vote changes: