on xenial help sign in
Prepare unity8 to the _uinput refactors in autopilot.
d245b9fLeo Arias
tests/autopilot/unity8/shell/__init__.py+11−2
@@ -50,13 +50,22 @@ def disable_qml_mocking(fn):
50
50
51class DragMixin(object):
51class DragMixin(object):
52 def _drag(self, x1, y1, x2, y2):
52 def _drag(self, x1, y1, x2, y2):
53+ # XXX This ugly code is here just temporarily, waiting for drag
54+ # improvements to land on autopilot so we don't have to access device
55+ # private internal attributes. --elopio - 2014-02-12
53 cur_x = x1
56 cur_x = x1
54 cur_y = y1
57 cur_y = y1
55 dx = 1.0 * (x2 - x1) / 100
58 dx = 1.0 * (x2 - x1) / 100
56 dy = 1.0 * (y2 - y1) / 100
59 dy = 1.0 * (y2 - y1) / 100
57 for i in range(0, 100):
60 for i in range(0, 100):
61+ try:
58− self.touch._finger_move(int(cur_x), int(cur_y))
62+ self.touch._finger_move(int(cur_x), int(cur_y))
63+ except AttributeError:
64+ self.touch._device.finger_move(int(cur_x), int(cur_y))
59 sleep(0.002)
65 sleep(0.002)
60 cur_x += dx
66 cur_x += dx
61 cur_y += dy
67 cur_y += dy
68+ try:
62− self.touch._finger_move(int(x2), int(y2))
69+ self.touch._finger_move(int(x2), int(y2))
70+ except AttributeError:
71+ self.touch._device.finger_move(int(x2), int(y2))
tests/autopilot/unity8/shell/emulators/hud.py+8−1
@@ -54,7 +54,14 @@ class Hud(UnityEmulatorBase, DragMixin):
54 except AssertionError:
54 except AssertionError:
55 raise
55 raise
56 finally:
56 finally:
57+ # XXX This ugly code is here just temporarily, waiting for uinput
58+ # improvements to land on autopilot so we don't have to access
59+ # device private internal attributes. --elopio - 2014-02-12
60+ try:
57− if self.touch._touch_finger is not None:
61+ pressed = self.touch._touch_finger is not None
62+ except AttributeError:
63+ pressed = self.touch.pressed
64+ if pressed:
58 self.touch.release()
65 self.touch.release()
59
66
60 def dismiss(self):
67 def dismiss(self):
tests/autopilot/unity8/shell/tests/test_hud.py+8−1
@@ -184,5 +184,12 @@ class TestHud(UnityTestCase, DragMixin):
184 # we don't.
184 # we don't.
185 def _maybe_release_finger(self):
185 def _maybe_release_finger(self):
186 """Only release the finger if it is in fact down."""
186 """Only release the finger if it is in fact down."""
187+ # XXX This ugly code is here just temporarily, waiting for uinput
188+ # improvements to land on autopilot so we don't have to access device
189+ # private internal attributes. --elopio - 2014-02-12
190+ try:
187− if self.touch._touch_finger is not None:
191+ pressed = self.touch._touch_finger is not None
192+ except AttributeError:
193+ pressed = self.touch.pressed
194+ if pressed:
188 self.touch.release()
195 self.touch.release()