mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Custom picker: Show differently pictures that are currently being uploaded (#5618)
* Custom picker: Show differently pictures that are currently being uploaded * fix tests * fix test * fix crash * handle all cases * handle all cases * fix * Hide Images When showAlreadyActioned is disabled * Fix Tests * cleanup
This commit is contained in:
parent
72cdb5d0dd
commit
2d333a2af0
9 changed files with 129 additions and 39 deletions
|
|
@ -128,8 +128,8 @@ class ImageAdapterTest {
|
|||
fun processThumbnailForActionedImage() = runBlocking {
|
||||
Whitebox.setInternalState(imageAdapter, "allImages", listOf(image))
|
||||
whenever(imageLoader.nextActionableImage(listOf(image), Dispatchers.IO, Dispatchers.Default,
|
||||
0)).thenReturn(0)
|
||||
imageAdapter.processThumbnailForActionedImage(holder, 0)
|
||||
0, emptyList())).thenReturn(0)
|
||||
imageAdapter.processThumbnailForActionedImage(holder, 0, emptyList())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,8 +138,8 @@ class ImageAdapterTest {
|
|||
@Test
|
||||
fun `processThumbnailForActionedImage when reached end of the folder`() = runBlocking {
|
||||
whenever(imageLoader.nextActionableImage(ArrayList(), Dispatchers.IO, Dispatchers.Default,
|
||||
0)).thenReturn(-1)
|
||||
imageAdapter.processThumbnailForActionedImage(holder, 0)
|
||||
0, emptyList())).thenReturn(-1)
|
||||
imageAdapter.processThumbnailForActionedImage(holder, 0, emptyList())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -243,4 +243,4 @@ class ImageAdapterTest {
|
|||
imageAdapter.init(listOf(image), listOf(image), TreeMap())
|
||||
Assertions.assertEquals(1, imageAdapter.getImageIdAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.contributions.ContributionDao
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import fr.free.nrw.commons.customselector.model.Image
|
||||
import fr.free.nrw.commons.customselector.ui.adapter.ImageAdapter
|
||||
|
|
@ -13,6 +14,7 @@ import org.junit.Test
|
|||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertNotNull
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.powermock.reflect.Whitebox
|
||||
|
|
@ -39,6 +41,9 @@ class CustomSelectorActivityTest {
|
|||
|
||||
private lateinit var image: Image
|
||||
|
||||
@Mock
|
||||
lateinit var contributionDao: ContributionDao
|
||||
|
||||
/**
|
||||
* Set up the tests.
|
||||
*/
|
||||
|
|
@ -58,6 +63,7 @@ class CustomSelectorActivityTest {
|
|||
|
||||
Whitebox.setInternalState(activity, "imageFragment", imageFragment)
|
||||
Whitebox.setInternalState(imageFragment, "imageAdapter", Mockito.mock(ImageAdapter::class.java))
|
||||
Whitebox.setInternalState(imageFragment,"contributionDao",contributionDao)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -276,4 +282,4 @@ class CustomSelectorActivityTest {
|
|||
assertEquals(false, overLimit.getBoolean(activity))
|
||||
assertEquals(0, exceededBy.getInt(activity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.nhaarman.mockitokotlin2.whenever
|
|||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.contributions.ContributionDao
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import fr.free.nrw.commons.customselector.model.CallbackStatus
|
||||
import fr.free.nrw.commons.customselector.model.Image
|
||||
|
|
@ -67,6 +68,9 @@ class ImageFragmentTest {
|
|||
@Mock
|
||||
private lateinit var savedInstanceState: Bundle
|
||||
|
||||
@Mock
|
||||
lateinit var contributionDao: ContributionDao
|
||||
|
||||
/**
|
||||
* Setup the image fragment.
|
||||
*/
|
||||
|
|
@ -94,6 +98,7 @@ class ImageFragmentTest {
|
|||
Whitebox.setInternalState(fragment, "selectorRV", selectorRV )
|
||||
Whitebox.setInternalState(fragment, "loader", loader)
|
||||
Whitebox.setInternalState(fragment, "filteredImages", arrayListOf(image,image))
|
||||
Whitebox.setInternalState(fragment, "contributionDao", contributionDao)
|
||||
|
||||
viewModelField = fragment.javaClass.getDeclaredField("viewModel")
|
||||
viewModelField.isAccessible = true
|
||||
|
|
@ -180,4 +185,4 @@ class ImageFragmentTest {
|
|||
func.invoke(fragment)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,10 +159,10 @@ class ImageLoaderTest {
|
|||
.thenReturn(Mockito.mock(SharedPreferences::class.java))
|
||||
|
||||
mapResult["testSha1"] = ImageLoader.Result.TRUE
|
||||
imageLoader.queryAndSetView(holder, image, testDispacher, testDispacher)
|
||||
imageLoader.queryAndSetView(holder, image, testDispacher, testDispacher, ArrayList())
|
||||
|
||||
mapResult["testSha1"] = ImageLoader.Result.FALSE
|
||||
imageLoader.queryAndSetView(holder, image, testDispacher, testDispacher)
|
||||
imageLoader.queryAndSetView(holder, image, testDispacher, testDispacher, ArrayList())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,7 +174,7 @@ class ImageLoaderTest {
|
|||
whenever(notForUploadStatusDao.find(any())).thenReturn(0)
|
||||
whenever(context.getSharedPreferences("custom_selector", 0))
|
||||
.thenReturn(Mockito.mock(SharedPreferences::class.java))
|
||||
imageLoader.queryAndSetView(holder, image, testDispacher, testDispacher)
|
||||
imageLoader.queryAndSetView(holder, image, testDispacher, testDispacher, ArrayList())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -193,16 +193,16 @@ class ImageLoaderTest {
|
|||
whenever(PickedFiles.pickedExistingPicture(context, Uri.parse("test"))).thenReturn(
|
||||
uploadableFile
|
||||
)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0, emptyList())
|
||||
|
||||
whenever(notForUploadStatusDao.find(any())).thenReturn(1)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0, emptyList())
|
||||
|
||||
whenever(uploadedStatusDao.findByImageSHA1(any(), any())).thenReturn(2)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0, emptyList())
|
||||
|
||||
whenever(uploadedStatusDao.findByModifiedImageSHA1(any(), any())).thenReturn(2)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0)
|
||||
imageLoader.nextActionableImage(listOf(image), testDispacher, testDispacher, 0, emptyList())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -249,4 +249,4 @@ class ImageLoaderTest {
|
|||
imageLoader.getResultFromUploadedStatus(uploadedStatus))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue