@Test public void listCount() { onView(Matchers.<View>instanceOf(RecyclerView.class)) .check(new AdapterCountAssertion(25)); }
public void testLoadUserHappyCaseViews() { onView(withId(R.id.rl_retry)).check(matches(not(isDisplayed()))); onView(withId(R.id.rl_progress)).check(matches(not(isDisplayed()))); onView(withId(R.id.tv_fullname)).check(matches(isDisplayed())); onView(withId(R.id.tv_email)).check(matches(isDisplayed())); onView(withId(R.id.tv_description)).check(matches(isDisplayed())); }
@Test public void clickAsyncWork() { onView(withId(R.id.async_work)).perform(click()); }
@Test public void testLithographyIsVisibleAndClickable() { onView(componentHostWithText(containsString("Lithography"))) .check(matches(allOf(isDisplayed(), isClickable()))); }
@Test public void testTreePropPropagation() { onView( componentHost( allOf(withText(containsString("root:leaf")), withTagValue(is((Object) 0))))) .check(matches(isDisplayed())); onView(componentHostWithText(containsString("root:top:bottom:leaf"))) .check(matches(isDisplayed())); onView(componentHostWithText(containsString("root:top:leaf"))).check(matches(isDisplayed())); } }
private int testOrientation() { int orientation=getOrientation(); if (orientation==Configuration.ORIENTATION_LANDSCAPE) { onView(withId(R.id.content)) .check(new OrientationAssertion(LinearLayout.HORIZONTAL)); } else { onView(withId(R.id.content)) .check(new OrientationAssertion(LinearLayout.VERTICAL)); } return(orientation); }
@Test public void asyncButtonHasStartText() { onView(withId(R.id.async_work)).check(matches(withText(R.string.start_async_work))); } }
private void assertToastIsShown(String text) { onView(withText(text)) .inRoot(withDecorView(not(is(mActivity.getActivity().getWindow().getDecorView())))) .check(matches(isDisplayed())); } }
@Test public void listCount() { onView(withId(android.R.id.list)) .check(new AdapterCountAssertion(25)); }
@Test public void scrollToBottom() { onView(withClassName(is(RecyclerView.class.getCanonicalName()))) .perform(scrollToPosition(24)) .check(matches(anything())); }
@Test public void testRenderCompleteEventTriggered() { onView(componentHostWithText(is("Hello World"))).check(matches(isDisplayed())); assertToastIsShown(TTIMarkerSectionSpec.RENDER_MARKER); }
@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"))))); } }
@Test public void testTreePropPropagation() { onView( componentHost( allOf(withText(containsString("rootdiff:top:leaf")), withTagValue(is((Object) 0))))) .check(matches(isDisplayed())); } }
@Test public void testTestKeyLookup() { onView(withTestKey("main_screen")) .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 testPlaygroundIsVisibleAndClickable() { onView(componentHostWithText(containsString("Playground"))) .check(matches(isDisplayed())) .check(matches(isClickable())); } }
@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 recreate() { stubPick(); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { main.getActivity().recreate(); } }); onView(withId(R.id.view)).check(matches(isEnabled())); }
@Test public void keyEvents() { onView(withId(android.R.id.list)) .perform(pressKey(KeyEvent.KEYCODE_DPAD_DOWN), pressKey(KeyEvent.KEYCODE_DPAD_DOWN), pressKey(KeyEvent.KEYCODE_DPAD_DOWN), pressKey(KeyEvent.KEYCODE_DPAD_DOWN)) .check(new ListSelectionAssertion(3)); }