AnalysisFragmentImpl extends AnalysisScreenContract.View { @Override void showErrorSnackbar(@NonNull final String message, final int duration, @Nullable final String buttonTitle, @Nullable final View.OnClickListener onClickListener) { if (mFragment.getActivity() == null) { return; } ErrorSnackbar.make(mFragment.getActivity(), mLayoutRoot, message, buttonTitle, onClickListener, ErrorSnackbar.LENGTH_INDEFINITE).show(); } AnalysisFragmentImpl(final FragmentImplCallback fragment,
            @NonNull final Document document,
            final String documentAnalysisErrorMessage); @Override void hideError(); @Override void onNoExtractionsFound(); @Override void onDocumentAnalyzed(); @Override void showError(@NonNull final String message, final int duration); @Override void showError(@NonNull final String message, @NonNull final String buttonTitle,
            @NonNull final View.OnClickListener onClickListener); @Override void startScanAnimation(); @Override void stopScanAnimation(); @Override void setListener(@NonNull final AnalysisFragmentListener listener); void onCreate(final Bundle savedInstanceState); View onCreateView(final LayoutInflater inflater, final ViewGroup container,
            final Bundle savedInstanceState); void onStart(); void onDestroy();  }
@Test public void should_showErrorSnackbar() throws Exception { final AtomicReference<AnalysisFragmentImpl> analysisFragmentImplRef = new AtomicReference<>(); try (final ActivityScenario<AnalysisFragmentHostActivity> scenario = launchHostActivity( analysisFragmentImplRef)) { scenario.onActivity( new ActivityScenario.ActivityAction<AnalysisFragmentHostActivity>() { @Override public void perform(final AnalysisFragmentHostActivity activity) { final AnalysisFragmentImpl analysisFragment = analysisFragmentImplRef.get(); analysisFragment.showErrorSnackbar("Message", 1000, "ButtonTitle", mock(View.OnClickListener.class)); } }); onView(withText("Message")).check(matches(isCompletelyDisplayed())); onView(withText("ButtonTitle")).check(matches(isCompletelyDisplayed())); } }