20 from __future__
import absolute_import
26 from testtools.matchers
import Equals
27 from autopilot.matchers
import Eventually
32 """Tests the Shell HUD."""
34 scenarios = _get_device_emulation_scenarios()
37 """Swiping up while an app is active must show the 'show hud' button.
39 It should follow some behaviours.
40 The button must disappear not opening the HUD when releasing the
41 mouse again somewhere on the screen except on the button itself
43 The button must disappear when touching somewhere on the screen
44 except the button itself.
48 unlock_unity(unity_proxy)
49 hud_show_button = self.main_window.get_hud_show_button()
50 edge_drag_area = self.main_window.get_hud_edge_drag_area()
51 hud = self.main_window.get_hud()
55 swipe_coords = hud.get_button_swipe_coords(
59 initialBottomMargin = int(hud_show_button.bottomMargin)
61 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
67 swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5)
68 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.5)))
70 hud_show_button.bottomMargin,
71 Eventually(Equals(initialBottomMargin)))
74 swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5,
76 swipe_coords.start_y - int(edge_drag_area.distanceThreshold) -
77 int(edge_drag_area.commitDistance) - 5)
78 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
79 self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
81 self.assertThat(hud.shown, Equals(
False))
82 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
84 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
89 swipe_coords.end_y - int(hud_show_button.height))
90 self.assertThat(hud.shown, Equals(
False))
91 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
93 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
96 swipe_coords.end_y - int(hud_show_button.height))
97 self.assertThat(hud.shown, Equals(
False))
98 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
101 """Releasing the touch on the 'show hud' button must display the hud.
102 Test that the hud button stays on screen and tapping it opens the
107 unlock_unity(unity_proxy)
108 hud_show_button = self.main_window.get_hud_show_button()
109 hud = self.main_window.get_hud()
113 swipe_coords = hud.get_button_swipe_coords(
118 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
121 swipe_coords.start_x,
122 swipe_coords.start_y,
123 swipe_coords.start_x,
125 self.assertThat(hud.shown, Eventually(Equals(
False)))
126 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
128 self.assertThat(hud.shown, Eventually(Equals(
True)))
129 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
130 x, y = hud.get_close_button_coords()
132 self.assertThat(hud.shown, Eventually(Equals(
False)))
134 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
136 swipe_coords.start_x,
137 swipe_coords.start_y,
138 swipe_coords.start_x,
139 swipe_coords.end_y - int(hud_show_button.height))
140 self.assertThat(hud.shown, Equals(
False))
141 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
143 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
144 self.touch.tap(swipe_coords.end_x, swipe_coords.end_y)
145 self.assertThat(hud.shown, Eventually(Equals(
True)))
146 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
149 """Tapping the close button of the Hud must dismiss it."""
151 unlock_unity(unity_proxy)
152 hud = self.main_window.get_hud()
158 x, y = hud.get_close_button_coords()
160 self.assertThat(hud.shown, Eventually(Equals(
False)))
163 """Once open the Hud must close if the upper bar is dragged and
168 unlock_unity(unity_proxy)
169 hud = self.main_window.get_hud()
175 start_x, start_y = hud.get_close_button_coords()
177 end_y = int(self.main_window.height / 2)
179 self.touch.drag(start_x, start_y, end_x, end_y)
180 self.assertThat(hud.shown, Eventually(Equals(
False)))
183 """Opening the Launcher while the Hud is active must close the Hud."""
185 unlock_unity(unity_proxy)
186 hud = self.main_window.get_hud()
187 launcher = self.main_window.get_launcher()
194 self.assertThat(hud.shown, Eventually(Equals(
False)))
196 def _launch_test_app_from_app_screen(self):
197 """Launches the browser app using the Dash UI.
199 Because when testing on the desktop running
200 self.launch_application() will launch the application on the desktop
201 itself and not within the Unity UI.
204 dash = self.main_window.get_dash()
205 icon = dash.get_application_icon(
'Browser')
206 self.touch.tap_object(icon)
209 bottombar = self.main_window.get_bottombar()
210 self.assertThat(bottombar.applicationIsOnForeground,
211 Eventually(Equals(
True)))
216 def _maybe_release_finger(self):
217 """Only release the finger if it is in fact down."""
222 pressed = self.touch._touch_finger
is not None
223 except AttributeError:
224 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