use of com.android.uiautomator.core.UiSelector in project android-player-samples by BrightcoveOS.
the class PlayStartMessTestCase method testPlayStartMessSeekBarCheck.
/**
* testPlayStartMessSeekBarCheck creates the scenario described in the class level comment,
* then waits for two seconds for the scenario to initialize. Then, the test checks asserts
* the seek bar will be there. If it is present, the test will fail.
*/
public void testPlayStartMessSeekBarCheck() throws Exception {
Log.v(TAG, "Beginning testPlayStartMessSeekBarCheck");
playVideoSpecialized();
TimeUnit.SECONDS.sleep(2);
UiObject seekBar = new UiObject(new UiSelector().resourceId("android:id/mediacontroller_progress"));
assertFalse("Failure: Seek Bar found.", seekBar.waitForExists(10000));
}
use of com.android.uiautomator.core.UiSelector in project Quality-Tools-for-Android by stephanenicolas.
the class UIAutomatorSampleTest method testCalculatorApp.
@LargeTest
@FlakyTest(tolerance = TEST_TOLERANCE)
public void testCalculatorApp() throws UiObjectNotFoundException {
setCurrentTestName("testCalculatorApp");
startAppOnEmulator("Calculator");
takeScreenshot("open");
UiObject deleteButton;
deleteButton = new UiObject(new UiSelector().text("DELETE"));
deleteButton.waitForExists(CALCULATOR_UPDATE_TIMEOUT);
if (!deleteButton.exists()) {
deleteButton = new UiObject(new UiSelector().text("CLR"));
}
deleteButton.waitForExists(CALCULATOR_UPDATE_TIMEOUT);
deleteButton.click();
takeScreenshot("after_clear");
new UiObject(new UiSelector().text("7")).click();
takeScreenshot("after_7");
new UiObject(new UiSelector().text("+")).click();
takeScreenshot("after_plus");
new UiObject(new UiSelector().text("5")).click();
takeScreenshot("after_5");
new UiObject(new UiSelector().text("=")).click();
takeScreenshot("after_equal");
assertTrue(new UiObject(new UiSelector().text("12")).waitForExists(CALCULATOR_UPDATE_TIMEOUT));
}
use of com.android.uiautomator.core.UiSelector in project Quality-Tools-for-Android by stephanenicolas.
the class UIAutomatorSampleTest method startAppOnEmulator.
private void startAppOnEmulator(String appName) throws UiObjectNotFoundException {
// Simulate a short press on the HOME button.
getUiDevice().pressHome();
new UiObject(new UiSelector().description("Apps"));
// We?re now in the home screen. Next, we want to simulate
// a user bringing up the All Apps screen.
// If you use the uiautomatorviewer tool to capture a snapshot
// of the Home screen, notice that the All Apps button?s
// content-description property has the value ?Apps?. We can
// use this property to create a UiSelector to find the button.
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
// Simulate a click to bring up the All Apps screen.
allAppsButton.clickAndWaitForNewWindow();
// In the All Apps screen, the Settings app is located in
// the Apps tab. To simulate the user bringing up the Apps tab,
// we create a UiSelector to find a tab with the text
// label ?Apps?.
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
// Simulate a click to enter the Apps tab.
appsTab.click();
// Next, in the apps tabs, we can simulate a user swiping until
// they come to the Settings app icon. Since the container view
// is scrollable, we can use a UiScrollable object.
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
// Set the swiping mode to horizontal (the default is vertical)
appViews.setAsHorizontalList();
appViews.setMaxSearchSwipes(MAX_SEARCH_SWIPES_IN_APP_MENU);
// Create a UiSelector to find the Settings app and simulate
// a user click to launch the app.
UiObject settingsApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), appName);
settingsApp.waitForExists(TIMEOUT_DURING_APP_SEARCH);
settingsApp.clickAndWaitForNewWindow();
}
use of com.android.uiautomator.core.UiSelector in project Quality-Tools-for-Android by stephanenicolas.
the class UIAutomatorSampleTest method testSettingsApp.
@LargeTest
@FlakyTest(tolerance = TEST_TOLERANCE)
public void testSettingsApp() throws UiObjectNotFoundException {
setCurrentTestName("testSettingsApp");
startAppOnEmulator("Settings");
takeScreenshot("open");
// Validate that the package name is the expected one
UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.android.settings"));
assertTrue("Unable to detect Settings", settingsValidation.exists());
}
use of com.android.uiautomator.core.UiSelector in project android-player-samples by BrightcoveOS.
the class CompanionAdTestCase method testCompanionAdLink.
/**
* Upon clicking the companion ad, the test assess if browser opens and the correct URL loads.
* It will wait for the browser's URL text to appear. If it does not appear within 5 seconds,
* the test will fail. Note that the UiObject representing the browser URL is context-sensitive
* for the particular ad being used. As a result, the selector should be changed accordingnly
* if a different ad is used.
*/
public void testCompanionAdLink() throws Exception {
Log.v(TAG, "Beginning testCompanionAdLink");
super.playVideo();
waitForCompanionAdCheck(msecToPreroll, ADTYPE_PREROLL);
companionAd.clickAndWaitForNewWindow();
UiObject companionAdUrl = new UiObject(new UiSelector().textContains("starbucks.com"));
assertTrue("Companion ad did not link to correct url.", companionAdUrl.waitForExists(15000));
Log.v(TAG, "Finished testCompanionAdLink");
}
Aggregations