Merge lp:~elopio/ubuntu-filemanager-app/clean_context_menu_tests into lp:ubuntu-filemanager-app
- clean_context_menu_tests
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Nicholas Skaggs |
Approved revision: | 205 |
Merged at revision: | 210 |
Proposed branch: | lp:~elopio/ubuntu-filemanager-app/clean_context_menu_tests |
Merge into: | lp:ubuntu-filemanager-app |
Diff against target: |
766 lines (+306/-178) 6 files modified
debian/control (+2/-1) tests/autopilot/filemanager/emulators.py (+86/-24) tests/autopilot/filemanager/fixture_setup.py (+78/-0) tests/autopilot/filemanager/tests/__init__.py (+42/-10) tests/autopilot/filemanager/tests/test_context_menu.py (+83/-0) tests/autopilot/filemanager/tests/test_filemanager.py (+15/-143) |
To merge this branch: | bzr merge lp:~elopio/ubuntu-filemanager-app/clean_context_menu_tests |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicholas Skaggs (community) | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+222888@code.launchpad.net |
Commit message
Refactored the first group of context menu tests.
Description of the change
I removed some clean ups unnecessary as we are working on a temp folder that will be deleted. I also removed the two tests that check the context popover is opened, because we are doing that check on open_actions.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:203
http://
Executed test runs:
SUCCESS: http://
deb: 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:204
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
_copy_xauthorit
Also, getting this error running on the device. Rebasing with trunk didn't seem to change anything;
17:09:09.133 ERROR testresult:46 - traceback: {{{
Traceback (most recent call last):
File "/home/
files_and_folders = self.get_
File "/home/
return folder_
File "/home/
raise NotImplementedE
NotImplementedError
}}}
Leo Arias (elopio) wrote : | # |
I'm sorry about the exception. It should be ready now.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:205
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
LGTM now..
Ran 22 tests in 491.443s
OK
Preview Diff
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-05-06 17:57:59 +0000 |
3 | +++ debian/control 2014-06-18 03:35:44 +0000 |
4 | @@ -38,7 +38,7 @@ |
5 | Qt is a cross-platform C++ application framework. Qt's primary feature |
6 | is its rich set of widgets that provide standard GUI functionality. |
7 | . |
8 | - This package contains the Folder List model plugin of the Nemo QML |
9 | + This package contains the Folder List model plugin of the Nemo QML |
10 | plugins collection. |
11 | |
12 | Package: ubuntu-filemanager-app-autopilot |
13 | @@ -49,5 +49,6 @@ |
14 | ubuntu-filemanager-app (>= ${source:Version}), |
15 | ubuntu-ui-toolkit-autopilot, |
16 | python3-autopilot, |
17 | + python3-fixtures, |
18 | Description: Autopilot tests for File Manager Application |
19 | This package contains the autopilot tests for the File Manager |
20 | |
21 | === modified file 'tests/autopilot/filemanager/emulators.py' |
22 | --- tests/autopilot/filemanager/emulators.py 2014-06-10 18:01:42 +0000 |
23 | +++ tests/autopilot/filemanager/emulators.py 2014-06-18 03:35:44 +0000 |
24 | @@ -49,6 +49,12 @@ |
25 | side_bar = self.get_folder_list_page().get_sidebar() |
26 | side_bar.go_to_place(object_name) |
27 | |
28 | + def get_folder_list_page(self): |
29 | + """Return the FolderListPage emulator of the MainView.""" |
30 | + page = self.wait_select_single(FolderListPage) |
31 | + page.main_view = self |
32 | + return page |
33 | + |
34 | def _go_to_place_from_popover(self, object_name): |
35 | popover = self.open_places() |
36 | place = popover.select_single('Standard', objectName=object_name) |
37 | @@ -70,11 +76,41 @@ |
38 | # --elopio - 2013-07-25 |
39 | return self.wait_select_single('Popover', objectName='placesPopover') |
40 | |
41 | - def get_folder_list_page(self): |
42 | - """Return the FolderListPage emulator of the MainView.""" |
43 | - page = self.wait_select_single(FolderListPage) |
44 | - page.main_view = self |
45 | - return page |
46 | + @autopilot.logging.log_action(logger.info) |
47 | + def rename(self, original_name, new_name): |
48 | + """Rename a file or directory. |
49 | + |
50 | + :param original_name: The name of the file or directory to rename. |
51 | + :param new_name: The new name to set for the file or directory. |
52 | + |
53 | + """ |
54 | + actions_popover = self.open_actions(original_name) |
55 | + actions_popover.click_button_by_text('Rename') |
56 | + confirm_dialog = self.wait_select_single(ConfirmDialogWithInput) |
57 | + confirm_dialog.enter_text(new_name) |
58 | + confirm_dialog.ok() |
59 | + |
60 | + @autopilot.logging.log_action(logger.info) |
61 | + def open_actions(self, name): |
62 | + """Open the list of available actions of a file or directory.""" |
63 | + folder_list_page = self.get_folder_list_page() |
64 | + folder_list_page.open_file_actions(name) |
65 | + actions_popover = self.get_action_selection_popover( |
66 | + 'fileActionsPopover') |
67 | + actions_popover.visible.wait_for(True) |
68 | + return actions_popover |
69 | + |
70 | + @autopilot.logging.log_action(logger.info) |
71 | + def delete(self, name): |
72 | + """Delete a file or directory. |
73 | + |
74 | + :param name: The name of the file or directory to delete. |
75 | + |
76 | + """ |
77 | + actions_popover = self.open_actions(name) |
78 | + actions_popover.click_button_by_text('Delete') |
79 | + confirm_dialog = self.wait_select_single(ConfirmDialog) |
80 | + confirm_dialog.ok() |
81 | |
82 | def get_file_actions_popover(self): |
83 | """Return the ActionSelectionPopover emulator of the file actions.""" |
84 | @@ -160,6 +196,27 @@ |
85 | class FolderListPage(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
86 | """FolderListPage Autopilot emulator.""" |
87 | |
88 | + def open_file_actions(self, name): |
89 | + """Open the actions menu of a file or folder. |
90 | + |
91 | + :param name: The name of the file or folder. |
92 | + |
93 | + """ |
94 | + delegate = self.get_file_by_name(name) |
95 | + delegate.open_actions_popover() |
96 | + |
97 | + def get_files_and_folders(self): |
98 | + """Return the list of files and folders of the opened directory. |
99 | + |
100 | + The list returned will contain the names of the files and folders. |
101 | + |
102 | + """ |
103 | + if self.showingListView: |
104 | + view = self.select_single(FolderListView) |
105 | + else: |
106 | + view = self.select_single(FolderIconView) |
107 | + return view.get_files_and_folders() |
108 | + |
109 | def get_number_of_files_from_list(self): |
110 | """Return the number of files shown on the folder.""" |
111 | if self.showingListView: |
112 | @@ -252,6 +309,16 @@ |
113 | _, number_of_files = self._split_header_text() |
114 | return int(number_of_files) |
115 | |
116 | + def get_files_and_folders(self): |
117 | + """Return the list of files and folders of the opened directory.""" |
118 | + list_delegates = self.select_many(FolderListDelegate) |
119 | + # sort by y, x |
120 | + list_delegates = sorted( |
121 | + list_delegates, |
122 | + key=lambda item: (item.globalRect.y, item.globalRect.x)) |
123 | + |
124 | + return [item.fileName for item in list_delegates] |
125 | + |
126 | |
127 | class FolderIconView(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
128 | """FolderListView Autopilot emulator.""" |
129 | @@ -278,6 +345,16 @@ |
130 | _, number_of_files = self._split_header_text() |
131 | return int(number_of_files) |
132 | |
133 | + def get_files_and_folders(self): |
134 | + """Return the list of files and folders of the opened directory.""" |
135 | + icon_delegates = self.select_many(FolderIconDelegate) |
136 | + # sort by y, x |
137 | + icon_delegates = sorted( |
138 | + icon_delegates, |
139 | + key=lambda icon: (icon.globalRect.y, icon.globalRect.x)) |
140 | + |
141 | + return [icon.fileName for icon in icon_delegates] |
142 | + |
143 | |
144 | class FolderListDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
145 | """FolderListPage Autopilot emulator. |
146 | @@ -391,27 +468,12 @@ |
147 | self.keyboard = input.Keyboard.create() |
148 | |
149 | def enter_text(self, text, clear=True): |
150 | - if clear: |
151 | - self.clear_text() |
152 | - text_field = self._select_text_field() |
153 | - self.pointing_device.click_object(text_field) |
154 | - self.keyboard.type(text) |
155 | - text_field.text.wait_for(text) |
156 | - |
157 | - def clear_text(self): |
158 | - text_field = self._select_text_field() |
159 | - # XXX The clear button doesn't have an objectName. Reported on |
160 | - # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205208 |
161 | - # --elopio - 2013-07-25 |
162 | - clear_button = text_field.select_single('AbstractButton') |
163 | - # XXX for some reason, we need to click the button twice. |
164 | - # More investigation is needed. --elopio - 2013-07-25 |
165 | - self.pointing_device.click_object(clear_button) |
166 | - self.pointing_device.click_object(clear_button) |
167 | - text_field.text.wait_for('') |
168 | + text_field = self._select_text_field() |
169 | + text_field.write(text, clear) |
170 | |
171 | def _select_text_field(self): |
172 | - return self.select_single('TextField', objectName='inputField') |
173 | + return self.select_single( |
174 | + toolkit_emulators.TextField, objectName='inputField') |
175 | |
176 | |
177 | class Dialog(ConfirmDialogWithInput): |
178 | |
179 | === added file 'tests/autopilot/filemanager/fixture_setup.py' |
180 | --- tests/autopilot/filemanager/fixture_setup.py 1970-01-01 00:00:00 +0000 |
181 | +++ tests/autopilot/filemanager/fixture_setup.py 2014-06-18 03:35:44 +0000 |
182 | @@ -0,0 +1,78 @@ |
183 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
184 | +# |
185 | +# Copyright (C) 2013, 2014 Canonical Ltd. |
186 | +# |
187 | +# This program is free software; you can redistribute it and/or modify |
188 | +# it under the terms of the GNU Lesser General Public License as published by |
189 | +# the Free Software Foundation; version 3. |
190 | +# |
191 | +# This program is distributed in the hope that it will be useful, |
192 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
193 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
194 | +# GNU Lesser General Public License for more details. |
195 | +# |
196 | +# You should have received a copy of the GNU Lesser General Public License |
197 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
198 | + |
199 | +import logging |
200 | +import os |
201 | +import shutil |
202 | +import tempfile |
203 | + |
204 | +import autopilot.logging |
205 | +import fixtures |
206 | + |
207 | + |
208 | +logger = logging.getLogger(__name__) |
209 | + |
210 | + |
211 | +class TemporaryFileInDirectory(fixtures.Fixture): |
212 | + """Create a temporafy file in a specified directory.""" |
213 | + |
214 | + def __init__(self, parent_directory): |
215 | + super(TemporaryFileInDirectory, self).__init__() |
216 | + self.parent_directory = parent_directory |
217 | + |
218 | + def setUp(self): |
219 | + super(TemporaryFileInDirectory, self).setUp() |
220 | + _, self.path = tempfile.mkstemp( |
221 | + prefix='tmpfm', dir=self.parent_directory) |
222 | + logger.debug( |
223 | + 'Created temporary file {} in {}.'.format( |
224 | + self.path, self.parent_directory)) |
225 | + self.addCleanup(self.delete_file, self.path) |
226 | + |
227 | + @autopilot.logging.log_action(logger.info) |
228 | + def delete_file(self, path): |
229 | + """Delete a file, if it exists.""" |
230 | + if os.path.exists(path): |
231 | + logger.debug('Deleting file.') |
232 | + os.remove(path) |
233 | + else: |
234 | + logger.debug('File does not exist.') |
235 | + |
236 | + |
237 | +class TemporaryDirectoryInDirectory(fixtures.Fixture): |
238 | + """Create a temporary directory in a specified directory.""" |
239 | + |
240 | + def __init__(self, parent_directory): |
241 | + super(TemporaryDirectoryInDirectory, self).__init__() |
242 | + self.parent_directory = parent_directory |
243 | + |
244 | + def setUp(self): |
245 | + super(TemporaryDirectoryInDirectory, self).setUp() |
246 | + self.path = tempfile.mkdtemp( |
247 | + prefix='tmpfm', dir=self.parent_directory) |
248 | + logger.debug( |
249 | + 'Created temporary directory {} in parent directory {}'.format( |
250 | + self.path, self.parent_directory)) |
251 | + self.addCleanup(self.delete_directory, self.path) |
252 | + |
253 | + @autopilot.logging.log_action(logger.info) |
254 | + def delete_directory(self, path): |
255 | + """Delete a directory, if it exists.""" |
256 | + if os.path.exists(path): |
257 | + logger.debug('Deleting directory.') |
258 | + shutil.rmtree(path) |
259 | + else: |
260 | + logger.debug('Directory does not exist.') |
261 | |
262 | === modified file 'tests/autopilot/filemanager/tests/__init__.py' |
263 | --- tests/autopilot/filemanager/tests/__init__.py 2014-06-17 02:32:55 +0000 |
264 | +++ tests/autopilot/filemanager/tests/__init__.py 2014-06-18 03:35:44 +0000 |
265 | @@ -16,9 +16,9 @@ |
266 | |
267 | """Filemanager app autopilot tests.""" |
268 | |
269 | +import logging |
270 | import os |
271 | import shutil |
272 | -import logging |
273 | |
274 | import fixtures |
275 | from autopilot import logging as autopilot_logging |
276 | @@ -32,7 +32,7 @@ |
277 | fixture_setup as toolkit_fixtures |
278 | ) |
279 | |
280 | -from filemanager import emulators |
281 | +from filemanager import emulators, fixture_setup |
282 | |
283 | logger = logging.getLogger(__name__) |
284 | |
285 | @@ -52,7 +52,7 @@ |
286 | local_location_qml = os.path.join(local_location, |
287 | 'src/app/qml/filemanager.qml') |
288 | local_location_binary = os.path.join(local_location, 'src/app/filemanager') |
289 | - installed_location_qml = "/usr/share/filemanager/qml/filemanager.qml" |
290 | + installed_location_qml = '/usr/share/filemanager/qml/filemanager.qml' |
291 | installed_location_binary = '/usr/bin/filemanager' |
292 | |
293 | def get_launcher_and_type(self): |
294 | @@ -111,18 +111,16 @@ |
295 | emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
296 | |
297 | def _copy_xauthority_file(self, directory): |
298 | - """ Copy .Xauthority file to directory, if it exists in /home |
299 | - """ |
300 | - xauth = os.path.expanduser(os.path.join('~', '.Xauthority')) |
301 | + """Copy .Xauthority file to directory, if it exists in /home""" |
302 | + xauth = os.path.join(os.environ.get('HOME'), '.Xauthority') |
303 | if os.path.isfile(xauth): |
304 | logger.debug("Copying .Xauthority to " + directory) |
305 | shutil.copyfile( |
306 | - os.path.expanduser(os.path.join('~', '.Xauthority')), |
307 | + os.path.join(os.environ.get('HOME'), '.Xauthority'), |
308 | os.path.join(directory, '.Xauthority')) |
309 | |
310 | def _patch_home(self): |
311 | - """ mock /home for testing purposes to preserve user data |
312 | - """ |
313 | + """mock /home for testing purposes to preserve user data""" |
314 | temp_dir_fixture = fixtures.TempDir() |
315 | self.useFixture(temp_dir_fixture) |
316 | temp_dir = temp_dir_fixture.path |
317 | @@ -142,10 +140,44 @@ |
318 | self.useFixture(fixtures.EnvironmentVariable('HOME', |
319 | newvalue=temp_dir)) |
320 | |
321 | - logger.debug("Patched home to fake home directory " + temp_dir) |
322 | + logger.debug('Patched home to fake home directory ' + temp_dir) |
323 | |
324 | return temp_dir |
325 | |
326 | @property |
327 | def main_view(self): |
328 | return self.app.wait_select_single(emulators.MainView) |
329 | + |
330 | + def make_file_in_home(self): |
331 | + return self.make_content_in_home('file') |
332 | + |
333 | + def make_directory_in_home(self): |
334 | + return self.make_content_in_home('directory') |
335 | + |
336 | + def make_content_in_home(self, type_): |
337 | + if type_ != 'file' and type_ != 'directory': |
338 | + raise ValueError('Unknown content type: "{0}"', type_) |
339 | + if type_ == 'file': |
340 | + temp_file = fixture_setup.TemporaryFileInDirectory(self.home_dir) |
341 | + self.useFixture(temp_file) |
342 | + path = temp_file.path |
343 | + else: |
344 | + temp_dir = fixture_setup.TemporaryDirectoryInDirectory( |
345 | + self.home_dir) |
346 | + self.useFixture(temp_dir) |
347 | + path = temp_dir.path |
348 | + logger.debug('Directory Listing for HOME\n%s' % |
349 | + os.listdir(self.home_dir)) |
350 | + self._assert_number_of_files(1) |
351 | + return path |
352 | + |
353 | + def _assert_number_of_files(self, expected_number_of_files, home=True): |
354 | + if home: |
355 | + expected_number_of_files += self.original_file_count |
356 | + folder_list_page = self.main_view.get_folder_list_page() |
357 | + self.assertThat( |
358 | + folder_list_page.get_number_of_files_from_list, |
359 | + Eventually(Equals(expected_number_of_files), timeout=60)) |
360 | + self.assertThat( |
361 | + folder_list_page.get_number_of_files_from_header, |
362 | + Eventually(Equals(expected_number_of_files), timeout=60)) |
363 | |
364 | === added file 'tests/autopilot/filemanager/tests/test_context_menu.py' |
365 | --- tests/autopilot/filemanager/tests/test_context_menu.py 1970-01-01 00:00:00 +0000 |
366 | +++ tests/autopilot/filemanager/tests/test_context_menu.py 2014-06-18 03:35:44 +0000 |
367 | @@ -0,0 +1,83 @@ |
368 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
369 | +# |
370 | +# Copyright (C) 2013, 2014 Canonical Ltd. |
371 | +# |
372 | +# This program is free software; you can redistribute it and/or modify |
373 | +# it under the terms of the GNU Lesser General Public License as published by |
374 | +# the Free Software Foundation; version 3. |
375 | +# |
376 | +# This program is distributed in the hope that it will be useful, |
377 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
378 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
379 | +# GNU Lesser General Public License for more details. |
380 | +# |
381 | +# You should have received a copy of the GNU Lesser General Public License |
382 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
383 | + |
384 | +import os |
385 | + |
386 | +from filemanager import tests |
387 | + |
388 | + |
389 | +class ContextMenuTestCase(tests.FileManagerTestCase): |
390 | + """Test cases for the context menu of the file manager app.""" |
391 | + |
392 | + def get_current_directory_files_and_folders(self): |
393 | + folder_list_page = self.main_view.get_folder_list_page() |
394 | + return folder_list_page.get_files_and_folders() |
395 | + |
396 | + def test_rename_directory(self): |
397 | + """Test renaming a directory. |
398 | + |
399 | + The name of the directory must be updated on the list of folder |
400 | + contents. |
401 | + |
402 | + """ |
403 | + original_directory = os.path.basename(self.make_directory_in_home()) |
404 | + new_name = original_directory + 'edit' |
405 | + |
406 | + self.main_view.rename(original_directory, new_name) |
407 | + |
408 | + files_and_folders = self.get_current_directory_files_and_folders() |
409 | + self.assertEquals(files_and_folders, [new_name]) |
410 | + |
411 | + def test_rename_file(self): |
412 | + """Test renaming a file. |
413 | + |
414 | + The name of the file must be updated on the list of folder contents. |
415 | + |
416 | + """ |
417 | + original_file = os.path.basename(self.make_file_in_home()) |
418 | + new_name = original_file + 'edit' |
419 | + |
420 | + self.main_view.rename(original_file, new_name) |
421 | + |
422 | + files_and_folders = self.get_current_directory_files_and_folders() |
423 | + self.assertEquals(files_and_folders, [new_name]) |
424 | + |
425 | + def test_delete_directory(self): |
426 | + """Test deleting a directory. |
427 | + |
428 | + The directory must no longer be displayed on the list of folder |
429 | + contents. |
430 | + |
431 | + """ |
432 | + dir_name = os.path.basename(self.make_directory_in_home()) |
433 | + |
434 | + self.main_view.delete(dir_name) |
435 | + |
436 | + files_and_folders = self.get_current_directory_files_and_folders() |
437 | + self.assertEquals(files_and_folders, []) |
438 | + |
439 | + def test_delete_file(self): |
440 | + """Test deleting a file. |
441 | + |
442 | + The file must no longer be displayed ont he list of folder contents. |
443 | + |
444 | + """ |
445 | + file_name = os.path.basename(self.make_file_in_home()) |
446 | + |
447 | + self.main_view.delete(file_name) |
448 | + |
449 | + files_and_folders = self.get_current_directory_files_and_folders() |
450 | + self.assertEquals(files_and_folders, []) |
451 | |
452 | === modified file 'tests/autopilot/filemanager/tests/test_filemanager.py' |
453 | --- tests/autopilot/filemanager/tests/test_filemanager.py 2014-06-10 02:34:07 +0000 |
454 | +++ tests/autopilot/filemanager/tests/test_filemanager.py 2014-06-18 03:35:44 +0000 |
455 | @@ -16,12 +16,10 @@ |
456 | |
457 | """File Manager app autopilot tests.""" |
458 | |
459 | -import tempfile |
460 | import unittest |
461 | import logging |
462 | |
463 | import os |
464 | -import shutil |
465 | |
466 | from autopilot import process |
467 | from autopilot.platform import model |
468 | @@ -35,42 +33,6 @@ |
469 | |
470 | class TestFolderListPage(FileManagerTestCase): |
471 | |
472 | - def _make_file_in_home(self): |
473 | - return self._make_content_in_home('file') |
474 | - |
475 | - def _make_content_in_home(self, type_): |
476 | - if type_ != 'file' and type_ != 'directory': |
477 | - raise ValueError('Unknown content type: "{0}"', type_) |
478 | - if type_ == 'file': |
479 | - _, path = tempfile.mkstemp(prefix='tmpfm', |
480 | - dir=self.home_dir) |
481 | - #path = self.home_dir + "/tmpfmFile" |
482 | - #os.system("touch " + path) |
483 | - logger.debug("Created %s, a file in HOME" % path) |
484 | - self.addCleanup(self._unlink_cleanup, path) |
485 | - else: |
486 | - path = tempfile.mkdtemp(prefix='tmpfm', dir=self.home_dir) |
487 | - #path = self.home_dir + "/tmpfmDir" |
488 | - #os.system("mkdir " + path) |
489 | - logger.debug("Created %s, a directory in HOME" % path) |
490 | - self.addCleanup(self._rmdir_cleanup, path) |
491 | - |
492 | - logger.debug("Directory Listing for HOME\n%s" % |
493 | - os.listdir(self.home_dir)) |
494 | - self._assert_number_of_files(1) |
495 | - return path |
496 | - |
497 | - def _assert_number_of_files(self, expected_number_of_files, home=True): |
498 | - if home: |
499 | - expected_number_of_files += self.original_file_count |
500 | - folder_list_page = self.main_view.get_folder_list_page() |
501 | - self.assertThat( |
502 | - folder_list_page.get_number_of_files_from_list, |
503 | - Eventually(Equals(expected_number_of_files), timeout=60)) |
504 | - self.assertThat( |
505 | - folder_list_page.get_number_of_files_from_header, |
506 | - Eventually(Equals(expected_number_of_files), timeout=60)) |
507 | - |
508 | def _get_file_by_name(self, name): |
509 | folder_list_page = self.main_view.get_folder_list_page() |
510 | fileDelegate = lambda: folder_list_page.get_file_by_name(name) |
511 | @@ -104,9 +66,6 @@ |
512 | goto_location.enter_text(location) |
513 | goto_location.ok() |
514 | |
515 | - def _make_directory_in_home(self): |
516 | - return self._make_content_in_home('directory') |
517 | - |
518 | def _open_directory(self, item): |
519 | expected_path = item.filePath |
520 | list_view = item.list_view |
521 | @@ -155,24 +114,12 @@ |
522 | confirm_dialog.enter_text(text) |
523 | confirm_dialog.ok() |
524 | |
525 | - def _unlink_cleanup(self, filename): |
526 | - logger.debug("Cleanup; checking to remove %s file" % filename) |
527 | - if os.path.exists(filename): |
528 | - logger.debug("Removing %s file" % filename) |
529 | - os.unlink(filename) |
530 | - |
531 | - def _rmdir_cleanup(self, directory): |
532 | - logger.debug("Cleanup; checking to remove %s directory" % directory) |
533 | - if os.path.exists(directory): |
534 | - logger.debug("Removing %s directory" % directory) |
535 | - shutil.rmtree(directory) |
536 | - |
537 | # We can't do this testcase on phablet devices because of a lack of |
538 | # Mir backend in autopilot |
539 | # see https://bugs.launchpad.net/autopilot/+bug/1209004 |
540 | @unittest.skip("Can't do this properly on desktop or phablet") |
541 | def test_open_file(self): |
542 | - self._make_file_in_home() |
543 | + self.make_file_in_home() |
544 | |
545 | first_file = self._get_file_by_index(0) |
546 | self.pointing_device.click_object(first_file) |
547 | @@ -205,23 +152,8 @@ |
548 | window = new_app.get_windows()[0] |
549 | window.close() |
550 | |
551 | - def test_rename_directory(self): |
552 | - orig_dir = os.path.basename(self._make_directory_in_home()) |
553 | - new_name = 'Renamed directory' |
554 | - self.addCleanup(self._rmdir_cleanup, |
555 | - os.path.join(self.home_dir, new_name)) |
556 | - |
557 | - first_dir = self._get_file_by_name(orig_dir) |
558 | - self._do_action_on_file(first_dir, action='Rename') |
559 | - self._confirm_dialog(new_name) |
560 | - |
561 | - self.assertThat( |
562 | - self.main_view.confirm_dialog_exists, Eventually(Equals(False))) |
563 | - self.assertThat(self._get_file_by_index(0).fileName, |
564 | - Eventually(Equals(new_name))) |
565 | - |
566 | def test_open_directory(self): |
567 | - dir_path = self._make_directory_in_home() |
568 | + dir_path = self.make_directory_in_home() |
569 | first_dir = self._get_file_by_name(os.path.basename(dir_path)) |
570 | |
571 | self._open_directory(first_dir) |
572 | @@ -233,21 +165,10 @@ |
573 | # TODO check the label that says the directory is empty. |
574 | # --elopio - 2013-07-25 |
575 | |
576 | - def test_folder_context_menu_shows(self): |
577 | - """Checks to make sure that the folder actions popover is shown.""" |
578 | - dir_path = os.path.basename(self._make_directory_in_home()) |
579 | - |
580 | - first_file = self._get_file_by_name(dir_path) |
581 | - self._safe_open_popover(first_file.open_actions_popover) |
582 | - |
583 | - file_actions_popover = self.main_view.get_file_actions_popover() |
584 | - self.assertThat( |
585 | - lambda: file_actions_popover.visible, Eventually(Equals(True))) |
586 | - |
587 | def test_list_folder_contents(self): |
588 | - dir_path = self._make_directory_in_home() |
589 | + dir_path = self.make_directory_in_home() |
590 | dir_name = os.path.basename(dir_path) |
591 | - file_path = self._make_file_in_home() |
592 | + file_path = self.make_file_in_home() |
593 | file_name = os.path.basename(file_path) |
594 | |
595 | self._assert_number_of_files(2) |
596 | @@ -259,7 +180,7 @@ |
597 | self.assertThat(file_.fileName, Eventually(Equals(file_name))) |
598 | |
599 | def test_cancel_rename_directory(self): |
600 | - dir_path = self._make_directory_in_home() |
601 | + dir_path = self.make_directory_in_home() |
602 | dir_name = os.path.basename(dir_path) |
603 | |
604 | first_dir = self._get_file_by_name(dir_name) |
605 | @@ -272,7 +193,7 @@ |
606 | lambda: first_dir.fileName, Eventually(Equals(dir_name))) |
607 | |
608 | def test_cancel_rename_file(self): |
609 | - file_path = self._make_file_in_home() |
610 | + file_path = self.make_file_in_home() |
611 | file_name = os.path.basename(file_path) |
612 | |
613 | first_file = self._get_file_by_name(file_name) |
614 | @@ -285,22 +206,8 @@ |
615 | lambda: first_file.fileName, |
616 | Eventually(Equals(file_name))) |
617 | |
618 | - def test_rename_file(self): |
619 | - file_name = os.path.basename(self._make_file_in_home()) |
620 | - new_name = 'Renamed file' |
621 | - self.addCleanup(self._unlink_cleanup, new_name) |
622 | - |
623 | - first_file = self._get_file_by_name(file_name) |
624 | - self._do_action_on_file(first_file, action='Rename') |
625 | - self._confirm_dialog(new_name) |
626 | - |
627 | - self.assertThat( |
628 | - self.main_view.confirm_dialog_exists, Eventually(Equals(False))) |
629 | - self.assertThat(self._get_file_by_index(0).fileName, |
630 | - Eventually(Equals(new_name))) |
631 | - |
632 | def test_cancel_delete_directory(self): |
633 | - dir_name = os.path.basename(self._make_directory_in_home()) |
634 | + dir_name = os.path.basename(self.make_directory_in_home()) |
635 | first_dir = self._get_file_by_name(dir_name) |
636 | |
637 | self._do_action_on_file(first_dir, 'Delete') |
638 | @@ -308,17 +215,8 @@ |
639 | |
640 | self._assert_number_of_files(1) |
641 | |
642 | - def test_delete_directory(self): |
643 | - dir_name = os.path.basename(self._make_directory_in_home()) |
644 | - first_dir = self._get_file_by_name(dir_name) |
645 | - |
646 | - self._do_action_on_file(first_dir, 'Delete') |
647 | - self._confirm_dialog() |
648 | - |
649 | - self._assert_number_of_files(0) |
650 | - |
651 | def test_cancel_delete_file(self): |
652 | - file_name = os.path.basename(self._make_file_in_home()) |
653 | + file_name = os.path.basename(self.make_file_in_home()) |
654 | first_file = self._get_file_by_name(file_name) |
655 | |
656 | self._do_action_on_file(first_file, 'Delete') |
657 | @@ -326,19 +224,8 @@ |
658 | |
659 | self._assert_number_of_files(1) |
660 | |
661 | - def test_delete_file(self): |
662 | - file_name = os.path.basename(self._make_file_in_home()) |
663 | - first_file = self._get_file_by_name(file_name) |
664 | - |
665 | - self._do_action_on_file(first_file, 'Delete') |
666 | - self._confirm_dialog() |
667 | - |
668 | - self._assert_number_of_files(0) |
669 | - |
670 | def test_create_directory(self): |
671 | dir_name = 'Test Directory' |
672 | - self.addCleanup(self._rmdir_cleanup, |
673 | - os.path.join(self.home_dir, dir_name)) |
674 | |
675 | open_popover = lambda: \ |
676 | self.main_view.open_toolbar().click_button('actions') |
677 | @@ -365,7 +252,7 @@ |
678 | self._assert_number_of_files(0) |
679 | |
680 | def test_show_directory_properties_from_list(self): |
681 | - dir_path = self._make_directory_in_home() |
682 | + dir_path = self.make_directory_in_home() |
683 | dir_name = os.path.basename(dir_path) |
684 | first_dir = self._get_file_by_name(dir_name) |
685 | |
686 | @@ -379,7 +266,7 @@ |
687 | # --elopio - 2013-07-25 |
688 | |
689 | def test_show_file_properties(self): |
690 | - file_path = self._make_file_in_home() |
691 | + file_path = self.make_file_in_home() |
692 | file_name = os.path.basename(file_path) |
693 | first_file = self._get_file_by_name(file_name) |
694 | |
695 | @@ -396,11 +283,9 @@ |
696 | 'destination') |
697 | destination_dir_name = os.path.basename(destination_dir_path) |
698 | os.mkdir(destination_dir_path) |
699 | - self.addCleanup(self._rmdir_cleanup, destination_dir_path) |
700 | dir_to_copy_path = os.path.join(self.home_dir, 'to_copy') |
701 | dir_to_copy_name = os.path.basename(dir_to_copy_path) |
702 | os.mkdir(dir_to_copy_path) |
703 | - self.addCleanup(self._rmdir_cleanup, dir_to_copy_path) |
704 | |
705 | folder_list_page = self.main_view.get_folder_list_page() |
706 | self._assert_number_of_files(2) |
707 | @@ -444,11 +329,9 @@ |
708 | 'destination') |
709 | destination_dir_name = os.path.basename(destination_dir_path) |
710 | os.mkdir(destination_dir_path) |
711 | - self.addCleanup(self._rmdir_cleanup, destination_dir_path) |
712 | dir_to_cut_path = os.path.join(self.home_dir, 'to_cut') |
713 | dir_to_cut_name = os.path.basename(dir_to_cut_path) |
714 | os.mkdir(dir_to_cut_path) |
715 | - self.addCleanup(self._rmdir_cleanup, dir_to_cut_path) |
716 | |
717 | folder_list_page = self.main_view.get_folder_list_page() |
718 | self._assert_number_of_files(2) |
719 | @@ -491,9 +374,9 @@ |
720 | |
721 | def test_copy_file(self): |
722 | # Set up a file to copy and a directory to copy it into. |
723 | - destination_dir_path = self._make_directory_in_home() |
724 | + destination_dir_path = self.make_directory_in_home() |
725 | destination_dir_name = os.path.basename(destination_dir_path) |
726 | - file_to_copy_path = self._make_file_in_home() |
727 | + file_to_copy_path = self.make_file_in_home() |
728 | file_to_copy_name = os.path.basename(file_to_copy_path) |
729 | |
730 | folder_list_page = self.main_view.get_folder_list_page() |
731 | @@ -538,9 +421,9 @@ |
732 | |
733 | def test_cut_file(self): |
734 | # Set up a file to cut and a directory to move it into. |
735 | - destination_dir_path = self._make_directory_in_home() |
736 | + destination_dir_path = self.make_directory_in_home() |
737 | destination_dir_name = os.path.basename(destination_dir_path) |
738 | - file_to_cut_path = self._make_file_in_home() |
739 | + file_to_cut_path = self.make_file_in_home() |
740 | file_to_cut_name = os.path.basename(file_to_cut_path) |
741 | |
742 | folder_list_page = self.main_view.get_folder_list_page() |
743 | @@ -583,7 +466,7 @@ |
744 | first_dir.fileName, Eventually(Equals(destination_dir_name))) |
745 | |
746 | def test_go_up(self): |
747 | - dir_name = os.path.basename(self._make_directory_in_home()) |
748 | + dir_name = os.path.basename(self.make_directory_in_home()) |
749 | first_dir = self._get_file_by_name(dir_name) |
750 | self._open_directory(first_dir) |
751 | |
752 | @@ -594,14 +477,3 @@ |
753 | self.assertThat( |
754 | folder_list_page.get_current_path, |
755 | Eventually(Equals(self.home_dir))) |
756 | - |
757 | - def test_file_context_menu_shows(self): |
758 | - """Checks to make sure that the file actions popover is shown.""" |
759 | - file_name = os.path.basename(self._make_file_in_home()) |
760 | - |
761 | - first_file = self._get_file_by_name(file_name) |
762 | - self._safe_open_popover(first_file.open_actions_popover) |
763 | - |
764 | - file_actions_popover = self.main_view.get_file_actions_popover() |
765 | - self.assertThat( |
766 | - lambda: file_actions_popover.visible, Eventually(Equals(True))) |
PASSED: Continuous integration, rev:201 91.189. 93.70:8080/ job/ubuntu- filemanager- app-ci/ 251/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 508 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 508/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/ubuntu- filemanager- app-utopic- amd64-ci/ 49
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/ 251/rebuild
http://