autopilot.application
- Autopilot Application Launchers¶
Base package for application launching and environment management.
-
class
autopilot.application.
ClickApplicationLauncher
(case_addDetail=None, emulator_base=None, dbus_bus='session')[source]¶ Fixture to manage launching a Click application.A class that knows how to launch an application with a certain type of introspection enabled.
Parameters: - case_addDetail – addDetail method to use.
- proxy_base – custom proxy base class to use, defaults to None
- dbus_bus – dbus bus to use, if set to something other than the default (‘session’) the environment will be patched
-
launch
(package_id, app_name=None, app_uris=[])[source]¶ Launch a click package application with introspection enabled.
This method takes care of launching a click package with introspection exabled. You probably want to use this method if your application is packaged in a click application, or is started via upstart.
Usage is similar to NormalApplicationLauncher.launch:
from autopilot.application import ClickApplicationLauncher launcher = ClickApplicationLauncher() launcher.setUp() app_proxy = launcher.launch('com.ubuntu.dropping-letters')
Parameters: - package_id – The Click package name you want to launch. For
example:
com.ubuntu.dropping-letters
- app_name – Currently, only one application can be packaged in a click package, and this parameter can be left at None. If specified, it should be the application name you wish to launch.
- app_uris – Parameters used to launch the click package. This parameter will be left empty if not used.
Raises: - RuntimeError – If the specified package_id cannot be found in the click package manifest.
- RuntimeError – If the specified app_name cannot be found within the specified click package.
Returns: proxy object for the launched package application
- package_id – The Click package name you want to launch. For
example:
-
class
autopilot.application.
NormalApplicationLauncher
(case_addDetail=None, emulator_base=None, dbus_bus='session')[source]¶ Fixture to manage launching an application.A class that knows how to launch an application with a certain type of introspection enabled.
Parameters: - case_addDetail – addDetail method to use.
- proxy_base – custom proxy base class to use, defaults to None
- dbus_bus – dbus bus to use, if set to something other than the default (‘session’) the environment will be patched
-
launch
(application, arguments=[], app_type=None, launch_dir=None, capture_output=True)[source]¶ Launch an application and return a proxy object.
Use this method to launch an application and start testing it. The arguments passed in
arguments
are used as arguments to the application to launch. Additional keyword arguments are used to control the manner in which the application is launched.This fixture is designed to be flexible enough to launch all supported types of applications. Autopilot can automatically determine how to enable introspection support for dynamically linked binary applications. For example, to launch a binary Gtk application, a test might start with:
from autopilot.application import NormalApplicationLauncher launcher = NormalApplicationLauncher() launcher.setUp() app_proxy = launcher.launch('gedit')
For use within a testcase, use useFixture:
from autopilot.application import NormalApplicationLauncher launcher = self.useFixture(NormalApplicationLauncher()) app_proxy = launcher.launch(‘gedit’)Applications can be given command line arguments by supplying an
arguments
argument to this method. For example, if we want to launchgedit
with a certain document loaded, we might do this:app_proxy = launcher.launch( 'gedit', arguments=['/tmp/test-document.txt'])
… a Qt5 Qml application is launched in a similar fashion:
app_proxy = launcher.launch( 'qmlscene', arguments=['my_scene.qml'])
If you wish to launch an application that is not a dynamically linked binary, you must specify the application type. For example, a Qt4 python application might be launched like this:
app_proxy = launcher.launch( 'my_qt_app.py', app_type='qt')
Similarly, a python/Gtk application is launched like so:
app_proxy = launcher.launch( 'my_gtk_app.py', app_type='gtk')
Parameters: - application –
The application to launch. The application can be specified as:
- A full, absolute path to an executable file.
(
/usr/bin/gedit
) - A relative path to an executable file.
(
./build/my_app
) - An app name, which will be searched for in $PATH (
my_app
)
- A full, absolute path to an executable file.
(
- arguments – If set, the list of arguments is passed to the launched app.
- app_type – If set, provides a hint to autopilot as to which kind of introspection to enable. This is needed when the application you wish to launch is not a dynamically linked binary. Valid values are ‘gtk’ or ‘qt’. These strings are case insensitive.
- launch_dir – If set to a directory that exists the process will be launched from that directory.
- capture_output – If set to True (the default), the process output will be captured and attached to the test as test detail.
Returns: A proxy object that represents the application. Introspection data is retrievable via this object.
- application –
-
class
autopilot.application.
UpstartApplicationLauncher
(case_addDetail=None, emulator_base=None, dbus_bus='session')[source]¶ A launcher class that launches applications with UpstartAppLaunch.A class that knows how to launch an application with a certain type of introspection enabled.
Parameters: - case_addDetail – addDetail method to use.
- proxy_base – custom proxy base class to use, defaults to None
- dbus_bus – dbus bus to use, if set to something other than the default (‘session’) the environment will be patched
-
launch
(app_id, app_uris=[])[source]¶ Launch an application with upstart.
This method launches an application via the
upstart-app-launch
library, on platforms that support it.Usage is similar to NormalApplicationLauncher:
from autopilot.application import UpstartApplicationLauncher launcher = UpstartApplicationLauncher() launcher.setUp() app_proxy = launcher.launch('gallery-app')
Parameters: - app_id – name of the application to launch
- app_uris – list of separate application uris to launch
Raises: RuntimeError – If the specified application cannot be launched.
Returns: proxy object for the launched package application