mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Improve extremely inefficient darkness-checking logic. (#2639)
* Improve extremely inefficient darkness-checking logic. * Use ExifInterface from AndroidX instead of android.media. * Fix false-positive detekt check. * Fix false-positive detekt check.
This commit is contained in:
parent
bc9d83a47c
commit
adf23c257f
9 changed files with 38 additions and 100 deletions
|
|
@ -1,11 +1,9 @@
|
|||
package fr.free.nrw.commons.upload
|
||||
|
||||
import android.graphics.BitmapRegionDecoder
|
||||
import android.net.Uri
|
||||
import fr.free.nrw.commons.location.LatLng
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi
|
||||
import fr.free.nrw.commons.nearby.Place
|
||||
import fr.free.nrw.commons.utils.BitmapRegionDecoderWrapper
|
||||
import fr.free.nrw.commons.utils.ImageUtils
|
||||
import fr.free.nrw.commons.utils.ImageUtilsWrapper
|
||||
import io.reactivex.Single
|
||||
|
|
@ -23,8 +21,6 @@ class u {
|
|||
@Mock
|
||||
internal var fileUtilsWrapper: FileUtilsWrapper? = null
|
||||
@Mock
|
||||
internal var bitmapRegionDecoderWrapper: BitmapRegionDecoderWrapper? = null
|
||||
@Mock
|
||||
internal var imageUtilsWrapper: ImageUtilsWrapper? = null
|
||||
@Mock
|
||||
internal var mwApi: MediaWikiApi? = null
|
||||
|
|
@ -68,9 +64,7 @@ class u {
|
|||
`when`(fileUtilsWrapper!!.getGeolocationOfFile(ArgumentMatchers.anyString()))
|
||||
.thenReturn("latLng")
|
||||
|
||||
`when`(bitmapRegionDecoderWrapper!!.newInstance(any(FileInputStream::class.java), anyBoolean()))
|
||||
.thenReturn(mock(BitmapRegionDecoder::class.java))
|
||||
`when`(imageUtilsWrapper!!.checkIfImageIsTooDark(any(BitmapRegionDecoder::class.java)))
|
||||
`when`(imageUtilsWrapper?.checkIfImageIsTooDark(ArgumentMatchers.anyString()))
|
||||
.thenReturn(Single.just(ImageUtils.IMAGE_OK))
|
||||
|
||||
`when`(imageUtilsWrapper!!.checkImageGeolocationIsDifferent(ArgumentMatchers.anyString(), any(LatLng::class.java)))
|
||||
|
|
@ -113,7 +107,7 @@ class u {
|
|||
|
||||
@Test
|
||||
fun validateImageForDarkImage() {
|
||||
`when`(imageUtilsWrapper!!.checkIfImageIsTooDark(any(BitmapRegionDecoder::class.java)))
|
||||
`when`(imageUtilsWrapper?.checkIfImageIsTooDark(ArgumentMatchers.anyString()))
|
||||
.thenReturn(Single.just(ImageUtils.IMAGE_DARK))
|
||||
val validateImage = imageProcessingService!!.validateImage(uploadItem, false)
|
||||
assertEquals(ImageUtils.IMAGE_DARK, validateImage.blockingGet())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue