1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2012 Canonical
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License version 3, as published
6
# by the Free Software Foundation.
8
"""Tavastia autopilot tests."""
12
from tempfile import mktemp
14
from autopilot.introspection.qt import QtIntrospectionTestMixin
15
from autopilot.testcase import AutopilotTestCase
18
def get_module_include_path():
19
return os.path.abspath(
21
os.path.dirname(__file__),
30
class TavastiaTestCase(AutopilotTestCase, QtIntrospectionTestMixin):
32
"""A common test case class that provides several useful methods for SDK tests."""
35
super(TavastiaTestCase, self).setUp()
36
self.launch_test_qml()
38
def launch_test_qml(self):
39
# If the test class has defined a 'test_qml' class attribute then we
40
# write it to disk and launch it inside the Qml Viewer. If not, then we
41
# silently do nothing (presumably the test has something else planned).
42
if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring):
43
qml_path = mktemp(suffix='.qml')
44
open(qml_path, 'w').write(self.test_qml)
45
self.addCleanup(remove, qml_path)
47
self.app = self.launch_test_application(
50
"-I", get_module_include_path(),