Merge lp:~sergiusens/music-app/ap_click_mods into lp:music-app/trusty

Proposed by Sergio Schvezov
Status: Rejected
Rejected by: Nicholas Skaggs
Proposed branch: lp:~sergiusens/music-app/ap_click_mods
Merge into: lp:music-app/trusty
Diff against target: 141 lines (+55/-40)
1 file modified
tests/autopilot/music_app/tests/__init__.py (+55/-40)
To merge this branch: bzr merge lp:~sergiusens/music-app/ap_click_mods
Reviewer Review Type Date Requested Status
Music App Developers Pending
Review via email: mp+190714@code.launchpad.net

Commit message

Test cleanup and initial click support

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

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/music_app/tests/__init__.py'
--- tests/autopilot/music_app/tests/__init__.py 2013-10-09 18:34:16 +0000
+++ tests/autopilot/music_app/tests/__init__.py 2013-10-11 16:03:49 +0000
@@ -41,17 +41,28 @@
41 local_location = local_location_dir + "/music-app.qml"41 local_location = local_location_dir + "/music-app.qml"
42 installed_location = "/usr/share/music-app/music-app.qml"42 installed_location = "/usr/share/music-app/music-app.qml"
4343
44 def setup_environment(self):
45 if os.path.exists(self.local_location):
46 launch = self.launch_test_local
47 test_type = 'deb'
48 elif os.path.exists(self.installed_location):
49 launch = self.launch_test_installed
50 test_type = 'local'
51 else:
52 launch = self.launch_test_click
53 test_type = 'click'
54 return launch, test_type
55
44 def setUp(self):56 def setUp(self):
45 self._patch_home()57 launch, self.test_type = self.setup_environment()
58 if self.test_type != 'click':
59 self._patch_home()
60 else:
61 self.home_dir = self._save_home()
46 self._create_music_library()62 self._create_music_library()
47 self.pointing_device = Pointer(self.input_device_class.create())63 self.pointing_device = Pointer(self.input_device_class.create())
48 super(MusicTestCase, self).setUp()64 super(MusicTestCase, self).setUp()
49 if os.path.exists(self.local_location):65 launch()
50 self.launch_test_local()
51 elif os.path.exists(self.installed_location):
52 self.launch_test_installed()
53 else:
54 self.launch_test_click()
5566
56 def launch_test_local(self):67 def launch_test_local(self):
57 self.app = self.launch_test_application(68 self.app = self.launch_test_application(
@@ -73,6 +84,22 @@
73 "com.ubuntu.music",84 "com.ubuntu.music",
74 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)85 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
7586
87 def _save_home(self):
88 logger.debug('Saving HOME')
89 home_dir = os.environ['HOME']
90 backup_list = ('Music', '.cache/mediascanner')
91 backup_path = [os.path.join(home_dir, i) for i in backup_list]
92 backups = [(i, '%s.bak' % i) for i in backup_path if os.path.exists(i)]
93 for b in backups:
94 logger.debug('backing up %s to %s' % b)
95 try:
96 shutil.rmtree(b[1])
97 except:
98 pass
99 shutil.move(b[0], b[1])
100 #self.addCleanup(shutil.move(b[1], b[0]))
101 return home_dir
102
76 def _patch_home(self):103 def _patch_home(self):
77 #make a temp dir104 #make a temp dir
78 temp_dir = tempfile.mkdtemp()105 temp_dir = tempfile.mkdtemp()
@@ -96,34 +123,27 @@
96 patcher.start()123 patcher.start()
97 logger.debug("Patched home to fake home directory " + temp_dir)124 logger.debug("Patched home to fake home directory " + temp_dir)
98 self.addCleanup(patcher.stop)125 self.addCleanup(patcher.stop)
126 return temp_dir
99127
100 def _create_music_library(self):128 def _create_music_library(self):
101 #use fake home129 logger.debug("Home set to %s" % self.home_dir)
102 home = os.environ['HOME']130 musicpath = os.path.join(self.home_dir, 'Music')
103 logger.debug("Home set to " + home)131 logger.debug("Music path set to %s" % musicpath)
104 musicpath = home + '/Music'132 mediascannerpath = os.path.join(self.home_dir, '.cache/mediascanner')
105 logger.debug("Music path set to " + musicpath)
106 mediascannerpath = home + '/.cache/mediascanner'
107 os.mkdir(musicpath)133 os.mkdir(musicpath)
108 logger.debug("Mediascanner path set to " + mediascannerpath)134 logger.debug("Mediascanner path set to %s" % mediascannerpath)
109135
110 #copy over the music and index136 #set content path
111 if os.path.exists(self.local_location):137 if self.test_type == 'local' or self.test_type == 'click':
112 shutil.copy(self.working_dir + '/music_app/content/'138 content_dir = os.path.join(self.working_dir, 'music_app/content/')
113 + '1.ogg',
114 musicpath)
115 shutil.copy(self.working_dir + '/music_app/content/'
116 + '2.ogg',
117 musicpath)
118 shutil.copytree(self.working_dir +
119 '/music_app/content/mediascanner',
120 mediascannerpath)
121
122 else:139 else:
123 pkg_dir = '/usr/lib/python2.7/dist-packages/music_app/'140 content_dir = '/usr/lib/python2.7/dist-packages/music_app/content/'
124 shutil.copy(pkg_dir + 'content/' + '1.ogg', musicpath)141
125 shutil.copy(pkg_dir + 'content/' + '2.ogg', musicpath)142 #copy content
126 shutil.copytree(pkg_dir + 'content/mediascanner', mediascannerpath)143 shutil.copy(os.path.join(content_dir, '1.ogg'), musicpath)
144 shutil.copy(os.path.join(content_dir, '2.ogg'), musicpath)
145 shutil.copytree(os.path.join(content_dir, 'mediascanner'),
146 mediascannerpath)
127147
128 logger.debug("Music copied, files " + str(os.listdir(musicpath)))148 logger.debug("Music copied, files " + str(os.listdir(musicpath)))
129 logger.debug(149 logger.debug(
@@ -134,7 +154,7 @@
134 #patch mediaindex to proper home154 #patch mediaindex to proper home
135 #these values are dependent upon our sampled db155 #these values are dependent upon our sampled db
136 logger.debug("Patching fake mediascanner database")156 logger.debug("Patching fake mediascanner database")
137 relhome = home[1:]157 relhome = self.home_dir[1:]
138 dblocation = "home/autopilot-music-app"158 dblocation = "home/autopilot-music-app"
139 dbfoldername = "ea50858c-4b21-4f87-9005-40aa960a84a3"159 dbfoldername = "ea50858c-4b21-4f87-9005-40aa960a84a3"
140 #patch mediaindex160 #patch mediaindex
@@ -142,14 +162,9 @@
142 "/mediaindex", dblocation, relhome)162 "/mediaindex", dblocation, relhome)
143163
144 #patch file indexes164 #patch file indexes
145 self._file_find_replace(mediascannerpath + "/" +165 index_template = '%s/%s/_%%s.cfs' % (mediascannerpath, dbfoldername)
146 dbfoldername + "/_0.cfs", dblocation, relhome)166 for i in range(4):
147 self._file_find_replace(mediascannerpath + "/" +167 self._file_find_replace(index_template % i, dblocation, relhome)
148 dbfoldername + "/_1.cfs", dblocation, relhome)
149 self._file_find_replace(mediascannerpath + "/" +
150 dbfoldername + "/_2.cfs", dblocation, relhome)
151 self._file_find_replace(mediascannerpath + "/" +
152 dbfoldername + "/_3.cfs", dblocation, relhome)
153168
154 def _file_find_replace(self, in_filename, find, replace):169 def _file_find_replace(self, in_filename, find, replace):
155 #replace all occurences of string find with string replace170 #replace all occurences of string find with string replace

Subscribers

People subscribed via source and target branches

to status/vote changes: