20 """Tests for shell-rotation"""
22 from autopilot.platform
import model
29 from testtools.matchers
import Equals
30 from autopilot.matchers
import Eventually
32 logger = logging.getLogger(__name__)
36 """Base class for all shell-rotation tests that provides helper methods."""
39 if model() ==
'Desktop':
40 self.skipTest(
'Test cannot be run on the desktop.')
45 def _assert_change_of_orientation_and_angle(self):
46 self.assertThat(self.shell_proxy.orientation,
47 Eventually(Equals(self.orientation)))
48 self.assertThat(self.shell_proxy.orientationAngle,
49 Eventually(Equals(self.angle)))
53 scenarios = [(
'top up', {
'action':
'top_up',
'orientation': 1}),
54 (
'right up', {
'action':
'right_up',
'orientation': 8}),
55 (
'top down', {
'action':
'top_down',
'orientation': 4}),
56 (
'left up', {
'action':
'left_up',
'orientation': 2})]
58 def test_fake_sensor(self):
60 self.useFixture(unity_with_sensors)
61 process_helpers.unlock_unity()
62 fake_sensors = unity_with_sensors.fake_sensors
63 o_proxy = unity_with_sensors.main_win.select_single(
'OrientedShell')
65 fake_sensors.set_orientation(self.action)
66 self.assertThat(o_proxy.physicalOrientation,
67 Eventually(Equals(self.orientation), timeout=15))
73 {
'action':
'top_up',
'orientation': 1,
'angle': 0}),
74 (
'right up, angle 90',
75 {
'action':
'right_up',
'orientation': 8,
'angle': 90}),
76 (
'top down, angle 180',
77 {
'action':
'top_down',
'orientation': 4,
'angle': 180}),
78 (
'left up, angle 270',
79 {
'action':
'left_up',
'orientation': 2,
'angle': 270})]
81 def test_rotation_with_webbrowser_app(self):
82 """Do an orientation-change and verify that an app and the shell
86 self.useFixture(unity_with_sensors)
87 process_helpers.unlock_unity()
88 fake_sensors = unity_with_sensors.fake_sensors
89 o_proxy = unity_with_sensors.main_win.select_single(
'OrientedShell')
90 self.shell_proxy = unity_with_sensors.main_win.select_single(
'Shell')
93 self.launch_upstart_application(
'webbrowser-app')
94 unity_with_sensors.main_win.show_dash_from_launcher()
95 unity_with_sensors.main_win.launch_application(
'webbrowser-app')
98 if not (self.shell_proxy.orientation & o_proxy.supportedOrientations):
99 self.skipTest(
'unsupported orientation ' + self.action)
102 unity_with_sensors.main_win.get_current_focused_app_id(),
103 Eventually(Equals(
'webbrowser-app')))
106 self.orientation = self.shell_proxy.orientation
107 self.angle = self.shell_proxy.orientationAngle
110 fake_sensors.set_orientation(self.action)
111 self.assertThat(o_proxy.physicalOrientation,
112 Eventually(Equals(self.orientation), timeout=15))
def _assert_change_of_orientation_and_angle(self)