~osomon/webbrowser-app/uriboni-tab-context-menu

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Michael Zanetti
  • Date: 2013-01-15 17:18:03 UTC
  • mfrom: (15.1.9 kalossi-browser)
  • Revision ID: tarmac-20130115171803-qg9e9ld7a3j939fn
Added initial autopilot tests and autopilot package.

Approved by Olivier Tilloy.

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
"""Ubuntu-browser autopilot tests."""
 
9
 
 
10
from os import remove
 
11
import os.path
 
12
 
 
13
from autopilot.introspection.qt import QtIntrospectionTestMixin
 
14
from autopilot.testcase import AutopilotTestCase
 
15
 
 
16
from ubuntu_browser.emulators.main_window import MainWindow
 
17
 
 
18
class BrowserTestCase(AutopilotTestCase, QtIntrospectionTestMixin):
 
19
 
 
20
    """A common test case class that provides several useful methods for ubuntu browser tests."""
 
21
 
 
22
    def setUp(self):
 
23
        super(BrowserTestCase, self).setUp()
 
24
        # Lets assume we are installed system wide if this file is somewhere in /usr
 
25
        if os.path.realpath(__file__).startswith("/usr/"):
 
26
            self.launch_test_installed()
 
27
        else:
 
28
            self.launch_test_local()
 
29
 
 
30
    def launch_test_local(self):
 
31
        self.app = self.launch_test_application(
 
32
            "../../src/ubuntu-browser")
 
33
 
 
34
    def launch_test_installed(self):
 
35
        if self.running_on_device():
 
36
            self.app = self.launch_test_application(
 
37
               "ubuntu-browser",
 
38
               "--fullscreen")
 
39
        else:
 
40
            self.app = self.launch_test_application(
 
41
               "ubuntu-browser")
 
42
 
 
43
    @staticmethod
 
44
    def running_on_device():
 
45
        return os.path.isfile('/system/usr/idc/autopilot-finger.idc')
 
46
 
 
47
    @property
 
48
    def main_window(self):
 
49
        return MainWindow(self.app)
 
50