Handle null URI while uploading picture (#2262)

* Handle null URI while uploading picture

* Modify cache method to never return null path

* Fix tests
This commit is contained in:
Vivek Maskara 2019-01-04 13:51:55 +05:30 committed by Josephine Lim
parent e69c03cf83
commit e773a82206
6 changed files with 71 additions and 36 deletions

View file

@ -64,10 +64,8 @@ class UploadModelTest {
`when`(context!!.applicationContext)
.thenReturn(mock(Application::class.java))
`when`(fileUtilsWrapper!!.createCopyPathAndCopy(any(Uri::class.java), any(Context::class.java)))
`when`(fileUtilsWrapper!!.createCopyPathAndCopy(anyBoolean(), any(Uri::class.java), nullable(ContentResolver::class.java), any(Context::class.java)))
.thenReturn("file.jpg")
`when`(fileUtilsWrapper!!.createExternalCopyPathAndCopy(any(Uri::class.java), any(ContentResolver::class.java)))
.thenReturn("extFile.jpg")
`when`(fileUtilsWrapper!!.getFileExt(anyString()))
.thenReturn("jpg")
`when`(fileUtilsWrapper!!.getSHA1(any(InputStream::class.java)))
@ -111,7 +109,7 @@ class UploadModelTest {
fun verifyPreviousNotAvailableForDirectUpload() {
val element = mock(Uri::class.java)
uploadModel!!.receiveDirect(element, "image/jpeg", "external", "Q1", "Test", "Test", { _, _ -> }
, "")
, "")
assertFalse(uploadModel!!.isPreviousAvailable)
}