Merge lp:~nskaggs/music-app/new-toolbar-autopilot into lp:music-app/trusty
- new-toolbar-autopilot
- Merge into trusty
Status: | Merged |
---|---|
Approved by: | Nicholas Skaggs |
Approved revision: | 172 |
Merged at revision: | 168 |
Proposed branch: | lp:~nskaggs/music-app/new-toolbar-autopilot |
Merge into: | lp:music-app/trusty |
Diff against target: |
286 lines (+77/-67) 3 files modified
tests/autopilot/music_app/emulators.py (+19/-25) tests/autopilot/music_app/tests/__init__.py (+30/-25) tests/autopilot/music_app/tests/test_music.py (+28/-17) |
To merge this branch: | bzr merge lp:~nskaggs/music-app/new-toolbar-autopilot |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Andrew Hayzen | Approve | ||
Review via email: mp+190201@code.launchpad.net |
Commit message
Increase robustness of music app autopilot tests; add waits for app to load, respect activity indicators, fix pep8 and pyflakes errors
Description of the change
Increase robustness of music app autopilot tests; add waits for app to load, respect activity indicators, fix pep8 and pyflakes errors
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:167
http://
Executed test runs:
UNSTABLE: http://
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: Continuous integration, rev:171
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 172. By Nicholas Skaggs
-
migrate to main_view and remove unneeded functions
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:172
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Andrew Hayzen (ahayzen) wrote : | # |
Looks good.
Passes autopilot locally and always good to see PEP8 conformity :)
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : | # |
Preview Diff
1 | === modified file 'tests/autopilot/music_app/emulators.py' |
2 | --- tests/autopilot/music_app/emulators.py 2013-10-07 12:30:00 +0000 |
3 | +++ tests/autopilot/music_app/emulators.py 2013-10-09 19:00:30 +0000 |
4 | @@ -8,6 +8,7 @@ |
5 | """Music app autopilot emulators.""" |
6 | from ubuntuuitoolkit import emulators as toolkit_emulators |
7 | from autopilot.input import Mouse |
8 | +from time import sleep |
9 | |
10 | |
11 | class MainView(toolkit_emulators.MainView): |
12 | @@ -17,28 +18,19 @@ |
13 | """ |
14 | retry_delay = 0.2 |
15 | |
16 | - def __init__(self, app): |
17 | - self.app = app |
18 | - |
19 | - def get_qml_view(self): |
20 | - """Get the main QML view""" |
21 | - return self.app.select_single("QQuickView") |
22 | - |
23 | - def get_main_view(self): |
24 | - return self.app.select_single("MainView", objectName = "music") |
25 | - |
26 | def get_toolbar(self): |
27 | - return self.app.select_single("MusicToolbar", objectName = "musicToolbarObject") |
28 | + return self.select_single("MusicToolbar", |
29 | + objectName="musicToolbarObject") |
30 | |
31 | def select_many_retry(self, object_type, **kwargs): |
32 | """Returns the item that is searched for with app.select_many |
33 | In case of no item was not found (not created yet) a second attempt is |
34 | taken 1 second later""" |
35 | - items = self.app.select_many(object_type, **kwargs) |
36 | + items = self.select_many(object_type, **kwargs) |
37 | tries = 10 |
38 | while len(items) < 1 and tries > 0: |
39 | - sleep(self.app.retry_delay) |
40 | - items = self.app.select_many(object_type, **kwargs) |
41 | + sleep(self.retry_delay) |
42 | + items = self.select_many(object_type, **kwargs) |
43 | tries = tries - 1 |
44 | return items |
45 | |
46 | @@ -46,19 +38,19 @@ |
47 | """Returns the item that is searched for with app.select_single |
48 | In case of the item was not found (not created yet) a second attempt is |
49 | taken 1 second later.""" |
50 | - item = self.app.select_single(object_type, **kwargs) |
51 | + item = self.select_single(object_type, **kwargs) |
52 | tries = 10 |
53 | while item is None and tries > 0: |
54 | - sleep(self.app.retry_delay) |
55 | - item = self.app.select_single(object_type, **kwargs) |
56 | + sleep(self.retry_delay) |
57 | + item = self.select_single(object_type, **kwargs) |
58 | tries = tries - 1 |
59 | return item |
60 | |
61 | def tap_item(self, item): |
62 | - self.app.pointing_device.move_to_object(item) |
63 | - self.app.pointing_device.press() |
64 | + self.pointing_device.move_to_object(item) |
65 | + self.pointing_device.press() |
66 | sleep(2) |
67 | - self.app.pointing_device.release() |
68 | + self.pointing_device.release() |
69 | |
70 | def show_toolbar(self): |
71 | # Get the toolbar object and create a mouse |
72 | @@ -74,12 +66,14 @@ |
73 | mouse.drag(x1, y1, x1, y1 - toolbar.height) |
74 | |
75 | def get_play_button(self): |
76 | - return self.app.select_single("UbuntuShape", objectName = "playshape") |
77 | + return self.select_single("UbuntuShape", objectName="playshape") |
78 | |
79 | def get_forward_button(self): |
80 | - return self.app.select_single( |
81 | - "UbuntuShape", objectName = "forwardshape") |
82 | + return self.select_single("UbuntuShape", objectName="forwardshape") |
83 | |
84 | def get_player_control_title(self): |
85 | - return self.app.select_single( |
86 | - "Label", objectName = "playercontroltitle") |
87 | + return self.select_single("Label", objectName="playercontroltitle") |
88 | + |
89 | + def get_spinner(self): |
90 | + return self.select_single("ActivityIndicator", |
91 | + objectName="LoadingSpinner") |
92 | |
93 | === modified file 'tests/autopilot/music_app/tests/__init__.py' |
94 | --- tests/autopilot/music_app/tests/__init__.py 2013-10-08 13:01:03 +0000 |
95 | +++ tests/autopilot/music_app/tests/__init__.py 2013-10-09 19:00:30 +0000 |
96 | @@ -20,7 +20,7 @@ |
97 | from autopilot.testcase import AutopilotTestCase |
98 | |
99 | from ubuntuuitoolkit import emulators as toolkit_emulators |
100 | -from music_app.emulators import MainView |
101 | +from music_app import emulators |
102 | |
103 | logger = logging.getLogger(__name__) |
104 | |
105 | @@ -57,14 +57,16 @@ |
106 | self.app = self.launch_test_application( |
107 | "qmlscene", |
108 | self.local_location, |
109 | - app_type='qt') |
110 | + app_type='qt', |
111 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
112 | |
113 | def launch_test_installed(self): |
114 | self.app = self.launch_test_application( |
115 | "qmlscene", |
116 | self.installed_location, |
117 | "--desktop_file_hint=/usr/share/applications/music-app.desktop", |
118 | - app_type='qt') |
119 | + app_type='qt', |
120 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
121 | |
122 | def launch_test_click(self): |
123 | self.app = self.launch_click_package( |
124 | @@ -108,26 +110,25 @@ |
125 | #copy over the music and index |
126 | if os.path.exists(self.local_location): |
127 | shutil.copy(self.working_dir + '/music_app/content/' |
128 | - +'1.ogg', |
129 | - musicpath) |
130 | + + '1.ogg', |
131 | + musicpath) |
132 | shutil.copy(self.working_dir + '/music_app/content/' |
133 | - +'2.ogg', |
134 | - musicpath) |
135 | - shutil.copytree(self.working_dir + '/music_app/content/mediascanner', |
136 | - mediascannerpath) |
137 | + + '2.ogg', |
138 | + musicpath) |
139 | + shutil.copytree(self.working_dir + |
140 | + '/music_app/content/mediascanner', |
141 | + mediascannerpath) |
142 | |
143 | else: |
144 | - shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/' |
145 | - +'1.ogg', |
146 | - musicpath) |
147 | - shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/' |
148 | - +'2.ogg', |
149 | - musicpath) |
150 | - shutil.copytree('/usr/lib/python2.7/dist-packages/music_app/content/mediascanner', |
151 | - mediascannerpath) |
152 | + pkg_dir = '/usr/lib/python2.7/dist-packages/music_app/' |
153 | + shutil.copy(pkg_dir + 'content/' + '1.ogg', musicpath) |
154 | + shutil.copy(pkg_dir + 'content/' + '2.ogg', musicpath) |
155 | + shutil.copytree(pkg_dir + 'content/mediascanner', mediascannerpath) |
156 | |
157 | logger.debug("Music copied, files " + str(os.listdir(musicpath))) |
158 | - logger.debug("Mediascanner database copied, files " + str(os.listdir(mediascannerpath))) |
159 | + logger.debug( |
160 | + "Mediascanner database copied, files " + |
161 | + str(os.listdir(mediascannerpath))) |
162 | |
163 | #do some inline db patching |
164 | #patch mediaindex to proper home |
165 | @@ -137,13 +138,18 @@ |
166 | dblocation = "home/autopilot-music-app" |
167 | dbfoldername = "ea50858c-4b21-4f87-9005-40aa960a84a3" |
168 | #patch mediaindex |
169 | - self._file_find_replace(mediascannerpath + "/mediaindex", dblocation, relhome) |
170 | + self._file_find_replace(mediascannerpath + |
171 | + "/mediaindex", dblocation, relhome) |
172 | |
173 | #patch file indexes |
174 | - self._file_find_replace(mediascannerpath + "/" + dbfoldername + "/_0.cfs", dblocation, relhome) |
175 | - self._file_find_replace(mediascannerpath + "/" + dbfoldername + "/_1.cfs", dblocation, relhome) |
176 | - self._file_find_replace(mediascannerpath + "/" + dbfoldername + "/_2.cfs", dblocation, relhome) |
177 | - self._file_find_replace(mediascannerpath + "/" + dbfoldername + "/_3.cfs", dblocation, relhome) |
178 | + self._file_find_replace(mediascannerpath + "/" + |
179 | + dbfoldername + "/_0.cfs", dblocation, relhome) |
180 | + self._file_find_replace(mediascannerpath + "/" + |
181 | + dbfoldername + "/_1.cfs", dblocation, relhome) |
182 | + self._file_find_replace(mediascannerpath + "/" + |
183 | + dbfoldername + "/_2.cfs", dblocation, relhome) |
184 | + self._file_find_replace(mediascannerpath + "/" + |
185 | + dbfoldername + "/_3.cfs", dblocation, relhome) |
186 | |
187 | def _file_find_replace(self, in_filename, find, replace): |
188 | #replace all occurences of string find with string replace |
189 | @@ -160,7 +166,6 @@ |
190 | os.remove(in_filename) |
191 | os.rename(out_filename, in_filename) |
192 | |
193 | - |
194 | @property |
195 | def main_view(self): |
196 | - return MainView(self.app) |
197 | + return self.app.select_single(emulators.MainView) |
198 | |
199 | === modified file 'tests/autopilot/music_app/tests/test_music.py' |
200 | --- tests/autopilot/music_app/tests/test_music.py 2013-10-07 12:30:00 +0000 |
201 | +++ tests/autopilot/music_app/tests/test_music.py 2013-10-09 19:00:30 +0000 |
202 | @@ -17,15 +17,24 @@ |
203 | |
204 | class TestMainWindow(MusicTestCase): |
205 | |
206 | + def setUp(self): |
207 | + super(TestMainWindow, self).setUp() |
208 | + self.assertThat( |
209 | + self.main_view.visible, Eventually(Equals(True))) |
210 | + #wait for activity indicator to stop spinning |
211 | + self.assertThat( |
212 | + self.main_view.get_spinner, Eventually(NotEquals(None))) |
213 | + spinner = lambda: self.main_view.get_spinner().running |
214 | + self.assertThat(spinner, Eventually(Equals(False))) |
215 | + |
216 | def test_reads_music_library(self): |
217 | """ tests if the music library is populated from our |
218 | fake mediascanner database""" |
219 | |
220 | - self.assertThat(self.main_view.get_main_view, Eventually(NotEquals(None))) |
221 | - mainView = self.main_view.get_main_view() |
222 | - title = lambda: mainView.currentTracktitle |
223 | - artist = lambda: mainView.currentArtist |
224 | - self.assertThat(title, Eventually(Equals("Foss Yeaaaah! (Radio Edit)"))) |
225 | + title = lambda: self.main_view.currentTracktitle |
226 | + artist = lambda: self.main_view.currentArtist |
227 | + self.assertThat(title, |
228 | + Eventually(Equals("Foss Yeaaaah! (Radio Edit)"))) |
229 | self.assertThat(artist, Eventually(Equals("Benjamin Kerensa"))) |
230 | |
231 | def test_play_pause(self): |
232 | @@ -33,20 +42,20 @@ |
233 | |
234 | self.main_view.show_toolbar() |
235 | |
236 | - self.assertThat(self.main_view.get_play_button, Eventually(NotEquals(None))) |
237 | + self.assertThat(self.main_view.get_play_button, |
238 | + Eventually(NotEquals(None))) |
239 | playbutton = self.main_view.get_play_button() |
240 | - mainView = self.main_view.get_main_view() |
241 | |
242 | """ Track is not playing""" |
243 | - self.assertThat(mainView.isPlaying, Eventually(Equals(False))) |
244 | + self.assertThat(self.main_view.isPlaying, Eventually(Equals(False))) |
245 | self.pointing_device.click_object(playbutton) |
246 | |
247 | """ Track is playing""" |
248 | - self.assertThat(mainView.isPlaying, Eventually(Equals(True))) |
249 | + self.assertThat(self.main_view.isPlaying, Eventually(Equals(True))) |
250 | |
251 | """ Track is not playing""" |
252 | self.pointing_device.click_object(playbutton) |
253 | - self.assertThat(mainView.isPlaying, Eventually(Equals(False))) |
254 | + self.assertThat(self.main_view.isPlaying, Eventually(Equals(False))) |
255 | |
256 | def test_next(self): |
257 | """ Test going to next track (Music Library must exist) """ |
258 | @@ -57,19 +66,21 @@ |
259 | label = self.main_view.get_player_control_title() |
260 | self.pointing_device.click_object(label) |
261 | |
262 | - self.assertThat(self.main_view.get_forward_button, Eventually(NotEquals(None))) |
263 | + self.assertThat(self.main_view.get_forward_button, |
264 | + Eventually(NotEquals(None))) |
265 | forwardbutton = self.main_view.get_forward_button() |
266 | - mainView = self.main_view.get_main_view() |
267 | - title = lambda: mainView.currentTracktitle |
268 | - artist = lambda: mainView.currentArtist |
269 | - self.assertThat(title, Eventually(Equals("Foss Yeaaaah! (Radio Edit)"))) |
270 | + |
271 | + title = lambda: self.main_view.currentTracktitle |
272 | + artist = lambda: self.main_view.currentArtist |
273 | + self.assertThat(title, |
274 | + Eventually(Equals("Foss Yeaaaah! (Radio Edit)"))) |
275 | self.assertThat(artist, Eventually(Equals("Benjamin Kerensa"))) |
276 | |
277 | """ Track is not playing""" |
278 | - self.assertThat(mainView.isPlaying, Equals(False)) |
279 | + self.assertThat(self.main_view.isPlaying, Equals(False)) |
280 | self.pointing_device.click_object(forwardbutton) |
281 | |
282 | """ Track is playing""" |
283 | - self.assertThat(mainView.isPlaying, Eventually(Equals(True))) |
284 | + self.assertThat(self.main_view.isPlaying, Eventually(Equals(True))) |
285 | self.assertThat(title, Eventually(Equals("Swansong"))) |
286 | self.assertThat(artist, Eventually(Equals("Josh Woodward"))) |
FAILED: Continuous integration, rev:167 91.189. 93.70:8080/ job/music- app-ci/ 136/ 91.189. 93.70:8080/ job/generic- mediumtests/ 855/console 91.189. 93.70:8080/ job/music- app-precise- amd64-ci/ 136/console 91.189. 93.70:8080/ job/music- app-quantal- amd64-ci/ 136/console 91.189. 93.70:8080/ job/music- app-raring- amd64-ci/ 136/console 91.189. 93.70:8080/ job/music- app-saucy- amd64-ci/ 136/console
http://
Executed test runs:
None: http://
None: http://
None: http://
None: http://
None: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/music- app-ci/ 136/rebuild
http://