32
32
fixture_setup as toolkit_fixtures
35
from filemanager import emulators
35
from filemanager import emulators, fixture_setup
37
37
logger = logging.getLogger(__name__)
52
52
local_location_qml = os.path.join(local_location,
53
53
'src/app/qml/filemanager.qml')
54
54
local_location_binary = os.path.join(local_location, 'src/app/filemanager')
55
installed_location_qml = "/usr/share/filemanager/qml/filemanager.qml"
55
installed_location_qml = '/usr/share/filemanager/qml/filemanager.qml'
56
56
installed_location_binary = '/usr/bin/filemanager'
58
58
def get_launcher_and_type(self):
111
111
emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
113
113
def _copy_xauthority_file(self, directory):
114
""" Copy .Xauthority file to directory, if it exists in /home
116
xauth = os.path.expanduser(os.path.join('~', '.Xauthority'))
114
"""Copy .Xauthority file to directory, if it exists in /home"""
115
xauth = os.path.join(os.environ.get('HOME'), '.Xauthority')
117
116
if os.path.isfile(xauth):
118
117
logger.debug("Copying .Xauthority to " + directory)
120
os.path.expanduser(os.path.join('~', '.Xauthority')),
119
os.path.join(os.environ.get('HOME'), '.Xauthority'),
121
120
os.path.join(directory, '.Xauthority'))
123
122
def _patch_home(self):
124
""" mock /home for testing purposes to preserve user data
123
"""mock /home for testing purposes to preserve user data"""
126
124
temp_dir_fixture = fixtures.TempDir()
127
125
self.useFixture(temp_dir_fixture)
128
126
temp_dir = temp_dir_fixture.path
142
140
self.useFixture(fixtures.EnvironmentVariable('HOME',
143
141
newvalue=temp_dir))
145
logger.debug("Patched home to fake home directory " + temp_dir)
143
logger.debug('Patched home to fake home directory ' + temp_dir)
150
148
def main_view(self):
151
149
return self.app.wait_select_single(emulators.MainView)
151
def make_file_in_home(self):
152
return self.make_content_in_home('file')
154
def make_directory_in_home(self):
155
return self.make_content_in_home('directory')
157
def make_content_in_home(self, type_):
158
if type_ != 'file' and type_ != 'directory':
159
raise ValueError('Unknown content type: "{0}"', type_)
161
temp_file = fixture_setup.TemporaryFileInDirectory(self.home_dir)
162
self.useFixture(temp_file)
163
path = temp_file.path
165
temp_dir = fixture_setup.TemporaryDirectoryInDirectory(
167
self.useFixture(temp_dir)
169
logger.debug('Directory Listing for HOME\n%s' %
170
os.listdir(self.home_dir))
171
self._assert_number_of_files(1)
174
def _assert_number_of_files(self, expected_number_of_files, home=True):
176
expected_number_of_files += self.original_file_count
177
folder_list_page = self.main_view.get_folder_list_page()
179
folder_list_page.get_number_of_files_from_list,
180
Eventually(Equals(expected_number_of_files), timeout=60))
182
folder_list_page.get_number_of_files_from_header,
183
Eventually(Equals(expected_number_of_files), timeout=60))