Porting Autopilot Tests

This document contains hints as to what is required to port a test suite from any version of autopilot to any newer version.

A note on Versions

Autopilot releases are reasonably tightly coupled with Ubuntu releases. However, the autopilot authors maintain separate version numbers, with the aim of separating the autopilot release cadence from the Ubuntu platform release cadence.

Autopilot versions earlier than 1.2 were not publicly announced, and were only used within Canonical. For that reason, this document assumes that version 1.2 is the lowest version of autopilot present “in the wild”.

Porting to Autopilot v1.3.x

The 1.3 release included many API breaking changes. Earlier versions of autopilot made several assumptions about where tests would be run, that turned out not to be correct. Autopilot 1.3 brought several much-needed features, including:

  • A system for building pluggable implementations for several core components. This system is used in several areas:
  • The input stack can now generate events using either the X11 client libraries, or the UInput kernel driver. This is necessary for devices that do not use X11.
  • The display stack can now report display information for systems that use both X11 and the mir display server.
  • The process stack can now report details regarding running processes & their windows on both Desktop, tablet, and phone platforms.
  • A large code cleanup and reorganisation. In particular, lots of code that came from the Unity 3D codebase has been removed if it was deemed to not be useful to the majority of test authors. This code cleanup includes a flattening of the autopilot namespace. Previously, many useful classes lived under the autopilot.emulators namespace. These have now been moved into the autopilot namespace.

QtIntrospectionTestMixin and GtkIntrospectionTestMixin no longer exist

In autopilot 1.2, tests enabled application introspection services by inheriting from one of two mixin classes: QtIntrospectionTestMixin to enable testing Qt4, Qt5, and Qml applications, and GtkIntrospectionTestMixin to enable testing Gtk 2 and Gtk3 applications. For example, a test case class in autopilot 1.2 might look like this:

from autopilot.introspection.qt import QtIntrospectionTestMixin
from autopilot.testcase import AutopilotTestCase


class MyAppTestCase(AutopilotTestCase, QtIntrospectionTestMixin):

    def setUp(self):
        super(MyAppTestCase, self).setUp()
        self.app = self.launch_test_application("../../my-app")

In Autopilot 1.3, the AutopilotTestCase class contains this functionality directly, so the QtIntrospectionTestMixin and GtkIntrospectionTestMixin classes no longer exist. The above example becomes simpler:

from autopilot.testcase import AutopilotTestCase


class MyAppTestCase(AutopilotTestCase):

    def setUp(self):
        super(MyAppTestCase, self).setUp()
        self.app = self.launch_test_application("../../my-app")

Autopilot will try and determine the introspection type automatically. If this process fails, you can specify the application type manually:

from autopilot.testcase import AutopilotTestCase


class MyAppTestCase(AutopilotTestCase):

    def setUp(self):
        super(MyAppTestCase, self).setUp()
        self.app = self.launch_test_application("../../my-app", app_type='qt')

See also

Method autopilot.testcase.AutopilotTestCase.launch_test_application
Launch test applications.
Method autopilot.testcase.AutopilotTestCase.pick_app_launcher
Set application type globally.

autopilot.emulators namespace has been deprecated

In autopilot 1.2 and earlier, the autopilot.emulators package held several modules and classes that were used frequently in tests. This package has been removed, and it’s contents merged into the autopilot package. Below is a table showing the basic translations that need to be made:

Old module New Module
autopilot.emulators.input autopilot.input
autopilot.emulators.X11 Deprecated - use autopilot.input for input and autopilot.display for getting display information.
autopilot.emulators.bamf Deprecated - use autopilot.process instead.