Merge lp:~nskaggs/ubuntu-filemanager-app/fix-ap-launch into lp:ubuntu-filemanager-app
- fix-ap-launch
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Nicholas Skaggs |
Approved revision: | 304 |
Merged at revision: | 303 |
Proposed branch: | lp:~nskaggs/ubuntu-filemanager-app/fix-ap-launch |
Merge into: | lp:ubuntu-filemanager-app |
Diff against target: |
352 lines (+68/-167) 5 files modified
tests/autopilot/filemanager/__init__.py (+2/-3) tests/autopilot/filemanager/_common.py (+0/-21) tests/autopilot/filemanager/tests/__init__.py (+60/-137) tests/autopilot/filemanager/tests/test_filemanager.py (+5/-5) tests/autopilot/filemanager/tests/test_places.py (+1/-1) |
To merge this branch: | bzr merge lp:~nskaggs/ubuntu-filemanager-app/fix-ap-launch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Ubuntu File Manager Developers | Pending | ||
Review via email: mp+238029@code.launchpad.net |
Commit message
This should resolve the applications failure to launch on the device.
Description of the change
This should resolve the applications failure to launch on the device.
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:301
http://
Executed test runs:
None: http://
None: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
This bug prevents fixing the tests to work better on device:
https:/
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:302
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:303
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 304. By Nicholas Skaggs
-
fix home_dir
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:304
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'tests/autopilot/filemanager/__init__.py' |
2 | --- tests/autopilot/filemanager/__init__.py 2014-09-22 21:52:42 +0000 |
3 | +++ tests/autopilot/filemanager/__init__.py 2014-10-14 18:53:19 +0000 |
4 | @@ -25,8 +25,6 @@ |
5 | from autopilot.introspection import dbus |
6 | import ubuntuuitoolkit |
7 | |
8 | -from filemanager import _common |
9 | - |
10 | logger = logging.getLogger(__name__) |
11 | |
12 | |
13 | @@ -88,7 +86,8 @@ |
14 | self.open_toolbar().click_button('places') |
15 | return self._get_places_popover() |
16 | else: |
17 | - raise _common('The places popover cannot be opened on wide mode.') |
18 | + raise FilemanagerException( |
19 | + 'The places popover cannot be opened on wide mode.') |
20 | |
21 | def _get_places_popover(self): |
22 | """Return the Places popover.""" |
23 | |
24 | === removed file 'tests/autopilot/filemanager/_common.py' |
25 | --- tests/autopilot/filemanager/_common.py 2014-06-10 02:34:07 +0000 |
26 | +++ tests/autopilot/filemanager/_common.py 1970-01-01 00:00:00 +0000 |
27 | @@ -1,21 +0,0 @@ |
28 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
29 | -# |
30 | -# Copyright (C) 2014 Canonical Ltd. |
31 | -# |
32 | -# This program is free software; you can redistribute it and/or modify |
33 | -# it under the terms of the GNU Lesser General Public License as published by |
34 | -# the Free Software Foundation; version 3. |
35 | -# |
36 | -# This program is distributed in the hope that it will be useful, |
37 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
38 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
39 | -# GNU Lesser General Public License for more details. |
40 | -# |
41 | -# You should have received a copy of the GNU Lesser General Public License |
42 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
43 | - |
44 | -from ubuntuuitoolkit import emulators as toolkit_emulators |
45 | - |
46 | - |
47 | -class FileManagerException(toolkit_emulators.ToolkitEmulatorException): |
48 | - """Exception raised when there is an error with the File Manager.""" |
49 | |
50 | === modified file 'tests/autopilot/filemanager/tests/__init__.py' |
51 | --- tests/autopilot/filemanager/tests/__init__.py 2014-09-30 22:38:30 +0000 |
52 | +++ tests/autopilot/filemanager/tests/__init__.py 2014-10-14 18:53:19 +0000 |
53 | @@ -29,7 +29,6 @@ |
54 | from autopilot.testcase import AutopilotTestCase |
55 | from testtools.matchers import Equals |
56 | import ubuntuuitoolkit |
57 | -from ubuntuuitoolkit import fixture_setup as toolkit_fixtures |
58 | |
59 | import filemanager |
60 | from filemanager import fixture_setup as fm_fixtures |
61 | @@ -75,30 +74,8 @@ |
62 | |
63 | super(BaseTestCaseWithPatchedHome, self).setUp() |
64 | self.launcher, self.test_type = self.get_launcher_and_type() |
65 | - self.real_home_dir = os.environ.get('HOME') |
66 | - self.home_dir = self._patch_home() |
67 | - |
68 | - self.original_file_count = \ |
69 | - len([i for i in os.listdir(self.home_dir) |
70 | - if not i.startswith('.')]) |
71 | - logger.debug('Directory Listing for HOME\n%s' % |
72 | - os.listdir(self.home_dir)) |
73 | - logger.debug('File count in HOME is %s' % self.original_file_count) |
74 | - |
75 | - def _get_build_dir(self): |
76 | - """ |
77 | - Returns the build dir after having parsed the CMake config file |
78 | - generated by Qt Creator. If it cannot find it or it cannot be parsed, |
79 | - an in-tree build is assumed and thus returned. |
80 | - """ |
81 | - try: |
82 | - cmake_config = CMakePluginParser.CMakePluginParser(os.path.join( |
83 | - self.source_dir, 'CMakeLists.txt.user')) |
84 | - build_dir = cmake_config.active_build_dir |
85 | - except: |
86 | - build_dir = self.source_dir |
87 | - |
88 | - return build_dir |
89 | + self.real_home_dir = os.getenv('HOME') |
90 | + self.patch_home() |
91 | |
92 | @autopilot_logging.log_action(logger.info) |
93 | def launch_test_local(self): |
94 | @@ -195,119 +172,74 @@ |
95 | '.Xauthority')), |
96 | os.path.join(directory, '.Xauthority')) |
97 | |
98 | - def _patch_home(self): |
99 | + def patch_home(self): |
100 | """ mock /home for testing purposes to preserve user data |
101 | """ |
102 | |
103 | - original_home = os.environ.get('HOME') |
104 | - original_app_launch = os.environ.get('UBUNTU_APP_LAUNCH_LINK_FARM') |
105 | - original_xdg_config_home = os.environ.get('XDG_CONFIG_HOME') |
106 | - |
107 | - # click requires apparmor profile, and writing to special dir |
108 | - # but the desktop can write to a traditional /tmp directory |
109 | - if self.test_type == 'click': |
110 | - env_dir = os.path.join(os.environ.get('HOME'), 'autopilot', |
111 | - 'fakeenv') |
112 | - |
113 | - if not os.path.exists(env_dir): |
114 | - os.makedirs(env_dir) |
115 | - |
116 | - temp_dir_fixture = fixtures.TempDir(env_dir) |
117 | - else: |
118 | + # if running on non-phablet device, |
119 | + # run in temp folder to avoid mucking up home |
120 | + # bug 1316746 |
121 | + # bug 1376423 |
122 | + if self.test_type is not 'click': |
123 | temp_dir_fixture = fixtures.TempDir() |
124 | - |
125 | - # setup fixture paths |
126 | - self.useFixture(temp_dir_fixture) |
127 | - temp_dir = temp_dir_fixture.path |
128 | - temp_xdg_config_home = os.path.join(temp_dir, '.config') |
129 | - temp_app_launch = os.path.join(temp_dir, '.cache', |
130 | - 'ubuntu-app-launch', 'desktop') |
131 | - |
132 | - # create the needed directores |
133 | - if not os.path.exists(temp_xdg_config_home): |
134 | - os.makedirs(temp_xdg_config_home) |
135 | - if not os.path.exists(temp_app_launch): |
136 | - os.makedirs(temp_app_launch) |
137 | - |
138 | - # for click, we need to create additional directories |
139 | - # apparmor doesn't allow the app to create needed directories, |
140 | - # so we create them now |
141 | - if self.test_type == 'click': |
142 | - temp_dir_cache = os.path.join(temp_dir, '.cache') |
143 | - temp_dir_cache_font = os.path.join(temp_dir_cache, 'fontconfig') |
144 | - temp_dir_cache_media = os.path.join(temp_dir_cache, 'media-art') |
145 | - temp_dir_cache_write = os.path.join(temp_dir_cache, |
146 | - 'tncache-write-text.null') |
147 | - temp_dir_config = os.path.join(temp_dir, '.config') |
148 | - temp_dir_toolkit = os.path.join(temp_dir_config, |
149 | - 'ubuntu-ui-toolkit') |
150 | - temp_dir_font = os.path.join(temp_dir_cache, '.fontconfig') |
151 | - temp_dir_local = os.path.join(temp_dir, '.local', 'share') |
152 | - temp_dir_confined = os.path.join(temp_dir, 'confined') |
153 | - |
154 | - if not os.path.exists(temp_dir_cache): |
155 | - os.makedirs(temp_dir_cache) |
156 | - if not os.path.exists(temp_dir_cache_font): |
157 | - os.makedirs(temp_dir_cache_font) |
158 | - if not os.path.exists(temp_dir_cache_media): |
159 | - os.makedirs(temp_dir_cache_media) |
160 | - if not os.path.exists(temp_dir_cache_write): |
161 | - os.makedirs(temp_dir_cache_write) |
162 | - if not os.path.exists(temp_dir_config): |
163 | - os.makedirs(temp_dir_config) |
164 | - if not os.path.exists(temp_dir_toolkit): |
165 | - os.makedirs(temp_dir_toolkit) |
166 | - if not os.path.exists(temp_dir_font): |
167 | - os.makedirs(temp_dir_font) |
168 | - if not os.path.exists(temp_dir_local): |
169 | - os.makedirs(temp_dir_local) |
170 | - if not os.path.exists(temp_dir_confined): |
171 | - os.makedirs(temp_dir_confined) |
172 | - |
173 | - # before we set fixture, copy xauthority if needed |
174 | - self._copy_xauthority_file(temp_dir) |
175 | - |
176 | - # set the fixture |
177 | - # for click, use initctl, otherwise set env directly |
178 | - if self.test_type == 'click': |
179 | - self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable( |
180 | - HOME=temp_dir)) |
181 | - self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable( |
182 | - XDG_CONFIG_HOME=temp_xdg_config_home)) |
183 | - self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable( |
184 | - UBUNTU_APP_LAUNCH_LINK_FARM=temp_app_launch)) |
185 | - |
186 | - else: |
187 | + self.useFixture(temp_dir_fixture) |
188 | + temp_dir = temp_dir_fixture.path |
189 | + |
190 | + # before we set fixture, copy xauthority if needed |
191 | + self._copy_xauthority_file(temp_dir) |
192 | self.useFixture(fixtures.EnvironmentVariable('HOME', |
193 | newvalue=temp_dir)) |
194 | - self.useFixture(fixtures.EnvironmentVariable( |
195 | - 'XDG_CONFIG_HOME', newvalue=temp_xdg_config_home)) |
196 | - self.useFixture(fixtures.EnvironmentVariable( |
197 | - 'UBUNTU_APP_LAUNCH_LINK_FARM', newvalue=temp_app_launch)) |
198 | - |
199 | - # For now, blow away actual env vars and restore |
200 | - # TODO: Remove code once pad.lv/1370800 is fixed |
201 | - def undo_patch(key, value): |
202 | + |
203 | + logger.debug("Patched home to fake home directory %s" % temp_dir) |
204 | + |
205 | + def patch_environment(self, key, value): |
206 | + def patch_var(key, value): |
207 | logging.info( |
208 | - "Resetting environment variable '%s' to '%s'", |
209 | + "Setting environment variable '%s' to '%s'", |
210 | key, |
211 | value |
212 | ) |
213 | |
214 | os.environ[key] = value |
215 | |
216 | - os.environ['HOME'] = temp_dir |
217 | - os.environ['XDG_CONFIG_HOME'] = temp_xdg_config_home |
218 | - os.environ['UBUNTU_APP_LAUNCH_LINK_FARM'] = temp_app_launch |
219 | - |
220 | - self.addCleanup(undo_patch, 'HOME', original_home) |
221 | - self.addCleanup(undo_patch, 'UBUNTU_APP_LAUNCH_LINK_FARM', |
222 | - original_app_launch or '') |
223 | - self.addCleanup(undo_patch, 'XDG_CONFIG_HOME', |
224 | - original_xdg_config_home or '') |
225 | - |
226 | - logger.debug("Patched home to fake home directory %s" % temp_dir) |
227 | - return temp_dir |
228 | + original = os.getenv(key) |
229 | + if original is None: |
230 | + original = '' |
231 | + patch_var(key, value) |
232 | + # on click, we should cleanup |
233 | + if self.test_type is 'click': |
234 | + self.addCleanup(patch_var, key, original) |
235 | + |
236 | + def _get_build_dir(self): |
237 | + """ |
238 | + Returns the build dir after having parsed the CMake config file |
239 | + generated by Qt Creator. If it cannot find it or it cannot be parsed, |
240 | + an in-tree build is assumed and thus returned. |
241 | + """ |
242 | + try: |
243 | + cmake_config = CMakePluginParser.CMakePluginParser(os.path.join( |
244 | + self.source_dir, 'CMakeLists.txt.user')) |
245 | + build_dir = cmake_config.active_build_dir |
246 | + except: |
247 | + build_dir = self.source_dir |
248 | + |
249 | + return build_dir |
250 | + |
251 | + |
252 | +class FileManagerTestCase(BaseTestCaseWithPatchedHome): |
253 | + |
254 | + """Base test case that launches the filemanager-app.""" |
255 | + |
256 | + def setUp(self): |
257 | + super(FileManagerTestCase, self).setUp() |
258 | + self.fakehome = os.getenv('HOME') |
259 | + self.original_file_count = \ |
260 | + len([i for i in os.listdir(self.fakehome) |
261 | + if not i.startswith('.')]) |
262 | + logger.debug('Directory Listing for HOME\n%s' % |
263 | + os.listdir(self.fakehome)) |
264 | + logger.debug('File count in HOME is %s' % self.original_file_count) |
265 | + self.app = filemanager.Filemanager(self.launcher(), self.test_type) |
266 | |
267 | def make_file_in_home(self): |
268 | return self.make_content_in_home('file') |
269 | @@ -319,16 +251,16 @@ |
270 | if type_ != 'file' and type_ != 'directory': |
271 | raise ValueError('Unknown content type: "{0}"', type_) |
272 | if type_ == 'file': |
273 | - temp_file = fm_fixtures.TemporaryFileInDirectory(self.home_dir) |
274 | + temp_file = fm_fixtures.TemporaryFileInDirectory(self.fakehome) |
275 | self.useFixture(temp_file) |
276 | path = temp_file.path |
277 | else: |
278 | temp_dir = fm_fixtures.TemporaryDirectoryInDirectory( |
279 | - self.home_dir) |
280 | + self.fakehome) |
281 | self.useFixture(temp_dir) |
282 | path = temp_dir.path |
283 | logger.debug('Directory Listing for HOME\n%s' % |
284 | - os.listdir(self.home_dir)) |
285 | + os.listdir(self.fakehome)) |
286 | self._assert_number_of_files(1) |
287 | return path |
288 | |
289 | @@ -342,12 +274,3 @@ |
290 | self.assertThat( |
291 | folder_list_page.get_number_of_files_from_header, |
292 | Eventually(Equals(expected_number_of_files), timeout=60)) |
293 | - |
294 | - |
295 | -class FileManagerTestCase(BaseTestCaseWithPatchedHome): |
296 | - |
297 | - """Base test case that launches the filemanager-app.""" |
298 | - |
299 | - def setUp(self): |
300 | - super(FileManagerTestCase, self).setUp() |
301 | - self.app = filemanager.Filemanager(self.launcher(), self.test_type) |
302 | |
303 | === modified file 'tests/autopilot/filemanager/tests/test_filemanager.py' |
304 | --- tests/autopilot/filemanager/tests/test_filemanager.py 2014-09-25 21:51:04 +0000 |
305 | +++ tests/autopilot/filemanager/tests/test_filemanager.py 2014-10-14 18:53:19 +0000 |
306 | @@ -281,11 +281,11 @@ |
307 | |
308 | def test_copy_directory(self): |
309 | # Set up a directory to copy and a directory to copy it into. |
310 | - destination_dir_path = os.path.join(self.home_dir, |
311 | + destination_dir_path = os.path.join(self.fakehome, |
312 | 'destination') |
313 | destination_dir_name = os.path.basename(destination_dir_path) |
314 | os.mkdir(destination_dir_path) |
315 | - dir_to_copy_path = os.path.join(self.home_dir, 'to_copy') |
316 | + dir_to_copy_path = os.path.join(self.fakehome, 'to_copy') |
317 | dir_to_copy_name = os.path.basename(dir_to_copy_path) |
318 | os.mkdir(dir_to_copy_path) |
319 | |
320 | @@ -327,11 +327,11 @@ |
321 | |
322 | def test_cut_directory(self): |
323 | # Set up a directory to cut and a directory to move it into. |
324 | - destination_dir_path = os.path.join(self.home_dir, |
325 | + destination_dir_path = os.path.join(self.fakehome, |
326 | 'destination') |
327 | destination_dir_name = os.path.basename(destination_dir_path) |
328 | os.mkdir(destination_dir_path) |
329 | - dir_to_cut_path = os.path.join(self.home_dir, 'to_cut') |
330 | + dir_to_cut_path = os.path.join(self.fakehome, 'to_cut') |
331 | dir_to_cut_name = os.path.basename(dir_to_cut_path) |
332 | os.mkdir(dir_to_cut_path) |
333 | |
334 | @@ -478,4 +478,4 @@ |
335 | folder_list_page = self.app.main_view.get_folder_list_page() |
336 | self.assertThat( |
337 | folder_list_page.get_current_path, |
338 | - Eventually(Equals(self.home_dir))) |
339 | + Eventually(Equals(self.fakehome))) |
340 | |
341 | === modified file 'tests/autopilot/filemanager/tests/test_places.py' |
342 | --- tests/autopilot/filemanager/tests/test_places.py 2014-09-22 21:43:02 +0000 |
343 | +++ tests/autopilot/filemanager/tests/test_places.py 2014-10-14 18:53:19 +0000 |
344 | @@ -30,7 +30,7 @@ |
345 | folder_list_page = self.app.main_view.get_folder_list_page() |
346 | self.assertThat( |
347 | folder_list_page.get_current_path, |
348 | - Eventually(Equals(self.home_dir))) |
349 | + Eventually(Equals(self.fakehome))) |
350 | |
351 | def test_go_to_root_must_open_the_root_directory(self): |
352 | """Test that opens the Device bookmark from the places section.""" |
PASSED: Continuous integration, rev:299 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 344/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic- python3/ 864 91.189. 93.70:8080/ job/generic- mediumtests- utopic- python3/ 864/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/ubuntu- filemanager- app-utopic- amd64-ci/ 142
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 344/rebuild
http://