MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / touchPoint

Method touchPoint

src/com/dtmilano/android/culebron.py:942–988  ·  view source on GitHub ↗

Touches a point in the device screen. The generated operation will use the units specified in L{coordinatesUnit} and the orientation in L{vc.display['orientation']}.

(self, x, y)

Source from the content-addressed store, hash-verified

940 self.printOperation(v, Operation.TOUCH_VIEW, root)
941
942 def touchPoint(self, x, y):
943 """
944 Touches a point in the device screen.
945 The generated operation will use the units specified in L{coordinatesUnit} and the
946 orientation in L{vc.display['orientation']}.
947 """
948
949 if DEBUG:
950 print('touchPoint(%d, %d)' % (x, y), file=sys.stderr)
951 print('touchPoint:', type(x), type(y), file=sys.stderr)
952 if self.areEventsDisabled:
953 if DEBUG:
954 print("Ignoring event", file=sys.stderr)
955 self.canvas.update_idletasks()
956 return
957 if DEBUG:
958 print("Is touching point:", self.isTouchingPoint, file=sys.stderr)
959 if self.isTouchingPoint:
960 self.showVignette()
961 if self.vc:
962 if self.vc.uiAutomatorHelper:
963 self.vc.uiAutomatorHelper.ui_device.click(int(x), int(y))
964 self.vc.uiAutomatorHelper.ui_device.wait_for_idle()
965 self.printOperation(None, Operation.CLICK_UI_AUTOMATOR_HELPER, int(x), int(y))
966 self.printOperation(None, Operation.WAIT_FOR_IDLE_UI_AUTOMATOR_HELPER)
967 self.isTouchingPoint = self.vc is None
968 self.takeScreenshotAndShowItOnWindow()
969 # self.hideVignette()
970 self.statusBar.clear()
971 return
972 else:
973 self.vc.touch(x, y)
974 if self.coordinatesUnit == Unit.DIP:
975 x = round(x / self.device.display['density'], 2)
976 y = round(y / self.device.display['density'], 2)
977 self.printOperation(None, Operation.TOUCH_POINT, x, y, self.coordinatesUnit,
978 self.device.display['orientation'])
979 self.sleep(5)
980 # FIXME: can we reduce this sleep? (was 5)
981 time.sleep(1)
982 self.isTouchingPoint = self.vc is None
983 self.takeScreenshotAndShowItOnWindow()
984 # self.hideVignette()
985 self.statusBar.clear()
986 return
987 else:
988 warnings.warn('isTouchingPoint is False')
989
990 def longTouchPoint(self, x, y):
991 '''

Callers 2

onButton1PressedMethod · 0.95

Calls 7

showVignetteMethod · 0.95
sleepMethod · 0.95
wait_for_idleMethod · 0.80
clickMethod · 0.45
clearMethod · 0.45
touchMethod · 0.45

Tested by

no test coverage detected