android.support.test.espresso.Espresso Java Examples

The following examples show how to use android.support.test.espresso.Espresso. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CameraHelperTest.java    From android-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testCameraFlow() {
  Bitmap icon = BitmapFactory.decodeResource(
      InstrumentationRegistry.getTargetContext().getResources(),
      R.mipmap.ic_launcher);

  Intent resultData = new Intent();
  resultData.putExtra("data", icon);
  Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);

  intending(hasAction(MediaStore.ACTION_IMAGE_CAPTURE)).respondWith(result);

  Espresso.onView(withId(R.id.camera_button)).perform(click());

  intended(hasAction(MediaStore.ACTION_IMAGE_CAPTURE));
}
 
Example #2
Source File: InjectPrimaryTypeExtrasFragment4Test.java    From PrettyBundle with Apache License 2.0 6 votes vote down vote up
public void testStartPrimaryTypeDisplayWithExtras() throws Exception {
    final String integerExtra = "1";
    final String longExtra = "2";
    final String floatExtra = "3.4";
    final String doubleExtra = "5.6";
    final String stringExtra = "String value";
    final String charSequenceExtra = "CharSequence value";

    Espresso.onView(ViewMatchers.withText(integerExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(longExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(floatExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(doubleExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText("true")).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(stringExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(charSequenceExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
 
Example #3
Source File: TaskCreateActivityTest.java    From friendly-plans with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void whenChangedViewChangeNavigationMenuHighlight() {
    onView(withId(R.id.id_et_task_name))
            .perform(replaceText(EXPECTED_NAME));
    closeSoftKeyboard();

    onView(withId(R.id.id_btn_steps))
            .perform(click());
    onView(withId(R.id.id_navigation_steps))
            .check(matches(isEnabled()));
    onView(withId(R.id.id_navigation_basic_info))
            .check(matches(not(isEnabled())));

    Espresso.pressBack();
    onView(withId(R.id.id_navigation_basic_info))
            .check(matches(isEnabled()));
    onView(withId(R.id.id_navigation_steps))
            .check(matches(not(isEnabled())));

    closeSoftKeyboard();

    List<TaskTemplate> taskTemplates = taskTemplateRepository.get(EXPECTED_NAME);
    idsToDelete.add(taskTemplates.get(0).getId());
}
 
Example #4
Source File: ManuallyProgressingButtonInstrumentedTest.java    From ProgressButton with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyProgressCycleWithCompleteStateText() throws InterruptedException {
    Espresso.onView(withId(R.id.button)).perform(scrollTo());
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton3), withText(idleStateText)))
            .perform(click());
    Thread.sleep(Constants.SUBMIT_TO_PROGRESS_MORPH_DURATION);
    Utils.doProgress(doProgressText);
    Utils.doProgress(doProgressText);
    Utils.doProgress(doProgressText);
    Utils.doProgress(doProgressText);
    Thread.sleep(Constants.MORPH_DURATION);
    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton3))
            .check(matches(allOf(withText(completeStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_accept)))));
    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton3);
}
 
Example #5
Source File: LoginActivityTest.java    From incubator-taverna-mobile with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if all the views are visible on the login activity
 */
@Test
public void checkAllViewAreVisible() throws Exception {
    mLoginActivityActivityTestRule.launchActivity(null);
    onView(withId(R.id.logo)).check(matches(isDisplayed()));
    onView(withId(R.id.tvAppName)).check(matches(withText(R.string.app_name)));
    onView(withId(R.id.loginlayout)).check(matches(isDisplayed()));
    onView(withId(R.id.myExperimentIcon)).check(matches(isDisplayed()));
    onView(withId(R.id.input_layout_email)).check(matches(isDisplayed()));
    onView(withId(R.id.input_layout_password)).check(matches(isDisplayed()));
    onView(withId(R.id.etEmail)).check(matches(isDisplayed()));
    onView(withId(R.id.etPassword)).check(matches(isDisplayed()));
    Espresso.closeSoftKeyboard();
    onView(withId(R.id.bLogin)).check(matches(isDisplayed()));
    onView(withId(R.id.bRegister)).check(matches(isDisplayed()));
}
 
Example #6
Source File: NumberPadTimePickerDialogTest.java    From NumberPadTimePicker with Apache License 2.0 6 votes vote down vote up
private static ViewInteraction[] getButtonInteractions() {
    ViewInteraction[] buttonsInteractions = new ViewInteraction[10];
    // We cannot rely on the withDigit() matcher to retrieve these because,
    // after performing a click on a button, the time display will update to
    // take on that button's digit text, and so withDigit() will return a matcher
    // that matches multiple views with that digit text: the button
    // itself and the time display. This will prevent us from performing
    // validation on the same ViewInteractions later.
    buttonsInteractions[0] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text10));
    buttonsInteractions[1] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text0));
    buttonsInteractions[2] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text1));
    buttonsInteractions[3] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text2));
    buttonsInteractions[4] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text3));
    buttonsInteractions[5] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text4));
    buttonsInteractions[6] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text5));
    buttonsInteractions[7] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text6));
    buttonsInteractions[8] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text7));
    buttonsInteractions[9] = Espresso.onView(ViewMatchers.withId(R.id.nptp_text8));
    return buttonsInteractions;
}
 
Example #7
Source File: InjectPrimaryTypeExtrasFragmentTest.java    From PrettyBundle with Apache License 2.0 6 votes vote down vote up
public void testStartPrimaryTypeDisplayWithExtras() throws Exception {
    final String integerExtra = "1";
    final String longExtra = "2";
    final String floatExtra = "3.4";
    final String doubleExtra = "5.6";
    final String stringExtra = "String value";
    final String charSequenceExtra = "CharSequence value";

    Espresso.onView(ViewMatchers.withText(integerExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(longExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(floatExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(doubleExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText("true")).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(stringExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(charSequenceExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
 
Example #8
Source File: MainActivityEspressoTest.java    From android-sdk with Apache License 2.0 6 votes vote down vote up
@Override
protected void before() throws Throwable {
    super.before();
    countingIdlingResource = new CountingIdlingResource("optly", true);
    CountingIdlingResourceInterface wrapper = new CountingIdlingResourceInterface() {
        @Override
        public void increment() {
            countingIdlingResource.increment();
        }

        @Override
        public void decrement() {
            countingIdlingResource.decrement();
        }
    };
    CountingIdlingResourceManager.setIdlingResource(wrapper);
    // To prove that the test fails, omit this call:
    Espresso.registerIdlingResources(countingIdlingResource);
}
 
Example #9
Source File: IndeterminateProgressErrorStateInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyCompleteProgressCycleWithErrorStateIcon() throws InterruptedException {
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton5), withText(idleStateText)))
            .perform(click());
    Thread.sleep(Constants.INDETERMINATE_PROGRESS_DURATION);
    Espresso.onView(withId(R.id.circularButton5)).perform(click());
    Thread.sleep(Constants.MORPH_DURATION);

    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton5))
            .check(matches(allOf(withText(emptyString), Utils.withCompoundDrawable(R.drawable.ic_action_cancel))));
    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton5);
}
 
Example #10
Source File: HugeEventActivityTest.java    From NYBus with Apache License 2.0 5 votes vote down vote up
@Before
public void registerIdlingResource() {
    List<View> viewList = Arrays.asList(mActivityRule.getActivity()
            .findViewById(R.id.textView));

    mIdlingResource = new ViewIdlingResource(viewList);

    Espresso.registerIdlingResources(mIdlingResource);
}
 
Example #11
Source File: IndeterminateProgressErrorStateInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyCompleteProgressCycleWithErrorStateText() throws InterruptedException {
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton5), withText(idleStateText)))
            .perform(click());
    Thread.sleep(Constants.INDETERMINATE_PROGRESS_DURATION);
    Espresso.onView(withId(R.id.circularButton5)).perform(click());
    Thread.sleep(Constants.MORPH_DURATION);

    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton5))
            .check(matches(allOf(withText(errorStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_cancel)))));
    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton5);
}
 
Example #12
Source File: FixedTimeProgressButtonInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyProgressCycleWithCompleteStateIcon() throws InterruptedException {
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton2), withText(idleStateText)))
            .perform(click());
    Thread.sleep(MainActivity.sweepDuration + MainActivity.sweepDuration/3);

    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton2))
            .check(matches(allOf(withText(emptyString), Utils.withCompoundDrawable(R.drawable.ic_action_accept))));
    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton2);
}
 
Example #13
Source File: InjectPrimaryTypeExtrasTest.java    From PrettyBundle with Apache License 2.0 5 votes vote down vote up
public void testStartPrimaryTypeDisplayWithExtras() throws Exception {
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override public void run() {
            ((CheckBox) activity.findViewById(R.id.cbBoolean)).setChecked(true);
        }
    });
    final String integerExtra = "1";
    Espresso.onView(ViewMatchers.withHint(R.string.hint_int)).perform(ViewActions.typeText(integerExtra), ViewActions.pressImeActionButton());
    final String longExtra = "2";
    Espresso.onView(ViewMatchers.withHint(R.string.hint_long)).perform(ViewActions.typeText(longExtra), ViewActions.pressImeActionButton());
    final String floatExtra = "3.4";
    Espresso.onView(ViewMatchers.withHint(R.string.hint_float)).perform(ViewActions.typeText(floatExtra), ViewActions.pressImeActionButton());
    final String doubleExtra = "5.6";
    Espresso.onView(ViewMatchers.withHint(R.string.hint_double)).perform(ViewActions.typeText(doubleExtra), ViewActions.pressImeActionButton());
    final String stringExtra = "String value";
    Espresso.onView(ViewMatchers.withHint(R.string.hint_string)).perform(ViewActions.typeText(stringExtra), ViewActions.pressImeActionButton());
    final String charSequenceExtra = "CharSequence value";
    Espresso.onView(ViewMatchers.withHint(R.string.hint_char_sequence)).perform(ViewActions.typeText(charSequenceExtra), ViewActions.pressImeActionButton());

    Espresso.closeSoftKeyboard();

    Espresso.onView(ViewMatchers.withText(R.string.submit)).perform(ExtViewActions.waitForSoftKeyboard(), ViewActions.scrollTo(), ViewActions.click());

    Espresso.onView(ViewMatchers.withText(integerExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(longExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(floatExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(doubleExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText("true")).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(stringExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    Espresso.onView(ViewMatchers.withText(charSequenceExtra)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
 
Example #14
Source File: FixedTimeProgressButtonInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyProgressCycleWithCompleteStateText() throws InterruptedException {
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton2), withText(idleStateText)))
            .perform(click());
    Thread.sleep(MainActivity.sweepDuration + MainActivity.sweepDuration/3);

    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton2))
            .check(matches(allOf(withText(completeStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_accept)))));

    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton2);
}
 
Example #15
Source File: TestActivityTest.java    From Awesome-WanAndroid with Apache License 2.0 5 votes vote down vote up
@Test
public void ViewMatchers() {
    Espresso.onView(ViewMatchers.withId(json.chao.com.wanandroid.R.id.button));
    //onView内部最好不要使用withText()断言处理
    Espresso.onView(Matchers.allOf(ViewMatchers.withId(json.chao.com.wanandroid.R.id.button), ViewMatchers.withText("HaHa")));
    Espresso.onView(Matchers.allOf(ViewMatchers.withId(json.chao.com.wanandroid.R.id.button), Matchers.not(ViewMatchers.withText("HaHa"))));
}
 
Example #16
Source File: RxAndroidJUnitRunner.java    From incubator-taverna-mobile with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);

    RxEspressoScheduleHandler rxEspressoScheduleHandler = new RxEspressoScheduleHandler();
    RxJavaPlugins.setScheduleHandler(rxEspressoScheduleHandler);
    Espresso.registerIdlingResources(rxEspressoScheduleHandler.getIdlingResource());
}
 
Example #17
Source File: MoviesActivityTest.java    From Material-Movies with Apache License 2.0 5 votes vote down vote up
public void testRecyclerViewIsShown () throws InterruptedException {

        // Work around, it would be better use Espresso Idling resources
        Thread.sleep(1000);

        Espresso.onView(withId(R.id.activity_movies_recycler))
            .check(matches(isDisplayed()));

        Espresso.onView(withId(R.id.activity_movies_progress))
            .check(matches(not(isDisplayed())));
    }
 
Example #18
Source File: RxAndroidJUnitRunner.java    From ribot-app-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    RxIdlingResource rxIdlingResource = new RxIdlingResource();
    RxJavaPlugins.getInstance()
            .registerObservableExecutionHook(new RxIdlingExecutionHook(rxIdlingResource));
    Espresso.registerIdlingResources(rxIdlingResource);
}
 
Example #19
Source File: RxAndroidJUnitRunner.java    From Stock-Hawk with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    RxIdlingResource rxIdlingResource = new RxIdlingResource();
    RxJavaPlugins.getInstance()
            .registerObservableExecutionHook(new RxIdlingExecutionHook(rxIdlingResource));
    Espresso.registerIdlingResources(rxIdlingResource);
}
 
Example #20
Source File: IndeterminateProgressCompleteStateInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyCompleteProgressCycleWithCompleteStateText() throws InterruptedException {
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton4), withText(idleStateText)))
            .perform(click());
    Thread.sleep(Constants.INDETERMINATE_PROGRESS_DURATION);
    Espresso.onView(withId(R.id.circularButton4)).perform(click());
    Thread.sleep(Constants.MORPH_DURATION);

    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton4))
            .check(matches(allOf(withText(completeStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_accept)))));
    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton4);
}
 
Example #21
Source File: StepDefinitions.java    From CleanGUITestArchitecture with MIT License 5 votes vote down vote up
/**
 * All the clean up of application's data and state after each scenario must happen here
 * The last call of this method should always be the call to parent's tear down method
 */
@After
public void tearDown() throws Exception {
    LoginActivity.setIdlingNotificationListener(null);
    Espresso.unregisterIdlingResources(mCountingIdlingResourceListener.getCountingIdlingResource());
    ActivityFinisher.finishOpenActivities(); // Required for testing App with multiple activities
    letScreenOfTestDeviceTurnOff();
}
 
Example #22
Source File: OrientationChangeInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
private void checkIndeterminateProgressIdleTestWithText() {
    Espresso.onView(withId(R.id.circularButton1))
            .check(matches(allOf(withText(idleStateText))));
    Espresso.onView(withId(R.id.circularButton4))
            .check(matches(allOf(withText(idleStateText))));
    Espresso.onView(withId(R.id.circularButton5))
            .check(matches(allOf(withText(idleStateText))));
}
 
Example #23
Source File: LoginInstrumentedTest.java    From flowless with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    Espresso.registerIdlingResources(EspressoIdlingResource.getIdlingResource());
    mainActivityActivityTestRule.launchActivity(null);
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    MainActivity mainActivity = mainActivityActivityTestRule.getActivity();
    instrumentation.runOnMainSync(() -> {
        Flow.get(mainActivity.getBaseContext()).setHistory(History.single(LoginKey.create()), Direction.REPLACE);
    });
    ServiceProvider serviceProvider = ServiceProvider.get(mainActivity.getBaseContext());
    LoginComponent loginComponent = serviceProvider.getService(LoginKey.create(), DaggerService.TAG);
    loginPresenter = loginComponent.loginPresenter();
}
 
Example #24
Source File: OrientationChangeInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
private void checkIndeterminateProgressCancelCompleteErrorTestWithText() {
    Espresso.onView(withId(R.id.circularButton1))
            .check(matches(allOf(withText(cancelStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_cross)))));
    Espresso.onView(withId(R.id.circularButton4))
            .check(matches(allOf(withText(completeStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_accept)))));
    Espresso.onView(withId(R.id.circularButton5))
            .check(matches(allOf(withText(errorStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_cancel)))));
}
 
Example #25
Source File: OkHttpIdlingResourceRule.java    From mockwebserver-demo with Apache License 2.0 5 votes vote down vote up
@Override
public Statement apply(final Statement base, Description description) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      IdlingResource idlingResource = OkHttp3IdlingResource.create(
          "okhttp", OkHttp.getInstance());
      Espresso.registerIdlingResources(idlingResource);

      base.evaluate();

      Espresso.unregisterIdlingResources(idlingResource);
    }
  };
}
 
Example #26
Source File: RepositoriesInstrumentedTest.java    From flowless with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    Espresso.registerIdlingResources(EspressoIdlingResource.getIdlingResource());
    mainPage = new MainPage();
    repositoriesPage = new RepositoriesPage();
    mainActivityActivityTestRule.launchActivity(null);
    Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
    MainActivity mainActivity = mainActivityActivityTestRule.getActivity();
    instrumentation.runOnMainSync(() -> {
        Flow.get(mainActivity.getBaseContext()).setHistory(History.single(RepositoriesKey.create()), Direction.REPLACE);
    });
}
 
Example #27
Source File: AuthActivityTest.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Test
public void testErrorAuth() throws Exception {
    RepositoryProvider.provideKeyValueStorage().saveToken(ERROR);

    onView(withId(R.id.loginEdit)).perform(typeText("login"));
    closeSoftKeyboard();
    onView(withId(R.id.passwordEdit)).perform(typeText("pass"));
    closeSoftKeyboard();
    onView(withId(R.id.logInButton)).perform(click());

    IdlingResource idlingResource = TimeIdlingResource.timeout(4000);
    onView(withId(R.id.loginInputLayout)).check(matches(withInputError(R.string.error)));
    Espresso.unregisterIdlingResources(idlingResource);
}
 
Example #28
Source File: RepositoriesActivityTest.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() throws Exception {
    Intents.release();
    if (idlingResource != null) {
        Espresso.unregisterIdlingResources(idlingResource);
    }
    RepositoryProvider.provideKeyValueStorage().clear();
    Realm.getDefaultInstance().executeTransaction(realm -> realm.deleteAll());
}
 
Example #29
Source File: IndeterminateProgressCancelStateInstrumentedTest.java    From ProgressButton with Apache License 2.0 5 votes vote down vote up
@Test
public void verifyProgressCycleWithCancelStateText() throws InterruptedException {
    // Click submit button.
    Espresso.onView(allOf(withId(R.id.circularButton1), withText(idleStateText)))
            .perform(click());
    Thread.sleep(Constants.INDETERMINATE_PROGRESS_DURATION);
    Espresso.onView(withId(R.id.circularButton1)).perform(click());
    Thread.sleep(Constants.MORPH_DURATION);

    // Check the text and compound drawable.
    Espresso.onView(withId(R.id.circularButton1))
            .check(matches(allOf(withText(cancelStateText), not(Utils.withCompoundDrawable(R.drawable.ic_action_cross)))));
    Utils.clickAndShowIdleState(idleStateText, R.id.circularButton1);
}
 
Example #30
Source File: FalconDialogInOnCreateTest.java    From Falcon with Apache License 2.0 5 votes vote down vote up
@Test
public void takesDialogOnCreate() {
  DialogOnCreate activity = _activityRule.getActivity();
  onView(withText(DialogOnCreate.DIALOG_TITLE)).check(matches(isDisplayed()));

  Bitmap withDialog = Falcon.takeScreenshotBitmap(activity);
  Espresso.pressBack();
  onView(withText(DialogOnCreate.DIALOG_TITLE)).check(doesNotExist());

  Bitmap afterDialogDismiss = Falcon.takeScreenshotBitmap(activity);

  assertThatBitmap(withDialog).isDarkerThan(afterDialogDismiss);
}