/** * Gets the given bounds equivalent relative to the bounds upper left corner; * * @param bounds * - {@link Bounds} for which to get the relative bounds to the bounds upper left corner * @return the bounds equivalent relative to the bounds upper left corner */ public Bounds getRelativeBounds(Bounds bounds) { Point boundsUpperLeftCorner = bounds.getUpperLeftCorner(); int boundsWidth = bounds.getWidth(); int boundsHeight = bounds.getHeight(); Point relativeUpperLeftCorner = getRelativePoint(boundsUpperLeftCorner); Bounds relativeBounds = new Bounds(relativeUpperLeftCorner, boundsWidth, boundsHeight); return relativeBounds; }
/** * Check if certain {@link Bounds} parameter is inside the bounds. * * @param bounds * - a {@link Bounds} parameter that needs to be contained in the bounds * @return true if the bounds contain the bounds parameter, false otherwise */ public boolean contains(Bounds bounds) { Point boundsUpperLeftCorner = bounds.getUpperLeftCorner(); int boundsWidth = bounds.getWidth(); int boundsHeight = bounds.getHeight(); boolean containsUpperLeftCorner = contains(boundsUpperLeftCorner); boolean containsWidth = boundsUpperLeftCorner.getX() + boundsWidth <= upperLeftCorner.getX() + width; boolean containsHeight = boundsUpperLeftCorner.getY() + boundsHeight <= upperLeftCorner.getY() + height; return containsUpperLeftCorner && containsWidth && containsHeight; }
upperLeftCornerPointX = lowerLeftCorner.getY(); upperLeftCornerPointY = lowerLeftCorner.getX(); elementWidth = elementBounds.getHeight(); elementHeight = elementBounds.getWidth(); upperLeftCornerPointX = upperRightCorner.getX(); upperLeftCornerPointY = upperRightCorner.getY(); elementWidth = elementBounds.getHeight(); elementHeight = elementBounds.getWidth(); upperLeftCornerPointY = upperLeftCorner.getY(); elementWidth = elementBounds.getWidth(); elementHeight = elementBounds.getHeight(); upperLeftCornerPointY = lowerRightCorner.getY(); elementWidth = elementBounds.getWidth(); elementHeight = elementBounds.getHeight();
Point selectorBoundsUpperCorner = selectorBounds.getUpperLeftCorner(); if ((nodeBounds.height() != selectorBounds.getHeight()) || (nodeBounds.width() != selectorBounds.getWidth()) || (selectorBoundsUpperCorner.getX() != nodeBounds.left) || (selectorBoundsUpperCorner.getY() != nodeBounds.top)) {
Point selectorBoundsUpperCorner = propertiesContainerBounds.getUpperLeftCorner(); if ((accessibilityNodeBounds.height() != propertiesContainerBounds.getHeight()) || (accessibilityNodeBounds.width() != propertiesContainerBounds.getWidth()) || (selectorBoundsUpperCorner.getX() != accessibilityNodeBounds.left)
/** * Simulates a pinch in on the element. NOTE emulator devices may not detect pinch gestures on UI elements with size * smaller than 100x100dp. * * @return <code>true</code> if the pinch in is successful, <code>false</code> if it fails * @throws StaleElementReferenceException * if the element has become stale before executing this method */ public boolean pinchIn() { revalidateThrowing(); Bounds elementBounds = propertiesContainer.getBounds(); final int BOUNDS_OFFSET_DENOMINATOR = 10; final int WIDTH_OFFSET = elementBounds.getWidth() / BOUNDS_OFFSET_DENOMINATOR; final int HEIGHT_OFFSET = elementBounds.getHeight() / BOUNDS_OFFSET_DENOMINATOR; // starting the pinch at a distance from the exact bounds of the element so that it will not affect other UI // elements Point lowerRight = elementBounds.getLowerRightCorner(); int firstFingerInitialX = lowerRight.getX() - WIDTH_OFFSET; int firstFingerInitialY = lowerRight.getY() - HEIGHT_OFFSET; Point firstFingerInitial = new Point(firstFingerInitialX, firstFingerInitialY); Point upperLeft = elementBounds.getUpperLeftCorner(); int secondFingerInitialX = upperLeft.getX() + WIDTH_OFFSET; int secondFingerInitialY = upperLeft.getY() + HEIGHT_OFFSET; Point secondFingerInitial = new Point(secondFingerInitialX, secondFingerInitialY); boolean result = (boolean) communicator.sendAction(RoutingAction.GESTURE_PINCH_IN, firstFingerInitial, secondFingerInitial); return result; }