FileDocCategorySizeDatePackage
UiAutomatorBridge.javaAPI DocAndroid 5.1 API4779Thu Mar 12 22:22:08 GMT 2015com.android.uiautomator.core

UiAutomatorBridge

public abstract class UiAutomatorBridge extends Object
hide

Fields Summary
private static final String
LOG_TAG
private static final long
QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE
This value has the greatest bearing on the appearance of test execution speeds. This value is used as the minimum time to wait before considering the UI idle after each action.
private static final long
TOTAL_TIME_TO_WAIT_FOR_IDLE_STATE
This is the maximum time the automation will wait for the UI to go idle. Execution will resume normally anyway. This is to prevent waiting forever on display updates that may be related to spinning wheels or progress updates of sorts etc...
private final android.app.UiAutomation
mUiAutomation
private final InteractionController
mInteractionController
private final QueryController
mQueryController
Constructors Summary
UiAutomatorBridge(android.app.UiAutomation uiAutomation)


      
        mUiAutomation = uiAutomation;
        mInteractionController = new InteractionController(this);
        mQueryController = new QueryController(this);
    
Methods Summary
public android.view.accessibility.AccessibilityEventexecuteCommandAndWaitForAccessibilityEvent(java.lang.Runnable command, android.app.UiAutomation.AccessibilityEventFilter filter, long timeoutMillis)

        return mUiAutomation.executeAndWaitForEvent(command,
                filter, timeoutMillis);
    
public abstract android.view.DisplaygetDefaultDisplay()

InteractionControllergetInteractionController()

        return mInteractionController;
    
QueryControllergetQueryController()

        return mQueryController;
    
public android.view.accessibility.AccessibilityNodeInfogetRootInActiveWindow()

        return mUiAutomation.getRootInActiveWindow();
    
public abstract intgetRotation()

public abstract longgetSystemLongPressTime()

public booleaninjectInputEvent(android.view.InputEvent event, boolean sync)

        return mUiAutomation.injectInputEvent(event, sync);
    
public abstract booleanisScreenOn()

public booleanperformGlobalAction(int action)

        return mUiAutomation.performGlobalAction(action);
    
public voidsetCompressedLayoutHierarchy(boolean compressed)

        AccessibilityServiceInfo info = mUiAutomation.getServiceInfo();
        if (compressed)
            info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
        else
            info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
        mUiAutomation.setServiceInfo(info);
    
public voidsetOnAccessibilityEventListener(android.app.UiAutomation.OnAccessibilityEventListener listener)

        mUiAutomation.setOnAccessibilityEventListener(listener);
    
public booleansetRotation(int rotation)

        return mUiAutomation.setRotation(rotation);
    
public booleantakeScreenshot(java.io.File storePath, int quality)

        Bitmap screenshot = mUiAutomation.takeScreenshot();
        if (screenshot == null) {
            return false;
        }
        BufferedOutputStream bos = null;
        try {
            bos = new BufferedOutputStream(new FileOutputStream(storePath));
            if (bos != null) {
                screenshot.compress(Bitmap.CompressFormat.PNG, quality, bos);
                bos.flush();
            }
        } catch (IOException ioe) {
            Log.e(LOG_TAG, "failed to save screen shot to file", ioe);
            return false;
        } finally {
            if (bos != null) {
                try {
                    bos.close();
                } catch (IOException ioe) {
                    /* ignore */
                }
            }
            screenshot.recycle();
        }
        return true;
    
public voidwaitForIdle()

        waitForIdle(TOTAL_TIME_TO_WAIT_FOR_IDLE_STATE);
    
public voidwaitForIdle(long timeout)

        try {
            mUiAutomation.waitForIdle(QUIET_TIME_TO_BE_CONSIDERD_IDLE_STATE, timeout);
        } catch (TimeoutException te) {
            Log.w(LOG_TAG, "Could not detect idle state.", te);
        }