~osomon/webbrowser-app/youtube-livestreams-3g

« back to all changes in this revision

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

  • Committer: Michael Zanetti
  • Date: 2013-01-14 15:47:33 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: michael_zanetti@gmx.net-20130114154733-99esebl4s4f242ym
Added initial autopilot tests and autopilot package

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
"""Kalossi-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 kalossi_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 camera-app 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/kalossi-browser")
 
33
 
 
34
    def launch_test_installed(self):
 
35
        if self.running_on_device():
 
36
            self.app = self.launch_test_application(
 
37
               "kalossi-browser",
 
38
               "--fullscreen")
 
39
        else:
 
40
            self.app = self.launch_test_application(
 
41
               "kalossi-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