on xenial help sign in
Comment and docstring cleanup.
8f87949Christopher Lee
tests/autopilot/unity8/shell/tests/test_hud.py+31−40
@@ -5,24 +5,6 @@
5# under the terms of the GNU General Public License version 3, as published
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8−
9−# This file contains general purpose test cases for Unity.
10−# Each test written in this file will be executed for a variety of
11−# configurations, such as Phone, Tablet or Desktop form factors.
12−#
13−# Sometimes there is the need to disable a certain test for a particular
14−# configuration. To do so, add this in a new line directly below your test:
15−#
16−# test_testname.blacklist = (FormFactors.Tablet, FormFactors.Desktop,)
17−#
18−# Available form factors are:
19−# FormFactors.Phone
20−# FormFactors.Tablet
21−# FormFactors.Desktop
22−
23−
24−"""Tests for the Shell"""
25−
26from __future__ import absolute_import
8from __future__ import absolute_import
27
9
28from collections import namedtuple
10from collections import namedtuple
@@ -53,7 +35,7 @@ class TestHud(Unity8TestCase):
53 hud_show_button = self.main_window.get_hud_show_button()
35 hud_show_button = self.main_window.get_hud_show_button()
54 hud = self.main_window.get_hud()
36 hud = self.main_window.get_hud()
55
37
56− self._launch_application_from_app_screen()
38+ self._launch_test_app_from_app_screen()
57
39
58 swipe_coords = self._get_hud_button_swipe_coords(window, hud_show_button)
40 swipe_coords = self._get_hud_button_swipe_coords(window, hud_show_button)
59 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
41 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
@@ -69,7 +51,7 @@ class TestHud(Unity8TestCase):
69 hud_show_button = self.main_window.get_hud_show_button()
51 hud_show_button = self.main_window.get_hud_show_button()
70 hud = self.main_window.get_hud()
52 hud = self.main_window.get_hud()
71
53
72− self._launch_application_from_app_screen()
54+ self._launch_test_app_from_app_screen()
73
55
74 swipe_coords = self._get_hud_button_swipe_coords(window, hud_show_button)
56 swipe_coords = self._get_hud_button_swipe_coords(window, hud_show_button)
75 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
57 self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
@@ -119,14 +101,11 @@ class TestHud(Unity8TestCase):
119 self.launch_unity()
101 self.launch_unity()
120 self.main_window.get_greeter().unlock()
102 self.main_window.get_greeter().unlock()
121 hud = self.main_window.get_hud()
103 hud = self.main_window.get_hud()
122− hud.show()
123
104
124− self._launch_application_from_app_screen()
105+ self._launch_test_app_from_app_screen()
125−
106+ hud.show()
126− rect = hud.globalRect
127− x = int(rect[0] + rect[2] / 2)
128− y = rect[1] + self.grid_size
129
107
108+ x, y = hud.get_close_button_coords(self.grid_size)
130 self.touch.tap(x, y)
109 self.touch.tap(x, y)
131 self.assertThat(hud.shown, Eventually(Equals(False)))
110 self.assertThat(hud.shown, Eventually(Equals(False)))
132
111
@@ -140,17 +119,25 @@ class TestHud(Unity8TestCase):
140 # self.touch.tap(x, y)
119 # self.touch.tap(x, y)
141 # self.assertRaises(MismatchError, lambda: self.assertThat(hud.shown, Eventually(Equals(False), timeout=3)))
120 # self.assertRaises(MismatchError, lambda: self.assertThat(hud.shown, Eventually(Equals(False), timeout=3)))
142
121
143− # def test_hide_hud_dragging(self):
122+ def test_hide_hud_dragging(self):
123+ """Once open the Hud must close if the upper bar is dragged and released
124+ downward.
125+
126+ """
127+ self.launch_unity()
128+ self.main_window.get_greeter().unlock()
144− # hud = self.main_window.get_hud()
129+ hud = self.main_window.get_hud()
145− # self.unlock_greeter()
130+ window = self.main_window.get_qml_view()
146− # self.show_hud()
131+
147− # rect = hud.globalRect
132+ self._launch_test_app_from_app_screen()
148− # start_x = rect[0] + (rect[2] - rect[0]) / 2
133+ hud.show()
149− # start_y = rect[1] + 1
134+
135+ start_x, start_y = hud.get_close_button_coords(self.grid_size)
150− # stop_x = start_x
136+ end_x = start_x
151− # stop_y = start_y + (rect[3] - rect[1]) / 2
137+ end_y = int(window.height / 2)
138+
152− # self.touch.drag(start_x, start_y, stop_x, stop_y)
139+ self.touch.drag(start_x, start_y, end_x, end_y)
153− # self.assertThat(hud.shown, Eventually(Equals(False)))
140+ self.assertThat(hud.shown, Eventually(Equals(False)))
154
141
155 def test_launcher_hides_hud(self):
142 def test_launcher_hides_hud(self):
156 """Opening the Launcher while the Hud is active must close the Hud."""
143 """Opening the Launcher while the Hud is active must close the Hud."""
@@ -159,17 +146,17 @@ class TestHud(Unity8TestCase):
159 hud = self.main_window.get_hud()
146 hud = self.main_window.get_hud()
160 launcher = self.main_window.get_launcher()
147 launcher = self.main_window.get_launcher()
161
148
162− self._launch_application_from_app_screen()
149+ self._launch_test_app_from_app_screen()
163
150
164 hud.show()
151 hud.show()
165 launcher.show()
152 launcher.show()
166
153
167 self.assertThat(hud.shown, Eventually(Equals(False)))
154 self.assertThat(hud.shown, Eventually(Equals(False)))
168
155
169− def _launch_application_from_app_screen(self):
156+ def _launch_test_app_from_app_screen(self):
170 """Launches the camera app using the Dash UI.
157 """Launches the camera app using the Dash UI.
171
158
172− This is becuase when testing on the desktop running
159+ Because when testing on the desktop running
173 self.launch_application() will launch the application on the desktop
160 self.launch_application() will launch the application on the desktop
174 itself and not within the Unity8 UI.
161 itself and not within the Unity8 UI.
175
162
@@ -191,6 +178,10 @@ class TestHud(Unity8TestCase):
191 self.touch.release()
178 self.touch.release()
192
179
193 def _get_hud_button_swipe_coords(self, main_view, hud_show_button):
180 def _get_hud_button_swipe_coords(self, main_view, hud_show_button):
181+ """Returns the coords both start and end x,y for swiping to make the
182+ 'hud show' button appear.
183+
184+ """
194 start_x = int(main_view.x + (main_view.width / 2))
185 start_x = int(main_view.x + (main_view.width / 2))
195 end_x = start_x
186 end_x = start_x
196 start_y = main_view.y + (main_view.height -3)
187 start_y = main_view.y + (main_view.height -3)
tests/autopilot/unity8/shell/tests/test_lock_screen.py−2
@@ -6,8 +6,6 @@
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8
8
9−"""Tests for the Shell"""
10−
11from __future__ import absolute_import
9from __future__ import absolute_import
12
10
13from unity8.shell.tests import Unity8TestCase
11from unity8.shell.tests import Unity8TestCase