@@ -20,12 +20,13 @@
2020from __future__ import absolute_import
2121
2222from unity8.process_helpers import unlock_unity
23−from unity8.shell import with_lightdm_mock, DragMixin
23+from unity8.shell import DragMixin
2424from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2525
2626from testtools.matchers import Equals
2727from autopilot.matchers import Eventually
2828
29+
2930class TestHud(UnityTestCase, DragMixin):
3031
3132 """Tests the Shell HUD."""
@@ -33,10 +34,14 @@ class TestHud(UnityTestCase, DragMixin):
3334 scenarios = _get_device_emulation_scenarios()
3435
3536 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.
38+
39+ It should follow some behaviours.
3740 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.
41+ mouse again somewhere on the screen except on the button itself
42+ following a timeout.
43+ The button must disappear when touching somewhere on the screen
44+ except the button itself.
4045
4146 """
4247 unity_proxy = self.launch_unity()
@@ -55,29 +60,47 @@ class TestHud(UnityTestCase, DragMixin):
5560
5661 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
5762 self.addCleanup(self._maybe_release_finger)
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)
63+ self._drag(
64+ swipe_coords.start_x,
65+ swipe_coords.start_y,
66+ swipe_coords.start_x,
67+ swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5)
5968 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)
69+ self.assertThat(
70+ hud_show_button.bottomMargin,
71+ Eventually(Equals(initialBottomMargin)))
72+ self._drag(
73+ swipe_coords.start_x,
74+ swipe_coords.start_y - int(edge_drag_area.distanceThreshold) - 5,
75+ swipe_coords.end_x,
76+ swipe_coords.start_y - int(edge_drag_area.distanceThreshold) -
77+ int(edge_drag_area.commitDistance) - 5)
6278 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
6379 self.assertThat(hud_show_button.bottomMargin, Eventually(Equals(0.0)))
64− self.touch.release();
80+ self.touch.release()
6581 self.assertThat(hud.shown, Equals(False))
6682 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
6783
6884 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))
85+ self._drag(
86+ swipe_coords.start_x,
87+ swipe_coords.start_y,
88+ swipe_coords.start_x,
89+ swipe_coords.end_y - int(hud_show_button.height))
7090 self.assertThat(hud.shown, Equals(False))
7191 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
7292 self.touch.release()
7393 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))
94+ self.touch.tap(
95+ swipe_coords.end_x,
96+ swipe_coords.end_y - int(hud_show_button.height))
7597 self.assertThat(hud.shown, Equals(False))
7698 self.assertThat(hud_show_button.opacity, Eventually(Equals(0.0)))
7799
78100 def test_show_hud_appears(self):
79101 """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
103+ hud.
81104
82105 """
83106 unity_proxy = self.launch_unity()
@@ -94,7 +117,11 @@ class TestHud(UnityTestCase, DragMixin):
94117
95118 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
96119 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,
124+ swipe_coords.end_y)
98125 self.assertThat(hud.shown, Eventually(Equals(False)))
99126 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
100127 self.touch.release()
@@ -105,7 +132,11 @@ class TestHud(UnityTestCase, DragMixin):
105132 self.assertThat(hud.shown, Eventually(Equals(False)))
106133
107134 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))
135+ self._drag(
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))
109140 self.assertThat(hud.shown, Equals(False))
110141 self.assertThat(hud_show_button.opacity, Eventually(Equals(1.0)))
111142 self.touch.release()