@@ -20,12 +20,13 @@
20from __future__ import absolute_import
20from __future__ import absolute_import
22from unity8.process_helpers import unlock_unity
22from unity8.process_helpers import unlock_unity
23−from unity8.shell import with_lightdm_mock, DragMixin
23+from unity8.shell import DragMixin
24from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
24from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
26from testtools.matchers import Equals
26from testtools.matchers import Equals
27from autopilot.matchers import Eventually
27from autopilot.matchers import Eventually
29class TestHud(UnityTestCase, DragMixin):
30class TestHud(UnityTestCase, DragMixin):
31 """Tests the Shell HUD."""
32 """Tests the Shell HUD."""
@@ -33,10 +34,14 @@ class TestHud(UnityTestCase, DragMixin):
33 scenarios = _get_device_emulation_scenarios()
34 scenarios = _get_device_emulation_scenarios()
35 def test_show_hud_button_appears(self):
36 def test_show_hud_button_appears(self):
36− """Swiping up while an app is active must show the 'show hud' button, following some behaviours.
37+ """Swiping up while an app is active must show the 'show hud' button.
39+ It should follow some behaviours.
37 The button must disappear not opening the HUD when releasing the
40 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.
41+ mouse again somewhere on the screen except on the button itself
39− The button must disappear when touching somewhere on the screen except the button itself.
43+ The button must disappear when touching somewhere on the screen
44+ except the button itself.
42 unity_proxy = self.launch_unity()
47 unity_proxy = self.launch_unity()
@@ -55,29 +60,47 @@ class TestHud(UnityTestCase, DragMixin):
56 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
61 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
57 self.addCleanup(self._maybe_release_finger)
62 self.addCleanup(self._maybe_release_finger)
64+ swipe_coords.start_x,
65+ swipe_coords.start_y,
66+ swipe_coords.start_x,
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)
67+ swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5)
59 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.5)))
68 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.5)))
70+ hud_show_button.bottomMargin,
60− self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(initialBottomMargin)))
71+ Eventually(Equals(initialBottomMargin)))
73+ swipe_coords.start_x,
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)
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)
62 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
78 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
63 self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
79 self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
64− self.touch.release();
80+ self.touch.release()
65 self.assertThat(hud.shown, Equals(False))
81 self.assertThat(hud.shown, Equals(False))
66 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
82 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
68 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
84 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
86+ swipe_coords.start_x,
87+ swipe_coords.start_y,
88+ swipe_coords.start_x,
69− self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height))
89+ swipe_coords.end_y - int(hud_show_button.height))
70 self.assertThat(hud.shown, Equals(False))
90 self.assertThat(hud.shown, Equals(False))
71 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
91 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
72 self.touch.release()
92 self.touch.release()
73 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
93 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))
96+ swipe_coords.end_y - int(hud_show_button.height))
75 self.assertThat(hud.shown, Equals(False))
97 self.assertThat(hud.shown, Equals(False))
76 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
98 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
78 def test_show_hud_appears(self):
100 def test_show_hud_appears(self):
79 """Releasing the touch on the 'show hud' button must display the hud.
101 """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.
102+ Test that the hud button stays on screen and tapping it opens the
83 unity_proxy = self.launch_unity()
106 unity_proxy = self.launch_unity()
@@ -94,7 +117,11 @@ class TestHud(UnityTestCase, DragMixin):
95 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
118 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
96 self.addCleanup(self._maybe_release_finger)
119 self.addCleanup(self._maybe_release_finger)
97− self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y)
120+ self._drag(
121+ swipe_coords.start_x,
122+ swipe_coords.start_y,
123+ swipe_coords.start_x,
98 self.assertThat(hud.shown, Eventually(Equals(False)))
125 self.assertThat(hud.shown, Eventually(Equals(False)))
99 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
126 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
100 self.touch.release()
127 self.touch.release()
@@ -105,7 +132,11 @@ class TestHud(UnityTestCase, DragMixin):
105 self.assertThat(hud.shown, Eventually(Equals(False)))
132 self.assertThat(hud.shown, Eventually(Equals(False)))
107 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
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,
108− self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y - int(hud_show_button.height))
139+ swipe_coords.end_y - int(hud_show_button.height))
109 self.assertThat(hud.shown, Equals(False))
140 self.assertThat(hud.shown, Equals(False))
110 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
141 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
111 self.touch.release()
142 self.touch.release()