Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 046d339d authored by Oli Lan's avatar Oli Lan
Browse files

Fix AvatarPhotoControllerTest.

This fixes a test issue with internalCropUsedIfNoSystemCropperFound.

A bitmap must be created or the internal cropping will fail. This
wasn't picked up before because files from previous tests were not
being cleared properly - this also corrects that behaviour.

Bug: 223498130
Test: atest AvatarPhotoControllerTest
Change-Id: I3b550e94bea5894f984122bce420144355ea1cb4
parent af4514e5
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -89,6 +89,10 @@ public class AvatarPhotoControllerTest {

    @After
    public void tearDown() {
        String[] entries = mImagesDir.list();
        for (String entry : entries) {
            new File(mImagesDir, entry).delete();
        }
        mImagesDir.delete();
    }

@@ -233,7 +237,8 @@ public class AvatarPhotoControllerTest {
    public void internalCropUsedIfNoSystemCropperFound() throws IOException {
        when(mMockAvatarUi.startSystemActivityForResult(any(), anyInt())).thenReturn(false);

        new File(mImagesDir, "file.txt").createNewFile();
        File file = new File(mImagesDir, "file.txt");
        saveBitmapToFile(file);

        Intent intent = new Intent();
        intent.setData(Uri.parse(
@@ -241,10 +246,6 @@ public class AvatarPhotoControllerTest {
        mController.onActivityResult(
                REQUEST_CODE_TAKE_PHOTO, Activity.RESULT_OK, intent);

        Intent startIntent = verifyStartSystemActivityForResult(
                "com.android.camera.action.CROP", REQUEST_CODE_CROP_PHOTO);
        assertThat(startIntent.getData()).isNotEqualTo(mTakePhotoUri);

        verify(mMockAvatarUi, timeout(TIMEOUT_MILLIS)).returnUriResult(mCropPhotoUri);

        InputStream imageStream = mContext.getContentResolver().openInputStream(mCropPhotoUri);