on xenial help sign in
Add get_grid_size for use in emulators.
6d154f1Christopher Lee
tests/autopilot/unity8/__init__.py+4
@@ -6,6 +6,7 @@
6# by the Free Software Foundation.
6# by the Free Software Foundation.
7
7
8"""unity8 autopilot tests and emulators - top level package."""
8"""unity8 autopilot tests and emulators - top level package."""
9+import os
9import os.path
10import os.path
10import subprocess
11import subprocess
11import sysconfig
12import sysconfig
@@ -45,3 +46,6 @@ def get_unity8_binary_path():
45 raise RuntimeError("Unable to locate unity8 binary: %r" % e)
46 raise RuntimeError("Unable to locate unity8 binary: %r" % e)
46 return binary_path
47 return binary_path
47
48
49+
50+def get_grid_size():
51+ os.getenv('GRID_UNIT_PX')
tests/autopilot/unity8/shell/emulators/greeter.py+1
@@ -29,6 +29,7 @@ class Greeter(Unity8EmulatorBase):
29 self.created.wait_for(False)
29 self.created.wait_for(False)
30
30
31 #TODO: This was moved here from helpers.TestShellHelpersg
31 #TODO: This was moved here from helpers.TestShellHelpersg
32+ # Needs a cleanup (used in borked above).
32 def select_greeter_user(self, username):
33 def select_greeter_user(self, username):
33 greeter = self.main_window.get_greeter()
34 greeter = self.main_window.get_greeter()
34 self.assertThat(greeter.created, Eventually(Equals(True)))
35 self.assertThat(greeter.created, Eventually(Equals(True)))
tests/autopilot/unity8/shell/emulators/hud.py+3−6
@@ -1,3 +1,4 @@
1+from unity8 import get_grid_size
1from unity8.shell.emulators import Unity8EmulatorBase
2from unity8.shell.emulators import Unity8EmulatorBase
2from autopilot.input import Touch
3from autopilot.input import Touch
3
4
@@ -40,13 +41,9 @@ class Hud(Unity8EmulatorBase):
40 x, y = self.get_close_button_coords()
41 x, y = self.get_close_button_coords()
41 touch.tap(x, y)
42 touch.tap(x, y)
42
43
43− # TODO: Should grid_size be passed in or should we have a get_grid_size in
44− # unity8.__init__ that reads it from the env.
45− # Yeah I think so as it doesn't seem to make sense when passing it in.
46− # Plus as above shows, we don't always have it.
47− def get_close_button_coords(self, grid_size):
44+ def get_close_button_coords(self):
48 """Returns the coordinates of the Huds close button bar."""
45 """Returns the coordinates of the Huds close button bar."""
49 rect = self.globalRect
46 rect = self.globalRect
50 x = int(rect[0] + rect[2] / 2)
47 x = int(rect[0] + rect[2] / 2)
51− y = rect[1] + grid_size
48+ y = rect[1] + get_grid_size()
52 return x, y
49 return x, y
tests/autopilot/unity8/shell/tests/test_big_screen_alignment.py−1
@@ -15,7 +15,6 @@ from unity8.shell.tests import Unity8TestCase
15
15
16# TODO: Find out if these tests are still required, if so, what they're supposed
16# TODO: Find out if these tests are still required, if so, what they're supposed
17# to be testing, and whether they're supposed to work on the devices.
17# to be testing, and whether they're supposed to work on the devices.
18−# Also, this doesn't work as automatically scales the geometry . . .
19class ScreenAlignmentTests(Unity8TestCase):
18class ScreenAlignmentTests(Unity8TestCase):
20
19
21 scenarios = [
20 scenarios = [
tests/autopilot/unity8/shell/tests/test_hud.py+2−2
@@ -109,7 +109,7 @@ class TestHud(Unity8TestCase):
109 self._launch_test_app_from_app_screen()
109 self._launch_test_app_from_app_screen()
110 hud.show()
110 hud.show()
111
111
112− x, y = hud.get_close_button_coords(self.grid_size)
112+ x, y = hud.get_close_button_coords()
113 self.touch.tap(x, y)
113 self.touch.tap(x, y)
114 self.assertThat(hud.shown, Eventually(Equals(False)))
114 self.assertThat(hud.shown, Eventually(Equals(False)))
115
115
@@ -137,7 +137,7 @@ class TestHud(Unity8TestCase):
137 self._launch_test_app_from_app_screen()
137 self._launch_test_app_from_app_screen()
138 hud.show()
138 hud.show()
139
139
140− start_x, start_y = hud.get_close_button_coords(self.grid_size)
140+ start_x, start_y = hud.get_close_button_coords()
141 end_x = start_x
141 end_x = start_x
142 end_y = int(window.height / 2)
142 end_y = int(window.height / 2)
143
143