@@ -19,29 +19,30 @@
1919
2020from __future__ import absolute_import
2121
22−from unity8.shell import with_lightdm_mock
22+from unity8.shell import with_lightdm_mock, DragMixin
2323from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2424
2525from testtools.matchers import Equals
2626from autopilot.matchers import Eventually
2727
28−
29−class TestHud(UnityTestCase):
28+class TestHud(UnityTestCase, DragMixin):
3029
3130 """Tests the Shell HUD."""
3231
3332 scenarios = _get_device_emulation_scenarios()
3433
3534 def test_show_hud_button_appears(self):
36− """Swiping up while an app is active must show the 'show hud' button.
35+ """Swiping up while an app is active must show the 'show hud' button, following some behaviours.
3736 The button must disappear not opening the HUD when releasing the
38− mouse again somewhere on the screen except on the button itself.
37+ mouse again somewhere on the screen except on the button itself following a timeout.
38+ The button must disappear when touching somewhere on the screen except the button itself.
3939
4040 """
4141 self.launch_unity()
4242 self.main_window.get_greeter().swipe()
4343 window = self.main_window.get_qml_view()
4444 hud_show_button = self.main_window.get_hud_show_button()
45+ edge_drag_area = self.main_window.get_hud_edge_drag_area()
4546 hud = self.main_window.get_hud()
4647
4748 self._launch_test_app_from_app_screen()
@@ -50,16 +51,33 @@ class TestHud(UnityTestCase):
5051 window,
5152 hud_show_button
5253 )
54+ initialBottomMargin = int(hud_show_button.bottomMargin)
55+
5356 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
5457 self.addCleanup(self._maybe_release_finger)
55− self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y + hud_show_button.height);
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)
5662 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
63+ self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
5764 self.touch.release();
65+ self.assertThat(hud.shown, Equals(False))
5866 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
67+
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)))
72+ self.touch.release()
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))
5975 self.assertThat(hud.shown, Equals(False))
76+ self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
6077
6178 def test_show_hud_appears(self):
6279 """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.
6381
6482 """
6583 self.launch_unity()
@@ -74,14 +92,28 @@ class TestHud(UnityTestCase):
7492 window,
7593 hud_show_button
7694 )
95+
7796 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
7897 self.addCleanup(self._maybe_release_finger)
79− self.touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
80−
98+ self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y)
99+ self.assertThat(hud.shown, Eventually(Equals(False)))
100+ self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
101+ self.touch.release()
102+ self.assertThat(hud.shown, Eventually(Equals(True)))
103+ self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
104+ x, y = hud.get_close_button_coords()
105+ self.touch.tap(x, y)
81106 self.assertThat(hud.shown, Eventually(Equals(False)))
107+
108+ self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
109+ self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height))
110+ self.assertThat(hud.shown, Equals(False))
82111 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
83112 self.touch.release()
113+ self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
114+ self.touch.tap(swipe_coords.end_x, swipe_coords.end_y)
84115 self.assertThat(hud.shown, Eventually(Equals(True)))
116+ self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
85117
86118 def test_hide_hud_click(self):
87119 """Tapping the close button of the Hud must dismiss it."""
@@ -90,6 +122,7 @@ class TestHud(UnityTestCase):
90122 hud = self.main_window.get_hud()
91123
92124 self._launch_test_app_from_app_screen()
125+
93126 hud.show()
94127
95128 x, y = hud.get_close_button_coords()
@@ -103,10 +136,11 @@ class TestHud(UnityTestCase):
103136 """
104137 self.launch_unity()
105138 self.main_window.get_greeter().swipe()
106− hud = self.main_window.get_hud()
107139 window = self.main_window.get_qml_view()
140+ hud = self.main_window.get_hud()
108141
109142 self._launch_test_app_from_app_screen()
143+
110144 hud.show()
111145
112146 start_x, start_y = hud.get_close_button_coords()