mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
5204: Fix unit test UploadMediaPresenterTest.handleImageResult (#5206)
* UploadMediaPresenterTest: fix failing unit tests * change else if to if condition to handle all cases * include errorCodes 68 for duplicate image and 96 for image without exif * optimise if statements * remove redundant cases * modify if statements to cover all cases * simplify all if statements * add removed comment again * remove unused imports
This commit is contained in:
parent
2c7f2d05cd
commit
a116a17e7b
2 changed files with 5 additions and 14 deletions
|
|
@ -3,12 +3,7 @@ package fr.free.nrw.commons.upload.mediaDetails;
|
||||||
import static fr.free.nrw.commons.di.CommonsApplicationModule.IO_THREAD;
|
import static fr.free.nrw.commons.di.CommonsApplicationModule.IO_THREAD;
|
||||||
import static fr.free.nrw.commons.di.CommonsApplicationModule.MAIN_THREAD;
|
import static fr.free.nrw.commons.di.CommonsApplicationModule.MAIN_THREAD;
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.EMPTY_CAPTION;
|
import static fr.free.nrw.commons.utils.ImageUtils.EMPTY_CAPTION;
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.FILE_FBMD;
|
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.FILE_NAME_EXISTS;
|
import static fr.free.nrw.commons.utils.ImageUtils.FILE_NAME_EXISTS;
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.FILE_NO_EXIF;
|
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_BLURRY;
|
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_DARK;
|
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_GEOLOCATION_DIFFERENT;
|
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_KEEP;
|
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_KEEP;
|
||||||
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_OK;
|
import static fr.free.nrw.commons.utils.ImageUtils.IMAGE_OK;
|
||||||
|
|
||||||
|
|
@ -331,11 +326,8 @@ public class UploadMediaPresenter implements UserActionListener, SimilarImageInt
|
||||||
view.showDuplicatePicturePopup(uploadItem);
|
view.showDuplicatePicturePopup(uploadItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If image has some problems check if the bits are set in errorCode and
|
// If image has some other problems, show popup accordingly
|
||||||
// show popup accordingly
|
if (errorCode != EMPTY_CAPTION && errorCode != FILE_NAME_EXISTS) {
|
||||||
if (((errorCode & FILE_NO_EXIF) != 0) || ((errorCode & IMAGE_DARK) != 0) ||
|
|
||||||
((errorCode & FILE_FBMD) != 0) || ((errorCode & IMAGE_GEOLOCATION_DIFFERENT) != 0) ||
|
|
||||||
((errorCode & IMAGE_BLURRY) != 0)) {
|
|
||||||
view.showBadImagePopup(errorCode, uploadItem);
|
view.showBadImagePopup(errorCode, uploadItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,10 +154,9 @@ class UploadMediaPresenterTest {
|
||||||
uploadMediaPresenter.handleImageResult(EMPTY_CAPTION, uploadItem)
|
uploadMediaPresenter.handleImageResult(EMPTY_CAPTION, uploadItem)
|
||||||
verify(view).showMessage(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())
|
verify(view).showMessage(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())
|
||||||
|
|
||||||
//Bad Picture test
|
// Bad Picture Test
|
||||||
//Empty Caption test
|
|
||||||
uploadMediaPresenter.handleImageResult(-7, uploadItem)
|
uploadMediaPresenter.handleImageResult(-7, uploadItem)
|
||||||
// TODO https://github.com/commons-app/apps-android-commons/issues/5204 verify(view)?.showBadImagePopup(ArgumentMatchers.anyInt(), ArgumentMatchers.eq(uploadItem))
|
verify(view)?.showBadImagePopup(ArgumentMatchers.anyInt(), ArgumentMatchers.eq(uploadItem))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -229,7 +228,7 @@ class UploadMediaPresenterTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
fun handleBadImageBaseTestFileNameExists() {
|
fun handleBadImageBaseTestFileNameExists() {
|
||||||
uploadMediaPresenter.handleBadImage(-4, uploadItem)
|
uploadMediaPresenter.handleBadImage(64, uploadItem)
|
||||||
verify(view).showDuplicatePicturePopup(uploadItem)
|
verify(view).showDuplicatePicturePopup(uploadItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue