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