Search in sources :

Example 6 with UiAutomationShellWrapper

use of com.android.uiautomator.core.UiAutomationShellWrapper in project platform_frameworks_base by android.

the class DumpCommand method run.

@Override
public void run(String[] args) {
    File dumpFile = DEFAULT_DUMP_FILE;
    boolean verboseMode = true;
    for (String arg : args) {
        if (arg.equals("--compressed"))
            verboseMode = false;
        else if (!arg.startsWith("-")) {
            dumpFile = new File(arg);
        }
    }
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    if (verboseMode) {
        // default
        automationWrapper.setCompressedLayoutHierarchy(false);
    } else {
        automationWrapper.setCompressedLayoutHierarchy(true);
    }
    // do a wait for idle in case the app is busy.
    try {
        UiAutomation uiAutomation = automationWrapper.getUiAutomation();
        uiAutomation.waitForIdle(1000, 1000 * 10);
        AccessibilityNodeInfo info = uiAutomation.getRootInActiveWindow();
        if (info == null) {
            System.err.println("ERROR: null root node returned by UiTestAutomationBridge.");
            return;
        }
        Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
        int rotation = display.getRotation();
        Point size = new Point();
        display.getSize(size);
        AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x, size.y);
    } catch (TimeoutException re) {
        System.err.println("ERROR: could not get idle state.");
        return;
    } finally {
        automationWrapper.disconnect();
    }
    System.out.println(String.format("UI hierchary dumped to: %s", dumpFile.getAbsolutePath()));
}
Also used : UiAutomation(android.app.UiAutomation) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point) File(java.io.File) Point(android.graphics.Point) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) Display(android.view.Display) TimeoutException(java.util.concurrent.TimeoutException)

Example 7 with UiAutomationShellWrapper

use of com.android.uiautomator.core.UiAutomationShellWrapper in project android_frameworks_base by DirtyUnicorns.

the class DumpCommand method run.

@Override
public void run(String[] args) {
    File dumpFile = DEFAULT_DUMP_FILE;
    boolean verboseMode = true;
    for (String arg : args) {
        if (arg.equals("--compressed"))
            verboseMode = false;
        else if (!arg.startsWith("-")) {
            dumpFile = new File(arg);
        }
    }
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    if (verboseMode) {
        // default
        automationWrapper.setCompressedLayoutHierarchy(false);
    } else {
        automationWrapper.setCompressedLayoutHierarchy(true);
    }
    // do a wait for idle in case the app is busy.
    try {
        UiAutomation uiAutomation = automationWrapper.getUiAutomation();
        uiAutomation.waitForIdle(1000, 1000 * 10);
        AccessibilityNodeInfo info = uiAutomation.getRootInActiveWindow();
        if (info == null) {
            System.err.println("ERROR: null root node returned by UiTestAutomationBridge.");
            return;
        }
        Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
        int rotation = display.getRotation();
        Point size = new Point();
        display.getSize(size);
        AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x, size.y);
    } catch (TimeoutException re) {
        System.err.println("ERROR: could not get idle state.");
        return;
    } finally {
        automationWrapper.disconnect();
    }
    System.out.println(String.format("UI hierchary dumped to: %s", dumpFile.getAbsolutePath()));
}
Also used : UiAutomation(android.app.UiAutomation) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point) File(java.io.File) Point(android.graphics.Point) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) Display(android.view.Display) TimeoutException(java.util.concurrent.TimeoutException)

Example 8 with UiAutomationShellWrapper

use of com.android.uiautomator.core.UiAutomationShellWrapper in project android_frameworks_base by DirtyUnicorns.

the class EventsCommand method run.

@Override
public void run(String[] args) {
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    automationWrapper.getUiAutomation().setOnAccessibilityEventListener(new OnAccessibilityEventListener() {

        @Override
        public void onAccessibilityEvent(AccessibilityEvent event) {
            SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
            System.out.println(String.format("%s %s", formatter.format(new Date()), event.toString()));
        }
    });
    // for user to press Ctrl+C
    synchronized (mQuitLock) {
        try {
            mQuitLock.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    automationWrapper.disconnect();
}
Also used : OnAccessibilityEventListener(android.app.UiAutomation.OnAccessibilityEventListener) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper)

Example 9 with UiAutomationShellWrapper

use of com.android.uiautomator.core.UiAutomationShellWrapper in project android_frameworks_base by AOSPA.

the class DumpCommand method run.

@Override
public void run(String[] args) {
    File dumpFile = DEFAULT_DUMP_FILE;
    boolean verboseMode = true;
    for (String arg : args) {
        if (arg.equals("--compressed"))
            verboseMode = false;
        else if (!arg.startsWith("-")) {
            dumpFile = new File(arg);
        }
    }
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    if (verboseMode) {
        // default
        automationWrapper.setCompressedLayoutHierarchy(false);
    } else {
        automationWrapper.setCompressedLayoutHierarchy(true);
    }
    // do a wait for idle in case the app is busy.
    try {
        UiAutomation uiAutomation = automationWrapper.getUiAutomation();
        uiAutomation.waitForIdle(1000, 1000 * 10);
        AccessibilityNodeInfo info = uiAutomation.getRootInActiveWindow();
        if (info == null) {
            System.err.println("ERROR: null root node returned by UiTestAutomationBridge.");
            return;
        }
        Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
        int rotation = display.getRotation();
        Point size = new Point();
        display.getSize(size);
        AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x, size.y);
    } catch (TimeoutException re) {
        System.err.println("ERROR: could not get idle state.");
        return;
    } finally {
        automationWrapper.disconnect();
    }
    System.out.println(String.format("UI hierchary dumped to: %s", dumpFile.getAbsolutePath()));
}
Also used : UiAutomation(android.app.UiAutomation) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point) File(java.io.File) Point(android.graphics.Point) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) Display(android.view.Display) TimeoutException(java.util.concurrent.TimeoutException)

Example 10 with UiAutomationShellWrapper

use of com.android.uiautomator.core.UiAutomationShellWrapper in project android_frameworks_base by AOSPA.

the class EventsCommand method run.

@Override
public void run(String[] args) {
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    automationWrapper.getUiAutomation().setOnAccessibilityEventListener(new OnAccessibilityEventListener() {

        @Override
        public void onAccessibilityEvent(AccessibilityEvent event) {
            SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
            System.out.println(String.format("%s %s", formatter.format(new Date()), event.toString()));
        }
    });
    // for user to press Ctrl+C
    synchronized (mQuitLock) {
        try {
            mQuitLock.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    automationWrapper.disconnect();
}
Also used : OnAccessibilityEventListener(android.app.UiAutomation.OnAccessibilityEventListener) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper)

Aggregations

UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)15 UiAutomation (android.app.UiAutomation)5 OnAccessibilityEventListener (android.app.UiAutomation.OnAccessibilityEventListener)5 Point (android.graphics.Point)5 Bundle (android.os.Bundle)5 HandlerThread (android.os.HandlerThread)5 Display (android.view.Display)5 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)5 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)5 ShellUiAutomatorBridge (com.android.uiautomator.core.ShellUiAutomatorBridge)5 Tracer (com.android.uiautomator.core.Tracer)5 File (java.io.File)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 TimeoutException (java.util.concurrent.TimeoutException)5 TestCase (junit.framework.TestCase)5 TestListener (junit.framework.TestListener)5 TestResult (junit.framework.TestResult)5