use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.
the class UiObject method isSelected.
/**
* Checks if the UI element's <code>selected</code> property is currently true.
*
* @return true if it is else false
* @throws UiObjectNotFoundException
* @since API Level 16
*/
public boolean isSelected() throws UiObjectNotFoundException {
Tracer.trace();
AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
if (node == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return node.isSelected();
}
use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.
the class UiObject method longClickTopLeft.
/**
* Long clicks on the top and left corner of the UI element
*
* @return true if operation was successful
* @throws UiObjectNotFoundException
* @since API Level 16
*/
public boolean longClickTopLeft() throws UiObjectNotFoundException {
Tracer.trace();
AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
if (node == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
Rect rect = getVisibleBounds(node);
return getInteractionController().longTapNoSync(rect.left + 5, rect.top + 5);
}
use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.
the class UiObject method pinchOut.
/**
* Performs a two-pointer gesture, where each pointer moves diagonally
* opposite across the other, from the center out towards the edges of the
* this UiObject.
* @param percent percentage of the object's diagonal length for the pinch gesture
* @param steps the number of steps for the gesture. Steps are injected
* about 5 milliseconds apart, so 100 steps may take around 0.5 seconds to complete.
* @return <code>true</code> if all touch events for this gesture are injected successfully,
* <code>false</code> otherwise
* @throws UiObjectNotFoundException
* @since API Level 18
*/
public boolean pinchOut(int percent, int steps) throws UiObjectNotFoundException {
// make value between 1 and 100
percent = (percent < 0) ? 1 : (percent > 100) ? 100 : percent;
float percentage = percent / 100f;
AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
if (node == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
Rect rect = getVisibleBounds(node);
if (rect.width() <= FINGER_TOUCH_HALF_WIDTH * 2)
throw new IllegalStateException("Object width is too small for operation");
// start from the same point at the center of the control
Point startPoint1 = new Point(rect.centerX() - FINGER_TOUCH_HALF_WIDTH, rect.centerY());
Point startPoint2 = new Point(rect.centerX() + FINGER_TOUCH_HALF_WIDTH, rect.centerY());
// End at the top-left and bottom-right corners of the control
Point endPoint1 = new Point(rect.centerX() - (int) ((rect.width() / 2) * percentage), rect.centerY());
Point endPoint2 = new Point(rect.centerX() + (int) ((rect.width() / 2) * percentage), rect.centerY());
return performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.
the class UiObject method isChecked.
/**
* Check if the UI element's <code>checked</code> property is currently true
*
* @return true if it is else false
* @since API Level 16
*/
public boolean isChecked() throws UiObjectNotFoundException {
Tracer.trace();
AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
if (node == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return node.isChecked();
}
use of android.view.accessibility.AccessibilityNodeInfo in project platform_frameworks_base by android.
the class UiObject method getChildCount.
/**
* Counts the child views immediately under the present UiObject.
*
* @return the count of child views.
* @throws UiObjectNotFoundException
* @since API Level 16
*/
public int getChildCount() throws UiObjectNotFoundException {
Tracer.trace();
AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout());
if (node == null) {
throw new UiObjectNotFoundException(getSelector().toString());
}
return node.getChildCount();
}
Aggregations