Merge lp:~nskaggs/music-app/click-mediascanner-tests into lp:music-app/trusty

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Victor Thompson
Approved revision: 132
Merged at revision: 134
Proposed branch: lp:~nskaggs/music-app/click-mediascanner-tests
Merge into: lp:music-app/trusty
Diff against target: 212 lines (+74/-16)
4 files modified
debian/control (+0/-1)
tests/autopilot/music_app/content/mediascanner/mediaindex (+22/-0)
tests/autopilot/music_app/emulators/emulators.py (+6/-0)
tests/autopilot/music_app/tests/__init__.py (+46/-15)
To merge this branch: bzr merge lp:~nskaggs/music-app/click-mediascanner-tests
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Victor Thompson Approve
Review via email: mp+188075@code.launchpad.net

Commit message

Add support for testing via click packages
Fix tests to work with new mediascanner

This change removes the need for example-content, and instead packages 2 ogg files and a mediascanner db for testing.

Description of the change

Add support for testing via click packages
Fix tests to work with new mediascanner

To post a comment you must log in.
131. By Nicholas Skaggs

cleanup for review

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
132. By Nicholas Skaggs

add in db patching

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
Victor Thompson (vthompson) wrote :

Ok, this is amazing, but what if there is a change in mediascanner? Could this break? Are the "segments' dependent upon anything they might change in the future? Everything passes and looks good otherwise. I agree with this merge though and will push it regardless. balloons++

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

If mediascanner changes the way it writes db's, then yes this could break. I don't see that as something they are likely to do or undertake.

This is probably the most brute force and ugliest way of doing it, so I'm open to hear of another route. That said, I needed to still tweak this so it will run in the lab, as it gives an error (something different in the pathing and it's not finding things). Expect to see another MP for that. Sorry about that, should have taken off ready for review :-)

http://reports.qa.ubuntu.com/smokeng/saucy/touch_ro/4470/music-app-autopilot/439811/

Overall, I'm just glad the proof of concept worked :-)

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Also, should probably be more pythonic and use the re module

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-09-23 19:31:29 +0000
3+++ debian/control 2013-09-27 21:56:07 +0000
4@@ -18,7 +18,6 @@
5 libqt5test5,
6 python-mock,
7 music-app (= ${source:Version}),
8- example-content,
9 ubuntu-ui-toolkit-autopilot
10 Description: Autopilot tests for Music App
11 This package contains the autopilot tests for the Music App
12
13=== added file 'tests/autopilot/music_app/content/1.ogg'
14Binary files tests/autopilot/music_app/content/1.ogg 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/1.ogg 2013-09-27 21:56:07 +0000 differ
15=== added file 'tests/autopilot/music_app/content/2.ogg'
16Binary files tests/autopilot/music_app/content/2.ogg 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/2.ogg 2013-09-27 21:56:07 +0000 differ
17=== removed file 'tests/autopilot/music_app/content/Benjamin_Kerensa_-_Foss_Yeaaaah___Radio_Edit_.ogg'
18Binary files tests/autopilot/music_app/content/Benjamin_Kerensa_-_Foss_Yeaaaah___Radio_Edit_.ogg 2013-08-30 19:51:23 +0000 and tests/autopilot/music_app/content/Benjamin_Kerensa_-_Foss_Yeaaaah___Radio_Edit_.ogg 1970-01-01 00:00:00 +0000 differ
19=== added directory 'tests/autopilot/music_app/content/mediascanner'
20=== added directory 'tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db'
21=== added file 'tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/segments.gen'
22Binary files tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/segments.gen 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/segments.gen 2013-09-27 21:56:07 +0000 differ
23=== added file 'tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/segments_1'
24Binary files tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/segments_1 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/segments_1 2013-09-27 21:56:07 +0000 differ
25=== added file 'tests/autopilot/music_app/content/mediascanner/09756d0b-9d3f-4e6b-8f2f-8525fb99e5db/write.lock'
26=== added directory 'tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c'
27=== added file 'tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/segments.gen'
28Binary files tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/segments.gen 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/segments.gen 2013-09-27 21:56:07 +0000 differ
29=== added file 'tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/segments_1'
30Binary files tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/segments_1 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/segments_1 2013-09-27 21:56:07 +0000 differ
31=== added file 'tests/autopilot/music_app/content/mediascanner/520da397-8f8b-4411-8aed-4de7a53bde8c/write.lock'
32=== added directory 'tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa'
33=== added file 'tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/segments.gen'
34Binary files tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/segments.gen 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/segments.gen 2013-09-27 21:56:07 +0000 differ
35=== added file 'tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/segments_1'
36Binary files tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/segments_1 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/segments_1 2013-09-27 21:56:07 +0000 differ
37=== added file 'tests/autopilot/music_app/content/mediascanner/6fb4ad21-303d-41ad-88ee-925f409accfa/write.lock'
38=== added directory 'tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605'
39=== added file 'tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/segments.gen'
40Binary files tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/segments.gen 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/segments.gen 2013-09-27 21:56:07 +0000 differ
41=== added file 'tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/segments_1'
42Binary files tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/segments_1 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/segments_1 2013-09-27 21:56:07 +0000 differ
43=== added file 'tests/autopilot/music_app/content/mediascanner/b6d687cb-c07d-4ea4-83db-d5404b9c9605/write.lock'
44=== added directory 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3'
45=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_0.cfs'
46Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_0.cfs 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_0.cfs 2013-09-27 21:56:07 +0000 differ
47=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_0_1.del'
48Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_0_1.del 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_0_1.del 2013-09-27 21:56:07 +0000 differ
49=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_1.cfs'
50Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_1.cfs 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_1.cfs 2013-09-27 21:56:07 +0000 differ
51=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_2.cfs'
52Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_2.cfs 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_2.cfs 2013-09-27 21:56:07 +0000 differ
53=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_2_1.del'
54Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_2_1.del 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_2_1.del 2013-09-27 21:56:07 +0000 differ
55=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_3.cfs'
56Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_3.cfs 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/_3.cfs 2013-09-27 21:56:07 +0000 differ
57=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/segments.gen'
58Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/segments.gen 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/segments.gen 2013-09-27 21:56:07 +0000 differ
59=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/segments_5'
60Binary files tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/segments_5 1970-01-01 00:00:00 +0000 and tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/segments_5 2013-09-27 21:56:07 +0000 differ
61=== added file 'tests/autopilot/music_app/content/mediascanner/ea50858c-4b21-4f87-9005-40aa960a84a3/write.lock'
62=== added file 'tests/autopilot/music_app/content/mediascanner/mediaindex'
63--- tests/autopilot/music_app/content/mediascanner/mediaindex 1970-01-01 00:00:00 +0000
64+++ tests/autopilot/music_app/content/mediascanner/mediaindex 2013-09-27 21:56:07 +0000
65@@ -0,0 +1,22 @@
66+[global]
67+format=Ubuntu Media Scanner Meta Index 1.0
68+
69+[media:home/autopilot-music-app/Downloads]
70+segments=b6d687cb-c07d-4ea4-83db-d5404b9c9605
71+relative-path=home/autopilot-music-app/Downloads
72+
73+[media:home/autopilot-music-app/Music]
74+segments=ea50858c-4b21-4f87-9005-40aa960a84a3
75+relative-path=home/autopilot-music-app/Music
76+
77+[media:home/autopilot-music-app/Pictures]
78+segments=520da397-8f8b-4411-8aed-4de7a53bde8c
79+relative-path=home/autopilot-music-app/Pictures
80+
81+[media:home/autopilot-music-app/Videos]
82+segments=09756d0b-9d3f-4e6b-8f2f-8525fb99e5db
83+relative-path=home/autopilot-music-app/Videos
84+
85+[media:]
86+segments=6fb4ad21-303d-41ad-88ee-925f409accfa
87+relative-path=
88
89=== modified file 'tests/autopilot/music_app/emulators/emulators.py'
90--- tests/autopilot/music_app/emulators/emulators.py 2013-09-14 18:41:15 +0000
91+++ tests/autopilot/music_app/emulators/emulators.py 2013-09-27 21:56:07 +0000
92@@ -49,6 +49,12 @@
93 tries = tries - 1
94 return item
95
96+ def tap_item(self, item):
97+ self.pointing_device.move_to_object(item)
98+ self.pointing_device.press()
99+ sleep(2)
100+ self.pointing_device.release()
101+
102 def get_play_button(self):
103 return self.app.select_single("UbuntuShape", objectName = "playshape")
104
105
106=== modified file 'tests/autopilot/music_app/tests/__init__.py'
107--- tests/autopilot/music_app/tests/__init__.py 2013-09-15 13:43:45 +0000
108+++ tests/autopilot/music_app/tests/__init__.py 2013-09-27 21:56:07 +0000
109@@ -37,6 +37,7 @@
110 working_dir = os.getcwd()
111 local_location_dir = os.path.dirname(os.path.dirname(working_dir))
112 local_location = local_location_dir + "/music-app.qml"
113+ installed_location = "/usr/share/music-app/music-app.qml"
114
115 def setUp(self):
116 self._patch_home()
117@@ -45,8 +46,10 @@
118 super(MusicTestCase, self).setUp()
119 if os.path.exists(self.local_location):
120 self.launch_test_local()
121- else:
122+ elif os.path.exists(self.installed_location):
123 self.launch_test_installed()
124+ else:
125+ self.launch_test_click()
126
127 def launch_test_local(self):
128 self.app = self.launch_test_application(
129@@ -57,41 +60,69 @@
130 def launch_test_installed(self):
131 self.app = self.launch_test_application(
132 "qmlscene",
133- "/usr/share/music-app/music-app.qml",
134+ self.installed_location,
135 "--desktop_file_hint=/usr/share/applications/music-app.desktop",
136 app_type='qt')
137
138+ def launch_test_click(self):
139+ self.app = self.launch_click_package(
140+ "com.ubuntu.music-app",
141+ emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
142+
143 def _patch_home(self):
144+ #make a temp dir
145 temp_dir = tempfile.mkdtemp()
146+ #delete it, and recreate it to the length
147+ #required so our patching the db works
148+ #require a length of 25
149+ shutil.rmtree(temp_dir)
150+ temp_dir = temp_dir.ljust(25, 'X')
151+ os.mkdir(temp_dir)
152 self.addCleanup(shutil.rmtree, temp_dir)
153 patcher = mock.patch.dict('os.environ', {'HOME': temp_dir})
154 patcher.start()
155 self.addCleanup(patcher.stop)
156
157 def _create_music_library(self):
158+ #use fake home
159 home = os.environ['HOME']
160 musicpath = home + '/Music'
161+ mediascannerpath = home + '/.cache/mediascanner'
162 os.mkdir(musicpath)
163
164- # this needs the package 'example-content' installed:
165- shutil.copy('/usr/share/example-content/'
166- +'Ubuntu_Free_Culture_Showcase/Josh Woodward - Swansong.ogg',
167- musicpath)
168+ #copy over our index
169+ shutil.copytree(self.working_dir + '/music_app/content/mediascanner',
170+ mediascannerpath)
171
172 if os.path.exists(self.local_location):
173 shutil.copy(self.working_dir + '/music_app/content/'
174- +'Benjamin_Kerensa_-_Foss_Yeaaaah___Radio_Edit_.ogg',
175+ +'1.ogg',
176+ musicpath)
177+ shutil.copy(self.working_dir + '/music_app/content/'
178+ +'2.ogg',
179 musicpath)
180 else:
181 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'
182- +'Benjamin_Kerensa_-_Foss_Yeaaaah___Radio_Edit_.ogg',
183- musicpath)
184-
185- def tap_item(self, item):
186- self.pointing_device.move_to_object(item)
187- self.pointing_device.press()
188- sleep(1)
189- self.pointing_device.release()
190+ +'1.ogg',
191+ musicpath)
192+ shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'
193+ +'2.ogg',
194+ musicpath)
195+
196+ #do some inline db patching
197+ #patch mediaindex to proper home
198+ #these values are dependent upon our sampled db
199+ relhome = home[1:]
200+ dblocation = "home/autopilot-music-app"
201+ dbfoldername = "ea50858c-4b21-4f87-9005-40aa960a84a3"
202+ #patch mediaindex
203+ os.system("sed -i 's!" + dblocation + "!" + str(relhome) + "!g' " + str(mediascannerpath) + "/mediaindex")
204+
205+ #patch file indexes
206+ os.system("sed -i 's!" + dblocation + "!" + str(relhome) + "!g' " + str(mediascannerpath) + "/" + dbfoldername + "/_0.cfs")
207+ os.system("sed -i 's!" + dblocation + "!" + str(relhome) + "!g' " + str(mediascannerpath) + "/" + dbfoldername + "/_1.cfs")
208+ os.system("sed -i 's!" + dblocation + "!" + str(relhome) + "!g' " + str(mediascannerpath) + "/" + dbfoldername + "/_2.cfs")
209+ os.system("sed -i 's!" + dblocation + "!" + str(relhome) + "!g' " + str(mediascannerpath) + "/" + dbfoldername + "/_3.cfs")
210
211 @property
212 def main_view(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: