20 from __future__
import absolute_import
26 from testtools.matchers
import Equals
27 from autopilot.matchers
import Eventually
31 """Tests the Shell HUD."""
33 scenarios = _get_device_emulation_scenarios()
36 """Swiping up while an app is active must show the 'show hud' button, following some behaviours.
37 The button must disappear not opening the HUD when releasing the
38 mouse again somewhere on the screen except on the button itself following a timeout.
39 The button must disappear when touching somewhere on the screen except the button itself.
43 unlock_unity(unity_proxy)
44 hud_show_button = self.main_window.get_hud_show_button()
45 edge_drag_area = self.main_window.get_hud_edge_drag_area()
46 hud = self.main_window.get_hud()
50 swipe_coords = hud.get_button_swipe_coords(
54 initialBottomMargin = int(hud_show_button.bottomMargin)
56 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
58 self.
_drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5)
59 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.5)))
60 self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(initialBottomMargin)))
61 self.
_drag(swipe_coords.start_x, swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5, swipe_coords.end_x, swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - int(edge_drag_area.commitDistance) - 5)
62 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
63 self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
65 self.assertThat(hud.shown, Equals(
False))
66 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
68 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
69 self.
_drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height))
70 self.assertThat(hud.shown, Equals(
False))
71 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
73 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
74 self.touch.tap(swipe_coords.end_x, swipe_coords.end_y - int(hud_show_button.height))
75 self.assertThat(hud.shown, Equals(
False))
76 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
79 """Releasing the touch on the 'show hud' button must display the hud.
80 Test that the hud button stays on screen and tapping it opens the hud.
84 unlock_unity(unity_proxy)
85 hud_show_button = self.main_window.get_hud_show_button()
86 hud = self.main_window.get_hud()
90 swipe_coords = hud.get_button_swipe_coords(
95 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
97 self.
_drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y)
98 self.assertThat(hud.shown, Eventually(Equals(
False)))
99 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
101 self.assertThat(hud.shown, Eventually(Equals(
True)))
102 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
103 x, y = hud.get_close_button_coords()
105 self.assertThat(hud.shown, Eventually(Equals(
False)))
107 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
108 self.
_drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height))
109 self.assertThat(hud.shown, Equals(
False))
110 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
112 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
113 self.touch.tap(swipe_coords.end_x, swipe_coords.end_y)
114 self.assertThat(hud.shown, Eventually(Equals(
True)))
115 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
118 """Tapping the close button of the Hud must dismiss it."""
120 unlock_unity(unity_proxy)
121 hud = self.main_window.get_hud()
127 x, y = hud.get_close_button_coords()
129 self.assertThat(hud.shown, Eventually(Equals(
False)))
132 """Once open the Hud must close if the upper bar is dragged and
137 unlock_unity(unity_proxy)
138 hud = self.main_window.get_hud()
144 start_x, start_y = hud.get_close_button_coords()
146 end_y = int(self.main_window.height / 2)
148 self.touch.drag(start_x, start_y, end_x, end_y)
149 self.assertThat(hud.shown, Eventually(Equals(
False)))
152 """Opening the Launcher while the Hud is active must close the Hud."""
154 unlock_unity(unity_proxy)
155 hud = self.main_window.get_hud()
156 launcher = self.main_window.get_launcher()
163 self.assertThat(hud.shown, Eventually(Equals(
False)))
165 def _launch_test_app_from_app_screen(self):
166 """Launches the browser app using the Dash UI.
168 Because when testing on the desktop running
169 self.launch_application() will launch the application on the desktop
170 itself and not within the Unity UI.
173 dash = self.main_window.get_dash()
174 icon = dash.get_application_icon(
'Browser')
175 self.touch.tap_object(icon)
178 bottombar = self.main_window.get_bottombar()
179 self.assertThat(bottombar.applicationIsOnForeground,
180 Eventually(Equals(
True)))
185 def _maybe_release_finger(self):
186 """Only release the finger if it is in fact down."""
191 pressed = self.touch._touch_finger
is not None
192 except AttributeError:
193 pressed = self.touch.pressed
def _maybe_release_finger
def test_hide_hud_dragging
def _launch_test_app_from_app_screen
def test_show_hud_appears
def test_launcher_hides_hud
def test_show_hud_button_appears