AnalysisFragmentImpl extends AnalysisScreenContract.View { @Override void showBitmap(@Nullable final Bitmap bitmap, final int rotationForDisplay) { rotateDocumentImageView(rotationForDisplay); mImageDocumentView.setImageBitmap(bitmap); } 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_showBitmap() throws Exception { final AtomicReference<AnalysisFragmentImpl> analysisFragmentImplRef = new AtomicReference<>(); final Bitmap bitmap; try (final ActivityScenario<AnalysisFragmentHostActivity> scenario = launchHostActivity( analysisFragmentImplRef)) { final Photo photo = PhotoFactory.newPhotoFromJpeg(getTestJpeg(), 0, "portrait", "phone", ImageDocument.Source.newCameraSource()); bitmap = photo.getBitmapPreview(); scenario.onActivity( new ActivityScenario.ActivityAction<AnalysisFragmentHostActivity>() { @Override public void perform(final AnalysisFragmentHostActivity activity) { final AnalysisFragmentImpl analysisFragment = analysisFragmentImplRef.get(); analysisFragment.showBitmap(bitmap, 0); } }); onView(withId(R.id.gv_image_picture)).check(matches(withBitmap(bitmap))); } }
@Test public void should_rotateImageView_forBitmap_accordingToRotation() throws Exception { final AtomicReference<AnalysisFragmentImpl> analysisFragmentImplRef = new AtomicReference<>(); try (final ActivityScenario<AnalysisFragmentHostActivity> scenario = launchHostActivity( analysisFragmentImplRef)) { final Photo photo = PhotoFactory.newPhotoFromJpeg(getTestJpeg(), 0, "portrait", "phone", ImageDocument.Source.newCameraSource()); final Bitmap bitmap = photo.getBitmapPreview(); scenario.onActivity( new ActivityScenario.ActivityAction<AnalysisFragmentHostActivity>() { @Override public void perform(final AnalysisFragmentHostActivity activity) { final AnalysisFragmentImpl analysisFragment = analysisFragmentImplRef.get(); analysisFragment.showBitmap(bitmap, 180); } }); onView(withId(R.id.gv_image_picture)).check(matches(withRotation(180))); } }