def setUp(self): super().setUp() if is_unity7_running(): self.useFixture(toolkit_fixtures.HideUnity7Launcher()) if model() != 'Desktop': # On the phone, we need unity to be running and unlocked. self.addCleanup(process_helpers.stop_job, 'unity8') process_helpers.restart_unity_with_testability() process_helpers.unlock_unity() self.ensure_dash_not_running() if self.qml_mock_enabled: self.environment['QML2_IMPORT_PATH'] = ( get_qml_import_path_with_mock() ) if self.should_simulate_device(): # This sets the grid units, so it should be called before launching # the app. self.simulate_device() binary_path = get_binary_path('unity8-dash') dash_proxy = self.launch_dash(binary_path, self.environment) self.dash_app = dash_helpers.DashApp(dash_proxy) self.dash = self.dash_app.dash self.wait_for_dash()
def setUp(self): super().setUp() if is_unity7_running(): self.useFixture(toolkit_fixtures.HideUnity7Launcher()) if model() != 'Desktop': # On the phone, we need unity to be running and unlocked. self.addCleanup(process_helpers.stop_job, 'unity8') process_helpers.restart_unity_with_testability() process_helpers.unlock_unity() self.ensure_dash_not_running() if self.qml_mock_enabled: self.environment['QML2_IMPORT_PATH'] = ( get_qml_import_path_with_mock()) if self.should_simulate_device(): # This sets the grid units, so it should be called before launching # the app. self.simulate_device() binary_path = get_binary_path('unity8-dash') dash_proxy = self.launch_dash(binary_path, self.environment) self.dash_app = dash_helpers.DashApp(dash_proxy) self.dash = self.dash_app.dash self.wait_for_dash()
def launch_service(self): logger.info("Starting unity-mock-indicator-service") binary_path = get_binary_path('unity-mock-indicator-service') binary_arg = 'BINARY={}'.format(binary_path) env_args = 'ARGS=-t {}'.format(self.action_delay) all_args = [binary_arg, env_args] process_helpers.start_job('unity-mock-indicator-service', *all_args)
def launch_unity(self, mode="full-greeter", *args): """ Launch the unity shell, return a proxy object for it. :param str mode: The type of greeter/shell mode to use :param args: A list of aguments to pass to unity8 """ binary_path = get_binary_path() lib_path = get_lib_path() logger.info( "Lib path is '%s', binary path is '%s'", lib_path, binary_path ) self.patch_lightdm_mock() if self._qml_mock_enabled: self._environment['QML2_IMPORT_PATH'] = ( get_qml_import_path_with_mock() ) if self._data_dirs_mock_enabled: self._patch_data_dirs() unity8_cli_args_list = ["--mode={}".format(mode)] if len(args) != 0: unity8_cli_args_list += args app_proxy = self._launch_unity_with_upstart( binary_path, self.unity_geometry_args + unity8_cli_args_list ) self._set_proxy(app_proxy) # Ensure that the dash is visible before we return: logger.debug("Unity started, waiting for it to be ready.") self.wait_for_unity() logger.debug("Unity loaded and ready.") if model() == 'Desktop': # On desktop, close the dash because it's opened in a separate # window and it gets in the way. process_helpers.stop_job('unity8-dash') return app_proxy
def launch_unity(self, mode="full-greeter", *args): """ Launch the unity shell, return a proxy object for it. :param str mode: The type of greeter/shell mode to use :param args: A list of aguments to pass to unity8 """ binary_path = get_binary_path() lib_path = get_lib_path() logger.info("Lib path is '%s', binary path is '%s'", lib_path, binary_path) self.patch_lightdm_mock() if self._qml_mock_enabled: self._environment['QML2_IMPORT_PATH'] = ( get_qml_import_path_with_mock()) if self._data_dirs_mock_enabled: self._patch_data_dirs() unity8_cli_args_list = ["--mode={}".format(mode)] if len(args) != 0: unity8_cli_args_list += args app_proxy = self._launch_unity_with_upstart( binary_path, self.unity_geometry_args + unity8_cli_args_list) self._set_proxy(app_proxy) # Ensure that the dash is visible before we return: logger.debug("Unity started, waiting for it to be ready.") self.wait_for_unity() logger.debug("Unity loaded and ready.") if model() == 'Desktop': # On desktop, close the dash because it's opened in a separate # window and it gets in the way. process_helpers.stop_job('unity8-dash') return app_proxy
def _restart_unity_with_testability(self): _environment = {} data_dirs = get_data_dirs(True) if data_dirs is not None: _environment['XDG_DATA_DIRS'] = data_dirs _environment['QML2_IMPORT_PATH'] = ( self._get_qml_import_path_with_mock() ) new_ld_library_path = [ get_default_extra_mock_libraries(), self._get_lightdm_mock_path() ] if os.getenv('LD_LIBRARY_PATH') is not None: new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH')) new_ld_library_path = ':'.join(new_ld_library_path) _environment['LD_LIBRARY_PATH'] = new_ld_library_path # FIXME: we shouldn't be doing this # $MIR_SOCKET, fallback to $XDG_RUNTIME_DIR/mir_socket and # /tmp/mir_socket as last resort try: os.unlink( os.getenv('MIR_SOCKET', os.path.join(os.getenv('XDG_RUNTIME_DIR', "/tmp"), "mir_socket"))) except OSError: pass try: os.unlink("/tmp/mir_socket") except OSError: pass binary_arg = "BINARY=%s" % get_binary_path() env_args = ["%s=%s" % (k, v) for k, v in _environment.items()] args = [binary_arg] + env_args self.unity_proxy = process_helpers.restart_unity_with_testability( *args) self.main_win = self.unity_proxy.select_single(shell.ShellView)
def _launch_unity(self): self.patch_environment("QT_LOAD_TESTABILITY", "1") try: host_socket = os.getenv("MIR_SOCKET", "/run/mir_socket") if stat.S_ISSOCK(os.stat(host_socket).st_mode): self.patch_environment("MIR_SERVER_HOST_SOCKET", host_socket) socket = os.path.join(os.getenv("XDG_RUNTIME_DIR", "/tmp"), "mir_socket") self.patch_environment("MIR_SERVER_FILE", socket) except OSError: pass self.process = subprocess.Popen( [get_binary_path()] + self.unity_geometry_args) def ensure_stopped(): self.process.terminate() for i in range(10): try: self._get_status() except OSError: break else: time.sleep(1) try: self._get_status() except OSError: pass else: self.process.kill() self.process.wait() self.addCleanup(ensure_stopped)