@Test public void clickAsyncWork() { onView(withId(R.id.async_work)).perform(click()); }
@Test public void testPlaygroundLaunches() { onView(componentHostWithText(containsString("Playground"))) .check(matches(isDisplayed())) .perform(click()); intended(allOf( toPackage("com.facebook.samples.litho"), hasComponent(hasClassName(DemoListActivity.class.getName())), hasExtras(hasEntry(equalTo("demoName"), equalTo("Playground"))))); } }
private void fillInCardForm() { onView(withId(100)).perform(click(), typeText("4111111111111111")); onView(withId(101)).perform(click(), typeText("1222")); onView(withId(102)).perform(click(), typeText("123")); onView(withId(103)).perform(click(), typeText("95131")); onView(withId(104)).perform(click(), typeText("John Doe")); } }
@Test public void canEnterManualEntryFromScanActivity() { onView(withText("Expiry")).perform(click()); onView(withText("CVV")).perform(click()); onView(withText("Postal Code")).perform(click()); onView(withText("Cardholder Name")).perform(click()); onView(withText("Scan Credit Card using Card.io")).perform(click()); onDevice().acceptRuntimePermission(Manifest.permission.CAMERA); onView(withText(LocalizedStrings.getString(StringKey.KEYBOARD))).check(matches(isDisplayed())); onView(withText(LocalizedStrings.getString(StringKey.KEYBOARD))).perform(click()); fillInCardForm(); onView(withText(LocalizedStrings.getString(StringKey.DONE))).perform(click()); }
@Test public void sendTenDollars() { spoon.screenshot(amountActivityRule.getActivity(), "amount_empty"); onView(withText("1")).perform(click()); onView(withText("0")).perform(click()); spoon.screenshot(amountActivityRule.getActivity(), "amount_ten"); onView(withText("Send")).perform(click()); spoon.screenshot(amountActivityRule.getActivity(), "send_clicked"); }
@Test public void sanityTest() { onView(withId(R.id.clear)).perform(click()); onView(withId(R.id.add)).perform(click()); onView(withId(R.id.edit)).perform(clearText(), typeText(FIRST_TEXT)); onView(withText(R.string.add)).inRoot(isDialog()).perform(click()); onView(withId(R.id.add)).perform(click()); onView(withId(R.id.edit)).perform(clearText(), typeText(SECOND_TEXT)); onView(withText(R.string.add)).inRoot(isDialog()).perform(click()); onView(withText(COL_FIRST_TEXT)).perform(click()); onView(withId(R.id.edit)).perform(clearText(), typeText(THIRD_TEXT)); onView(withText(R.string.edit)).inRoot(isDialog()).perform(click()); onView(withText(COL_SECOND_TEXT)).perform(longClick()); onView(withId(R.id.clear)).perform(click()); } }
@Test public void stubPick() { Instrumentation.ActivityResult result= new Instrumentation.ActivityResult(Activity.RESULT_OK, new Intent(null, ContactsContract.Contacts.CONTENT_URI)); intending(hasAction(Intent.ACTION_PICK)).respondWith(result); onView(withId(R.id.pick)).perform(click()); intended(allOf( hasAction(Intent.ACTION_PICK), hasData(ContactsContract.Contacts.CONTENT_URI))); onView(withId(R.id.view)).check(matches(isEnabled())); }
@Test public void manualEntryReturnsCardData() { onView(withText("Expiry")).perform(click()); onView(withText("CVV")).perform(click()); onView(withText("Postal Code")).perform(click()); onView(withText("Cardholder Name")).perform(click()); onView(withText("Force keyboard entry (bypass scan)")).perform(click()); onView(withText("Scan Credit Card using Card.io")).perform(click()); fillInCardForm(); onView(withText(LocalizedStrings.getString(StringKey.DONE))).perform(click()); onView(withId(R.id.result)).check(matches(withText(containsString("1111")))); onView(withId(R.id.result)).check(matches(withText(containsString("Expiry: 12/2022")))); onView(withId(R.id.result)).check(matches(withText(containsString("CVV: 123")))); onView(withId(R.id.result)).check(matches(withText(containsString("Postal Code: 95131")))); onView(withId(R.id.result)).check(matches(withText(containsString("Cardholder Name: John Doe")))); }
@Test public void shouldOpenCharacterDetailActivityOnRecyclerViewItemClicked() throws Exception { List<Character> characters = givenThereAreSomeCharacters(ANY_NUMBER_OF_CHARACTERS); int characterIndex = 0; startActivity(); onView(withId(R.id.rv_characters)). perform(RecyclerViewActions.actionOnItemAtPosition(characterIndex, click())); Character characterSelected = characters.get(characterIndex); intended(hasComponent(CharacterDetailsActivity.class.getCanonicalName())); intended(hasExtra("CharacterDetailsActivity.CharacterKey", characterSelected.getKey())); }
@Test public void cancelInManualEntryExistsActivity() { onView(withText("Force keyboard entry (bypass scan)")).perform(click()); onView(withText("Scan Credit Card using Card.io")).perform(click()); onView(withText("Card Number")).check(matches(isDisplayed())); onView(withText(LocalizedStrings.getString(StringKey.CANCEL))).perform(click()); onView(withText("Force keyboard entry (bypass scan)")).check(matches(isDisplayed())); }
@Test public void canceledPick() { Instrumentation.ActivityResult result= new Instrumentation.ActivityResult(Activity.RESULT_CANCELED, null); intending(hasAction(Intent.ACTION_PICK)).respondWith(result); onView(withId(R.id.pick)).perform(click()); intended(allOf( hasAction(Intent.ACTION_PICK), hasData(ContactsContract.Contacts.CONTENT_URI))); onView(withId(R.id.view)).check(matches(not(isEnabled()))); }
@Test public void sendNothing() { spoon.screenshot(amountActivityRule.getActivity(), "amount_empty"); onView(withText("Send")).perform(click()); spoon.screenshot(amountActivityRule.getActivity(), "send_clicked"); } }
@Test public void shouldOpenComicSeriesDetailActivityOnRecyclerViewItemClicked() throws Exception { givenThereAreSomeCharacters(ANY_NUMBER_OF_CHARACTERS); List<ComicSeries> comicSeries = givenThereAreSomeComicSeries(ANY_NUMBER_OF_COMIC_SERIES); givenAnyComicSeriesDetail(); int comicSeriesIndex = 0; Activity activity = startActivity(); registerIdlingResources( new ViewPagerIdlingResource((ViewPager) activity.findViewById(R.id.vp_main))); onView(withId(R.id.vp_main)).perform(swipeLeft()); onView(withId(R.id.rv_comics)). perform(RecyclerViewActions.actionOnItemAtPosition(comicSeriesIndex, click())); ComicSeries comicSeriesSelected = comicSeries.get(comicSeriesIndex); intended(hasComponent(ComicSeriesDetailsActivity.class.getCanonicalName())); intended(hasExtra("ComicSeriesDetailsActivity.ComicSeriesKey", comicSeriesSelected.getKey().intValue())); }
@Test public void til() { onView(withTILHint("URL")) .perform(typeText(URL), closeSoftKeyboard()); Instrumentation.ActivityResult result= new Instrumentation.ActivityResult(Activity.RESULT_CANCELED, null); intending(hasAction(Intent.ACTION_VIEW)).respondWith(result); onView(withId(R.id.browse)).perform(click()); intended(allOf(hasAction(Intent.ACTION_VIEW), hasData(URL))); }
@Test public void dontPostWithEmptyTextView() { FeedController mockFeedController = mock(FeedController.class); doNothing().when(mockFeedController).sendPostAsync(anyString()); when(mComponent.feedController()).thenReturn(mockFeedController); getActivity(); onView(withId(R.id.fab)).perform(ViewActions.click()); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(mockFeedController, never()).sendPostAsync(captor.capture()); }
private void navigateToMenuItem(int menuItemIdx) { onView(withContentDescription(R.string.app_name)).perform(click()); Context context = InstrumentationRegistry.getTargetContext(); if (context != null) { String menuItem = context.getResources().getStringArray(R.array.styles)[menuItemIdx]; onView(withText(menuItem)).perform(click()); } }
@Test public void testClickGroup() { onView(withId(R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItemAtPosition(0, click())); assertTrue(adapter.isGroupExpanded(0)); }
@Test public void testClickItem() { onView(withId(R.id.recycler_view)) .perform(RecyclerViewActions.actionOnItemAtPosition(1, click())); } }
@Test public void shouldSetAClickListenerToEveryPDFPage() throws Exception { startActivity(); openActionBarMenu(); onView(withText(R.string.menu_sample9_txt)).perform(click()); onView(withClassName(containsString(PDFViewPager.class.getSimpleName()))).perform(click()); onView(withClassName(containsString(PDFViewPager.class.getSimpleName()))).check(matches(isDisplayed())); }