Java 类android.support.test.espresso.action.ViewActions 实例源码

项目:NumberPadTimePicker    文件:NumberPadTimePickerDialogTest.java   
private static void verifyViewEnabledStates(TestCase test) {
    ViewInteraction[] buttonsInteractions = getButtonInteractions();
    ViewInteraction[] altButtonsInteractions = getAltButtonInteractions();
    for (int digit : test.sequence) {
        buttonsInteractions[digit]
                .check(ViewAssertions.matches(ViewMatchers.isEnabled()))
                .perform(ViewActions.click());
    }
    for (int i = 0; i < 10; i++) {
        buttonsInteractions[i].check(matchesIsEnabled(
                i >= test.numberKeysEnabledStart && i < test.numberKeysEnabledEnd));
        altButtonsInteractions[0].check(matchesIsEnabled(test.leftAltKeyEnabled));
        altButtonsInteractions[1].check(matchesIsEnabled(test.rightAltKeyEnabled));
    }

    Espresso.onView(ViewMatchers.withText(android.R.string.ok))
            .check(matchesIsEnabled(test.okButtonEnabled));

    ViewInteraction backspaceInteraction = Espresso.onView(
            ViewMatchers.withId(R.id.nptp_backspace));
    // Reset after each iteration by backspacing on the button just clicked.
    backspaceInteraction.check(matchesIsEnabled(true))
            .perform(ViewActions.longClick())
            .check(matchesIsEnabled(false));
}
项目:smart-lens    文件:InfoActivityTest.java   
@Test
public void checkRealApiResponse() throws Exception {
    WikiHelper.BASE_WIKI_URL = "https://en.wikipedia.org/w/";
    openActivity();

    //Wait for the api call
    Delay.startDelay(TestConfig.DELAY_FOR_REAL_API);
    onView(withId(R.id.root_view)).perform(ViewActions.closeSoftKeyboard());

    //Check if there are text?
    assertTrue(mWikiFragmentFragmentTestRule.getActivity().mViewFlipper.getDisplayedChild() ==
            INFO_VIEW);
    onView(withId(R.id.wiki_page_tv)).check(ViewAssertions.matches(CustomMatchers.hasText()));
    onView(withId(R.id.wiki_page_iv)).check(ViewAssertions.matches(CustomMatchers.hasImage()));
    Delay.stopDelay();
}
项目:smart-lens    文件:InfoActivityTest.java   
@Test
public void checkInfoNotFoundApiResponse() throws Exception {
    MockWebServer mockWebServer = startMockWebServer();
    //Success response for the info api
    mockWebServer.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
                    com.kevalpatel2106.smartlens.test.R.raw.wiki_info_not_found_success_response)));
    //Success response for the image api.
    mockWebServer.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
                    com.kevalpatel2106.smartlens.test.R.raw.wiki_image_success_response)));
    openActivity();

    //Wait for mock api
    Delay.startDelay(TestConfig.DELAY_FOR_MOCK_API);
    onView(withId(R.id.root_view)).perform(ViewActions.closeSoftKeyboard());

    //Check if is error?
    assertTrue(mWikiFragmentFragmentTestRule.getActivity().mViewFlipper.getDisplayedChild() ==
            ERROR_VIEW);

    Delay.stopDelay();
    mockWebServer.shutdown();
}
项目:smart-lens    文件:InfoActivityTest.java   
@Test
public void checkInfoApiResponseFail() throws Exception {
    MockWebServer mockWebServer = startMockWebServer();
    //Fail response for the info api.
    mockWebServer.enqueue(new MockResponse().setResponseCode(500));
    //Success response for the image api.
    mockWebServer.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
                    com.kevalpatel2106.smartlens.test.R.raw.wiki_image_success_response)));
    openActivity();

    //Wait for mock api
    Delay.startDelay(TestConfig.DELAY_FOR_MOCK_API);
    onView(withId(R.id.root_view)).perform(ViewActions.closeSoftKeyboard());

    //Check if error occurred?
    assertTrue(mWikiFragmentFragmentTestRule.getActivity().mViewFlipper.getDisplayedChild() ==
            ERROR_VIEW);

    Delay.stopDelay();
    mockWebServer.shutdown();
}
项目:smart-lens    文件:InfoActivityTest.java   
@Test
public void checkImageApiResponseFail() throws Exception {
    MockWebServer mockWebServer = startMockWebServer();
    //Success response for the info api
    mockWebServer.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
                    com.kevalpatel2106.smartlens.test.R.raw.wiki_info_success_response)));
    //Fail response for the image api.
    mockWebServer.enqueue(new MockResponse().setResponseCode(500));
    openActivity();

    //Wait for mock api
    Delay.startDelay(TestConfig.DELAY_FOR_MOCK_API);
    onView(withId(R.id.root_view)).perform(ViewActions.closeSoftKeyboard());

    //Check if there are text?
    assertTrue(mWikiFragmentFragmentTestRule.getActivity().mViewFlipper.getDisplayedChild() ==
            INFO_VIEW);
    onView(withId(R.id.wiki_page_tv)).check(ViewAssertions.matches(CustomMatchers.hasText()));
    onView(withId(R.id.wiki_page_iv)).check(ViewAssertions.matches(not(CustomMatchers.hasImage())));

    Delay.stopDelay();
    mockWebServer.shutdown();
}
项目:AdSimasTeam    文件:ShowAds.java   
@Test
    public void openAd() {

        try {
            Thread.sleep(20000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        onView(ViewMatchers.withId(R.id.buttonShowAd))
                .perform(ViewActions.click());

//        intended(allOf(
//                hasComponent(hasShortClassName("AdSimasFullActivity"))
//        ));

        onView(ViewMatchers.withText("hardMOB - Promoções"));
    }
项目:Android-BlogExample    文件:MainFragmentTest.java   
@Test
public void testWebViewUpdateElementByDisplayed() throws Exception {
    String go = MainFragment.DEFAULT_URL;

    onView(withId(R.id.et_url)).perform(clearText());
    onView(withId(R.id.et_url)).perform(typeText(go)).perform(ViewActions.pressImeActionButton());

    waitWebViewLoad();

    onView(withId(R.id.et_keyword)).perform(clearText()).perform(typeText(JAVASCRIPT_CALL));
    onView(withId(R.id.btn_search)).perform(click());

    onWebView()
            // Find the message element by ID
            .withElement(findElement(Locator.ID, "message"))
            // Verify that the text is displayed
            .check(webMatches(getText(), containsString(JAVASCRIPT_CALL)));
}
项目:Red-Calorie    文件:OverviewActivityTest.java   
@Test
public void testCanAddNewMeal() {
    onView(withId(R.id.fab_expand_menu_button)).perform(click());
    onView(withId(R.id.overview_fab_add_meal)).perform(click());
    intended(hasComponent(new ComponentName(getTargetContext(), AddMealActivity.class)));
    onView(withId(R.id.add_meal_content)).check(matches(isDisplayed()));
    onView(withId(R.id.add_meal_name)).perform(typeTextIntoFocusedView("Meal 3"));
    closeSoftKeyboard();
    onView(withId(R.id.add_meal_fab_add_ingredient)).perform(click());
    intended(hasComponent(new ComponentName(getTargetContext(), IngredientsActivity.class)));
    onView(allOf(withId(R.id.ingredients_content), isAssignableFrom(RecyclerView.class)))
            .check(matches(isDisplayed()));
    onView(withText(IngredientActivityTest.exampleIngredients[0].getName())).check(matches(isDisplayed()))
            .perform(click());
    intended(hasComponent(new ComponentName(getTargetContext(), IngredientDetailActivity.class)));
    onView(withText(IngredientActivityTest.exampleIngredients[0].getName())).check(matches(isDisplayed()));
    onView(withHint(R.string.add_meal_ingredient_amount_hint)).perform(click())
            .perform(typeTextIntoFocusedView("200"))
            .perform(ViewActions.closeSoftKeyboard());
    onView(withId(R.id.add_meal_ingredient_accept)).perform(click());
    onView(withText(R.string.add_meal_save_action)).perform(click());
    onView(ViewMatchers.withId(R.id.overview_fab_add_meal)).check(matches(isDisplayed()));
    onView(withText("Meal 3"))
            .check(matches(isDisplayed()));
}
项目:Red-Calorie    文件:TagsActivityTest.java   
@Test
    public void testAddNewTag() throws Exception {
        main.launchActivity(null);
        final String tagName = "My tag name";
        onView(ViewMatchers.withId(R.id.tags_fab_add_new)).check(matches(isDisplayed()))
                .perform(click());
        onView(withText(R.string.tags_new_tag_dialog)).check(matches(isDisplayed()));
        onView(withHint(R.string.tags_new_tag_hint)).check(matches(isDisplayed()))
                .perform(ViewActions.typeTextIntoFocusedView(tagName));
        onView(withText(tagName)).check(matches(isDisplayed()));
        onView(withText(android.R.string.ok)).check(matches(isDisplayed()))
                .perform(click());
        onView(withText(tagName)).check(matches(isDisplayed()));

//        onView(withText(R.string.tags_undo)).perform(click());
//        onView(withText(tagName)).check(doesNotExist());
    }
项目:bluesnap-android-int    文件:ShippingFlowTest.java   
public void enterCardDetails() throws InterruptedException {
    // Check that the sipping button appears
    onView(withId(R.id.buyNowButton))
            .check(matches(withText("Shipping")));

    onView(withId(R.id.creditCardNumberEditText))
            .perform(typeText(cardNumberGeneratorTest()), ViewActions.closeSoftKeyboard());

    CardFormTesterCommon.fillInAllFieldsWithValidCard();

    onView(withId(R.id.buyNowButton)).perform(click());
    Thread.sleep(2000);
    //TODO: check that the shipping activity is launched.
    CardFormTesterCommon.fillInShippingDetails();
    Thread.sleep(2000);
    onView(withId(R.id.shippingBuyNowButton)).perform(ViewActions.closeSoftKeyboard()).perform(click());
    //TOOD: Verify that flow returns to Payment


}
项目:Android-BlogExample    文件:MainFragmentTest.java   
@Test
public void testWebToAndroidScriptCall() throws Exception {
    String go = MainFragment.DEFAULT_URL;

    onView(withId(R.id.et_url)).perform(clearText());
    onView(withId(R.id.et_url)).perform(typeText(go)).perform(ViewActions.pressImeActionButton());

    waitWebViewLoad();

    onWebView()
            // Find the search keyword element by ID
            .withElement(findElement(Locator.ID, "search_keyword"))
            // Clear previous input
            .perform(clearElement())
            // Enter text into the input element
            .perform(DriverAtoms.webKeys(ANDROID_SCRIPT_CALL))
            // Value check. script getValue 'search_keyword'
            .check(webMatches(script("return document.getElementById('search_keyword').value", castOrDie(String.class)), containsString(ANDROID_SCRIPT_CALL)))
            // Find the submit button
            .withElement(findElement(Locator.ID, "updateKeywordBtn"))
            // Simulate a click via javascript
            .perform(webClick());

    onView(withId(R.id.et_keyword)).check(matches(withText(ANDROID_SCRIPT_CALL)));
}
项目:2016.2-WikiLegis    文件:SearchBillFragmentTest.java   
public void testResultSearchExistWithInternet() {
    Boolean isLoggedIn = PreferenceManager.getDefaultSharedPreferences
            (activityOnTest.getBaseContext()).getBoolean("IsLoggedIn", false);

    if(isLoggedIn){
        onView(withId(R.id.action_profile_logged)).perform(click());
        onView(withText("Sair")).perform(click());
    }

    closeSoftKeyboard();

    onView(withText("Visitante")).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.action_search)).perform(click());

    onView(isAssignableFrom(EditText.class)).perform(typeText("Gr"),
            pressKey(KeyEvent.KEYCODE_ENTER));

    closeSoftKeyboard();

    onView(withId(R.id.recycler_view_search))
            .perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));

    onView(withId(R.id.textViewTitleBill)).check(matches(isDisplayed()));
}
项目:2016.2-WikiLegis    文件:SearchBillFragmentTest.java   
public void testResultSearchNotExistWithInternet() {
    Boolean isLoggedIn = PreferenceManager.getDefaultSharedPreferences
            (activityOnTest.getBaseContext()).getBoolean("IsLoggedIn", false);

    if(isLoggedIn){
        onView(withId(R.id.action_profile_logged)).perform(click());
        onView(withText("Sair")).perform(click());
    }

    closeSoftKeyboard();

    onView(withText("Visitante")).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.action_search)).perform(click());

    onView(isAssignableFrom(EditText.class)).perform(typeText("Gremio"),
            pressKey(KeyEvent.KEYCODE_ENTER));

    closeSoftKeyboard();

    onView(withText("Nenhum resultado encontrado!")).inRoot(withDecorView(not(is(getActivity()
            .getWindow().getDecorView())))).check(matches(isDisplayed()));
}
项目:bluesnap-android-int    文件:CCormValidityTest.java   
@Test
public void dateFieldValidationCheck() throws InterruptedException {
    //Test validation of invalid Month (56)
    onView(withId(R.id.expDateLabelTextView)).check(matches(not(TestUtils.withCurrentTextColor(Color.RED))));
    onView(withId(R.id.expDateEditText))
            .perform(clearText(), typeText("56 44"), ViewActions.closeSoftKeyboard());
    onView(withId(R.id.buyNowButton)).perform(click());
    Thread.sleep(1000);
    onView(withId(R.id.expDateLabelTextView)).check(matches((TestUtils.withCurrentTextColor(Color.RED))));
    onView(withId(R.id.expDateEditText))
            .perform(clearText());

    //Now enter a valid month
    onView(withId(R.id.expDateEditText))
            .perform(typeText("12 26"), ViewActions.closeSoftKeyboard());

    onView(withId(R.id.buyNowButton)).perform(click());
    onView(withId(R.id.expDateLabelTextView)).check(matches(not(TestUtils.withCurrentTextColor(Color.RED))));
}
项目:bluesnap-android-int    文件:CCormValidityTest.java   
@Test
public void dateFieldPastCheck() throws InterruptedException {
    onView(withId(R.id.expDateLabelTextView)).check(matches(not(TestUtils.withCurrentTextColor(Color.RED))));
    onView(withId(R.id.expDateEditText))
            .perform(typeText("11 05"), ViewActions.closeSoftKeyboard());
    onView(withId(R.id.buyNowButton)).perform(click());
    onView(withId(R.id.expDateLabelTextView)).check(matches((TestUtils.withCurrentTextColor(Color.RED))));
    onView(withId(R.id.expDateEditText))
            .perform(clearText());

    //Now enter a valid month
    onView(withId(R.id.expDateEditText))
            .perform(typeText("12 26"), ViewActions.closeSoftKeyboard());

    onView(withId(R.id.buyNowButton)).perform(click());
    onView(withId(R.id.expDateLabelTextView)).check(matches(not(TestUtils.withCurrentTextColor(Color.RED))));
}
项目:material-components-android    文件:BottomSheetBehaviorTest.java   
@Test
@MediumTest
public void testSwipeDownToHide() {
  Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
      .perform(
          DesignViewActions.withCustomConstraints(
              ViewActions.swipeDown(), ViewMatchers.isDisplayingAtLeast(5)));
  registerIdlingResourceCallback();
  try {
    Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
        .check(ViewAssertions.matches(not(ViewMatchers.isDisplayed())));
    assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_HIDDEN));
  } finally {
    unregisterIdlingResourceCallback();
  }
}
项目:material-components-android    文件:BottomSheetBehaviorTouchTest.java   
@Test
public void testTouchCoordinatorLayout() {
  final CoordinatorLayoutActivity activity = activityTestRule.getActivity();
  down = false;
  Espresso.onView(sameInstance((View) activity.mCoordinatorLayout))
      .perform(ViewActions.click()) // Click outside the bottom sheet
      .check(
          new ViewAssertion() {
            @Override
            public void check(View view, NoMatchingViewException e) {
              assertThat(e, is(nullValue()));
              assertThat(view, is(notNullValue()));
              // Check that the touch event fell through to the container
              assertThat(down, is(true));
            }
          });
}
项目:material-components-android    文件:BottomSheetDialogTest.java   
@Test
public void testTouchInside() throws Throwable {
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          showDialog();
          // Confirms that the dialog is shown
          assertThat(dialog.isShowing(), is(true));
          FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
          // The bottom sheet is not clickable
          assertNotNull(bottomSheet);
          assertThat(bottomSheet.isClickable(), is(false));
        }
      });
  // Click on the bottom sheet
  Espresso.onView(ViewMatchers.withId(R.id.design_bottom_sheet)).perform(ViewActions.click());
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          // Confirm that touch didn't fall through as outside touch
          assertThat(dialog.isShowing(), is(true));
        }
      });
}
项目:material-components-android    文件:BottomSheetDialogTest.java   
@Test
public void testClickContent() throws Throwable {
  final View.OnClickListener mockListener = mock(View.OnClickListener.class);
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          showDialog();
          // Confirms that the dialog is shown
          assertThat(dialog.isShowing(), is(true));
          FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
          // Set up an OnClickListener to the content of the bottom sheet
          assertNotNull(bottomSheet);
          View child = bottomSheet.getChildAt(0);
          child.setOnClickListener(mockListener);
        }
      });
  // Click on the bottom sheet; since the whole sheet is occupied with its only child, this
  // clicks the child
  Espresso.onView(ViewMatchers.withParent(ViewMatchers.withId(R.id.design_bottom_sheet)))
      .perform(ViewActions.click());
  verify(mockListener, times(1)).onClick(any(View.class));
}
项目:material-components-android    文件:BottomSheetDialogTest.java   
@Test
public void testNonCancelableDialog() throws Throwable {
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          showDialog();
          dialog.setCancelable(false);
        }
      });
  // Click outside the bottom sheet
  Espresso.onView(ViewMatchers.withId(R.id.touch_outside)).perform(ViewActions.click());
  activityTestRule.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
          BottomSheetBehavior<FrameLayout> behavior = BottomSheetBehavior.from(bottomSheet);
          assertThat(behavior.isHideable(), is(false));
          assertThat(dialog.isShowing(), is(true));
          dialog.cancel();
          assertThat(dialog.isShowing(), is(false));
        }
      });
}
项目:RecipeFinderJavaVersion    文件:SearchRecipesFragmentTest.java   
@Test
public void testStartSearching() {
    when(repository.searchRecipes(Mockito.<String, String>anyMap()))
            .thenReturn(Single.just(AssetUtils.getRecipeList(context)));
    when(repository.loadMore(Mockito.<String, String>anyMap()))
            .thenReturn(Single.just(AssetUtils.getMoreRecipeList(context)));
    when(repository.isInFavorites(Mockito.<Recipe>any()))
            .thenReturn(Single.just(true));
    rule.launchActivity(new Intent());
    performSearch();

    onView(withText(firstRecipeTitle)).check(matches(isDisplayed()));
    onView(ViewMatchers.withId(R.id.rv_recipe_list)).perform(RecyclerViewActions.scrollToPosition(9));
    onView(withText(lastRecipeTitle)).check(matches(isDisplayed()));

    // Scroll to top and click upon the first item
    Recipe recipe = AssetUtils.getRecipeEntity(InstrumentationRegistry.getContext());
    onView(withId(R.id.rv_recipe_list)).perform(RecyclerViewActions.scrollToPosition(0));

    onView(withText(recipe.getLabel())).perform(ViewActions.click());

    onView(withId(R.id.tv_health_labels)).check(matches(isDisplayed()));
    onView(withId(R.id.iv_recipe_image)).check(matches(isDisplayed()));
    onView(withId(R.id.toolbar)).check(matches(isDisplayed()));
}
项目:bluesnap-android-int    文件:CCormValidityTest.java   
@Test
public void invalidCardMessageCheck() throws InterruptedException {
    //Test validation of invalid number
    onView(withId(R.id.invaildCreditCardMessageTextView)).check(matches(not(ViewMatchers.isDisplayed())));
    onView(withId(R.id.creditCardNumberEditText))
            .perform(typeText(invalidCardNumberGeneratorTest()), ViewActions.closeSoftKeyboard());
    onView(withId(R.id.buyNowButton)).perform(click());
    onView(withId(R.id.invaildCreditCardMessageTextView)).check(matches(ViewMatchers.isDisplayed()));

    //Clear the invalid number
    onView(withId(R.id.creditCardNumberEditText)).perform(clearText());

    //Put a valid number
    onView(withId(R.id.creditCardNumberEditText))
            .perform(typeText(cardNumberGeneratorTest()), ViewActions.closeSoftKeyboard());
    onView(withId(R.id.buyNowButton)).perform(click());
    onView(withId(R.id.invaildCreditCardMessageTextView)).check(matches(not(ViewMatchers.isDisplayed())));
}
项目:smart-lens    文件:InfoActivityTest.java   
@Test
public void checkInfoFoundApiResponse() throws Exception {
    MockWebServer mockWebServer = startMockWebServer();
    //Success response for the info api
    mockWebServer.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
                    com.kevalpatel2106.smartlens.test.R.raw.wiki_info_success_response)));
    //Success response for the image api.
    mockWebServer.enqueue(new MockResponse()
            .setResponseCode(200)
            .setBody(getStringFromFile(InstrumentationRegistry.getInstrumentation().getContext(),
                    com.kevalpatel2106.smartlens.test.R.raw.wiki_image_success_response)));
    openActivity();

    //Wait for mock api
    Delay.startDelay(TestConfig.DELAY_FOR_REAL_API);
    onView(withId(R.id.root_view)).perform(ViewActions.closeSoftKeyboard());

    //Check if there are text?
    assertTrue(mWikiFragmentFragmentTestRule.getActivity().mViewFlipper.getDisplayedChild() ==
            INFO_VIEW);
    onView(withId(R.id.wiki_page_tv)).check(ViewAssertions.matches(CustomMatchers.hasText()));
    onView(withId(R.id.wiki_page_iv)).check(ViewAssertions.matches(CustomMatchers.hasImage()));

    Delay.stopDelay();
    mockWebServer.shutdown();
}
项目:Clases-2017c1    文件:SelectPictureActivityTest.java   
@Test
public void checkDownloadUrl() {
    // CountingIdleResource sirve para sincronizar tests cuando se ejecutan tareas asíncronas.
    // En este caso pausa el avance del test mientras descarga un archivo y eso lo hicimos
    // pisando el Factory de UrlRequest para que lo utilice.
    onView(withId(R.id.urlEditText)).perform(ViewActions.typeText("http://esotericos.org/wp-content/uploads/2012/08/Buscar-la-felicidad.jpg"));
    // La siguiente instrucción detiene el test porque arranca una descarga:
    onView(withId(R.id.urlButton)).perform(click());
    // La siguiente instrucción se ejecuta una vez que la descarga termina:
    onView(withId(R.id.progressBar)).check(matches(not(isDisplayed())));
}
项目:bluesnap-android-int    文件:CCormValidityTest.java   
/**
 * Test that when entering valid data and then modifying it eventually invalidates the form.
 *
 * @throws InterruptedException
 */
@Test
public void test_validate_invalidate() throws InterruptedException {
    CardFormTesterCommon.fillInAllFieldsWithValidCard();

    onView(withId(R.id.creditCardNumberEditText))
            .perform(ViewActions.closeSoftKeyboard())
            //.perform(pressKey(KeyEvent.KEYCODE_DEL))
            .perform(clearText())
            .perform(typeText("1"), ViewActions.closeSoftKeyboard());

    onView(withId(R.id.buyNowButton)).perform(click());
    onView(withId(R.id.invaildCreditCardMessageTextView)).check(matches(ViewMatchers.isDisplayed()));
}
项目:bluesnap-android-int    文件:CardFormTesterCommon.java   
public static void fillInShippingDetails() {
    onView(withId(R.id.shippingNameEditText)).perform(clearText(), typeText("John Doe"));
    onView(withId(R.id.shippingAddressLine)).perform(clearText(), typeText("9 Baker street"));
    onView(withId(R.id.shippingCityEditText)).perform(clearText(), typeText("London"));
    onView(withId(R.id.shippingStateEditText)).perform(clearText(), typeText("UK")).perform(ViewActions.closeSoftKeyboard());

}
项目:2016.2-WikiLegis    文件:RegisterUserFragmentTest.java   
public void testErrorWithNumbersFirstName(){
    closeSoftKeyboard();
    onView(withId(R.id.registerText)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).perform(typeText("aaa125"));
    closeSoftKeyboard();
    onView(withId(R.id.registerButton)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).check(matches(hasErrorText("O nome deve ter apenas letras.")));
}
项目:2016.2-WikiLegis    文件:RegisterUserFragmentTest.java   
public void testErrorWithNumbersLastName(){
    closeSoftKeyboard();
    onView(withId(R.id.registerText)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).perform(typeText("aaa"));
    onView(withId(R.id.lastNameField)).perform(typeText("aaa125"));
    closeSoftKeyboard();
    onView(withId(R.id.registerButton)).perform(ViewActions.scrollTo()).perform(click());

    onView(withId(R.id.lastNameField)).check(matches(hasErrorText("O sobrenome deve ter apenas letras.")));
}
项目:2016.2-WikiLegis    文件:RegisterUserFragmentTest.java   
public void testErrorWithEmptyEmail(){
    closeSoftKeyboard();
    onView(withId(R.id.registerText)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).perform(typeText("aaaaa"));
    onView(withId(R.id.lastNameField)).perform(typeText("aaaaaa"));
    closeSoftKeyboard();
    onView(withId(R.id.emailField)).perform(typeText(""));
    onView(withId(R.id.registerButton)).perform(ViewActions.scrollTo()).perform(click());

    onView(withId(R.id.emailField)).check(matches(hasErrorText("Inválido, o email não pode ser vazio.")));
}
项目:2016.2-WikiLegis    文件:RegisterUserFragmentTest.java   
public void testErrorWithOverMaxLengthFirstName(){
    closeSoftKeyboard();
    onView(withId(R.id.registerText)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).perform(typeText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
    closeSoftKeyboard();
    onView(withId(R.id.registerButton)).perform(ViewActions.scrollTo()).perform(click());

    onView((withId(R.id.firstNameField))).check(matches(hasErrorText("Inválido, o nome deve ter no máximo 30 caractéres")));
}
项目:2016.2-WikiLegis    文件:RegisterUserFragmentTest.java   
public void testErrorWithEmptyLastName(){
    closeSoftKeyboard();
    onView(withId(R.id.registerText)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).perform(typeText("aaaaaaaaaaa"));
    onView(withId(R.id.lastNameField)).perform(typeText(""));
    closeSoftKeyboard();
    onView(withId(R.id.registerButton)).perform(ViewActions.scrollTo()).perform(click());
    onView((withId(R.id.lastNameField))).check(matches(hasErrorText("Inválido, o sobrenome não pode ser vazio.")));
}
项目:2016.2-WikiLegis    文件:RegisterUserFragmentTest.java   
public void testErrorWithOverMaxLengthLastName(){
    closeSoftKeyboard();
    onView(withId(R.id.registerText)).perform(ViewActions.scrollTo()).perform(click());
    onView(withId(R.id.firstNameField)).perform(typeText("aaaaaaaaaaa"));
    onView(withId(R.id.lastNameField)).perform(typeText("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
    closeSoftKeyboard();
    onView(withId(R.id.registerButton)).perform(ViewActions.scrollTo()).perform(click());
    onView((withId(R.id.lastNameField))).check(matches(hasErrorText("Inválido, o sobrenome deve ter no máximo 30 caractéres")));
}