Search in sources :

Example 11 with UiObject

use of com.stardust.automator.UiObject in project Auto.js by hyb1996.

the class NodeInfo method capture.

public static NodeInfo capture(@NonNull UiObject uiObject, @Nullable NodeInfo parent) {
    NodeInfo nodeInfo = new NodeInfo(uiObject, parent);
    int childCount = uiObject.getChildCount();
    for (int i = 0; i < childCount; i++) {
        UiObject child = uiObject.child(i);
        if (child != null) {
            nodeInfo.children.add(capture(child, nodeInfo));
        }
    }
    return nodeInfo;
}
Also used : UiObject(com.stardust.automator.UiObject) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)

Example 12 with UiObject

use of com.stardust.automator.UiObject in project Auto.js by hyb1996.

the class DfsFilterTest method filter.

@Test
public void filter() throws Exception {
    DfsFilter filter = new RandomDfsFilter();
    UiObject root = new TestUiObject(10);
    List<UiObject> list = filter.filter(root);
    for (UiObject uiObject : list) {
        if (root != uiObject)
            uiObject.recycle();
    }
    System.out.println(TestUiObject.max);
    assertEquals(1, TestUiObject.count);
}
Also used : UiObject(com.stardust.automator.UiObject) TestUiObject(com.stardust.automator.test.TestUiObject) TestUiObject(com.stardust.automator.test.TestUiObject) Test(org.junit.Test)

Example 13 with UiObject

use of com.stardust.automator.UiObject in project Auto.js by hyb1996.

the class ScrollActionTest method perform.

@Test
public void perform() throws Exception {
    ScrollAction action = new ScrollAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD, 0);
    UiObject root = new TestUiObject(5);
    action.perform(root);
    System.out.println(TestUiObject.max);
    assertEquals(1, TestUiObject.count);
}
Also used : UiObject(com.stardust.automator.UiObject) TestUiObject(com.stardust.automator.test.TestUiObject) TestUiObject(com.stardust.automator.test.TestUiObject) Test(org.junit.Test)

Example 14 with UiObject

use of com.stardust.automator.UiObject in project Auto.js by hyb1996.

the class ScrollAction method findScrollableNodes.

private static void findScrollableNodes(UiObject node, List<UiObject> list) {
    if (node == null) {
        return;
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        UiObject child = node.child(i);
        if (child == null)
            continue;
        findScrollableNodes(child, list);
        if (child.isScrollable()) {
            list.add(child);
        } else {
            child.recycle();
        }
    }
}
Also used : UiObject(com.stardust.automator.UiObject)

Aggregations

UiObject (com.stardust.automator.UiObject)14 TestUiObject (com.stardust.automator.test.TestUiObject)4 Test (org.junit.Test)4 Bundle (android.os.Bundle)1 RequiresApi (android.support.annotation.RequiresApi)1 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)1 UiGlobalSelector (com.stardust.automator.UiGlobalSelector)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1