Merge lp:~nik90/ubuntu-clock-app/fix-alarm-tests into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 358
Merged at revision: 346
Proposed branch: lp:~nik90/ubuntu-clock-app/fix-alarm-tests
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 1029 lines (+307/-463)
9 files modified
alarm/AddAlarmPage.qml (+11/-3)
alarm/AlarmDays.qml (+2/-0)
alarm/AlarmPage.qml (+5/-4)
tests/autopilot/ubuntu_clock_app/emulators.py (+188/-161)
tests/autopilot/ubuntu_clock_app/tests/__init__.py (+1/-1)
tests/autopilot/ubuntu_clock_app/tests/test_alarm.py (+82/-265)
tests/autopilot/ubuntu_clock_app/tests/test_clock.py (+8/-8)
tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py (+2/-2)
tests/autopilot/ubuntu_clock_app/tests/test_timer.py (+8/-19)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/fix-alarm-tests
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Leo Arias (community) code review Approve
Nicholas Skaggs autopilot code review Pending
Review via email: mp+205154@code.launchpad.net

Commit message

Fixes the alarm tests.

Description of the change

This MP revamps the entire alarms AP tests by ensuring that,
- All alarm emulator and test function have a proper docstring explaining what each function does.
- Added autopilot logging to the public emulator functions exposed to the alarm tests.
- Removed unnecessary import statements
- Cleaned up tests to only contain high-level statements and moved all the smaller tasks into the emulator functions.
- Added reference to bug reports where needed to make it clear why certain temporary code has been added.

BLOCKED: Do note that the tests currently fail in the jenkins machine since the TextField UITK emulator used in this MP has not yet landed in the 14.04 archive. Please ensure that this is fixed before merging MP to trunk.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

25 + containerHeight: itemHeight * 7 // Temporary fix for autopilot

Please, file a bug where you explain the problem, and put a link to it next to the comment in the code.

Remember updating the copyright. You are missing it here:
tests/autopilot/ubuntu_clock_app/emulators.py

209 + tx = x + (w / 2)
210 + ty = y + (h / 2.5)
211 + self.pointing_device.drag(tx, ty - (h / 4), tx - (w / 2), ty + (h / 2))
217 + tx = x + (w / 2)
218 + ty = y + (h / 2.5)
219 + self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))

I've seen some code by barry where he changes the / to //. // returns the floor division, so it sounds safer to use when we need ints, like in this case. And with it, we will get the same behaviour on python 2 and 3.
http://www.python.org/dev/peps/pep-0238/

266 + days_object = day_option_selector.select_single("StyledItem",
267 + objectName="listContainer")
266 + days_object = day_option_selector.select_single("StyledItem",
267 + objectName="listContainer")
296 + day_array.append(self.wait_select_single('CheckBox',
297 + objectName='repeatDaysSwitch' + repr(i)))
314 + done_button = self.wait_select_single('Button',
315 + objectName='confirmRepeatDaysButton')
367 + alarm = self.wait_select_single('CheckBox',
368 + objectName='listAlarmStatus{}'.format(index))

This is not properly aligned, and pep8 will complain.
I prefer:
days_object = day_option_selector.select_single(
    "StyledItem", objectName="listContainer")

But it's totally valid to break after the first argument and some people prefer it. You just have to make sure all arguments start on the same column.

278 + day_index = i

You can add a break after you found the element, so you stop the loop and don't do more unnecessary checks.
I find the for loops prettier, but that's a matter of preference:

for index, day_element in enumerate(daylist):
    if(day_element.text == day):
        day_index = index
        break

292 + day_array = []

Why do you need this date array?

for index in range(7):
    day_element = self.wait_select_single(
        toolkit_emulators.CheckBox, objectName='repeatDaysSwitch{}'.format(index))
        if index % 2 == 0:
            day_element.check()
        else:
            day_element.uncheck()

That looks a little cleaner for me ^

779 + """ Test to add a single type alarm and check if it is properly
780 + added to the alarm list.
781 + """

When the comments are of more than one line, please split them into a one line summary, and then add extra information on following paragraphs. That's from http://www.python.org/dev/peps/pep-0257/
In this case, I'd just remove the comment because you have given the test a perfect name that explains it all.

I like this very much. You have hidden all the low level details behind the public methods add_alarm, delete_alarm and toggle_alarm, and you named them using the user language. I couldn't have asked for more.

Well, I always can ask for more because I'm a PITA. Please add the logging decorator to those three public methods, so the autopilot logs show a trace of what we were doing.

Thank you!

Revision history for this message
Leo Arias (elopio) :
review: Needs Fixing (code review)
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
Nekhelesh Ramananthan (nik90) wrote :
Download full text (3.3 KiB)

> Remember updating the copyright. You are missing it here:
> tests/autopilot/ubuntu_clock_app/emulators.py
>

fixed in rev 343

> 209 + tx = x + (w / 2)
> 210 + ty = y + (h / 2.5)
> 211 + self.pointing_device.drag(tx, ty - (h / 4), tx - (w / 2), ty + (h /
> 2))
> 217 + tx = x + (w / 2)
> 218 + ty = y + (h / 2.5)
> 219 + self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h /
> 2))
>
> I've seen some code by barry where he changes the / to //. // returns the
> floor division, so it sounds safer to use when we need ints, like in this
> case. And with it, we will get the same behaviour on python 2 and 3.
> http://www.python.org/dev/peps/pep-0238/

Fixed in rev 345

>
> 266 + days_object = day_option_selector.select_single("StyledItem",
> 267 + objectName="listContainer")
> 266 + days_object = day_option_selector.select_single("StyledItem",
> 267 + objectName="listContainer")
> 296 + day_array.append(self.wait_select_single('CheckBox',
> 297 + objectName='repeatDaysSwitch' + repr(i)))
> 314 + done_button = self.wait_select_single('Button',
> 315 + objectName='confirmRepeatDaysButton')
> 367 + alarm = self.wait_select_single('CheckBox',
> 368 + objectName='listAlarmStatus{}'.format(index))
>
> This is not properly aligned, and pep8 will complain.
> I prefer:
> days_object = day_option_selector.select_single(
> "StyledItem", objectName="listContainer")
>
> But it's totally valid to break after the first argument and some people
> prefer it. You just have to make sure all arguments start on the same column.

Fixed in rev 346

>
> 278 + day_index = i
>
> You can add a break after you found the element, so you stop the loop and
> don't do more unnecessary checks.
> I find the for loops prettier, but that's a matter of preference:
>
> for index, day_element in enumerate(daylist):
> if(day_element.text == day):
> day_index = index
> break
>
> 292 + day_array = []
>
> Why do you need this date array?
>
> for index in range(7):
> day_element = self.wait_select_single(
> toolkit_emulators.CheckBox,
> objectName='repeatDaysSwitch{}'.format(index))
> if index % 2 == 0:
> day_element.check()
> else:
> day_element.uncheck()
>
> That looks a little cleaner for me ^
>

Fixed in rev 347

> 779 + """ Test to add a single type alarm and check if it is properly
> 780 + added to the alarm list.
> 781 + """
>
> When the comments are of more than one line, please split them into a one line
> summary, and then add extra information on following paragraphs. That's from
> http://www.python.org/dev/peps/pep-0257/
> In this case, I'd just remove the comment because you have given the test a
> perfect name that explains it all.

Fixed in rev 349. I removed the comments since the test name is good enough.

> I like this very much. You have hidden all the low level details behind the
> public methods add_alarm, delete_alarm and toggle_alarm, and you named them
> using the user language. I couldn't have asked for more.
>
> Well, I always can ask for more because I'm a PITA. Please add the logg...

Read more...

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

elopio> nik90: oh, and I forgot one more thing. Try to be consistent on your use of 'strings' vrs "strings". I prefer the single quote.

Fixed in rev 344

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
Nicholas Skaggs (nskaggs) wrote :

I've not yet run it on the phone, some thoughts;

Can you explain what this temp fix is, etc? bug number?
containerHeight: itemHeight * 7 // Temporary fix for autopilot

I like the changes to page up and page down with _wait_to_stop_moving.

Yay for using _ to start function names of utility functions :-)

Probably should try and be consistent on all of your docstrings, add them for all the emulator functions.

Your ' and " are still inconsistent, since elopio mentioned it :-) My preference is probably different than his; strings are ", literal strings are '.

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
Nekhelesh Ramananthan (nik90) wrote :

Thanks for your review Nicholas. I am happy that you like the changes to the emulator functions in terms of naming and other subtle changes.

>
> Can you explain what this temp fix is, etc? bug number?
> containerHeight: itemHeight * 7 // Temporary fix for autopilot
>

Fixed in rev 351. I have added a detailed comment there explaining why that fix is needed for the AP tests.

>
> Probably should try and be consistent on all of your docstrings, add them for
> all the emulator functions.
>

In this MP I want to only modify/improve the alarm tests. I do not want to change other parts of the tests. As a result, looking at the test_alarm.py and the alarm emulator functions, all of them have a docstring explaining what they. I added better docstrings for the alarm tests in rev 352.

> Your ' and " are still inconsistent, since elopio mentioned it :-) My
> preference is probably different than his; strings are ", literal strings are
> '.

As far as the alarms AP is concerned, I have made all of the consistently to using single quotes. There are inconsistencies in stopwatch, timer and clock tests. But I rather address in another MP than this one.

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
Nicholas Skaggs (nskaggs) wrote :

Yes, I agree not to inflate the merge with lots of changes in other places. This is looking REALLY good :-)

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 :
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
Leo Arias (elopio) wrote :

Thanks for all your work on this.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'alarm/AddAlarmPage.qml'
2--- alarm/AddAlarmPage.qml 2014-02-10 13:55:59 +0000
3+++ alarm/AddAlarmPage.qml 2014-02-19 00:55:51 +0000
4@@ -310,6 +310,7 @@
5
6 Label {
7 id: hourLabel
8+ objectName: "hourLabel"
9 color: "LightGreen"
10 font.pixelSize: units.dp(55)
11 anchors.verticalCenter: parent.verticalCenter
12@@ -336,6 +337,7 @@
13
14 Label {
15 id: minuteLabel
16+ objectName: "minuteLabel"
17 font.pixelSize: units.dp(41)
18 anchors.verticalCenter: parent.verticalCenter
19 onTextChanged: if(addAlarmFace.state == "minuteMode") updateHoursOnMinuteRotation()
20@@ -489,7 +491,13 @@
21 objectName: "OccursSelector"
22 text: i18n.tr("Occurs")
23 visible: repeatSwitch.checked == false // Show the day selector only when the alarm is a one-type alarm
24- containerHeight: itemHeight * 4
25+
26+ // TODO: To avoid a long option selector list, it would be best to only show 4 days at a time and encourage
27+ // scrolling the option selector to choose other days. However this is blocked by http://pad.lv/1277059 since
28+ // showing only 4 days will inhibit the alarm autopilot tests since they use a custom emulator function.
29+ // -- nik90 2014-02-10
30+ containerHeight: itemHeight * 7
31+
32 model: [Qt.locale().standaloneDayName(0), Qt.locale().standaloneDayName(1), Qt.locale().standaloneDayName(2), Qt.locale().standaloneDayName(3), Qt.locale().standaloneDayName(4), Qt.locale().standaloneDayName(5), Qt.locale().standaloneDayName(6)]
33
34 selectedIndex: alarm.date.getDay();
35@@ -523,9 +531,9 @@
36
37 ListItem.MultiValue {
38 id: multipleOccurSelector
39- anchors { left: parent.left; right: parent.right; margins: -units.gu(2) }
40- text: i18n.tr("Occurrence")
41 objectName: "OccurrenceList"
42+ anchors { left: parent.left; right: parent.right; margins: -units.gu(2) }
43+ text: i18n.tr("Occurrence")
44 values: getValues()
45 visible: repeatSwitch.checked == true
46 onClicked: PopupUtils.open(Qt.resolvedUrl("AlarmDays.qml"), multipleOccurSelector, {"alarm": alarm});
47
48=== modified file 'alarm/AlarmDays.qml'
49--- alarm/AlarmDays.qml 2014-02-01 15:30:26 +0000
50+++ alarm/AlarmDays.qml 2014-02-19 00:55:51 +0000
51@@ -73,6 +73,7 @@
52 }
53
54 control: Switch {
55+ objectName: "repeatDaysSwitch" + index
56 checked: (alarm.daysOfWeek & flag) == flag
57 onCheckedChanged: {
58 if (checked)
59@@ -87,6 +88,7 @@
60
61 Button {
62 text: "Done"
63+ objectName: "confirmRepeatDaysButton"
64 onClicked: PopupUtils.close(root);
65 }
66 }
67
68=== modified file 'alarm/AlarmPage.qml'
69--- alarm/AlarmPage.qml 2014-02-11 15:45:26 +0000
70+++ alarm/AlarmPage.qml 2014-02-19 00:55:51 +0000
71@@ -202,9 +202,10 @@
72 currentIndex: -1
73
74 delegate: ListItem.Base {
75+ objectName: "alarm" + index
76 Label {
77 id: alarmTime
78- objectName: "listAlarmTime"
79+ objectName: "listAlarmTime" + index
80 fontSize: "large";
81 text: Utils.convertTime(date.getHours(), date.getMinutes(), 0, appSetting.contents.timeFormat)
82 anchors { verticalCenter: parent.verticalCenter; right: alarmStatus.left; rightMargin: units.gu(2) }
83@@ -213,7 +214,7 @@
84
85 Label {
86 id: alarmLabel
87- objectName: "listAlarmLabel"
88+ objectName: "listAlarmLabel" + index
89 fontSize: "large";
90 text: message
91 elide: Text.ElideRight
92@@ -230,7 +231,7 @@
93
94 Label {
95 id: alarmSubtitle
96- objectName: "listAlarmSubtitle"
97+ objectName: "listAlarmSubtitle" + index
98 fontSize: "small";
99 text: format_day_string(daysOfWeek, type)
100 anchors { left: alarmLabel.left; top: alarmLabel.bottom }
101@@ -239,7 +240,7 @@
102
103 Switch {
104 id: alarmStatus
105- objectName: "listAlarmStatus"
106+ objectName: "listAlarmStatus" + index
107 checked: model.enabled
108 anchors { right: parent.right; verticalCenter: alarmTime.verticalCenter }
109 onClicked: {
110
111=== modified file 'tests/autopilot/ubuntu_clock_app/emulators.py'
112--- tests/autopilot/ubuntu_clock_app/emulators.py 2014-02-05 15:18:08 +0000
113+++ tests/autopilot/ubuntu_clock_app/emulators.py 2014-02-19 00:55:51 +0000
114@@ -1,6 +1,6 @@
115 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
116 #
117-# Copyright (C) 2013 Canonical Ltd.
118+# Copyright (C) 2013, 2014 Canonical Ltd.
119 #
120 # This program is free software; you can redistribute it and/or modify
121 # it under the terms of the GNU Lesser General Public License as published by
122@@ -17,21 +17,26 @@
123 # Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
124 # Nicholas Skaggs <nicholas.skaggs@canonical.com>
125
126+import logging
127+from time import sleep
128+
129+from autopilot import logging as autopilot_logging
130 from ubuntuuitoolkit import emulators as toolkit_emulators
131-from autopilot.matchers import Eventually
132-from testtools.matchers import Not, Is, Equals
133-from time import sleep
134+
135+logger = logging.getLogger(__name__)
136+
137+
138+class ClockEmulatorException(toolkit_emulators.ToolkitEmulatorException):
139+ """Exception raised when there is an error with the emulator."""
140+
141
142 class MainView(toolkit_emulators.MainView):
143
144 # Common Emulator Functions
145- def _drag_page(self, page, test_case, direction):
146+ def _drag_page(self, page, direction):
147 """Function to drag the page up/down"""
148 page = self.wait_select_single(page)
149- animating = lambda: page.select_single("QQuickFlickable").moving
150-
151- #make sure we're not already moving :-)
152- test_case.assertThat(animating, Eventually(Equals(False)))
153+ self._wait_to_stop_moving(page)
154
155 x, y, w, h = page.globalRect
156 tx = x + (w / 2)
157@@ -42,15 +47,15 @@
158 else:
159 self.pointing_device.drag(tx, ty, tx, ty - h / 3)
160
161- test_case.assertThat(animating, Eventually(Equals(False)))
162+ self._wait_to_stop_moving(page)
163
164- def drag_page_up(self, page, test_case):
165+ def drag_page_up(self, page):
166 """Drag the given page up."""
167- self._drag_page(page, test_case, "up")
168+ self._drag_page(page, "up")
169
170- def drag_page_down(self, page, test_case):
171+ def drag_page_down(self, page):
172 """Drag the given page down."""
173- self._drag_page(page, test_case, "down")
174+ self._drag_page(page, "down")
175
176 def longpress_object(self, obj):
177 """Function to longpress an object"""
178@@ -59,6 +64,9 @@
179 sleep(2)
180 self.pointing_device.release()
181
182+ def _wait_to_stop_moving(self, page):
183+ page.select_single("QQuickFlickable").moving.wait_for(False)
184+
185 # CLOCK Page Emulator Functions
186 def get_clock_page(self):
187 """Return the page containing the main clock."""
188@@ -108,7 +116,7 @@
189
190 def get_timer_name_preset(self):
191 """Returns the TextField where insert the name of the preset"""
192- return self.wait_select_single("LabelDots", objectName="namePreset")
193+ return self.wait_select_single(LabelDots, objectName="namePreset")
194
195 def get_timer_minute_hand(self):
196 """Returns the hour hand of clock in timer tab"""
197@@ -167,156 +175,175 @@
198 # ALARM Page Emulator Functions
199 def get_addalarm_page(self):
200 """Returns the add alarm page object"""
201- return self.select_single("Page", objectName="addAlarmPage")
202+ return self.select_single('Page', objectName='addAlarmPage')
203
204 def get_alarm_page(self):
205 """Returns the alarm page object"""
206- return self.select_single("AlarmPage")
207-
208- def get_alarm_name_label(self):
209- """Returns the TextField where insert the name of the preset"""
210- return self.select_single("LabelDots", objectName="addAlarmName")
211-
212- def get_label_alarm(self):
213- """Return the label with the alarm"""
214- return self.select_single("Label", objectName="labelAlarmSetup")
215+ return self.select_single('AlarmPage')
216+
217+ @autopilot_logging.log_action(logger.info)
218+ def add_alarm(self, name, alarm_type, day):
219+ """Function to add an alarm"""
220+ self._click_add_alarm_button()
221+ self._set_alarm_time()
222+ self.drag_page_up('AddAlarmPage')
223+ self._set_alarm_name(name)
224+ self._click_alarm_hour_label()
225+ self._set_alarm_type(alarm_type)
226+ self.drag_page_up('AddAlarmPage')
227+ self._set_alarm_trigger_day(day, alarm_type)
228+ self._click_save_alarm_button()
229+
230+ def _click_add_alarm_button(self):
231+ """Internal function to click add alarm toolbar button"""
232+ toolbar = self.open_toolbar()
233+ toolbar.click_button('addAlarmButton')
234+
235+ def _set_alarm_name(self, name):
236+ """Internal funcion to set alarm name"""
237+ name_alarm = self.wait_select_single(
238+ LabelDots, objectName='addAlarmName')
239+ name_alarm.write(name)
240+
241+ def _set_alarm_time(self):
242+ """Internal function to set alarm time"""
243+ self._click_alarm_hour_label()
244+ hour = self._get_alarm_hour_hand()
245+
246+ x, y, w, h = hour.globalRect
247+ tx = x + (w // 2)
248+ ty = y + (h // 2.5)
249+ self.pointing_device.drag(
250+ tx, ty - (h // 4), tx - (w // 2), ty + (h // 2))
251+
252+ self._click_alarm_minute_label()
253+ minute = self._get_alarm_minute_hand()
254+
255+ x, y, w, h = minute.globalRect
256+ tx = x + (w // 2)
257+ ty = y + (h // 2.5)
258+ self.pointing_device.drag(
259+ tx, ty - (h // 4), tx + (w // 2), ty + (h // 2))
260+
261+ def _click_alarm_hour_label(self):
262+ """Internal function to click alarm hour label"""
263+ hour_label = self.wait_select_single(
264+ 'Label', objectName='hourLabel')
265+ self.pointing_device.click_object(hour_label)
266+
267+ def _click_alarm_minute_label(self):
268+ """Internal function to click alarm minute label"""
269+ minute_label = self.wait_select_single(
270+ 'Label', objectName='minuteLabel')
271+ self.pointing_device.click_object(minute_label)
272+
273+ def _get_alarm_hour_hand(self):
274+ """Returns the hour hand of clock in add alarm page"""
275+ return self.select_single("AddAlarmPage").wait_select_single(
276+ 'DialerHand', objectName='hourHand')
277+
278+ def _get_alarm_minute_hand(self):
279+ """Returns the minute hand of clock in add alarm page"""
280+ return self.select_single("AddAlarmPage").wait_select_single(
281+ 'DialerHand', objectName='minuteHand')
282+
283+ def _set_alarm_type(self, alarm_type):
284+ """Internal function to set the alarm type"""
285+ alarm_type_checkbox = self.wait_select_single(
286+ toolkit_emulators.CheckBox, objectName='RepeatSelector')
287+ if alarm_type == 'Single':
288+ alarm_type_checkbox.uncheck()
289+ else:
290+ alarm_type_checkbox.check()
291+
292+ def _set_alarm_trigger_day(self, day, alarm_type):
293+ """Internal function to set the day the alarm triggers on"""
294+ if alarm_type == 'Single':
295+ self._set_single_alarm_day(day)
296+ else:
297+ self._set_recurring_alarm_day()
298+
299+ def _set_single_alarm_day(self, day):
300+ """Internal function to set the alarm day of a single type alarm"""
301+ # TODO: we need a proper UITK emulator for optionSelector
302+ # http://pad.lv/1277059 --nik90 2014-02-06
303+ day_option_selector = self.select_single(
304+ 'OptionSelector', objectName='OccursSelector')
305+ days_object = day_option_selector.select_single(
306+ 'StyledItem', objectName='listContainer')
307+ dayslist = days_object.select_many('Label', visible=True)
308+
309+ # Click on days option selector to expand it
310+ self.pointing_device.click_object(dayslist[0])
311+
312+ for index, day_element in enumerate(dayslist):
313+ if(day_element.text == day):
314+ day_index = index
315+ break
316+ else:
317+ raise ClockEmulatorException('Unknown day: {}'.format(day))
318+
319+ self.drag_page_up('AddAlarmPage')
320+ self.pointing_device.click_object(dayslist[day_index])
321+
322+ def _set_recurring_alarm_day(self):
323+ """Internal function to set the alarm days of a recurring alarm"""
324+ self._open_recurring_alarm_dialog()
325+
326+ # Get all the day objects in the column and enable only those
327+ # days whose index is an even number and disable the others
328+ for index in range(7):
329+ day_element = self.wait_select_single(
330+ toolkit_emulators.CheckBox,
331+ objectName='repeatDaysSwitch{}'.format(index))
332+ if index % 2 == 0:
333+ day_element.check()
334+ else:
335+ day_element.uncheck()
336+
337+ self._click_confirm_recurring_alarm_days()
338+
339+ def _open_recurring_alarm_dialog(self):
340+ """Internal function to open the recurring alarm dialogue"""
341+ recurring_option = self.wait_select_single(
342+ toolkit_emulators.MultiValue, objectName='OccurrenceList')
343+ self.pointing_device.click_object(recurring_option)
344+
345+ def _click_confirm_recurring_alarm_days(self):
346+ """Internal function to click Done button in recurring alarms dialog"""
347+ done_button = self.wait_select_single(
348+ 'Button', objectName='confirmRepeatDaysButton')
349+ self.pointing_device.click_object(done_button)
350+
351+ def _click_save_alarm_button(self):
352+ """Click the save alarm button"""
353+ toolbar = self.open_toolbar()
354+ toolbar.click_button('saveAlarmButton')
355
356 def get_num_of_alarms(self):
357- """Returns the number of alarms in the alarm page."""
358- listview = self.select_single("QQuickListView",
359- objectName="listSavedAlarm")
360- #each alarm has 3 labels
361- return len(listview.select_many("Label", visible=True)) / 3
362-
363- #TODO: QQuickListView.count does not work as expected
364- #fix once this is working properly and use it
365-
366- #TODO: all of the get_first functions need to
367- #be refactored where possible to get X item, not
368- #just the first
369-
370- def get_first_alarm_list_item(self):
371- """Returns the first alarm list item in the alarm page."""
372- listview = self.select_single("QQuickListView",
373- objectName="listSavedAlarm")
374- return listview.select_many("Base")[0]
375-
376- def toggle_first_alarm(self, test_case):
377- """Toggles the alarm on and off in the alarm page."""
378- alarm = self.select_single("CheckBox",
379- objectName="listAlarmStatus")
380+ """Return the number of saved alarms"""
381+ return int(self.wait_select_single(
382+ toolkit_emulators.QQuickListView,
383+ objectName='listSavedAlarm').count)
384+
385+ @autopilot_logging.log_action(logger.info)
386+ def delete_alarm(self, index):
387+ """Deletes an alarm at the specified index"""
388+ alarm = self.wait_select_single(
389+ toolkit_emulators.Base, objectName='alarm{}'.format(index))
390+ self.drag_page_up('AlarmPage')
391+ alarm.swipe_to_delete()
392+ alarm.confirm_removal()
393+
394+ @autopilot_logging.log_action(logger.info)
395+ def toggle_alarm(self, index):
396+ """Toggles an alarm on/off"""
397+ alarm = self.wait_select_single(
398+ toolkit_emulators.CheckBox,
399+ objectName='listAlarmStatus{}'.format(index))
400+ self.drag_page_up('AlarmPage')
401 self.pointing_device.click_object(alarm)
402
403- test_case.assertThat(lambda: self.get_alarm_page().select_single(
404- "QQuickFlickable").moving,
405- Eventually(Equals(False)))
406-
407- def get_first_alarm_time(self):
408- """Gets the first alarm time in the alarm page."""
409- alarm = self.get_first_alarm_list_item()
410- return alarm.select_single("Label",
411- objectName="listAlarmTime").text
412-
413- def get_first_alarm_subtitle(self):
414- """Gets the first alarm subtitle in the alarm page."""
415- alarm = self.get_first_alarm_list_item()
416- return alarm.select_single("Label",
417- objectName="listAlarmSubtitle").text
418-
419- def get_first_alarm_label(self):
420- """Gets the first alarm label in the alarm page."""
421- alarm = self.get_first_alarm_list_item()
422- return alarm.select_single("Label",
423- objectName="listAlarmLabel").text
424-
425- def get_first_alarm_status(self):
426- """Gets the first alarm checkbox status in the alarm page."""
427- alarm = self.get_first_alarm_list_item()
428- return alarm.select_single("CheckBox",
429- objectName="listAlarmStatus").checked
430-
431- def get_alarm_minute_hand(self):
432- """Returns the hour hand of clock in alarm tab"""
433- return self.select_single("AlarmPage").select_single("DialerHand",
434- objectName="minuteHand")
435-
436- def get_alarm_hour_hand(self):
437- """Returns the hour hand of clock in alarm tab"""
438- return self.select_single("AlarmPage").select_single("DialerHand",
439- objectName="hourHand")
440-
441- def set_alarm_week(self, day, test_case):
442- #TODO: add support for setting days of week
443- dayselectDialog = self.select_single("Dialog",
444- objectName="alarmDaysDialog")
445-
446- return dayselectDialog
447-
448- def _retry_selector_assert(self, clickobj, selector, status, test_case):
449- test_case.assertThat(lambda: self.get_alarm_page().select_single(
450- "QQuickFlickable").moving,
451- Eventually(Equals(False)))
452- timeout = 0
453- test_case.assertThat(lambda: selector.select_single(
454- "OptionSelectorDelegate", selected=True),
455- Eventually(Not(Is(None))))
456-
457- option = selector.select_single("OptionSelectorDelegate",
458- selected=True).state
459- while option != status and timeout < 10:
460- self.pointing_device.click_object(clickobj)
461- option = selector.select_single("OptionSelectorDelegate",
462- selected=True).state
463- sleep(1)
464- timeout += 1
465-
466- test_case.assertThat(lambda: self.get_alarm_page().select_single(
467- "QQuickFlickable").moving,
468- Eventually(Equals(False)))
469-
470- def set_alarm_day(self, day, test_case):
471- select = self.select_single("OptionSelector",
472- objectName="OccursSelector")
473- occur = select.select_single("StyledItem", objectName="listContainer")
474- #optionslist = occur.select_single("OptionSelectorDelegate",
475- # selected=True)
476- occurlist = occur.select_many("Label", visible=True)
477-
478- self.pointing_device.click_object(select)
479- self._retry_selector_assert(select, occur,
480- "dividerExpanded", test_case)
481-
482- self.drag_page_up("AlarmPage", test_case)
483- self.pointing_device.click_object(occurlist[day])
484- self._retry_selector_assert(select, occur,
485- "dividerCollapsed", test_case)
486-
487- #check index
488- #TODO: clock doesn't put things in in the proper order atm
489- #test_case.assertThat(lambda: self.select_single("OptionSelector",
490- # objectName="OccursSelector").selectedIndex+1,
491- # Eventually(Equals(day)))
492-
493- def set_alarm_frequency(self, occurence, test_case):
494- select = self.select_single("OptionSelector",
495- objectName="RepeatSelector")
496- repeat = select.select_single("StyledItem",
497- objectName="listContainer")
498- #optionslist = occur.select_single("OptionSelectorDelegate",
499- # selected=True)
500- repeatlist = repeat.select_many("Label", visible=True)
501-
502- self.pointing_device.click_object(repeat)
503- self._retry_selector_assert(select, repeat,
504- "dividerExpanded", test_case)
505-
506- self.drag_page_up("AlarmPage", test_case)
507- self.pointing_device.click_object(repeatlist[occurence])
508- self._retry_selector_assert(select, repeat,
509- "dividerCollapsed", test_case)
510-
511- #check index
512- test_case.assertThat(lambda: self.select_single(
513- "OptionSelector", objectName="RepeatSelector").selectedIndex+1,
514- Eventually(Equals(occurence)))
515-
516+
517+class LabelDots(toolkit_emulators.TextField):
518+ """Autopilot helper for the LabelDots component."""
519
520=== modified file 'tests/autopilot/ubuntu_clock_app/tests/__init__.py'
521--- tests/autopilot/ubuntu_clock_app/tests/__init__.py 2014-02-10 22:41:51 +0000
522+++ tests/autopilot/ubuntu_clock_app/tests/__init__.py 2014-02-19 00:55:51 +0000
523@@ -118,4 +118,4 @@
524
525 @property
526 def main_view(self):
527- return self.app.select_single(emulators.MainView)
528+ return self.app.wait_select_single(emulators.MainView)
529
530=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_alarm.py'
531--- tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2014-01-21 15:10:14 +0000
532+++ tests/autopilot/ubuntu_clock_app/tests/test_alarm.py 2014-02-19 00:55:51 +0000
533@@ -1,6 +1,6 @@
534 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
535 #
536-# Copyright (C) 2013 Canonical Ltd
537+# Copyright (C) 2013, 2014 Canonical Ltd
538 #
539 # This program is free software: you can redistribute it and/or modify
540 # it under the terms of the GNU General Public License version 3 as
541@@ -15,284 +15,101 @@
542 # along with this program. If not, see <http://www.gnu.org/licenses/>.
543 #
544 # Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com>
545+# Nekhelesh Ramananthan <krnekhelesh@gmail.com>
546
547 """Tests for the Clock App - Alarm"""
548
549 from __future__ import absolute_import
550
551-from testtools.matchers import Equals, NotEquals, Is, Not
552+import datetime
553+import unittest
554+
555 from autopilot.matchers import Eventually
556-import time
557-import datetime
558+from testtools.matchers import Equals, NotEquals
559 from ubuntu_clock_app.tests import ClockAppTestCase
560-import unittest
561
562
563 class TestAlarm(ClockAppTestCase):
564 """Tests the alarm page features"""
565
566- """ This is needed to wait for the application to start.
567- In the testfarm, the application may take some time to show up."""
568-
569- #TODO: alarms shares similarities with stopwatch
570- #the utility functions could be shared between them
571- #ie, the emulator functions
572 def setUp(self):
573+ """ This is needed to wait for the application to start.
574+
575+ In the testfarm, the application may take some time to show up.
576+
577+ """
578 super(TestAlarm, self).setUp()
579 self.assertThat(
580 self.main_view.visible, Eventually(Equals(True)))
581
582- #move to alarm tab
583- self.main_view.switch_to_tab("AlarmTab")
584-
585- def select_name_alarm_label(self):
586- label = self.main_view.get_alarm_name_label()
587- timeout = 0
588- while not label.focus and timeout < 10:
589- self.pointing_device.click_object(label)
590- time.sleep(1)
591- timeout += 1
592- return label
593-
594- @unittest.skip("Pending development, bug 1269064")
595- def test_longpress_new_alarm(self):
596- """Test longpress on alarm and back button"""
597- #TODO: needs this merge
598- #https://code.launchpad.net/~elopio/
599- #ubuntu-ui-toolkit/fix1239751_go_back/+merge/191002
600- #thus is disabled for now until landing
601-
602- self.assertThat(self.main_view.get_label_alarm,
603- Eventually(Not(Is(None))))
604- self.main_view.longpress_object(self.main_view.get_label_alarm())
605-
606- self.assertThat(self.main_view.get_addalarm_page,
607- Eventually(Not(Is(None))))
608-
609- toolbar = self.main_view.open_toolbar()
610-
611- # Click the add alarm button
612- toolbar.go_back()
613-
614- self.assertThat(self.main_view.get_alarm_page,
615- Eventually(Not(Is(None))))
616-
617- @unittest.skip("Pending development, bug 1269064")
618- def test_add_remove_alarm(self):
619- """Test to check if button to add and remove an alarm working"""
620-
621- #test once
622- #use tomorrow as day
623- day = datetime.datetime.today().weekday() + 1
624- if day > 7:
625- day = 0
626- self.add_alarm(day, 1)
627- self.delete_alarm()
628-
629- #test daily
630- self.add_alarm(4, 2)
631- self.delete_alarm()
632-
633- #test weekly
634- #self.add_alarm(1, 3)
635- #self.delete_alarm()
636-
637- def add_alarm(self, day, occurence):
638- #setTime = "16:20"
639-
640- # Show the toolbar
641- toolbar = self.main_view.open_toolbar()
642-
643- # Click the add alarm button
644- toolbar.click_button("addAlarmButton")
645-
646- self.assertThat(lambda: self.main_view.get_alarm_page().select_single(
647- "QQuickFlickable").moving,
648- Eventually(Equals(False)))
649-
650- #TODO: these should be broken out for reuse in timer as well
651- #as well as allowing for various times
652- # Set hour
653- self.assertThat(self.main_view.get_alarm_hour_hand,
654- Eventually(Not(Is(None))))
655- hour = self.main_view.get_alarm_hour_hand()
656-
657- x, y, w, h = hour.globalRect
658- tx = x + (w / 2)
659- ty = y + (h / 2)
660- self.pointing_device.drag(tx, ty - (h / 4), tx - (w / 2), ty + (h / 2))
661-
662- self.assertThat(lambda: self.main_view.get_alarm_page().select_single(
663- "QQuickFlickable").moving,
664- Eventually(Equals(False)))
665-
666- # Set minute
667- self.assertThat(self.main_view.get_alarm_minute_hand,
668- Eventually(Not(Is(None))))
669- minute = self.main_view.get_alarm_minute_hand()
670-
671- x, y, w, h = minute.globalRect
672- tx = x + (w / 2)
673- ty = y + (h / 2.5)
674- self.pointing_device.drag(tx, ty - (h / 4), tx + (w / 2), ty + (h / 2))
675-
676- self.assertThat(lambda: self.main_view.get_alarm_page().select_single(
677- "QQuickFlickable").moving,
678- Eventually(Equals(False)))
679-
680- #TODO: Choosing the same day hides the day
681- #https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1240629
682-
683- self.edit_alarm(day, occurence)
684-
685-
686- #TODO: fix time check.. time doesn't always set properly
687- #and will randomly fail the test
688- #self.assertThat(self.main_view.get_first_alarm_time,
689- # Eventually(Equals(setTime)))
690-
691- def edit_alarm(self, day, occurence):
692- setName = "test" + str(int(time.time()))
693- setStatus = True
694-
695- # Write in the label
696- self.main_view.drag_page_up("AlarmPage", self)
697- self.assertThat(self.main_view.get_alarm_name_label,
698- Eventually(Not(Is(None))))
699- label = self.select_name_alarm_label()
700- self.assertThat(label.focus, Eventually(Equals(True)))
701- self.keyboard.press('Ctrl+a')
702- self.assertThat(label.focus, Eventually(Equals(True)))
703-
704- #set unique alarm name
705- self.keyboard.type(setName)
706- self.assertThat(label.text, Eventually(Equals(setName)))
707-
708- #set alarm day and frequency
709- self.main_view.set_alarm_frequency(occurence, self)
710-
711- #depending on occurrence, we set the day differently
712- if occurence == 1:
713- #one time, use day passed in
714- self.main_view.set_alarm_day(day, self)
715- elif occurence == 2:
716- #daily, ignore day
717- pass
718- elif occurence == 3:
719- #weekly, pass day into dialog
720- #TODO: support weekly dialog
721- self.main_view.set_alarm_week(day, self)
722-
723- #grab current alarm number
724- self.assertThat(self.main_view.get_num_of_alarms,
725- Eventually(Not(Is(None))))
726- num_of_alarms_old = self.main_view.get_num_of_alarms()
727-
728- # Press "Save" toolbar button
729- toolbar = self.main_view.open_toolbar()
730- toolbar.click_button("saveAlarmButton")
731-
732- #assert alarm is added
733- self.assertThat(self.main_view.get_num_of_alarms,
734- Eventually(NotEquals(num_of_alarms_old)))
735-
736- #check label, time, subtitle, name
737- #TODO: decipher proper subtitles and check for them
738- #self.assertThat(self.main_view.get_first_alarm_subtitle,
739- # Eventually(Equals( ? )))
740-
741- self.assertThat(self.main_view.get_first_alarm_label,
742- Eventually(Not(Is(None))))
743-
744- self.assertThat(self.main_view.get_first_alarm_label,
745- Eventually(Equals(setName)))
746-
747- self.assertThat(self.main_view.get_first_alarm_status,
748- Eventually(Equals(setStatus)))
749-
750- def delete_alarm(self):
751- """Test if the swipe of a alarm deletes it"""
752- #TODO: fix this with https://code.launchpad.net/~renatofilho/
753- #ubuntu-ui-toolkit/fix-1236464/+merge/190496
754- #once it lands
755- self.assertThat(self.main_view.get_num_of_alarms,
756- Eventually(Not(Is(None))))
757- num_of_alarms_old = self.main_view.get_num_of_alarms()
758-
759- self.main_view.drag_page_up("AlarmPage", self)
760-
761- # Delete the alarm
762- self.assertThat(self.main_view.get_first_alarm_list_item,
763- Eventually(Not(Is(None))))
764- timeout = 0
765- while self.main_view.get_num_of_alarms() != num_of_alarms_old - 1 \
766- and timeout < 10:
767- first_alarm = self.main_view.get_first_alarm_list_item()
768- x, y, w, h = first_alarm.globalRect
769- tx = x + (w / 8)
770- ty = y + (h / 2)
771- self.pointing_device.drag(tx, ty, w - w / 8, ty)
772- time.sleep(1)
773- timeout += 1
774-
775- # Check has been deleted
776- self.assertThat(
777- self.main_view.get_num_of_alarms,
778- Eventually(Equals(num_of_alarms_old - 1)))
779-
780- @unittest.skip("Pending development, bug 1269064")
781- def test_toggle_and_edit_alarm(self):
782- """Tests if a alarm can be toggled on and off and edited"""
783-
784- # Create a new alarm
785- self.add_alarm(1, 2)
786-
787- self.main_view.drag_page_up("AlarmPage", self)
788-
789- # Click to select the alarm
790- self.assertThat(self.main_view.get_first_alarm_list_item,
791- Eventually(Not(Is(None))))
792- first_alarm = self.main_view.get_first_alarm_list_item()
793-
794- #grab current values
795- self.assertThat(self.main_view.get_first_alarm_label,
796- Eventually(Not(Is(None))))
797-
798- oldName = self.main_view.get_first_alarm_label()
799- oldStatus = self.main_view.get_first_alarm_status()
800-
801- # Perform edit
802- self.pointing_device.click_object(first_alarm)
803-
804- #TODO: objects aren't quite the same :-(
805- #self.edit_alarm(1, 1)
806- #just save it instead
807- toolbar = self.main_view.open_toolbar()
808- toolbar.click_button("saveAlarmButton")
809-
810- #verify everything is still good
811- self.assertThat(self.main_view.get_first_alarm_label,
812- Eventually(Not(Is(None))))
813-
814- self.assertThat(self.main_view.get_first_alarm_label,
815- Eventually(Equals(oldName)))
816-
817- self.assertThat(self.main_view.get_first_alarm_status,
818- Eventually(Equals(oldStatus)))
819-
820- # Click to switch off the alarm
821- self.assertThat(self.main_view.get_first_alarm_status,
822- Eventually(Equals(True)))
823-
824- self.main_view.toggle_first_alarm(self)
825-
826- self.assertThat(self.main_view.get_first_alarm_status,
827- Eventually(Equals(False)))
828-
829- # Click to switch on the alarm
830- self.main_view.toggle_first_alarm(self)
831-
832- self.assertThat(self.main_view.get_first_alarm_status,
833- Eventually(Equals(True)))
834-
835- self.delete_alarm()
836+ # move to alarm tab
837+ self.main_view.switch_to_tab('AlarmTab')
838+
839+ def test_add_single_type_alarm_must_add_to_alarm_list(self):
840+ """Test to check if a single type alarm is saved properly
841+
842+ This test saves a single type alarm and verifies if it is added to the
843+ alarm list in the alarm page.
844+
845+ """
846+ # The alarm day is always set to tomorrow to ensure that it is
847+ # not rejected by the clock app since the clock app does not
848+ # allow alarms to be created before the current time of the same
849+ # day. This limitation will be removed later.
850+ # -- nik90 2014-02-06
851+ now = datetime.datetime.now() + datetime.timedelta(days=1)
852+ tomorrow_day = now.strftime("%A")
853+ old_alarm_count = self.main_view.get_num_of_alarms()
854+ self.main_view.add_alarm('Single Test', 'Single', tomorrow_day)
855+
856+ # Check if the alarm count has increased
857+ self.assertThat(self.main_view.get_num_of_alarms,
858+ Eventually(NotEquals(old_alarm_count)))
859+
860+ #TODO: Check if the newly saved alarm has the properties set by
861+ # add_alarm method
862+
863+ def test_add_recurring_type_alarm_must_add_to_alarm_list(self):
864+ """ Test to check if a recurring alarm is saved properly
865+
866+ Recurring alarms are triggered on more than one day. This test saves a
867+ recurring alarm and check if it has been saved and is added to the
868+ alarm list in the alarm page.
869+
870+ """
871+ old_alarm_count = self.main_view.get_num_of_alarms()
872+ self.main_view.add_alarm('Recurring Test', 'Recurring', 'Null')
873+
874+ # Check if the alarm count has increased
875+ self.assertThat(self.main_view.get_num_of_alarms,
876+ Eventually(NotEquals(old_alarm_count)))
877+
878+ def test_delete_alarm_must_delete_from_alarm_list(self):
879+ """Test to delete an alarm and check if it has been properly removed"""
880+ # FIXME: Instead of always deleting the first alarm, run the alarm
881+ # which was created. To do this in a nice way, we should use the
882+ # QQuickListView but it has a bug that makes it fail in this case:
883+ # http://pad.lv/1275060 --elopio - 2014-01-31
884+
885+ # (set-up) Create a recurring alarm
886+ self.main_view.add_alarm('Recurring Test', 'Recurring', 'Null')
887+
888+ old_alarm_count = self.main_view.get_num_of_alarms()
889+ self.main_view.delete_alarm(index=0)
890+
891+ # Check that the alarm is deleted
892+ self.assertThat(self.main_view.get_num_of_alarms,
893+ Eventually(Equals(old_alarm_count - 1)))
894+
895+ @unittest.skip("Pending development, bug 1272337")
896+ def test_toggle_alarm_status_must_enable_or_disable_alarm(self):
897+ """Test to toggle an alarm and check it has been done properly"""
898+ # FIXME: This test is skipped due to an upstream bug in EDS which
899+ # causes the alarm status to not be properly toggled. This could
900+ # result in flaky test.
901+ # http://pad.lv/1272337 -- nik90 - 2014-02-07
902+
903+ # (set-up) Create a recurring alarm
904+ self.main_view.add_alarm('Recurring Test', 'Recurring', 'Null')
905+
906+ self.main_view.toggle_alarm(index=0)
907
908=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_clock.py'
909--- tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-02-05 15:28:52 +0000
910+++ tests/autopilot/ubuntu_clock_app/tests/test_clock.py 2014-02-19 00:55:51 +0000
911@@ -48,7 +48,7 @@
912 super(TestClock, self).tearDown()
913
914 def add_local_world_city(self):
915- # Open clock toolbar
916+ # Open clock toolbar
917 self.main_view.open_toolbar()
918
919 # Click add city toolbar button
920@@ -74,21 +74,21 @@
921 def test_add_local_world_city(self):
922 """Test to check if adding a local listed world city works"""
923
924- # Add a local world city
925+ # Add a local world city
926 city_name = self.add_local_world_city()
927-
928+
929 saved_city_name = self.main_view.get_city_name(self.main_view.grab_first_saved_city())
930- self.assertThat(saved_city_name, Eventually(Equals(city_name)))
931-
932+ self.assertThat(saved_city_name, Eventually(Equals(city_name)))
933+
934 def test_delete_local_world_city(self):
935 """Test to check if deleting a saved local world city works"""
936
937- # Add a local world city
938+ # Add a local world city
939 city_name = self.add_local_world_city()
940
941- # Close toolbar and drag page up to see the saved world city list
942+ # Close toolbar and drag page up to see the saved world city list
943 self.main_view.close_toolbar()
944- self.main_view.drag_page_up("ClockPage", self)
945+ self.main_view.drag_page_up("ClockPage")
946
947 # Get the saved world city and swipe to delete
948 old_saved_city_count = self.main_view.get_saved_cities_list().count
949
950=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py'
951--- tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2013-12-17 22:17:08 +0000
952+++ tests/autopilot/ubuntu_clock_app/tests/test_stopwatch.py 2014-02-19 00:55:51 +0000
953@@ -49,7 +49,7 @@
954 def start_stop_stopwatch(self):
955 """Function to start/stop the stopwatch"""
956 start_stop_button = self.main_view.get_stopwatch_button()
957- self.pointing_device.click_object(start_stop_button)
958+ self.pointing_device.click_object(start_stop_button)
959
960 def test_start_stop_reset_stopwatch(self):
961 """Test to check the proper functioning of the start/stop/reset of stopwatch"""
962@@ -105,7 +105,7 @@
963 self.create_lap()
964
965 num_of_laps_old = self.main_view.get_num_of_laps()
966- self.main_view.drag_page_up("StopwatchPage", self)
967+ self.main_view.drag_page_up("StopwatchPage")
968
969 # Delete stopwatch lap
970 first_lap = self.main_view.get_first_laps_list_item()
971
972=== modified file 'tests/autopilot/ubuntu_clock_app/tests/test_timer.py'
973--- tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2014-01-21 15:32:01 +0000
974+++ tests/autopilot/ubuntu_clock_app/tests/test_timer.py 2014-02-19 00:55:51 +0000
975@@ -44,17 +44,8 @@
976 # Move to Timer tab
977 self.main_view.switch_to_tab("TimerTab")
978
979- def select_name_preset_label(self):
980- label = self.main_view.get_timer_name_preset()
981- timeout = 0
982- while not label.focus and timeout < 10:
983- self.pointing_device.click_object(label)
984- sleep(1)
985- timeout += 1
986- return label
987-
988 def delete_first_preset(self):
989- self.main_view.drag_page_up("TimerPage", self)
990+ self.main_view.drag_page_up("TimerPage")
991
992 # Delete the preset
993 first_preset = self.main_view.get_first_preset_list_item()
994@@ -69,13 +60,11 @@
995 self.main_view.get_toolbar().click_button('addPresetButton')
996
997 # Set Timer label as "test"
998- self.main_view.drag_page_up("TimerPage", self)
999- label = self.select_name_preset_label()
1000- self.assertThat(label.focus, Eventually(Equals(True)))
1001- self.keyboard.type("test")
1002- self.assertThat(label.text, Eventually(Equals("test")))
1003-
1004- self.main_view.drag_page_down("TimerPage", self)
1005+ self.main_view.drag_page_up("TimerPage")
1006+ label = self.main_view.get_timer_name_preset()
1007+ label.write("AutopilotTimer")
1008+ self.assertThat(label.text, Eventually(Equals("AutopilotTimer")))
1009+ self.main_view.drag_page_down("TimerPage")
1010
1011 if setTime:
1012 # Set timer minute
1013@@ -124,14 +113,14 @@
1014 # Create a new preset
1015 self.add_preset()
1016
1017- self.main_view.drag_page_up("TimerPage", self)
1018+ self.main_view.drag_page_up("TimerPage")
1019
1020 # Click to select the preset
1021 # FIXME: Instead of always running the first preset, run the preset which was created
1022 first_preset = self.main_view.get_first_preset_list_item()
1023 self.pointing_device.click_object(first_preset)
1024
1025- self.main_view.drag_page_down("TimerPage", self)
1026+ self.main_view.drag_page_down("TimerPage")
1027
1028 # Click to start the preset
1029 label = self.main_view.get_label_timer()

Subscribers

People subscribed via source and target branches