~phablet-team/mediaplayer-app/remove_powerd

« back to all changes in this revision

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

  • Committer: Michael Zanetti
  • Date: 2013-02-21 14:09:03 UTC
  • mto: (49.2.1 mediaplayer-app)
  • mto: This revision was merged to the branch mainline in revision 50.
  • Revision ID: michael.zanetti@canonical.com-20130221140903-fi9tyube84wvc92o
add initial autopilot structure

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
"""mediaplayer-app 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 mediaplayer_app.emulators.main_window import MainWindow
 
17
 
 
18
class MediaplayerAppTestCase(AutopilotTestCase, QtIntrospectionTestMixin):
 
19
 
 
20
    """A common test case class that provides several useful methods for mediaplayer-app tests."""
 
21
 
 
22
    def setUp(self):
 
23
        super(MediaplayerAppTestCase, 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
            "../../mediaplayer-app")
 
33
 
 
34
    def launch_test_installed(self):
 
35
        if self.running_on_device():
 
36
            self.app = self.launch_test_application(
 
37
               "mediaplyer-app",
 
38
               "--fullscreen")
 
39
        else:
 
40
            self.app = self.launch_test_application(
 
41
               "mediaplayer-app")
 
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