~zsombi/ubuntu-ui-toolkit/32-listitemactions-attached

« back to all changes in this revision

Viewing changes to tests/autopilot/tavastia/tests/__init__.py

  • Committer: Tarmac
  • Author(s): Gerry Boland, Juhapekka Piiroinen
  • Date: 2012-09-25 08:59:11 UTC
  • mfrom: (74.2.4 autopilot-tests-2)
  • Revision ID: tarmac-20120925085911-xer62zdjd2isce1c
[added] autopilot test for button. Approved by Gerry Boland, jenkins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
# Copyright 2012 Canonical
 
3
#
 
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.
 
7
 
 
8
"""Tavastia autopilot tests."""
 
9
 
 
10
from os import remove
 
11
import os.path
 
12
from tempfile import mktemp
 
13
 
 
14
from autopilot.introspection.qt import QtIntrospectionTestMixin
 
15
from autopilot.testcase import AutopilotTestCase
 
16
 
 
17
 
 
18
def get_module_include_path():
 
19
    return os.path.abspath(
 
20
        os.path.join(
 
21
            os.path.dirname(__file__),
 
22
            '..',
 
23
            '..',
 
24
            '..',
 
25
            '..',
 
26
            'modules')
 
27
        )
 
28
 
 
29
 
 
30
class TavastiaTestCase(AutopilotTestCase, QtIntrospectionTestMixin):
 
31
 
 
32
    """A common test case class that provides several useful methods for SDK tests."""
 
33
 
 
34
    def setUp(self):
 
35
        super(TavastiaTestCase, self).setUp()
 
36
        self.launch_test_qml()
 
37
 
 
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)
 
46
 
 
47
            self.app = self.launch_test_application(
 
48
                "qmlviewer",
 
49
                "-opengl",
 
50
                "-I", get_module_include_path(),
 
51
                qml_path)