Search in sources :

Example 21 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by DirtyUnicorns.

the class BugreportReceiverTest method testProgress_cancel.

public void testProgress_cancel() throws Exception {
    resetProperties();
    sendBugreportStarted(1000);
    waitForScreenshotButtonEnabled(true);
    final NumberFormat nf = NumberFormat.getPercentInstance();
    nf.setMinimumFractionDigits(2);
    nf.setMaximumFractionDigits(2);
    assertProgressNotification(NAME, 00.00f);
    openProgressNotification(ID);
    UiObject cancelButton = mUiBot.getVisibleObject(mContext.getString(com.android.internal.R.string.cancel).toUpperCase());
    mUiBot.click(cancelButton, "cancel_button");
    waitForService(false);
}
Also used : UiObject(android.support.test.uiautomator.UiObject) NumberFormat(java.text.NumberFormat)

Example 22 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by DirtyUnicorns.

the class UiBot method clickJustOnce.

private void clickJustOnce() {
    boolean gotIt = mDevice.wait(Until.hasObject(By.res("android", "button_once")), mTimeout);
    assertTrue("'Just Once' button not visible yet", gotIt);
    UiObject justOnce = mDevice.findObject(new UiSelector().resourceId("android:id/button_once"));
    assertTrue("'Just Once' button not found", justOnce.exists());
    click(justOnce, "Just Once");
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector)

Example 23 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by DirtyUnicorns.

the class UiBot method getVisibleObjectById.

/**
     * Gets an object which is guaranteed to be present in the current UI.
     *
     * @param text Object's text as displayed by the UI.
     */
public UiObject getVisibleObjectById(String id) {
    UiObject uiObject = mDevice.findObject(new UiSelector().resourceId(id));
    assertTrue("could not find object with id '" + id + "'", uiObject.exists());
    return uiObject;
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector)

Example 24 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by DirtyUnicorns.

the class UiBot method clickOnNotification.

/**
     * Opens the system notification and clicks a given notification.
     *
     * @param text Notificaton's text as displayed by the UI.
     */
public void clickOnNotification(String text) {
    UiObject notification = getNotification(text);
    click(notification, "bug report notification");
}
Also used : UiObject(android.support.test.uiautomator.UiObject)

Example 25 with UiObject

use of android.support.test.uiautomator.UiObject in project android_frameworks_base by AOSPA.

the class UiBot method chooseActivity.

/**
     * Chooses a given activity to handle an Intent, using the "Just Once" button.
     *
     * @param name name of the activity as displayed in the UI (typically the value set by
     *            {@code android:label} in the manifest).
     */
// TODO: UI Automator should provide such logic.
public void chooseActivity(String name) {
    // First check if the activity is the default option.
    String shareText = "Share with " + name;
    Log.v(TAG, "Waiting for ActivityChooser text: '" + shareText + "'");
    boolean gotIt = mDevice.wait(Until.hasObject(By.text(shareText)), mTimeout);
    boolean justOnceHack = false;
    if (gotIt) {
        Log.v(TAG, "Found activity " + name + ", it's the default action");
        clickJustOnce();
    } else {
        // Since it's not, need to find it in the scrollable list...
        Log.v(TAG, "Activity " + name + " is not default action");
        UiScrollable activitiesList = new UiScrollable(new UiSelector().scrollable(true));
        try {
            activitiesList.scrollForward();
        } catch (UiObjectNotFoundException e) {
            // TODO: for some paranormal issue, the first time a test is run the scrollable
            // activity list is displayed but calling scrollForwad() (or even isScrollable())
            // throws a "UiObjectNotFoundException: UiSelector[SCROLLABLE=true]" exception
            justOnceHack = true;
            Log.d(TAG, "could not scroll forward", e);
        }
        UiObject activity = getVisibleObject(name);
        // ... then select it.
        click(activity, name);
        if (justOnceHack) {
            clickJustOnce();
        }
    }
}
Also used : UiObject(android.support.test.uiautomator.UiObject) UiSelector(android.support.test.uiautomator.UiSelector) UiObjectNotFoundException(android.support.test.uiautomator.UiObjectNotFoundException) UiScrollable(android.support.test.uiautomator.UiScrollable)

Aggregations

UiObject (android.support.test.uiautomator.UiObject)140 UiSelector (android.support.test.uiautomator.UiSelector)44 UiScrollable (android.support.test.uiautomator.UiScrollable)13 UiObjectNotFoundException (android.support.test.uiautomator.UiObjectNotFoundException)7 DownloadManager (android.app.DownloadManager)5 Request (android.app.DownloadManager.Request)5 Bundle (android.os.Bundle)5 Suppress (android.test.suitebuilder.annotation.Suppress)5 NumberFormat (java.text.NumberFormat)5 Test (org.junit.Test)3 MediumTest (android.support.test.filters.MediumTest)2 UiDevice (android.support.test.uiautomator.UiDevice)2 RelativeLayout (android.widget.RelativeLayout)1