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
"""unity8 autopilot tests."""
12
from autopilot.testcase import AutopilotTestCase
13
from autopilot.matchers import Eventually
14
from autopilot.platform import model
15
from testtools.matchers import Equals
17
from unity8.emulators.main_window import MainWindow
19
class FormFactors(object):
20
Phone, Tablet, Desktop = range(3)
22
class ShellTestCase(AutopilotTestCase):
24
"""A common test case class that provides several useful methods for shell tests."""
28
def setUp(self, geometry, grid_size):
29
super(ShellTestCase, self).setUp()
30
# Lets assume we are installed system wide if this file is somewhere in /usr
32
os.environ['GRID_UNIT_PX'] = grid_size
33
self.grid_size = int(grid_size)
35
self.grid_size = int(os.environ['GRID_UNIT_PX'])
36
if os.path.realpath(__file__).startswith("/usr/"):
37
self.launch_test_installed(geometry)
39
self.launch_test_local(geometry)
41
def launch_test_local(self, geometry):
42
os.environ['LD_LIBRARY_PATH'] = "../../../unity_build/build/lib:../../builddir/tests/mocks/LightDM/" + self.lightdm_mock
43
os.environ['QML2_IMPORT_PATH'] = "../../builddir/tests/mocks:../../builddir/plugins"
45
self.app = self.launch_test_application(
46
"../../builddir/unity8", "-geometry", geometry, "-frameless", app_type='qt')
48
self.app = self.launch_test_application(
49
"../../builddir/unity8", "-fullscreen", app_type='qt')
51
def launch_test_installed(self, geometry):
52
os.environ['LD_LIBRARY_PATH'] = "/usr/share/unity8/plugins/mocks/LightDM/" + self.lightdm_mock
53
os.environ['QML2_IMPORT_PATH'] = "/usr/share/unity8/plugins/mocks:/usr/share/unity8/plugins"
54
if model() == 'Desktop' and geometry != "0x0":
55
self.app = self.launch_test_application(
56
"unity8", "-geometry", geometry, "-frameless", app_type='qt')
58
self.app = self.launch_test_application(
59
"unity8", "-fullscreen", app_type='qt')
61
def skipWrapper(*args, **kwargs):
64
def form_factor(self):
65
return FormFactors.Desktop
67
def __getattribute__(self, attr_name):
68
attr = object.__getattribute__(self, attr_name);
69
if attr_name.startswith("test_"):
71
if self.form_factor() in attr.blacklist:
72
return self.skipWrapper
78
def main_window(self):
79
return MainWindow(self.app)