Returns the I{screen} coordinates of this C{View}. WARNING: Don't call self.getX() or self.getY() inside this method or it will enter an infinite loop @return: The I{screen} coordinates of this C{View}
(self, debug=False)
| 694 | return y |
| 695 | |
| 696 | def getXY(self, debug=False): |
| 697 | """ |
| 698 | Returns the I{screen} coordinates of this C{View}. |
| 699 | |
| 700 | WARNING: Don't call self.getX() or self.getY() inside this method |
| 701 | or it will enter an infinite loop |
| 702 | |
| 703 | @return: The I{screen} coordinates of this C{View} |
| 704 | """ |
| 705 | |
| 706 | if DEBUG_COORDS or debug: |
| 707 | try: |
| 708 | _id = self.getId() |
| 709 | except: |
| 710 | _id = "NO_ID" |
| 711 | print("getXY(%s %s ## %s)" % (self.getClass(), _id, self.getUniqueId()), file=sys.stderr) |
| 712 | |
| 713 | x = self.__getX() |
| 714 | y = self.__getY() |
| 715 | if self.useUiAutomator: |
| 716 | return (x, y) |
| 717 | |
| 718 | parent = self.parent |
| 719 | if DEBUG_COORDS: print(" getXY: x=%s y=%s parent=%s" % (x, y, parent.getUniqueId() if parent else "None"), |
| 720 | file=sys.stderr) |
| 721 | hx = 0 |
| 722 | ''' Hierarchy accumulated X ''' |
| 723 | hy = 0 |
| 724 | ''' Hierarchy accumulated Y ''' |
| 725 | |
| 726 | if DEBUG_COORDS: print(" getXY: not using UiAutomator, calculating parent coordinates", file=sys.stderr) |
| 727 | while parent is not None: |
| 728 | if DEBUG_COORDS: print(" getXY: parent: %s %s <<<<" % (parent.getClass(), parent.getId()), |
| 729 | file=sys.stderr) |
| 730 | if SKIP_CERTAIN_CLASSES_IN_GET_XY_ENABLED: |
| 731 | if parent.getClass() in ['com.android.internal.widget.ActionBarView', |
| 732 | 'com.android.internal.widget.ActionBarContextView', |
| 733 | 'com.android.internal.view.menu.ActionMenuView', |
| 734 | 'com.android.internal.policy.impl.PhoneWindow$DecorView']: |
| 735 | if DEBUG_COORDS: print(" getXY: skipping %s %s (%d,%d)" % ( |
| 736 | parent.getClass(), parent.getId(), parent.__getX(), parent.__getY()), file=sys.stderr) |
| 737 | parent = parent.parent |
| 738 | continue |
| 739 | if DEBUG_COORDS: print(" getXY: parent=%s x=%d hx=%d y=%d hy=%d" % (parent.getId(), x, hx, y, hy), |
| 740 | file=sys.stderr) |
| 741 | hx += parent.__getX() |
| 742 | hy += parent.__getY() |
| 743 | parent = parent.parent |
| 744 | |
| 745 | (wvx, wvy) = self.__dumpWindowsInformation(debug=debug) |
| 746 | if DEBUG_COORDS or debug: |
| 747 | print(" getXY: wv=(%d, %d) (windows information)" % (wvx, wvy), file=sys.stderr) |
| 748 | try: |
| 749 | if self.windowId: |
| 750 | fw = self.windows[self.windowId] |
| 751 | else: |
| 752 | fw = self.windows[self.currentFocus] |
| 753 | if DEBUG_STATUSBAR: |