Loading...
Searching...
No Matches
lomiri.shell.tests.LomiriTestCase Class Reference
Inheritance diagram for lomiri.shell.tests.LomiriTestCase:
[legend]

## Public Member Functions

| setUpClass (cls)
| setUp (self)
| launch_lomiri (self, mode="full-greeter", *args)
| patch_lightdm_mock (self)
| wait_for_lomiri (self)
| get_dash (self)
| main_window (self)

## Public Attributes

list | lomiri_geometry_args = []
int | grid_size = 8

## Protected Member Functions

| _setup_display_details (self)
| _determine_geometry (self)
| _setup_grid_size (self, scale_divisor)
| _geo_larger_than_display (self, width, height)
| _get_scaled_down_geo (self, width, height)
| _launch_lomiri_with_upstart (self, binary_path, args)
| _patch_data_dirs (self)
| _get_lightdm_mock_path (self)
| _set_proxy (self, proxy)
| _clear_proxy (self)

## Protected Attributes

| _proxy = None
bool | _qml_mock_enabled = True
bool | _data_dirs_mock_enabled = True
dict | _environment = {}
| _clear_proxy

## Detailed Description

    A test case base class for the Lomiri shell tests.

Definition at line 88 of file __init__.py.

## Member Function Documentation

## _clear_proxy()

lomiri.shell.tests.LomiriTestCase._clear_proxy | ( |  | self | ) |

protected

Definition at line 285 of file __init__.py.

def _clear_proxy(self):
self._proxy = None

## _determine_geometry()

lomiri.shell.tests.LomiriTestCase._determine_geometry | ( |  | self | ) |

protected

    Use the geometry that may be supplied or use the default.

Definition at line 131 of file __init__.py.

def _determine_geometry(self):
"""Use the geometry that may be supplied or use the default."""
width = getattr(self, 'app_width', 0)
height = getattr(self, 'app_height', 0)
scale_divisor = 1
self.lomiri_geometry_args = []
if width > 0 and height > 0:
if self._geo_larger_than_display(width, height):
scale_divisor = self._get_scaled_down_geo(width, height)
width = width / scale_divisor
height = height / scale_divisor
logger.info(
"Geometry larger than display, scaled down to: %dx%d",
width,
height
)
geo_string = "%dx%d" % (width, height)
self.lomiri_geometry_args = [
'-windowgeometry',
geo_string,
'-frameless',
'-mousetouch'
]
return scale_divisor

## _geo_larger_than_display()

lomiri.shell.tests.LomiriTestCase._geo_larger_than_display | ( |  | self,
|  |  | width,
|  |  | height )

protected

Definition at line 167 of file __init__.py.

def _geo_larger_than_display(self, width, height):
should_scale = getattr(self, 'scale_geo', True)
if should_scale:
screen = Display.create()
screen_width = screen.get_screen_width()
screen_height = screen.get_screen_height()
return (width > screen_width) or (height > screen_height)
else:
return False

## _get_lightdm_mock_path()

lomiri.shell.tests.LomiriTestCase._get_lightdm_mock_path | ( |  | self | ) |

protected

Definition at line 264 of file __init__.py.

def _get_lightdm_mock_path(self):
lib_path = get_mocks_library_path()
lightdm_mock_path = os.path.abspath(
os.path.join(lib_path, "liblightdm")
)
if not os.path.exists(lightdm_mock_path):
raise RuntimeError(
"LightDM mock does not exist at path '%s'."
% (lightdm_mock_path)
)
return lightdm_mock_path

## _get_scaled_down_geo()

lomiri.shell.tests.LomiriTestCase._get_scaled_down_geo | ( |  | self,
|  |  | width,
|  |  | height )

protected

Definition at line 177 of file __init__.py.

def _get_scaled_down_geo(self, width, height):
divisor = 1
while self._geo_larger_than_display(width / divisor, height / divisor):
divisor = divisor * 2
return divisor

## _launch_lomiri_with_upstart()

lomiri.shell.tests.LomiriTestCase._launch_lomiri_with_upstart | ( |  | self,
|  |  | binary_path,
|  |  | args )

protected

Definition at line 233 of file __init__.py.

def _launch_lomiri_with_upstart(self, binary_path, args):
logger.info("Starting lomiri")
self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable(
global_=True, QT_LOAD_TESTABILITY=1))
variables = self._environment
variables['ARGS'] = " ".join(args)
launch_lomiri_fixture = fixture_setup.RestartLomiriWithTestability(
binary_path, variables)
self.useFixture(launch_lomiri_fixture)
return launch_lomiri_fixture.lomiri_proxy

## _patch_data_dirs()

lomiri.shell.tests.LomiriTestCase._patch_data_dirs | ( |  | self | ) |

protected

Definition at line 245 of file __init__.py.

def _patch_data_dirs(self):
data_dirs = get_data_dirs(self._data_dirs_mock_enabled)
if data_dirs is not None:
self._environment['XDG_DATA_DIRS'] = data_dirs

## _set_proxy()

lomiri.shell.tests.LomiriTestCase._set_proxy | ( |  | self,
|  |  | proxy )

protected

    Keep a copy of the proxy object, so we can use it to get common
    parts of the shell later on.

Definition at line 277 of file __init__.py.

def _set_proxy(self, proxy):
"""Keep a copy of the proxy object, so we can use it to get common
parts of the shell later on.
"""
self._proxy = proxy
self.addCleanup(self._clear_proxy)

## _setup_display_details()

lomiri.shell.tests.LomiriTestCase._setup_display_details | ( |  | self | ) |

protected

Definition at line 127 of file __init__.py.

def _setup_display_details(self):
scale_divisor = self._determine_geometry()
self._setup_grid_size(scale_divisor)

## _setup_grid_size()

lomiri.shell.tests.LomiriTestCase._setup_grid_size | ( |  | self,
|  |  | scale_divisor )

protected

    Use the grid size that may be supplied or use the default.

Definition at line 156 of file __init__.py.

def _setup_grid_size(self, scale_divisor):
"""Use the grid size that may be supplied or use the default."""
if getattr(self, 'grid_unit_px', 0) == 0:
if os.getenv('GRID_UNIT_PX') == None:
self.grid_size = 8
else:
self.grid_size = int(os.getenv('GRID_UNIT_PX'))
else:
self.grid_size = int(self.grid_unit_px / scale_divisor)
self._environment["GRID_UNIT_PX"] = str(self.grid_size)

## get_dash()

lomiri.shell.tests.LomiriTestCase.get_dash | ( |  | self | ) |

Definition at line 292 of file __init__.py.

def get_dash(self):
pid = process_helpers.get_job_pid('lomiri-dash')
dash_proxy = introspection.get_proxy_object_for_existing_process(
pid=pid,
emulator_base=lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase
)
dash_app = dash_helpers.DashApp(dash_proxy)
return dash_app.dash

## launch_lomiri()

lomiri.shell.tests.LomiriTestCase.launch_lomiri | ( |  | self,
|  |  | mode = "full-greeter",
|  | * | args )

        Launch the lomiri 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 lomiri

Definition at line 183 of file __init__.py.

def launch_lomiri(self, mode="full-greeter", *args):
"""
Launch the lomiri 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 lomiri
"""
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()
lomiri_cli_args_list = ["--mode={}".format(mode)]
if len(args) != 0:
lomiri_cli_args_list += args
app_proxy = self._launch_lomiri_with_upstart(
binary_path,
self.lomiri_geometry_args + lomiri_cli_args_list
)
self._set_proxy(app_proxy)
# Ensure that the dash is visible before we return:
logger.debug("Lomiri started, waiting for it to be ready.")
self.wait_for_lomiri()
logger.debug("Lomiri 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('lomiri-dash')
return app_proxy

## main_window()

lomiri.shell.tests.LomiriTestCase.main_window | ( |  | self | ) |

Definition at line 302 of file __init__.py.

def main_window(self):
return self._proxy.select_single(shell.ShellView)

## patch_lightdm_mock()

lomiri.shell.tests.LomiriTestCase.patch_lightdm_mock | ( |  | self | ) |

Definition at line 250 of file __init__.py.

def patch_lightdm_mock(self):
logger.info("Setting up LightDM mock lib")
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)
logger.info("New library path: %s", new_ld_library_path)
self._environment['LD_LIBRARY_PATH'] = new_ld_library_path

## setUp()

lomiri.shell.tests.LomiriTestCase.setUp | ( |  | self | ) |

Definition at line 115 of file __init__.py.

def setUp(self):
super().setUp()
if is_lomiri7_running():
self.useFixture(toolkit_fixtures.HideLomiri7Launcher())
self._proxy = None
self._qml_mock_enabled = True
self._data_dirs_mock_enabled = True
self._environment = {}
self._setup_display_details()

## setUpClass()

lomiri.shell.tests.LomiriTestCase.setUpClass | ( |  | cls | ) |

Definition at line 93 of file __init__.py.

def setUpClass(cls):
try:
is_lomiri_running = process_helpers.is_job_running('lomiri')
except process_helpers.JobError as e:
xdg_config_home = os.getenv(
'XDG_CONFIG_HOME', os.path.join(os.getenv('HOME'), '.config'))
upstart_config_path = os.path.join(xdg_config_home, 'upstart')
logger.error(
'`initctl status lomiri` failed, most probably the '
'lomiri session could not be found:\n\n'
'{0}\n'
'Please install lomiri or copy data/lomiri.conf to '
'{1}\n'.format(e.output, upstart_config_path)
)
raise e
else:
assert not is_lomiri_running, (
'Lomiri is currently running, these tests require it to be '
'stopped.\n'
'Please run this command before running these tests: \n'
'initctl stop lomiri\n')

## wait_for_lomiri()

lomiri.shell.tests.LomiriTestCase.wait_for_lomiri | ( |  | self | ) |

Definition at line 288 of file __init__.py.

def wait_for_lomiri(self):
greeter = self.main_window.wait_select_single(objectName='greeter')
greeter.waiting.wait_for(False)

## Member Data Documentation

## _clear_proxy

lomiri.shell.tests.LomiriTestCase._clear_proxy

protected

Definition at line 283 of file __init__.py.

## _data_dirs_mock_enabled

bool lomiri.shell.tests.LomiriTestCase._data_dirs_mock_enabled = True

protected

Definition at line 122 of file __init__.py.

## _environment

dict lomiri.shell.tests.LomiriTestCase._environment = {}

protected

Definition at line 123 of file __init__.py.

## _proxy

lomiri.shell.tests.LomiriTestCase._proxy = None

protected

Definition at line 120 of file __init__.py.

## _qml_mock_enabled

bool lomiri.shell.tests.LomiriTestCase._qml_mock_enabled = True

protected

Definition at line 121 of file __init__.py.

## grid_size

int lomiri.shell.tests.LomiriTestCase.grid_size = 8

Definition at line 160 of file __init__.py.

## lomiri_geometry_args

list lomiri.shell.tests.LomiriTestCase.lomiri_geometry_args = []

Definition at line 136 of file __init__.py.

The documentation for this class was generated from the following file:

- tests/autopilot/lomiri/shell/tests/__init__.py