Exemplo n.º 1
0
  def test(self):
    """Tests copy_local_directory_to_remote."""
    utils.write_data_to_file('a', os.path.join(self.local_temp_dir, 'a'))
    shell.create_directory(os.path.join(self.local_temp_dir, 'b'))
    utils.write_data_to_file('c', os.path.join(self.local_temp_dir, 'b', 'c'))

    adb.copy_local_directory_to_remote(self.local_temp_dir,
                                       self.device_temp_dir)

    self.assertTrue(adb.file_exists(os.path.join(self.device_temp_dir, 'a')))
    self.assertFalse(
        adb.directory_exists(os.path.join(self.device_temp_dir, 'a')))
    self.assertEqual(
        adb.get_file_size(os.path.join(self.device_temp_dir, 'a')), 1)

    self.assertTrue(
        adb.directory_exists(os.path.join(self.device_temp_dir, 'b')))
    self.assertFalse(adb.file_exists(os.path.join(self.device_temp_dir, 'b')))

    self.assertTrue(
        adb.file_exists(os.path.join(self.device_temp_dir, 'b', 'c')))
    self.assertFalse(
        adb.directory_exists(os.path.join(self.device_temp_dir, 'b', 'c')))
    self.assertEqual(
        adb.get_file_size(os.path.join(self.device_temp_dir, 'b', 'c')), 1)
Exemplo n.º 2
0
  def test_directory_exists(self):
    """Tests directory_exists."""
    utils.write_data_to_file('a', os.path.join(self.local_temp_dir, 'a'))
    shell.create_directory(os.path.join(self.local_temp_dir, 'b'))
    utils.write_data_to_file('c', os.path.join(self.local_temp_dir, 'b', 'c'))

    adb.copy_local_directory_to_remote(self.local_temp_dir,
                                       self.device_temp_dir)

    existent_file_path_remote = os.path.join(self.device_temp_dir, 'a')
    existent_directory_path_remote = os.path.join(self.device_temp_dir, 'b')
    non_existent_file_path_remote = os.path.join(self.device_temp_dir, 'd')
    non_existent_directory_path_remote = os.path.join(self.device_temp_dir, 'e')

    self.assertFalse(adb.directory_exists(existent_file_path_remote))
    self.assertTrue(adb.directory_exists(existent_directory_path_remote))
    self.assertFalse(adb.directory_exists(non_existent_file_path_remote))
    self.assertFalse(adb.directory_exists(non_existent_directory_path_remote))
Exemplo n.º 3
0
    def test_copy_local_directory_to_remote(self):
        """Tests copy_local_directory_to_remote."""
        utils.write_data_to_file('a', os.path.join(self.local_temp_dir, 'a'))
        shell.create_directory_if_needed(os.path.join(self.local_temp_dir,
                                                      'b'))
        utils.write_data_to_file('c',
                                 os.path.join(self.local_temp_dir, 'b', 'c'))
        adb.copy_local_directory_to_remote(self.local_temp_dir,
                                           self.device_temp_dir)

        self.assertTrue(
            adb.file_exists(os.path.join(self.device_temp_dir, 'a')))
        self.assertTrue(
            adb.directory_exists(os.path.join(self.device_temp_dir, 'b')))
        self.assertTrue(
            adb.file_exists(os.path.join(self.device_temp_dir, 'b', 'c')))
Exemplo n.º 4
0
def update_system_web_view():
    """Updates the system webview on the device."""
    app_directory = environment.get_value('APP_DIR')
    system_webview_apk = os.path.join(app_directory, SYSTEM_WEBVIEW_APK_NAME)
    if not os.path.exists(system_webview_apk):
        logs.log_error('System Webview apk not found.')
        return
    adb.set_property('persist.sys.webview.vmsize', SYSTEM_WEBVIEW_VMSIZE_BYTES)

    adb.run_as_root()
    if any([adb.directory_exists(d) for d in SYSTEM_WEBVIEW_DIRS]):
        adb.remount()
        adb.stop_shell()
        adb.run_adb_shell_command(['rm', '-rf', ' '.join(SYSTEM_WEBVIEW_DIRS)])
        reboot()

    adb.uninstall_package(SYSTEM_WEBVIEW_PACKAGE)
    adb.install_package(system_webview_apk)

    if not adb.is_package_installed(SYSTEM_WEBVIEW_PACKAGE):
        logs.log_error('Package %s was not installed successfully.' %
                       SYSTEM_WEBVIEW_PACKAGE)