~mutse-young/ubuntu-docviewer-app/trunk

« back to all changes in this revision

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

  • Committer: Omer Akram
  • Date: 2013-05-31 11:28:00 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: om26er@ubuntu.com-20130531112800-bfcz8wxtf6jxjvwa
add initial autopilot skeleton and packaging

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 2013 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
"""Docviewer app autopilot tests."""
 
9
 
 
10
import os.path
 
11
 
 
12
from autopilot.input import Mouse, Touch, Pointer
 
13
from autopilot.platform import model
 
14
from autopilot.testcase import AutopilotTestCase
 
15
 
 
16
from ubuntu_docviewer_app.emulators.main_window import MainWindow
 
17
 
 
18
 
 
19
class DocviewerTestCase(AutopilotTestCase):
 
20
 
 
21
    """A common test case class that provides several useful methods for
 
22
    docviewer-app tests.
 
23
 
 
24
    """
 
25
    if model() == 'Desktop':
 
26
        scenarios = [('with mouse', dict(input_device_class=Mouse))]
 
27
    else:
 
28
        scenarios = [('with touch', dict(input_device_class=Touch))]
 
29
 
 
30
    local_location = "../../ubuntu-docviewer-app.qml"
 
31
 
 
32
    def setUp(self):
 
33
        self.pointing_device = Pointer(self.input_device_class.create())
 
34
        super(DocviewerTestCase, self).setUp()
 
35
        if os.path.exists(self.local_location):
 
36
            self.launch_test_local()
 
37
        else:
 
38
            self.launch_test_installed()
 
39
 
 
40
    def launch_test_local(self):
 
41
        self.app = self.launch_test_application(
 
42
            "qmlscene",
 
43
            self.local_location,
 
44
            app_type='qt')
 
45
 
 
46
    def launch_test_installed(self):
 
47
        self.app = self.launch_test_application(
 
48
            "qmlscene",
 
49
            "/usr/share/ubuntu-docviewer-app/ubuntu-docviewer-app.qml",
 
50
            "--desktop_file_hint=/usr/share/applications/ubuntu-docviewer-app.desktop",
 
51
            app_type='qt')
 
52
 
 
53
    @property
 
54
    def main_window(self):
 
55
        return MainWindow(self.app)