Search in sources :

Example 6 with UiObject

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

the class SearchTargetAction method perform.

@Override
public boolean perform(List<UiObject> nodes) {
    boolean performed = false;
    for (UiObject node : nodes) {
        node = searchTarget(node);
        if (node != null) {
            performAction(node);
            performed = true;
        }
    }
    return performed;
}
Also used : UiObject(com.stardust.automator.UiObject)

Example 7 with UiObject

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

the class SearchUpTargetAction method searchTarget.

@Override
public UiObject searchTarget(UiObject n) {
    UiObject node = n;
    int i = 0;
    while (node != null && !mAble.isAble(node)) {
        i++;
        if (i > LOOP_MAX) {
            return null;
        }
        node = node.parent();
    }
    return node;
}
Also used : UiObject(com.stardust.automator.UiObject)

Example 8 with UiObject

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

the class DfsFilter method filterChildren.

private void filterChildren(UiObject parent, List<UiObject> list) {
    for (int i = 0; i < parent.getChildCount(); i++) {
        UiObject child = parent.child(i);
        if (child == null)
            continue;
        boolean included = isIncluded(child);
        if (included) {
            list.add(child);
        }
        filterChildren(child, list);
        if (!included) {
            child.recycle();
        }
    }
}
Also used : UiObject(com.stardust.automator.UiObject)

Example 9 with UiObject

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

the class ScrollMaxActionTest method perform.

@Test
public void perform() throws Exception {
    ScrollMaxAction action = new ScrollMaxAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
    UiObject root = new TestUiObject(20);
    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 10 with UiObject

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

the class DepthFirstSearchTargetActionTest method perform.

@Test
public void perform() {
    DepthFirstSearchTargetAction action = new DepthFirstSearchTargetAction(AccessibilityNodeInfo.ACTION_CLICK, new FilterAction.Filter() {

        @Override
        public List<UiObject> filter(UiObject root) {
            List<UiObject> list = new ArrayList<>();
            for (int i = 0; i < root.getChildCount(); i++) {
                list.add(root.child(i));
            }
            return list;
        }
    });
    TestUiObject 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) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

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