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

Proposed by Carla Sella
Status: Superseded
Proposed branch: lp:~carla-sella/ubuntu-calendar-app/calendar-app
Merge into: lp:ubuntu-calendar-app
Diff against target: 205 lines (+97/-16)
3 files modified
TimePicker.qml (+4/-0)
tests/autopilot/calendar_app/emulators/main_window.py (+30/-0)
tests/autopilot/calendar_app/tests/test_calendar.py (+63/-16)
To merge this branch: bzr merge lp:~carla-sella/ubuntu-calendar-app/calendar-app
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Olivier Tilloy (community) Approve
Carla Sella (community) Needs Resubmitting
Ubuntu Calendar Developers Pending
Review via email: mp+179795@code.launchpad.net

This proposal has been superseded by a proposal from 2013-08-19.

Commit message

Calendar app autopilot new event test

Description of the change

Calendar app autopilot new event test

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Going to give this a whirl on a device -- if anyone can try it on a galaxy nexus or nexus 4, that would be great. I'll try on the nexus 10.

Revision history for this message
Olivier Tilloy (osomon) wrote :

101 +## @unittest.skip("Adding a new event is broken, needs fixing. "
102 +## "See http://pad.lv/1206048.")

Instead of commented out, the skip decorator should be removed altogether, as bug #1206048 is now fixed.

Revision history for this message
Olivier Tilloy (osomon) wrote :

30 + objectName: "OKButton"

That’s a very generic name, probably too generic. If in the future the app gets more popups, there will probably be several "OK buttons".

Revision history for this message
Olivier Tilloy (osomon) wrote :

84 +from time import sleep

This import is unused, can you please remove it?

Revision history for this message
Olivier Tilloy (osomon) wrote :

79 +import math

Same for this import, it seems it is unused.

Revision history for this message
Olivier Tilloy (osomon) wrote :

148 + self.pointing_device.drag(x_Hscroller+(width_Hscroller/4),
149 + (y_Hscroller+((height_Hscroller/4)*3)),
150 + x_Hscroller+(width_Hscroller/4),
151 + (y_Hscroller+((height_Hscroller/4)*2)))

You should ensure you always pass integers as parameters to .drag(…), so you need to surround each parameter with int(…).

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

182 + #---> TODO input end time

So this MR is not complete yet, is it? If not complete, please set its status to "Work in progress", and set it back to "Needs review" once it is actually ready. Thanks!

Revision history for this message
Carla Sella (carla-sella) wrote :

The test is complete for now even if it can be improved, but for the moment we want to run it as it is.

Revision history for this message
Carla Sella (carla-sella) :
review: Needs Resubmitting
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

A minor nitpick; I would add eventually to these lines:

self.assertThat(title_label, NotEquals(None))

and

self.assertThat(save_button, NotEquals(None))

Revision history for this message
Carla Sella (carla-sella) wrote :

If I add eventually to the two lines you suggested, I get this error: TypeError: Eventually is only usable with attributes that have a wait_for function or callable objects.

Revision history for this message
Olivier Tilloy (osomon) wrote :

172 + save_button = self.main_window.get_event_save_button()
173 + self.assertThat(lambda: save_button, Eventually(NotEquals(None)))

179 + title_label = self.main_window.get_title_label(eventTitle)
180 + self.assertThat(lambda: title_label, Eventually(NotEquals(None)))

This is not doing what you think it does: because 'save_button' and 'title_label' are assigned before defining the lambda function, they contain static values, so the lambda is useless. For it to be useful, you need to use it like that:

    lambda: self.main_window.get_event_save_button()
    lambda: self.main_window.get_title_label(eventTitle)

And since you’re comparing to None, instead of using Equals (or NotEquals), you should use the identity matcher, Is, like that:

    self.assertThat(…, Eventually(Not(Is(None))))

review: Needs Fixing
Revision history for this message
Carla Sella (carla-sella) wrote :

Thanks Olivier, I fixed the two asserts, hope they are ok now.

review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote :

42 - def get_month_view(self):
43 - return self.app.select_single("MonthView")

Removing this breaks all the other existing tests. Please revert this change.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

92 - @unittest.skip("Adding a new event is broken, needs fixing. "
93 - "See http://pad.lv/1206048.")

Now that you removed this decorator, the "import unittest" line should be removed from tests/autopilot/calendar_app/tests/test_calendar.py.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

pyflakes reports 4 warnings, all of them easily fixable by just removing unused code:

tests/autopilot/calendar_app/tests/test_calendar.py:17: 'unittest' imported but unused
tests/autopilot/calendar_app/tests/test_calendar.py:47: local variable 'end_time_field' is assigned to but never used
tests/autopilot/calendar_app/tests/test_calendar.py:82: local variable 'minutesBeforeChange' is assigned to but never used
tests/autopilot/calendar_app/tests/test_calendar.py:120: local variable 'title_label' is assigned to but never used

Revision history for this message
Carla Sella (carla-sella) wrote :

Hope everything's fine now :p.
Thanks Olilvier.

review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote :

> 42 - def get_month_view(self):
> 43 - return self.app.select_single("MonthView")
>
> Removing this breaks all the other existing tests. Please revert this change.

This one still needs to be fixed, all the other autopilot tests are currently failing because of this removal.

Revision history for this message
Carla Sella (carla-sella) :
review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good, thanks Carla!

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
Olivier Tilloy (osomon) wrote :

Apparently the builder is now considering pep8 warnings as errors…
I’ll fix all the warnings in trunk in a separate branch and we’ll get it merged first, so that you have to address only those that are related to your changes in this branch.

Revision history for this message
Olivier Tilloy (osomon) wrote :

> Apparently the builder is now considering pep8 warnings as errors…
> I’ll fix all the warnings in trunk in a separate branch and we’ll get it
> merged first, so that you have to address only those that are related to your
> changes in this branch.

In fact it appears all the pep8 warnings were introduced by your changes, the trunk is "clean".
To get a list of all the warnings, simply install 'pep8' on your machine, and from within your branch, run `pep8 tests`.
This will print out a list of warnings, usually self-explanatory on how to fix them.

Revision history for this message
Carla Sella (carla-sella) :
review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote :

I’m still getting 20 pep8 warnings:

$ pep8 tests
tests/autopilot/calendar_app/tests/test_calendar.py:78:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:78:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:79:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:79:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:79:73: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:80:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:80:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:81:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:81:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:81:73: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:94:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:94:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:95:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:95:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:95:73: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:96:50: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:96:67: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:97:51: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:97:70: E225 missing whitespace around operator
tests/autopilot/calendar_app/tests/test_calendar.py:97:73: E225 missing whitespace around operator

If you add whitespaces around the "+" operator, this should fix it.

Revision history for this message
Carla Sella (carla-sella) :
review: Needs Resubmitting
Revision history for this message
Olivier Tilloy (osomon) wrote :

Yes, looks like all the warnings are fixed now! Thanks for your patience Carla :)

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)
88. By Carla Sella

Calendar app autopilot new event test.

Approved by Ubuntu Phone Apps Jenkins Bot, Olivier Tilloy.

89. By Carla Sella

Added asserts for error on location field in new event test.

90. By Carla Sella

Added a couple of minor fixes.

91. By Carla Sella

Work in progress for fixing new event test.

92. By Carla Sella

Fixed code on animation fields, except the time picker.

Unmerged revisions

92. By Carla Sella

Fixed code on animation fields, except the time picker.

91. By Carla Sella

Work in progress for fixing new event test.

90. By Carla Sella

Added a couple of minor fixes.

89. By Carla Sella

Added asserts for error on location field in new event test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'TimePicker.qml'
2--- TimePicker.qml 2013-07-11 13:26:41 +0000
3+++ TimePicker.qml 2013-08-15 12:37:20 +0000
4@@ -40,18 +40,21 @@
5 height: units.gu(24)
6 Scroller {
7 id: hourScroller
8+ objectName: "hourScroller"
9 anchors {
10 top: parent.top
11 bottom: parent.bottom
12 }
13 width: parent.width / 2
14 labelText: i18n.tr("Hour")
15+
16 min: 00
17 max: 23
18 currentIndex: priv.now.getHours()
19 }
20 Scroller {
21 id: minuteScroller
22+ objectName: "minuteScroller"
23 anchors {
24 top: parent.top
25 bottom: parent.bottom
26@@ -75,6 +78,7 @@
27 width: (parent.width - parent.spacing) / 2
28 }
29 Button {
30+ objectName: "TimePickerOKButton"
31 text: i18n.tr("OK")
32 color: "#dd4814"
33
34
35=== modified file 'tests/autopilot/calendar_app/emulators/main_window.py'
36--- tests/autopilot/calendar_app/emulators/main_window.py 2013-07-19 14:15:17 +0000
37+++ tests/autopilot/calendar_app/emulators/main_window.py 2013-08-15 12:37:20 +0000
38@@ -19,5 +19,35 @@
39 def get_event_view(self):
40 return self.app.select_single("EventView")
41
42+ def get_new_event(self):
43+ return self.app.select_single("NewEvent")
44+
45+ def get_new_event_name_input_box(self):
46+ return self.app.select_single("TextField", objectName="newEventName")
47+
48+ def get_event_start_time_field(self):
49+ return self.app.select_single("Button", objectName="startTimeInput")
50+
51+ def get_event_end_time_field(self):
52+ return self.app.select_single("Button", objectName="endTimeInput")
53+
54+ def get_event_location_field(self):
55+ return self.app.select_single(
56+ "TextField", objectName="eventLocationInput")
57+
58+ def get_event_people_field(self):
59+ return self.app.select_single(
60+ "TextField", objectName="eventPeopleInput")
61+
62 def get_month_view(self):
63 return self.app.select_single("MonthView")
64+
65+ def get_time_picker_ok_button(self):
66+ return self.app.select_single(
67+ "Button", objectName="TimePickerOKButton")
68+
69+ def get_event_save_button(self):
70+ return self.app.select_single("Button", objectName="eventSaveButton")
71+
72+ def get_title_label(self, title):
73+ return self.app.select_many("Label", text=title)
74
75=== modified file 'tests/autopilot/calendar_app/tests/test_calendar.py'
76--- tests/autopilot/calendar_app/tests/test_calendar.py 2013-08-05 08:37:43 +0000
77+++ tests/autopilot/calendar_app/tests/test_calendar.py 2013-08-15 12:37:20 +0000
78@@ -14,7 +14,6 @@
79 from testtools.matchers import Equals, NotEquals
80
81 import time
82-import unittest
83
84 from calendar_app.tests import CalendarTestCase
85
86@@ -22,6 +21,8 @@
87 class TestMainWindow(CalendarTestCase):
88
89 def test_timeline_view_shows(self):
90+ """test timeline view"""
91+
92 event_view = self.main_window.get_event_view()
93
94 self.assertThat(
95@@ -33,9 +34,9 @@
96 self.assertThat(
97 event_view.eventViewType, Eventually(Equals("DiaryView.qml")))
98
99- @unittest.skip("Adding a new event is broken, needs fixing. "
100- "See http://pad.lv/1206048.")
101 def test_new_event(self):
102+ """test add new event """
103+
104 #click on new event button
105 self.ubuntusdk.click_toolbar_button('New Event')
106
107@@ -43,12 +44,13 @@
108 #event_view = self.main_window.get_event_view()
109 event_name_field = self.main_window.get_new_event_name_input_box()
110 start_time_field = self.main_window.get_event_start_time_field()
111- end_time_field = self.main_window.get_event_end_time_field()
112 location_field = self.main_window.get_event_location_field()
113 people_field = self.main_window.get_event_people_field()
114 save_button = self.main_window.get_event_save_button()
115
116 #input a new event name
117+ self.assertThat(
118+ self.main_window.get_new_event().visible, Eventually(Equals(True)))
119 eventTitle = "Test event" + str(time.time())
120
121 self.pointing_device.click_object(event_name_field)
122@@ -56,16 +58,56 @@
123 self.assertThat(event_name_field.text, Eventually(Equals(eventTitle)))
124
125 #input start time
126+ self.assertThat(
127+ lambda: self.main_window.get_event_start_time_field(),
128+ Eventually(NotEquals(None)))
129 self.pointing_device.click_object(start_time_field)
130- self.keyboard.press_and_release("Ctrl+a")
131- self.keyboard.type("11")
132- self.assertThat(start_time_field.text, Eventually(Equals("11")))
133-
134- #input end time
135- self.pointing_device.click_object(end_time_field)
136- self.keyboard.press_and_release("Ctrl+a")
137- self.keyboard.type("00")
138- self.assertThat(end_time_field.text, Eventually(Equals("00")))
139+
140+ #change hour
141+ timePicker = self.app.select_single("TimePicker")
142+ self.assertThat(timePicker.visible, Eventually(Equals(True)))
143+
144+ hourScroller = self.ubuntusdk.get_object("Scroller", "hourScroller")
145+ self.assertThat(hourScroller.visible, Eventually(Equals(True)))
146+
147+ y_Hscroller = hourScroller.globalRect[1]
148+ height_Hscroller = hourScroller.globalRect[3]
149+ x_Hscroller = hourScroller.globalRect[0]
150+ width_Hscroller = hourScroller.globalRect[2]
151+
152+ self.pointing_device.drag(
153+ int(x_Hscroller + (width_Hscroller / 4)),
154+ int((y_Hscroller + ((height_Hscroller / 4) * 3))),
155+ int(x_Hscroller + (width_Hscroller / 4)),
156+ int((y_Hscroller + ((height_Hscroller / 4) * 2))))
157+
158+ #change minutes
159+ minuteScroller = self.ubuntusdk.get_object(
160+ "Scroller", "minuteScroller")
161+ self.assertThat(
162+ minuteScroller.visible, Eventually(Equals(True)))
163+
164+ y_Mscroller = minuteScroller.globalRect[1]
165+ height_Mscroller = minuteScroller.globalRect[3]
166+ x_Mscroller = minuteScroller.globalRect[0]
167+ width_Mscroller = minuteScroller.globalRect[2]
168+
169+ self.pointing_device.drag(
170+ int(x_Mscroller + (width_Mscroller / 4)),
171+ int((y_Mscroller + ((height_Mscroller / 4) * 3))),
172+ int(x_Mscroller + (width_Mscroller / 4)),
173+ int((y_Mscroller + ((height_Mscroller / 4) * 2))))
174+
175+ #click ok button
176+ timepicker_ok_button = self.main_window.get_time_picker_ok_button()
177+ self.assertThat(
178+ lambda: self.main_window.get_time_picker_ok_button(),
179+ Eventually(NotEquals(None)))
180+ self.pointing_device.click_object(timepicker_ok_button)
181+
182+ self.assertThat(
183+ lambda: self.main_window.get_new_event().visible,
184+ Eventually(Equals(True)))
185
186 #input location
187 self.pointing_device.click_object(location_field)
188@@ -77,9 +119,14 @@
189 self.keyboard.type("Me")
190 self.assertThat(people_field.text, Eventually(Equals("Me")))
191
192- #click save button
193+ #click save button
194+ save_button = self.main_window.get_event_save_button()
195+ self.assertThat(
196+ lambda: self.main_window.get_event_save_button(),
197+ Eventually(NotEquals(None)))
198 self.pointing_device.click_object(save_button)
199
200 #verify that the event has been created in timeline
201- title_label = lambda: self.main_window.get_title_label(eventTitle)
202- self.assertThat(title_label, Eventually(NotEquals(None)))
203+ self.assertThat(
204+ lambda: self.main_window.get_title_label(eventTitle),
205+ Eventually(NotEquals(None)))

Subscribers

People subscribed via source and target branches

to status/vote changes: