@@ -1,46 +1,66 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−# Copyright 2013 Canonical
3+# Unity8 Autopilot Test Suite
4+# Copyright (C) 2012-2013 Canonical
4−# This program is free software: you can redistribute it and/or modify it
6+# This program is free software: you can redistribute it and/or modify
5−# under the terms of the GNU General Public License version 3, as published
7+# it under the terms of the GNU General Public License as published by
6−# by the Free Software Foundation.
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
8"""unity8 autopilot tests."""
20"""unity8 autopilot tests."""
10from autopilot.platform import model
22from autopilot.platform import model
11from autopilot.testcase import AutopilotTestCase
23from autopilot.testcase import AutopilotTestCase
12from autopilot.matchers import Eventually
24from autopilot.matchers import Eventually
13−from testtools.matchers import Equals, NotEquals
14from autopilot.input import Touch
25from autopilot.input import Touch
15from autopilot.display import Display
26from autopilot.display import Display
16import logging
27import logging
17import os.path
28import os.path
18−import sysconfig
29+from testtools.matchers import Equals, NotEquals
20from unity8 import get_lib_path, get_unity8_binary_path
31from unity8 import get_lib_path, get_unity8_binary_path
21−from unity8.shell.emulators.main_window import MainWindow
22from unity8.shell.emulators import Unity8EmulatorBase
32from unity8.shell.emulators import Unity8EmulatorBase
23from unity8.shell.emulators.dash import Dash
33from unity8.shell.emulators.dash import Dash
34+from unity8.shell.emulators.main_window import MainWindow
26logger = logging.getLogger(__name__)
37logger = logging.getLogger(__name__)
29−class FormFactors(object):
30− Phone, Tablet, Desktop = range(3)
32def _get_device_emulation_scenarios():
40def _get_device_emulation_scenarios():
33 if model() == 'Desktop':
41 if model() == 'Desktop':
35− ('Desktop Nexus 4', dict(app_width=768, app_height=1280, grid_unit_px=18)),
45+ dict(app_width=768, app_height=1280, grid_unit_px=18)
36− ('Desktop Nexus 10', dict(app_width=2560, app_height=1600, grid_unit_px=20)),
49+ dict(app_width=2560, app_height=1600, grid_unit_px=20)
39− return [ ('Native Device', dict(app_width=0, app_height=0, grid_unit_px=0)) ]
56+ dict(app_width=0, app_height=0, grid_unit_px=0)
41class Unity8TestCase(AutopilotTestCase):
61class Unity8TestCase(AutopilotTestCase):
43− """A sane test case base class for the Unity8 shell tests."""
63+ """A test case base class for the Unity8 shell tests."""
45 def setUp(self):
65 def setUp(self):
46 super(Unity8TestCase, self).setUp()
66 super(Unity8TestCase, self).setUp()
@@ -49,7 +69,6 @@ class Unity8TestCase(AutopilotTestCase):
49 self._setup_display_details()
69 self._setup_display_details()
51 def _setup_display_details(self):
71 def _setup_display_details(self):
52− # This needs a bit of a cleanup, make it clearer
53 scale_divisor = self._determine_geometry()
72 scale_divisor = self._determine_geometry()
54 self._setup_grid_size(scale_divisor)
73 self._setup_grid_size(scale_divisor)
@@ -65,12 +84,18 @@ class Unity8TestCase(AutopilotTestCase):
65 scale_divisor = self._get_scaled_down_geo(width, height)
84 scale_divisor = self._get_scaled_down_geo(width, height)
66 width = width / scale_divisor
85 width = width / scale_divisor
67 height = height / scale_divisor
86 height = height / scale_divisor
68− logger.info("Provided geometry larger than Display, scaled down to: %sx%s",
88+ "Geometry larger than display, scaled down to: %dx%d",
72− geo_string = "%sx%s" % (width, height)
92+ geo_string = "%dx%d" % (width, height)
73− self.unity_geometry_args = ['-geometry', geo_string, '-frameless', '-mousetouch']
93+ self.unity_geometry_args = [
74 return scale_divisor
99 return scale_divisor
76 def _setup_grid_size(self, scale_divisor):
101 def _setup_grid_size(self, scale_divisor):
@@ -122,18 +147,18 @@ class Unity8TestCase(AutopilotTestCase):
122 self._set_proxy(app_proxy)
147 self._set_proxy(app_proxy)
124 # Ensure that the dash is visible before we return:
149 # Ensure that the dash is visible before we return:
125− self.assertThat(self.get_dash().showScopeOnLoaded, Eventually(Equals("")))
151+ self.get_dash().showScopeOnLoaded,
152+ Eventually(Equals(""))
126 return app_proxy
154 return app_proxy
128 def _patch_environment(self, lib_path):
156 def _patch_environment(self, lib_path):
129 """Patch environment variables for launching the unity8 shell."""
157 """Patch environment variables for launching the unity8 shell."""
130− # ld_lib_path_patches = (
131− # os.path.join(lib_path, "qml/mocks/libusermetrics"),
132− # os.path.join(lib_path, "qml/mocks/LightDM/" + self.lightdm_mock),
135− # self.patch_environment("LD_LIBRARY_PATH", ":".join(ld_lib_path_patches))
158+ self.patch_environment(
136− self.patch_environment("QML2_IMPORT_PATH", os.path.join(lib_path, "qml/mocks"))
160+ os.path.join(lib_path, "qml/mocks")
138 def _set_proxy(self, proxy):
163 def _set_proxy(self, proxy):
139 """Keep a copy of the proxy object, so we can use it to get common parts
164 """Keep a copy of the proxy object, so we can use it to get common parts