Search in sources :

Example 1 with UiObjectNotFoundException

use of com.android.uiautomator.core.UiObjectNotFoundException in project android-player-samples by BrightcoveOS.

the class CompanionAdTestCase method companionCheck.

// Utility Methods
/**
     * companionCheck returns <code>true</code> if it finds the companion and, and <code>false</code> 
     * if it does not find it. The method searches for the companion ad frame,
     * then it finds the companion ad itself using the frame as a parent Ui Object.
     *
     * @return true if the companion ad is found, otherwise false.
     */
private boolean companionCheck() throws Exception {
    Log.v(TAG, "Beginning companionCheck");
    UiObject companionAdFrame = new UiObject(new UiSelector().resourceId("com.brightcove.player.samples.onceux.basic:id/ad_frame"));
    try {
        companionAd = companionAdFrame.getChild(new UiSelector().className(android.widget.ImageView.class));
        assertTrue(companionAd.isEnabled());
        return true;
    } catch (UiObjectNotFoundException companionAdNotFound) {
        return false;
    }
}
Also used : UiObject(com.android.uiautomator.core.UiObject) UiSelector(com.android.uiautomator.core.UiSelector) UiObjectNotFoundException(com.android.uiautomator.core.UiObjectNotFoundException)

Example 2 with UiObjectNotFoundException

use of com.android.uiautomator.core.UiObjectNotFoundException in project android-player-samples by BrightcoveOS.

the class OnceUxUiAutomatorBase method playVideo.

// Other Universal Utility Methods
/**
     * playVideo provides a method that allows for universal access to the play function. It was
     * created as a separate entity to the tests and setUp to help prevent subtle changes from
     * breaking the sample app before function has begun. A universal method helps in this case,
     * and in order to keep the setUp method universal across all test cases, play was kept separate.
     *
     * @throws UiObjectNotFoundException playButtonMissing when the seek controls are hidden.
     */
protected void playVideo() throws Exception {
    // First, wait for the Sample App to entirely process the video and we tap the screen to reveal the seek controls and press play.
    TimeUnit.SECONDS.sleep(6);
    UiObject playButton = new UiObject(new UiSelector().resourceId("android:id/pause"));
    Log.v(TAG, "Pressing Play...");
    try {
        playButton.click();
    } catch (UiObjectNotFoundException playButtonMissing) {
        Log.v(TAG, "Play button not found. Trying again.");
        toggleSeekControlsVisibility();
        playButton.click();
    }
}
Also used : UiObject(com.android.uiautomator.core.UiObject) UiSelector(com.android.uiautomator.core.UiSelector) UiObjectNotFoundException(com.android.uiautomator.core.UiObjectNotFoundException)

Example 3 with UiObjectNotFoundException

use of com.android.uiautomator.core.UiObjectNotFoundException in project android-player-samples by BrightcoveOS.

the class PlayStartMessTestCase method playVideoSpecialized.

/**
     * The scenario as described in the class level comment occurs based on an outdated 
     * version of the super.playVideo method. As a result, that version needed to be 
     * preserved here for testing that scenario. Unlike the current super.playVideo(),
     * playVideoSpecialized() does not wait for the video to load, and instead presses play
     * as soon as the sample app reveals seek controls.
     */
private void playVideoSpecialized() throws Exception {
    UiObject playButton = new UiObject(new UiSelector().resourceId("android:id/pause"));
    playButton.waitForExists(6000);
    Log.v(TAG, "Pressing Play...");
    try {
        playButton.click();
    } catch (UiObjectNotFoundException playButtonMissing) {
        playButtonMissing.printStackTrace();
        Log.v(TAG, "Play button not found. Trying again.");
        super.toggleSeekControlsVisibility();
        playButton.click();
    }
}
Also used : UiObject(com.android.uiautomator.core.UiObject) UiSelector(com.android.uiautomator.core.UiSelector) UiObjectNotFoundException(com.android.uiautomator.core.UiObjectNotFoundException)

Aggregations

UiObject (com.android.uiautomator.core.UiObject)3 UiObjectNotFoundException (com.android.uiautomator.core.UiObjectNotFoundException)3 UiSelector (com.android.uiautomator.core.UiSelector)3