24 from autopilot
import introspection
32 logger = logging.getLogger(__name__)
36 """Fixture to launch the Dash app."""
39 """Initialize an instance.
41 :param str binary_path: The path to the Dash app binary.
42 :param variables: The variables to use when launching the app.
43 :type variables: A dictionary.
51 """Launch the dash app when the fixture is used."""
56 def launch_application(self):
58 testability_arg =
'QT_LOAD_TESTABILITY={}'.format(1)
60 '{}={}'.format(key, value)
for key, value
in self.variables.items()
62 all_args = [binary_arg, testability_arg] + env_args
64 pid = process_helpers.start_job(
'unity8-dash', *all_args)
65 return introspection.get_proxy_object_for_existing_process(
67 emulator_base=emulators.UnityEmulatorBase,
70 def stop_application(self):
71 process_helpers.stop_job(
'unity8-dash')
74 class DisplayRotationLock(fixtures.Fixture):
82 original_state = self._is_rotation_lock_enabled()
83 if self.enable != original_state:
84 self.addCleanup(self._set_rotation_lock, original_state)
85 self._set_rotation_lock(self.enable)
87 def _is_rotation_lock_enabled(self):
90 'com.ubuntu.touch.system',
93 output = subprocess.check_output(command, universal_newlines=
True)
94 return True if output.count(
'true')
else False
96 def _set_rotation_lock(self, value):
97 value_string =
'true' if value
else 'false'
100 'com.ubuntu.touch.system',
101 'rotation-lock', value_string
103 subprocess.check_output(command)
107 """Fixture to launch the indicator test service."""
109 def __init__(self, action_delay, ensure_not_running=True):
110 """Initialize an instance.
112 :param action_delay: The delay to use when activating actions.
113 Measured in milliseconds. Value of -1 will result in infinite delay.
114 :type action_delay: An integer.
115 :param boolean ensure_not_running: Make sure service is not running
118 super(LaunchMockIndicatorService, self).
__init__()
123 super(LaunchMockIndicatorService, self).setUp()
129 def launch_service(self):
130 logger.info(
"Starting unity-mock-indicator-service")
131 binary_path = get_binary_path(
'unity-mock-indicator-service')
132 binary_arg =
'BINARY={}'.format(binary_path)
134 all_args = [binary_arg, env_args]
135 process_helpers.start_job(
'unity-mock-indicator-service', *all_args)
137 def stop_service(self):
138 logger.info(
"Stopping unity-mock-indicator-service")
139 process_helpers.stop_job(
'unity-mock-indicator-service')
141 def ensure_service_not_running(self):
142 if process_helpers.is_job_running(
'unity-mock-indicator-service'):
def __init__(self, binary_path, variables)
def launch_application(self)
def ensure_service_not_running(self)
def stop_application(self)