on xenial help sign in
Add get_grid_size for use in emulators.
commit6d154f1965bd7a7881fd61a410ed68cc111a6113 authorChristopher Lee <chris.lee@canonical.com> dateWed 17 Jul 2013, 19:20 (13 years ago) parent78e0bc9
5 files changed+10−9
tests/autopilot/unity8/__init__.py+4 tests/autopilot/unity8/shell/emulators/greeter.py+1 tests/autopilot/unity8/shell/emulators/hud.py+3−6 tests/autopilot/unity8/shell/tests/test_big_screen_alignment.py−1 tests/autopilot/unity8/shell/tests/test_hud.py+2−2
tests/autopilot/unity8/__init__.py+4
@@ -6,6 +6,7 @@
66# by the Free Software Foundation.
77
88"""unity8 autopilot tests and emulators - top level package."""
9+import os
910import os.path
1011import subprocess
1112import sysconfig
@@ -45,3 +46,6 @@ def get_unity8_binary_path():
4546 raise RuntimeError("Unable to locate unity8 binary: %r" % e)
4647 return binary_path
4748
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):
2929 self.created.wait_for(False)
3030
3131 #TODO: This was moved here from helpers.TestShellHelpersg
32+ # Needs a cleanup (used in borked above).
3233 def select_greeter_user(self, username):
3334 greeter = self.main_window.get_greeter()
3435 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
12from unity8.shell.emulators import Unity8EmulatorBase
23from autopilot.input import Touch
34
@@ -40,13 +41,9 @@ class Hud(Unity8EmulatorBase):
4041 x, y = self.get_close_button_coords()
4142 touch.tap(x, y)
4243
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):
4845 """Returns the coordinates of the Huds close button bar."""
4946 rect = self.globalRect
5047 x = int(rect[0] + rect[2] / 2)
51− y = rect[1] + grid_size
48+ y = rect[1] + get_grid_size()
5249 return x, y
tests/autopilot/unity8/shell/tests/test_big_screen_alignment.py−1
@@ -15,7 +15,6 @@ from unity8.shell.tests import Unity8TestCase
1515
1616# TODO: Find out if these tests are still required, if so, what they're supposed
1717# to be testing, and whether they're supposed to work on the devices.
18−# Also, this doesn't work as automatically scales the geometry . . .
1918class ScreenAlignmentTests(Unity8TestCase):
2019
2120 scenarios = [
tests/autopilot/unity8/shell/tests/test_hud.py+2−2
@@ -109,7 +109,7 @@ class TestHud(Unity8TestCase):
109109 self._launch_test_app_from_app_screen()
110110 hud.show()
111111
112− x, y = hud.get_close_button_coords(self.grid_size)
112+ x, y = hud.get_close_button_coords()
113113 self.touch.tap(x, y)
114114 self.assertThat(hud.shown, Eventually(Equals(False)))
115115
@@ -137,7 +137,7 @@ class TestHud(Unity8TestCase):
137137 self._launch_test_app_from_app_screen()
138138 hud.show()
139139
140− start_x, start_y = hud.get_close_button_coords(self.grid_size)
140+ start_x, start_y = hud.get_close_button_coords()
141141 end_x = start_x
142142 end_y = int(window.height / 2)
143143