1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2013 Canonical
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.
8
"""qml-phone-shell autopilot tests."""
12
from autopilot.input import Mouse, Touch, Pointer
13
from autopilot.testcase import AutopilotTestCase
14
from autopilot.matchers import Eventually
15
from autopilot.platform import model
16
from testtools.matchers import Equals
18
from unity8.indicators_client.emulators.main_window import MainWindow
19
from logging import getLogger
21
from time import sleep
23
log = getLogger(__name__)
25
class FormFactors(object):
26
Phone, Tablet, Desktop = range(3)
28
class IndicatorsTestCase(AutopilotTestCase):
30
"""A common test case class that provides several useful methods for indicator tests."""
32
if model() == 'Desktop':
34
('with mouse', dict(input_device_class=Mouse)),
38
('with touch', dict(input_device_class=Touch)),
41
def setUp(self, geometry, grid_size):
42
self.pointing_device = Pointer(self.input_device_class.create())
43
super(IndicatorsTestCase, self).setUp()
45
os.environ['GRID_UNIT_PX'] = grid_size
46
self.grid_size = int(grid_size)
48
self.grid_size = int(os.environ['GRID_UNIT_PX'])
50
if os.path.realpath(__file__).startswith("/usr/"):
51
self.launch_test_installed(geometry)
53
self.launch_test_local(geometry)
55
def launch_test_local(self, geometry):
57
self.app = self.launch_test_application("../../builddir/src/Panel/Indicators/client/indicators-client",
58
"-geometry", geometry, app_type='qt')
60
self.app = self.launch_test_application("../../builddir/src/Panel/Indicators/client/indicators-client",
63
def launch_test_installed(self, geometry):
65
self.app = self.launch_test_application("indicators-client", "-geometry", geometry, app_type='qt')
67
self.app = self.launch_test_application("indicators-client", app_type='qt')
69
def skipWrapper(*args, **kwargs):
72
def form_factor(self):
73
return FormFactors.Desktop
75
def __getattribute__(self, attr_name):
76
attr = object.__getattribute__(self, attr_name);
77
if attr_name.startswith("test_"):
79
if self.form_factor() in attr.blacklist:
80
return self.skipWrapper
86
def main_window(self):
87
return MainWindow(self.app)