Merge lp:~nskaggs/ubuntu-filemanager-app/setup-ap-env into lp:ubuntu-filemanager-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 190
Merged at revision: 173
Proposed branch: lp:~nskaggs/ubuntu-filemanager-app/setup-ap-env
Merge into: lp:ubuntu-filemanager-app
Diff against target: 788 lines (+199/-177)
4 files modified
src/app/qml/components/AutoSpacedGrid.qml (+2/-1)
tests/autopilot/filemanager/emulators.py (+26/-58)
tests/autopilot/filemanager/tests/__init__.py (+68/-41)
tests/autopilot/filemanager/tests/test_filemanager.py (+103/-77)
To merge this branch: bzr merge lp:~nskaggs/ubuntu-filemanager-app/setup-ap-env
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Leo Arias (community) Approve
Review via email: mp+218836@code.launchpad.net

Commit message

Properly setup environment for test running
Fix test in accordance with source changes
Fix flo tests
Restore skipped tests

Description of the change

Properly setup environment for test running by mocking home and tweaking launching
Fix test in accordance with source changes
Fix flo tests
Restore skipped tests

To post a comment you must log in.
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) :
review: Approve
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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
181. By Nicholas Skaggs

finish wide UI fixes

182. By Nicholas Skaggs

fix local launching

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

migrate to ActionSelectionPopover from emulator

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
184. By Nicholas Skaggs

popover fixes

185. By Nicholas Skaggs

flake8 fixes

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
186. By Nicholas Skaggs

encapsulate all popover calls, remove skip's from tests

187. By Nicholas Skaggs

fix typos

188. By Nicholas Skaggs

tweaks to _safe_open_popover

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

tweaks

190. By Nicholas Skaggs

missing ()

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/components/AutoSpacedGrid.qml'
2--- src/app/qml/components/AutoSpacedGrid.qml 2014-03-29 09:20:11 +0000
3+++ src/app/qml/components/AutoSpacedGrid.qml 2014-05-08 23:20:37 +0000
4@@ -71,7 +71,8 @@
5
6 function calcSpacing(count) {
7 var spacing = (width - count * cellWidth)/(count)
8- print("Spacing for count", count, "is", spacing/8, "gu")
9+ //this is REALLY spammy on the console, only use for debugging
10+ //print("Spacing for count", count, "is", spacing/8, "gu")
11 return spacing
12 }
13
14
15=== modified file 'tests/autopilot/filemanager/emulators.py'
16--- tests/autopilot/filemanager/emulators.py 2014-05-01 18:35:42 +0000
17+++ tests/autopilot/filemanager/emulators.py 2014-05-08 23:20:37 +0000
18@@ -36,30 +36,39 @@
19
20 def get_file_actions_popover(self):
21 """Return the ActionSelectionPopover emulator of the file actions."""
22- return self.wait_select_single(
23- ActionSelectionPopover, objectName='fileActionsPopover')
24+ return self.get_action_selection_popover('fileActionsPopover')
25
26 def get_folder_actions_popover(self):
27 """Return the ActionSelectionPopover emulator of the folder actions."""
28- return self.wait_select_single(
29- ActionSelectionPopover, objectName='folderActionsPopover')
30+ return self.get_action_selection_popover('folderActionsPopover')
31
32 def folder_actions_popover_exists(self):
33- """Boolean, checks if the Actions Popover exists."""
34- popover = self.select_many(
35- ActionSelectionPopover, objectName='folderActionsPopover')
36- if popover == '[]':
37- return True
38- return False
39+ """Boolean, checks if the folder actions popover exists."""
40+ try:
41+ popover = self.get_folder_actions_popover()
42+ if popover:
43+ return True
44+ except:
45+ return False
46+
47+ def file_actions_popover_exists(self):
48+ """Boolean, checks if the file actions popover exists."""
49+ try:
50+ popover = self.get_file_actions_popover()
51+ if popover:
52+ return True
53+ except:
54+ return False
55
56 def get_places_popover(self):
57 """Return the Places popover."""
58- if not self.internal_wideAspect:
59+ if not self.showSidebar:
60 # XXX It would be easier if the places popover was an object
61 # that inherits from Popover, like the
62 # ActionSelectionPopover does.
63 # --elopio - 2013-07-25
64- return self.select_single('Popover', objectName='placesPopover')
65+ return self.wait_select_single('Popover',
66+ objectName='placesPopover')
67 else:
68 raise ValueError(
69 'Places sidebar is hidden in wide mode.')
70@@ -172,14 +181,14 @@
71 return self.select_single(FolderIconView).get_number_of_files()
72
73 def get_sidebar(self):
74- if self.main_view.internal_wideAspect:
75+ if self.main_view.showSidebar:
76 return self.select_single(PlacesSidebar)
77 else:
78 raise ValueError(
79 'Places sidebar is hidden in small mode.')
80
81 def get_pathbar(self):
82- if self.main_view.internal_wideAspect:
83+ if self.main_view.showSidebar:
84 return self.main_view.get_toolbar().select_single(PathBar)
85 else:
86 raise ValueError(
87@@ -200,7 +209,7 @@
88
89 def _split_header_text(self):
90 header_text = self.select_single(
91- 'Header', objectName='directoryHeader').text
92+ 'Header', objectName='listViewSmallHeader').text
93 match = re.match(self.SPLIT_HEADER_REGEX, header_text)
94 if match:
95 path = match.group(1)
96@@ -270,13 +279,8 @@
97 """Open the actions popover of the file or folder."""
98 self.pointing_device.move_to_object(self)
99 self.pointing_device.press()
100- time.sleep(1)
101+ time.sleep(2)
102 self.pointing_device.release()
103- # TODO wait for the popover to be opened. For this we would need to
104- # access the MainView, but that's not currently possible with
105- # autopilot. Reported on
106- # https://bugs.launchpad.net/autopilot/+bug/1195141
107- # --elopio - 2013-07-25
108
109
110 class FolderIconDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
111@@ -311,13 +315,8 @@
112 """Open the actions popover of the file or folder."""
113 self.pointing_device.move_to_object(self)
114 self.pointing_device.press()
115- time.sleep(1)
116+ time.sleep(2)
117 self.pointing_device.release()
118- # TODO wait for the popover to be opened. For this we would need to
119- # access the MainView, but that's not currently possible with
120- # autopilot. Reported on
121- # https://bugs.launchpad.net/autopilot/+bug/1195141
122- # --elopio - 2013-07-25
123
124
125 class FileActionDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
126@@ -336,37 +335,6 @@
127 self.pointing_device.click_object(cancel_button)
128
129
130-class ActionSelectionPopover(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
131- """ActionSelectionPopover Autopilot emulator."""
132- # TODO Move this to the ubuntu-ui-toolkit. Reported on
133- # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205205
134- # --elopio - 2013-07-25
135-
136- def __init__(self, *args):
137- super(ActionSelectionPopover, self).__init__(*args)
138- self.pointing_device = toolkit_emulators.get_pointing_device()
139-
140- def click_button(self, text):
141- """Click a button on the popover.
142-
143- XXX We are receiving the text because there's no way to set the
144- objectName on the action. This is reported at
145- https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205144
146- --elopio - 2013-07-25
147-
148- :parameter text: The text of the button.
149-
150- """
151- button = self._get_button(text)
152- self.pointing_device.click_object(button)
153-
154- def _get_button(self, text):
155- buttons = self.select_many('Empty')
156- for button in buttons:
157- if button.text == text:
158- return button
159-
160-
161 class ConfirmDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
162 """ConfirmDialog Autopilot emulator."""
163
164
165=== modified file 'tests/autopilot/filemanager/tests/__init__.py'
166--- tests/autopilot/filemanager/tests/__init__.py 2014-05-01 18:35:42 +0000
167+++ tests/autopilot/filemanager/tests/__init__.py 2014-05-08 23:20:37 +0000
168@@ -9,7 +9,6 @@
169
170 import os
171 import shutil
172-import tempfile
173 import logging
174
175 import fixtures
176@@ -21,7 +20,8 @@
177 from autopilot import logging as autopilot_logging
178
179 from ubuntuuitoolkit import (
180- emulators as toolkit_emulators
181+ emulators as toolkit_emulators,
182+ fixture_setup as toolkit_fixtures
183 )
184
185 logger = logging.getLogger(__name__)
186@@ -38,8 +38,28 @@
187 else:
188 scenarios = [('with touch', dict(input_device_class=Touch))]
189
190+ local_location = os.path.dirname(os.path.dirname(os.getcwd()))
191+ local_location_qml = os.path.join(local_location,
192+ 'src/app/qml/filemanager.qml')
193+ local_location_binary = os.path.join(local_location, 'src/app/filemanager')
194+ installed_location_qml = "/usr/share/filemanager/qml/filemanager.qml"
195+ installed_location_binary = '/usr/bin/filemanager'
196+
197+ def get_launcher_and_type(self):
198+ if os.path.exists(self.local_location_binary):
199+ launcher = self.launch_test_local
200+ test_type = 'local'
201+ elif os.path.exists(self.installed_location_binary):
202+ launcher = self.launch_test_installed
203+ test_type = 'deb'
204+ else:
205+ launcher = self.launch_test_click
206+ test_type = 'click'
207+ return launcher, test_type
208+
209 def setUp(self):
210- self._create_test_root()
211+ launcher, self.test_type = self.get_launcher_and_type()
212+ self.home_dir = self._patch_home()
213 self.pointing_device = Pointer(self.input_device_class.create())
214 super(FileManagerTestCase, self).setUp()
215
216@@ -49,51 +69,22 @@
217 self.addCleanup(os.system, 'start maliit-server')
218
219 self.original_file_count = \
220- len([i for i in os.listdir(os.environ['TESTHOME'])
221+ len([i for i in os.listdir(self.home_dir)
222 if not i.startswith('.')])
223- logger.debug('Directory Listing for TESTHOME\n%s' %
224- os.listdir(os.environ['TESTHOME']))
225- logger.debug('File count in TESTHOME is %s' % self.original_file_count)
226-
227- self.EXEC = 'filemanager'
228- self.source_dir = os.path.dirname(
229- os.path.dirname(os.path.abspath('.')))
230- self.build_dir = self._get_build_dir()
231- self.local_location_binary = os.path.join(self.build_dir,
232- 'src', 'app', self.EXEC)
233- self.installed_location_binary = os.path.join('/usr/bin/', self.EXEC)
234- self.installed_location_qml = \
235- '/usr/share/filemanager/qml/filemanager.qml'
236-
237- if os.path.exists(self.local_location_binary):
238- self.app = self.launch_test_local()
239- elif os.path.exists(self.installed_location_binary):
240- self.app = self.launch_test_installed()
241- else:
242- self.app = self.launch_test_click()
243-
244- def _get_build_dir(self):
245- build_dir = self.source_dir
246-
247- return build_dir
248-
249- def _create_test_root(self):
250- #create a temporary directory for testing purposes
251- #due to security lockdowns, make it under /home always
252- temp_dir = tempfile.mkdtemp(dir=os.path.expanduser('~'))
253- self.addCleanup(shutil.rmtree, temp_dir)
254- logger.debug('Created root test directory ' + temp_dir)
255- self.patch_environment('TESTHOME', temp_dir)
256- return temp_dir
257+ logger.debug('Directory Listing for HOME\n%s' %
258+ os.listdir(self.home_dir))
259+ logger.debug('File count in HOME is %s' % self.original_file_count)
260+
261+ self.app = launcher()
262
263 @autopilot_logging.log_action(logger.info)
264 def launch_test_local(self):
265 self.useFixture(fixtures.EnvironmentVariable(
266- 'QML2_IMPORT_PATH', newvalue=os.path.join(self.build_dir,
267+ 'QML2_IMPORT_PATH', newvalue=os.path.join(self.local_location,
268 'src', 'plugin')))
269-
270 return self.launch_test_application(
271 self.local_location_binary,
272+ '-q', self.local_location_qml,
273 app_type='qt',
274 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
275
276@@ -111,6 +102,42 @@
277 'com.ubuntu.filemanager',
278 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
279
280+ def _copy_xauthority_file(self, directory):
281+ """ Copy .Xauthority file to directory, if it exists in /home
282+ """
283+ xauth = os.path.expanduser(os.path.join('~', '.Xauthority'))
284+ if os.path.isfile(xauth):
285+ logger.debug("Copying .Xauthority to " + directory)
286+ shutil.copyfile(
287+ os.path.expanduser(os.path.join('~', '.Xauthority')),
288+ os.path.join(directory, '.Xauthority'))
289+
290+ def _patch_home(self):
291+ """ mock /home for testing purposes to preserve user data
292+ """
293+ temp_dir_fixture = fixtures.TempDir()
294+ self.useFixture(temp_dir_fixture)
295+ temp_dir = temp_dir_fixture.path
296+
297+ #If running under xvfb, as jenkins does,
298+ #xsession will fail to start without xauthority file
299+ #Thus if the Xauthority file is in the home directory
300+ #make sure we copy it to our temp home directory
301+ self._copy_xauthority_file(temp_dir)
302+
303+ #click requires using initctl env (upstart), but the desktop can set
304+ #an environment variable instead
305+ if self.test_type == 'click':
306+ self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable(
307+ HOME=temp_dir))
308+ else:
309+ self.useFixture(fixtures.EnvironmentVariable('HOME',
310+ newvalue=temp_dir))
311+
312+ logger.debug("Patched home to fake home directory " + temp_dir)
313+
314+ return temp_dir
315+
316 @property
317 def main_view(self):
318- return self.app.select_single(emulators.MainView)
319+ return self.app.wait_select_single(emulators.MainView)
320
321=== modified file 'tests/autopilot/filemanager/tests/test_filemanager.py'
322--- tests/autopilot/filemanager/tests/test_filemanager.py 2014-05-01 18:35:42 +0000
323+++ tests/autopilot/filemanager/tests/test_filemanager.py 2014-05-08 23:20:37 +0000
324@@ -39,31 +39,29 @@
325 super(TestFolderListPage, self).setUp()
326 self.assertThat(
327 self.main_view.visible, Eventually(Equals(True)))
328- #start in testhome everytime
329- self._go_to_location(os.environ['TESTHOME'])
330-
331- def _make_file_in_testhome(self):
332- return self._make_content_in_testhome('file')
333-
334- def _make_content_in_testhome(self, type_):
335+
336+ def _make_file_in_home(self):
337+ return self._make_content_in_home('file')
338+
339+ def _make_content_in_home(self, type_):
340 if type_ != 'file' and type_ != 'directory':
341 raise ValueError('Unknown content type: "{0}"', type_)
342 if type_ == 'file':
343 _, path = tempfile.mkstemp(prefix='tmpfm',
344- dir=os.environ['TESTHOME'])
345- #path = os.environ['TESTHOME'] + "/tmpfmFile"
346+ dir=self.home_dir)
347+ #path = self.home_dir + "/tmpfmFile"
348 #os.system("touch " + path)
349- logger.debug("Created %s, a file in TESTHOME" % path)
350+ logger.debug("Created %s, a file in HOME" % path)
351 self.addCleanup(self._unlink_cleanup, path)
352 else:
353- path = tempfile.mkdtemp(prefix='tmpfm', dir=os.environ['TESTHOME'])
354- #path = os.environ['TESTHOME'] + "/tmpfmDir"
355+ path = tempfile.mkdtemp(prefix='tmpfm', dir=self.home_dir)
356+ #path = self.home_dir + "/tmpfmDir"
357 #os.system("mkdir " + path)
358- logger.debug("Created %s, a directory in TESTHOME" % path)
359+ logger.debug("Created %s, a directory in HOME" % path)
360 self.addCleanup(self._rmdir_cleanup, path)
361
362- logger.debug("Directory Listing for TESTHOME\n%s" %
363- os.listdir(os.environ['TESTHOME']))
364+ logger.debug("Directory Listing for HOME\n%s" %
365+ os.listdir(self.home_dir))
366 self._assert_number_of_files(1)
367 return path
368
369@@ -100,29 +98,31 @@
370 # https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1205201
371 # --elopio - 2013-07-25
372 place = None
373- if self.main_view.internal_wideAspect:
374+ if self.main_view.showSidebar:
375 place = (self.main_view.get_folder_list_page().get_sidebar()
376 .get_place(text))
377 else:
378- self.main_view.open_toolbar()
379- self.main_view.get_toolbar().click_button('places')
380+ open_popover = lambda: \
381+ self.main_view.open_toolbar().click_button('places')
382+ self._safe_open_popover(open_popover)
383 place = self._get_place(text)
384 self.pointing_device.click_object(place)
385
386 def _go_to_location(self, location):
387 #go to specified location
388- toolbar = self.main_view.open_toolbar()
389 #on wide UI display, we get the location dialog
390 #on phone UI display, we get places popover
391 device = model()
392- if self.main_view.internal_wideAspect:
393+ if self.main_view.showSidebar:
394 logger.debug("Using goto to goto %s on %s" % (location, device))
395 (self.main_view.get_folder_list_page().get_pathbar()
396 .go_to_location())
397 goto_location = self.main_view.get_dialog()
398 else:
399 logger.debug("Using places to goto %s on %s" % (location, device))
400- toolbar.click_button('places')
401+ open_popover = lambda: \
402+ self.main_view.open_toolbar().click_button('places')
403+ self._safe_open_popover(open_popover)
404 goto_location = self.main_view.get_popover()
405 goto_location.enter_text(location)
406 goto_location.ok()
407@@ -136,8 +136,8 @@
408 raise ValueError(
409 'Place "{0}" not found.'.format(text))
410
411- def _make_directory_in_testhome(self):
412- return self._make_content_in_testhome('directory')
413+ def _make_directory_in_home(self):
414+ return self._make_content_in_home('directory')
415
416 def _open_directory(self, item):
417 expected_path = item.filePath
418@@ -148,11 +148,34 @@
419 self.assertThat(
420 list_view.get_current_path, Eventually(Equals(expected_path)))
421
422+ def _check_popover_exists(self):
423+ """Boolean, checks if popover exists."""
424+ try:
425+ popover = \
426+ self.main_view.wait_select_single('ActionSelectionPopover')
427+ if popover:
428+ return True
429+ except:
430+ try:
431+ popover = self.main_view.wait_select_single('Popover')
432+ if popover:
433+ return True
434+ except:
435+ return False
436+
437+ def _safe_open_popover(self, popover_open_function):
438+ timeout = 0
439+ popover_exists = False
440+ while timeout < 3 and not popover_exists:
441+ popover_open_function()
442+ popover_exists = self._check_popover_exists()
443+ timeout += 1
444+
445 def _do_action_on_file(self, file_, action):
446 logger.debug("Performing %s on file %s" % (action, file_))
447- file_.open_actions_popover()
448+ self._safe_open_popover(file_.open_actions_popover)
449 file_actions_popover = self.main_view.get_file_actions_popover()
450- file_actions_popover.click_button(action)
451+ file_actions_popover.click_button_by_text(action)
452
453 def _cancel_confirm_dialog(self):
454 confirm_dialog = self.main_view.get_confirm_dialog()
455@@ -181,7 +204,7 @@
456 # see https://bugs.launchpad.net/autopilot/+bug/1209004
457 @unittest.skip("Can't do this properly on desktop or phablet")
458 def test_open_file(self):
459- self._make_file_in_testhome()
460+ self._make_file_in_home()
461
462 first_file = self._get_file_by_index(0)
463 self.pointing_device.click_object(first_file)
464@@ -215,10 +238,10 @@
465 window.close()
466
467 def test_rename_directory(self):
468- orig_dir = os.path.basename(self._make_directory_in_testhome())
469+ orig_dir = os.path.basename(self._make_directory_in_home())
470 new_name = 'Renamed directory'
471 self.addCleanup(self._rmdir_cleanup,
472- os.path.join(os.environ['TESTHOME'], new_name))
473+ os.path.join(self.home_dir, new_name))
474
475 first_dir = self._get_file_by_name(orig_dir)
476 self._do_action_on_file(first_dir, action='Rename')
477@@ -230,7 +253,7 @@
478 Eventually(Equals(new_name)))
479
480 def test_open_directory(self):
481- dir_path = self._make_directory_in_testhome()
482+ dir_path = self._make_directory_in_home()
483 first_dir = self._get_file_by_name(os.path.basename(dir_path))
484
485 self._open_directory(first_dir)
486@@ -244,20 +267,19 @@
487
488 def test_folder_context_menu_shows(self):
489 """Checks to make sure that the folder actions popover is shown."""
490- dir_path = os.path.basename(self._make_directory_in_testhome())
491+ dir_path = os.path.basename(self._make_directory_in_home())
492
493 first_file = self._get_file_by_name(dir_path)
494- first_file.open_actions_popover()
495+ self._safe_open_popover(first_file.open_actions_popover)
496
497 file_actions_popover = self.main_view.get_file_actions_popover()
498 self.assertThat(
499 lambda: file_actions_popover.visible, Eventually(Equals(True)))
500
501- @unittest.skip("Fails in lab due to lab issues not present on phone")
502 def test_list_folder_contents(self):
503- dir_path = self._make_directory_in_testhome()
504+ dir_path = self._make_directory_in_home()
505 dir_name = os.path.basename(dir_path)
506- file_path = self._make_file_in_testhome()
507+ file_path = self._make_file_in_home()
508 file_name = os.path.basename(file_path)
509
510 self._assert_number_of_files(2)
511@@ -269,7 +291,7 @@
512 self.assertThat(file_.fileName, Eventually(Equals(file_name)))
513
514 def test_cancel_rename_directory(self):
515- dir_path = self._make_directory_in_testhome()
516+ dir_path = self._make_directory_in_home()
517 dir_name = os.path.basename(dir_path)
518
519 first_dir = self._get_file_by_name(dir_name)
520@@ -282,7 +304,7 @@
521 lambda: first_dir.fileName, Eventually(Equals(dir_name)))
522
523 def test_cancel_rename_file(self):
524- file_path = self._make_file_in_testhome()
525+ file_path = self._make_file_in_home()
526 file_name = os.path.basename(file_path)
527
528 first_file = self._get_file_by_name(file_name)
529@@ -296,7 +318,7 @@
530 Eventually(Equals(file_name)))
531
532 def test_rename_file(self):
533- file_name = os.path.basename(self._make_file_in_testhome())
534+ file_name = os.path.basename(self._make_file_in_home())
535 new_name = 'Renamed file'
536 self.addCleanup(self._unlink_cleanup, new_name)
537
538@@ -310,7 +332,7 @@
539 Eventually(Equals(new_name)))
540
541 def test_cancel_delete_directory(self):
542- dir_name = os.path.basename(self._make_directory_in_testhome())
543+ dir_name = os.path.basename(self._make_directory_in_home())
544 first_dir = self._get_file_by_name(dir_name)
545
546 self._do_action_on_file(first_dir, 'Delete')
547@@ -319,7 +341,7 @@
548 self._assert_number_of_files(1)
549
550 def test_delete_directory(self):
551- dir_name = os.path.basename(self._make_directory_in_testhome())
552+ dir_name = os.path.basename(self._make_directory_in_home())
553 first_dir = self._get_file_by_name(dir_name)
554
555 self._do_action_on_file(first_dir, 'Delete')
556@@ -328,7 +350,7 @@
557 self._assert_number_of_files(0)
558
559 def test_cancel_delete_file(self):
560- file_name = os.path.basename(self._make_file_in_testhome())
561+ file_name = os.path.basename(self._make_file_in_home())
562 first_file = self._get_file_by_name(file_name)
563
564 self._do_action_on_file(first_file, 'Delete')
565@@ -337,7 +359,7 @@
566 self._assert_number_of_files(1)
567
568 def test_delete_file(self):
569- file_name = os.path.basename(self._make_file_in_testhome())
570+ file_name = os.path.basename(self._make_file_in_home())
571 first_file = self._get_file_by_name(file_name)
572
573 self._do_action_on_file(first_file, 'Delete')
574@@ -348,13 +370,14 @@
575 def test_create_directory(self):
576 dir_name = 'Test Directory'
577 self.addCleanup(self._rmdir_cleanup,
578- os.path.join(os.environ['TESTHOME'], dir_name))
579+ os.path.join(self.home_dir, dir_name))
580
581- toolbar = self.main_view.open_toolbar()
582- toolbar.click_button('actions')
583+ open_popover = lambda: \
584+ self.main_view.open_toolbar().click_button('actions')
585+ self._safe_open_popover(open_popover)
586
587 folder_actions_popover = self.main_view.get_folder_actions_popover()
588- folder_actions_popover.click_button('Create New Folder')
589+ folder_actions_popover.click_button_by_text('Create New Folder')
590 self._confirm_dialog(dir_name)
591
592 self._assert_number_of_files(1)
593@@ -363,17 +386,18 @@
594 self.assertThat(dir_.fileName, Eventually(Equals(dir_name)))
595
596 def test_cancel_create_directory(self):
597- toolbar = self.main_view.open_toolbar()
598- toolbar.click_button('actions')
599+ open_popover = lambda: \
600+ self.main_view.open_toolbar().click_button('actions')
601+ self._safe_open_popover(open_popover)
602
603 folder_actions_popover = self.main_view.get_folder_actions_popover()
604- folder_actions_popover.click_button('Create New Folder')
605+ folder_actions_popover.click_button_by_text('Create New Folder')
606 self._cancel_confirm_dialog()
607
608 self._assert_number_of_files(0)
609
610 def test_show_directory_properties_from_list(self):
611- dir_path = self._make_directory_in_testhome()
612+ dir_path = self._make_directory_in_home()
613 dir_name = os.path.basename(dir_path)
614 first_dir = self._get_file_by_name(dir_name)
615
616@@ -387,7 +411,7 @@
617 # --elopio - 2013-07-25
618
619 def test_show_file_properties(self):
620- file_path = self._make_file_in_testhome()
621+ file_path = self._make_file_in_home()
622 file_name = os.path.basename(file_path)
623 first_file = self._get_file_by_name(file_name)
624
625@@ -400,12 +424,12 @@
626
627 def test_copy_directory(self):
628 # Set up a directory to copy and a directory to copy it into.
629- destination_dir_path = os.path.join(os.environ['TESTHOME'],
630+ destination_dir_path = os.path.join(self.home_dir,
631 'destination')
632 destination_dir_name = os.path.basename(destination_dir_path)
633 os.mkdir(destination_dir_path)
634 self.addCleanup(self._rmdir_cleanup, destination_dir_path)
635- dir_to_copy_path = os.path.join(os.environ['TESTHOME'], 'to_copy')
636+ dir_to_copy_path = os.path.join(self.home_dir, 'to_copy')
637 dir_to_copy_name = os.path.basename(dir_to_copy_path)
638 os.mkdir(dir_to_copy_path)
639 self.addCleanup(self._rmdir_cleanup, dir_to_copy_path)
640@@ -423,11 +447,12 @@
641 self._open_directory(destination_dir)
642
643 # Paste the directory.
644- toolbar = self.main_view.open_toolbar()
645- toolbar.click_button('actions')
646+ open_popover = lambda: \
647+ self.main_view.open_toolbar().click_button('actions')
648+ self._safe_open_popover(open_popover)
649
650 folder_actions_popover = self.main_view.get_folder_actions_popover()
651- folder_actions_popover.click_button('Paste 1 File')
652+ folder_actions_popover.click_button_by_text('Paste 1 File')
653 self.assertThat(
654 self.main_view.folder_actions_popover_exists,
655 Eventually(Equals(False)))
656@@ -447,12 +472,12 @@
657
658 def test_cut_directory(self):
659 # Set up a directory to cut and a directory to move it into.
660- destination_dir_path = os.path.join(os.environ['TESTHOME'],
661+ destination_dir_path = os.path.join(self.home_dir,
662 'destination')
663 destination_dir_name = os.path.basename(destination_dir_path)
664 os.mkdir(destination_dir_path)
665 self.addCleanup(self._rmdir_cleanup, destination_dir_path)
666- dir_to_cut_path = os.path.join(os.environ['TESTHOME'], 'to_cut')
667+ dir_to_cut_path = os.path.join(self.home_dir, 'to_cut')
668 dir_to_cut_name = os.path.basename(dir_to_cut_path)
669 os.mkdir(dir_to_cut_path)
670 self.addCleanup(self._rmdir_cleanup, dir_to_cut_path)
671@@ -470,11 +495,12 @@
672 self._open_directory(destination_dir)
673
674 # Paste the directory.
675- toolbar = self.main_view.open_toolbar()
676- toolbar.click_button('actions')
677+ open_popover = lambda: \
678+ self.main_view.open_toolbar().click_button('actions')
679+ self._safe_open_popover(open_popover)
680
681 folder_actions_popover = self.main_view.get_folder_actions_popover()
682- folder_actions_popover.click_button('Paste 1 File')
683+ folder_actions_popover.click_button_by_text('Paste 1 File')
684 self.assertThat(
685 self.main_view.folder_actions_popover_exists,
686 Eventually(Equals(False)))
687@@ -495,12 +521,11 @@
688 self.assertThat(
689 first_dir.fileName, Eventually(Equals(destination_dir_name)))
690
691- @unittest.skip("Fails in lab due to lab issues not present on phone")
692 def test_copy_file(self):
693 # Set up a file to copy and a directory to copy it into.
694- destination_dir_path = self._make_directory_in_testhome()
695+ destination_dir_path = self._make_directory_in_home()
696 destination_dir_name = os.path.basename(destination_dir_path)
697- file_to_copy_path = self._make_file_in_testhome()
698+ file_to_copy_path = self._make_file_in_home()
699 file_to_copy_name = os.path.basename(file_to_copy_path)
700
701 folder_list_page = self.main_view.get_folder_list_page()
702@@ -516,11 +541,12 @@
703 self._open_directory(destination_dir)
704
705 # Paste the file.
706- toolbar = self.main_view.open_toolbar()
707- toolbar.click_button('actions')
708+ open_popover = lambda: \
709+ self.main_view.open_toolbar().click_button('actions')
710+ self._safe_open_popover(open_popover)
711
712 folder_actions_popover = self.main_view.get_folder_actions_popover()
713- folder_actions_popover.click_button('Paste 1 File')
714+ folder_actions_popover.click_button_by_text('Paste 1 File')
715
716 self.assertThat(
717 self.main_view.folder_actions_popover_exists,
718@@ -542,12 +568,11 @@
719 self.assertThat(
720 first_dir.fileName, Eventually(Equals(destination_dir_name)))
721
722- @unittest.skip("Fails in lab due to lab issues not present on phone")
723 def test_cut_file(self):
724 # Set up a file to cut and a directory to move it into.
725- destination_dir_path = self._make_directory_in_testhome()
726+ destination_dir_path = self._make_directory_in_home()
727 destination_dir_name = os.path.basename(destination_dir_path)
728- file_to_cut_path = self._make_file_in_testhome()
729+ file_to_cut_path = self._make_file_in_home()
730 file_to_cut_name = os.path.basename(file_to_cut_path)
731
732 folder_list_page = self.main_view.get_folder_list_page()
733@@ -563,11 +588,12 @@
734 self._open_directory(destination_dir)
735
736 # Paste the file.
737- toolbar = self.main_view.open_toolbar()
738- toolbar.click_button('actions')
739+ open_popover = lambda: \
740+ self.main_view.open_toolbar().click_button('actions')
741+ self._safe_open_popover(open_popover)
742
743 folder_actions_popover = self.main_view.get_folder_actions_popover()
744- folder_actions_popover.click_button('Paste 1 File')
745+ folder_actions_popover.click_button_by_text('Paste 1 File')
746 self.assertThat(
747 self.main_view.folder_actions_popover_exists,
748 Eventually(Equals(False)))
749@@ -589,7 +615,7 @@
750 first_dir.fileName, Eventually(Equals(destination_dir_name)))
751
752 def test_go_up(self):
753- dir_name = os.path.basename(self._make_directory_in_testhome())
754+ dir_name = os.path.basename(self._make_directory_in_home())
755 first_dir = self._get_file_by_name(dir_name)
756 self._open_directory(first_dir)
757
758@@ -599,7 +625,7 @@
759 folder_list_page = self.main_view.get_folder_list_page()
760 self.assertThat(
761 folder_list_page.get_current_path,
762- Eventually(Equals(os.environ['TESTHOME'])))
763+ Eventually(Equals(self.home_dir)))
764
765 def test_go_home(self):
766 self._go_to_place('Home')
767@@ -607,7 +633,7 @@
768 folder_list_page = self.main_view.get_folder_list_page()
769 self.assertThat(
770 folder_list_page.get_current_path,
771- Eventually(Equals(os.environ['HOME'])))
772+ Eventually(Equals(self.home_dir)))
773
774 def test_go_to_root(self):
775 self._go_to_place('File System')
776@@ -619,10 +645,10 @@
777
778 def test_file_context_menu_shows(self):
779 """Checks to make sure that the file actions popover is shown."""
780- file_name = os.path.basename(self._make_file_in_testhome())
781+ file_name = os.path.basename(self._make_file_in_home())
782
783 first_file = self._get_file_by_name(file_name)
784- first_file.open_actions_popover()
785+ self._safe_open_popover(first_file.open_actions_popover)
786
787 file_actions_popover = self.main_view.get_file_actions_popover()
788 self.assertThat(

Subscribers

People subscribed via source and target branches