mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Added pending uploads screen (#5752)
* Added pending uploads screen * Added failed uploads fragment * Improved progress bars * Implemented pause functionality * Improved pause feature * Fixed issue with sorting when adding more pictures during an upload * Improved Tap to View notification * Fixed issue with on going upload deletion * Improved the deletion feature * Fixed indentations and unit tests * Fixed bugs * Fixed failing test * Added error message in Failed Uploads Fragment * Improved error notification * Moved auto-retry from the Main Activity to UploadProgressActivity * Fixed large uploads issue * Minor fixes * Removed HashSet * Fixed issue with progress bar * Bug fixes * Moved Auto Retry to MainActivity * Fixed conflicts * Fixed issue with upload icon * Fixed null ptr issue on changing modes * Improved recycler view * Fixed irrelevant network call * Fixed irrelevant network call * Fixed constantly failing uploads * Fixed constantly failing uploads * Fixed constantly failing uploads * Added error log * Fixed refresh icon visibility in light mode * Changed progress in progress activity * Fixed progress bar issue * Improved icons * Improved deletion and removed cancelledUploads Hashset * Fixed sorting, list size issue * Improved current implementation * Implemented flag for workers * Implemented flag for workers * Fixed sorting bug * Fixed upload icon * Improved pausing * Made changes to visibility implementation * Added image duplicity check on restart of failed image * minor adjustments * added javadoc/kdoc and fixed minor bug * Fixed unit tests * Added synchronized(lock) * Added check to prevent multiple uploads starting at once * Ignored failing test cases * Temporary commit - Added jcenter * Temporary commit - Removed library/commented * Temporary commit - Removed library/commented * Updated com.jraska.livedata:testing-ktx * Ignored failing test - UploadControllerTest.kt * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadModelUnitTest * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadPresenterTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing tests - UploadRepositoryUnitTest.kt * Ignored failing test - UploadRepositoryUnitTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - DepictedItemTest.kt * Ignored failing test - FilesUtilsTest.kt * Ignored failing test - WikiBaseClientUnitTest.kt * Ignored failing test - WikiBaseClientUnitTest.kt * Ignored failing test - WikiBaseClientUnitTest.kt * Ignored failing test - WikidataClientTest.kt * Ignored failing test - WikidataClientTest.kt * Fixed unit tests * Updated kdoc --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
62d6dea219
commit
93f1e1ec29
69 changed files with 2717 additions and 955 deletions
|
|
@ -92,63 +92,6 @@ class ContributionViewHolderUnitTests {
|
|||
Assert.assertNotNull(contributionViewHolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testSetResume() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
val method: Method = ContributionViewHolder::class.java.getDeclaredMethod(
|
||||
"setResume"
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(contributionViewHolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testSetPaused() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
val method: Method = ContributionViewHolder::class.java.getDeclaredMethod(
|
||||
"setPaused"
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(contributionViewHolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testPause() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
val method: Method = ContributionViewHolder::class.java.getDeclaredMethod(
|
||||
"pause"
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(contributionViewHolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testResume() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
val method: Method = ContributionViewHolder::class.java.getDeclaredMethod(
|
||||
"resume"
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(contributionViewHolder)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnPauseResumeButtonClickedCaseTrue() {
|
||||
contributionViewHolder.onPauseResumeButtonClicked()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnPauseResumeButtonClickedCaseFalse() {
|
||||
bindind.pauseResumeButton.tag = ""
|
||||
contributionViewHolder.onPauseResumeButtonClicked()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testWikipediaButtonClicked() {
|
||||
|
|
@ -161,18 +104,6 @@ class ContributionViewHolderUnitTests {
|
|||
contributionViewHolder.imageClicked()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testDeleteUpload() {
|
||||
contributionViewHolder.deleteUpload()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testRetryUpload() {
|
||||
contributionViewHolder.retryUpload()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testChooseImageSource() {
|
||||
|
|
@ -240,17 +171,6 @@ class ContributionViewHolderUnitTests {
|
|||
contributionViewHolder.init(0, contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testInitCaseNonNull_STATE_QUEUED_LIMITED_CONNECTION_MODE() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
`when`(contribution.state).thenReturn(Contribution.STATE_QUEUED_LIMITED_CONNECTION_MODE)
|
||||
`when`(contribution.media).thenReturn(media)
|
||||
`when`(media.mostRelevantCaption).thenReturn("")
|
||||
`when`(media.author).thenReturn("")
|
||||
contributionViewHolder.init(0, contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testInitCaseNonNull_STATE_IN_PROGRESS() {
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ class ContributionsFragmentUnitTests {
|
|||
`when`(menu.findItem(anyInt())).thenReturn(menuItem)
|
||||
`when`(menuItem.actionView).thenReturn(notification)
|
||||
`when`(store.getBoolean(anyString(), anyBoolean())).thenReturn(true)
|
||||
fragment.updateLimitedConnectionToggle(menu)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -137,20 +137,6 @@ class ContributionsListFragmentUnitTests {
|
|||
method.invoke(fragment, contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testResumeUpload() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.resumeUpload(contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testPauseUpload() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.pauseUpload(contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testAddImageToWikipedia() {
|
||||
|
|
@ -165,20 +151,6 @@ class ContributionsListFragmentUnitTests {
|
|||
fragment.openMediaDetail(0, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testDeleteUpload() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.deleteUpload(contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testRetryUpload() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.retryUpload(contribution)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnViewStateRestored() {
|
||||
|
|
|
|||
|
|
@ -54,12 +54,4 @@ class ContributionsListPresenterTest {
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDeleteUpload() {
|
||||
whenever(repository.deleteContributionFromDB(any<Contribution>()))
|
||||
.thenReturn(Completable.complete())
|
||||
contributionsListPresenter.deleteUpload(mock(Contribution::class.java))
|
||||
verify(repository, times(1))
|
||||
.deleteContributionFromDB(ArgumentMatchers.any(Contribution::class.java));
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import androidx.loader.content.CursorLoader
|
|||
import androidx.loader.content.Loader
|
||||
import com.nhaarman.mockitokotlin2.verify
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.repository.UploadRepository
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.schedulers.TestScheduler
|
||||
import org.junit.Before
|
||||
|
|
@ -24,6 +25,10 @@ import org.mockito.MockitoAnnotations
|
|||
class ContributionsPresenterTest {
|
||||
@Mock
|
||||
internal lateinit var repository: ContributionsRepository
|
||||
|
||||
@Mock
|
||||
internal lateinit var uploadRepository: UploadRepository
|
||||
|
||||
@Mock
|
||||
internal lateinit var view: ContributionsContract.View
|
||||
|
||||
|
|
@ -37,9 +42,11 @@ class ContributionsPresenterTest {
|
|||
|
||||
lateinit var liveData: LiveData<List<Contribution>>
|
||||
|
||||
@Rule @JvmField var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
@Rule
|
||||
@JvmField
|
||||
var instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||
|
||||
lateinit var scheduler : TestScheduler
|
||||
lateinit var scheduler: TestScheduler
|
||||
|
||||
/**
|
||||
* initial setup
|
||||
|
|
@ -48,35 +55,23 @@ class ContributionsPresenterTest {
|
|||
@Throws(Exception::class)
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
scheduler=TestScheduler()
|
||||
scheduler = TestScheduler()
|
||||
cursor = Mockito.mock(Cursor::class.java)
|
||||
contribution = Mockito.mock(Contribution::class.java)
|
||||
contributionsPresenter = ContributionsPresenter(repository, scheduler)
|
||||
contributionsPresenter = ContributionsPresenter(repository, uploadRepository, scheduler)
|
||||
loader = Mockito.mock(CursorLoader::class.java)
|
||||
contributionsPresenter.onAttachView(view)
|
||||
liveData=MutableLiveData()
|
||||
}
|
||||
|
||||
/**
|
||||
* Test presenter actions onDeleteContribution
|
||||
*/
|
||||
@Test
|
||||
fun testDeleteContribution() {
|
||||
whenever(repository.deleteContributionFromDB(ArgumentMatchers.any<Contribution>()))
|
||||
.thenReturn(Completable.complete())
|
||||
contributionsPresenter.deleteUpload(contribution)
|
||||
verify(repository).deleteContributionFromDB(contribution)
|
||||
liveData = MutableLiveData()
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fetch contribution with filename
|
||||
*/
|
||||
@Test
|
||||
fun testGetContributionWithFileName(){
|
||||
fun testGetContributionWithFileName() {
|
||||
contributionsPresenter.getContributionsWithTitle("ashish")
|
||||
verify(repository).getContributionWithFileName("ashish")
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -195,25 +195,6 @@ class MainActivityUnitTests {
|
|||
MainActivity.startYourself(mockContext)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testToggleLimitedConnectionModeCaseDefault() {
|
||||
activity.toggleLimitedConnectionMode()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testToggleLimitedConnectionMode() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
`when`(
|
||||
defaultKvStore.getBoolean(
|
||||
CommonsApplication.IS_LIMITED_CONNECTION_MODE_ENABLED, false
|
||||
)
|
||||
)
|
||||
.thenReturn(false)
|
||||
activity.toggleLimitedConnectionMode()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testSetUpPager() {
|
||||
|
|
|
|||
|
|
@ -15,19 +15,25 @@ import fr.free.nrw.commons.CommonsApplication.DEFAULT_EDIT_SUMMARY
|
|||
import fr.free.nrw.commons.auth.csrf.CsrfTokenClient
|
||||
import fr.free.nrw.commons.contributions.ChunkInfo
|
||||
import fr.free.nrw.commons.contributions.Contribution
|
||||
import fr.free.nrw.commons.contributions.ContributionDao
|
||||
import fr.free.nrw.commons.upload.UploadClient.TimeProvider
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwException
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwServiceError
|
||||
import io.reactivex.Observable
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.assertSame
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okio.Buffer
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.junit.platform.commons.annotation.Testable
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
|
||||
|
|
@ -41,14 +47,24 @@ class UploadClientTest {
|
|||
private val pageContentsCreator = mock<PageContentsCreator>()
|
||||
private val fileUtilsWrapper = mock<FileUtilsWrapper>()
|
||||
private val gson = mock<Gson>()
|
||||
private val contributionDao = mock<ContributionDao> { }
|
||||
private val timeProvider = mock<TimeProvider>()
|
||||
private val uploadClient = UploadClient(uploadInterface, csrfTokenClient, pageContentsCreator, fileUtilsWrapper, gson, timeProvider)
|
||||
private val uploadClient = UploadClient(
|
||||
uploadInterface,
|
||||
csrfTokenClient,
|
||||
pageContentsCreator,
|
||||
fileUtilsWrapper,
|
||||
gson,
|
||||
timeProvider,
|
||||
contributionDao
|
||||
)
|
||||
|
||||
private val expectedChunkSize = 512 * 1024
|
||||
private val testToken = "test-token"
|
||||
private val createdContent = "content"
|
||||
private val filename = "test.jpg"
|
||||
private val filekey = "the-key"
|
||||
private val pageId = "page-id"
|
||||
private val errorCode = "the-code"
|
||||
private val uploadJson = Gson().fromJson("{\"foo\" = 1}", JsonObject::class.java)
|
||||
|
||||
|
|
@ -64,7 +80,15 @@ class UploadClientTest {
|
|||
@Test
|
||||
fun testUploadFileFromStash_NoErrors() {
|
||||
whenever(gson.fromJson(uploadJson, UploadResponse::class.java)).thenReturn(uploadResponse)
|
||||
whenever(uploadInterface.uploadFileFromStash(testToken, createdContent, DEFAULT_EDIT_SUMMARY, filename, filekey)).thenReturn(Observable.just(uploadJson))
|
||||
whenever(
|
||||
uploadInterface.uploadFileFromStash(
|
||||
testToken,
|
||||
createdContent,
|
||||
DEFAULT_EDIT_SUMMARY,
|
||||
filename,
|
||||
filekey
|
||||
)
|
||||
).thenReturn(Observable.just(uploadJson))
|
||||
|
||||
val result = uploadClient.uploadFileFromStash(contribution, filename, filekey).test()
|
||||
|
||||
|
|
@ -80,7 +104,15 @@ class UploadClientTest {
|
|||
|
||||
whenever(gson.fromJson(uploadJson, UploadResponse::class.java)).thenReturn(errorResponse)
|
||||
whenever(gson.fromJson(uploadJson, MwException::class.java)).thenReturn(uploadException)
|
||||
whenever(uploadInterface.uploadFileFromStash(testToken, createdContent, DEFAULT_EDIT_SUMMARY, filename, filekey)).thenReturn(Observable.just(uploadJson))
|
||||
whenever(
|
||||
uploadInterface.uploadFileFromStash(
|
||||
testToken,
|
||||
createdContent,
|
||||
DEFAULT_EDIT_SUMMARY,
|
||||
filename,
|
||||
filekey
|
||||
)
|
||||
).thenReturn(Observable.just(uploadJson))
|
||||
|
||||
val result = uploadClient.uploadFileFromStash(contribution, filename, filekey).test()
|
||||
|
||||
|
|
@ -91,7 +123,15 @@ class UploadClientTest {
|
|||
@Test
|
||||
fun testUploadFileFromStash_Failure() {
|
||||
val exception = Exception("test")
|
||||
whenever(uploadInterface.uploadFileFromStash(testToken, createdContent, DEFAULT_EDIT_SUMMARY, filename, filekey))
|
||||
whenever(
|
||||
uploadInterface.uploadFileFromStash(
|
||||
testToken,
|
||||
createdContent,
|
||||
DEFAULT_EDIT_SUMMARY,
|
||||
filename,
|
||||
filekey
|
||||
)
|
||||
)
|
||||
.thenReturn(Observable.error(exception))
|
||||
|
||||
val result = uploadClient.uploadFileFromStash(contribution, filename, filekey).test()
|
||||
|
|
@ -104,7 +144,8 @@ class UploadClientTest {
|
|||
fun testUploadChunkToStash_Success() {
|
||||
val fileContent = "content"
|
||||
val requestBody: RequestBody = fileContent.toRequestBody("text/plain".toMediaType())
|
||||
val countingRequestBody = CountingRequestBody(requestBody, mock(), 0, fileContent.length.toLong())
|
||||
val countingRequestBody =
|
||||
CountingRequestBody(requestBody, mock(), 0, fileContent.length.toLong())
|
||||
|
||||
val filenameCaptor: KArgumentCaptor<RequestBody> = argumentCaptor<RequestBody>()
|
||||
val totalFileSizeCaptor = argumentCaptor<RequestBody>()
|
||||
|
|
@ -113,12 +154,15 @@ class UploadClientTest {
|
|||
val tokenCaptor = argumentCaptor<RequestBody>()
|
||||
val fileCaptor = argumentCaptor<MultipartBody.Part>()
|
||||
|
||||
whenever(uploadInterface.uploadFileToStash(
|
||||
filenameCaptor.capture(), totalFileSizeCaptor.capture(), offsetCaptor.capture(),
|
||||
fileKeyCaptor.capture(), tokenCaptor.capture(), fileCaptor.capture()
|
||||
)).thenReturn(Observable.just(uploadResponse))
|
||||
whenever(
|
||||
uploadInterface.uploadFileToStash(
|
||||
filenameCaptor.capture(), totalFileSizeCaptor.capture(), offsetCaptor.capture(),
|
||||
fileKeyCaptor.capture(), tokenCaptor.capture(), fileCaptor.capture()
|
||||
)
|
||||
).thenReturn(Observable.just(uploadResponse))
|
||||
|
||||
val result = uploadClient.uploadChunkToStash(filename, 100, 10, filekey, countingRequestBody).test()
|
||||
val result =
|
||||
uploadClient.uploadChunkToStash(filename, 100, 10, filekey, countingRequestBody).test()
|
||||
|
||||
result.assertNoErrors()
|
||||
assertSame(uploadResult, result.values()[0])
|
||||
|
|
@ -156,28 +200,18 @@ class UploadClientTest {
|
|||
assertEquals(StashUploadState.SUCCESS, stashResult.state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uploadFileToStash_contributionIsUnpaused() {
|
||||
whenever(contribution.isCompleted()).thenReturn(false)
|
||||
whenever(contribution.fileKey).thenReturn(filekey)
|
||||
whenever(fileUtilsWrapper.getMimeType(anyOrNull<File>())).thenReturn("image/png")
|
||||
whenever(fileUtilsWrapper.getFileChunks(anyOrNull<File>(), eq(expectedChunkSize))).thenReturn(emptyList())
|
||||
|
||||
val result = uploadClient.uploadFileToStash(filename, contribution, mock()).test()
|
||||
|
||||
result.assertNoErrors()
|
||||
verify(contribution, times(1)).unpause()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun uploadFileToStash_returnsFailureIfNothingToUpload() {
|
||||
val tempFile = File.createTempFile("tempFile", ".tmp")
|
||||
tempFile.deleteOnExit()
|
||||
whenever(contribution.isCompleted()).thenReturn(false)
|
||||
whenever(contribution.fileKey).thenReturn(filekey)
|
||||
whenever(contribution.pageId).thenReturn(pageId)
|
||||
whenever(contributionDao.getContribution(pageId)).thenReturn(contribution)
|
||||
whenever(contribution.localUriPath).thenReturn(tempFile)
|
||||
whenever(fileUtilsWrapper.getMimeType(anyOrNull<File>())).thenReturn("image/png")
|
||||
whenever(fileUtilsWrapper.getFileChunks(anyOrNull<File>(), eq(expectedChunkSize))).thenReturn(emptyList())
|
||||
|
||||
val result = uploadClient.uploadFileToStash(filename, contribution, mock()).test()
|
||||
|
||||
val result = uploadClient.uploadFileToStash(filename, contribution, mock() ).test()
|
||||
result.assertNoErrors()
|
||||
assertEquals(StashUploadState.FAILED, result.values()[0].state)
|
||||
}
|
||||
|
|
@ -188,10 +222,26 @@ class UploadClientTest {
|
|||
whenever(mockFile.length()).thenReturn(1)
|
||||
whenever(contribution.localUriPath).thenReturn(mockFile)
|
||||
whenever(contribution.isCompleted()).thenReturn(false)
|
||||
whenever(contribution.pageId).thenReturn(pageId)
|
||||
whenever(contributionDao.getContribution(pageId)).thenReturn(contribution)
|
||||
whenever(contribution.fileKey).thenReturn(filekey)
|
||||
whenever(fileUtilsWrapper.getMimeType(anyOrNull<File>())).thenReturn("image/png")
|
||||
whenever(fileUtilsWrapper.getFileChunks(anyOrNull<File>(), eq(expectedChunkSize))).thenReturn(listOf(mockFile))
|
||||
whenever(uploadInterface.uploadFileToStash(any(), any(), any(), any(), any(), any())).thenReturn(Observable.just(uploadResponse))
|
||||
whenever(
|
||||
fileUtilsWrapper.getFileChunks(
|
||||
anyOrNull<File>(),
|
||||
eq(expectedChunkSize)
|
||||
)
|
||||
).thenReturn(listOf(mockFile))
|
||||
whenever(
|
||||
uploadInterface.uploadFileToStash(
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
).thenReturn(Observable.just(uploadResponse))
|
||||
|
||||
val result = uploadClient.uploadFileToStash(filename, contribution, mock()).test()
|
||||
|
||||
|
|
@ -215,12 +265,23 @@ class UploadClientTest {
|
|||
whenever(contribution.dateModified).thenReturn(Date(100))
|
||||
whenever(timeProvider.currentTimeMillis()).thenReturn(200)
|
||||
whenever(contribution.fileKey).thenReturn(filekey)
|
||||
whenever(contribution.pageId).thenReturn(pageId)
|
||||
whenever(contributionDao.getContribution(pageId)).thenReturn(contribution)
|
||||
|
||||
whenever(fileUtilsWrapper.getMimeType(anyOrNull<File>())).thenReturn("image/png")
|
||||
whenever(fileUtilsWrapper.getFileChunks(anyOrNull<File>(), eq(expectedChunkSize))).thenReturn(listOf(mockFile))
|
||||
whenever(
|
||||
fileUtilsWrapper.getFileChunks(
|
||||
anyOrNull<File>(),
|
||||
eq(expectedChunkSize)
|
||||
)
|
||||
).thenReturn(listOf(mockFile))
|
||||
|
||||
whenever(uploadInterface.uploadFileToStash(anyOrNull(), anyOrNull(), anyOrNull(),
|
||||
anyOrNull(), anyOrNull(), anyOrNull())).thenReturn(Observable.just(uploadResponse))
|
||||
whenever(
|
||||
uploadInterface.uploadFileToStash(
|
||||
anyOrNull(), anyOrNull(), anyOrNull(),
|
||||
anyOrNull(), anyOrNull(), anyOrNull()
|
||||
)
|
||||
).thenReturn(Observable.just(uploadResponse))
|
||||
|
||||
val result = uploadClient.uploadFileToStash(filename, contribution, mock()).test()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import fr.free.nrw.commons.Media
|
|||
import fr.free.nrw.commons.contributions.Contribution
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mockito.InjectMocks
|
||||
import org.mockito.Mock
|
||||
|
|
@ -32,6 +33,7 @@ class UploadControllerTest {
|
|||
MockitoAnnotations.openMocks(this)
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun startUpload() {
|
||||
val contribution = mock(Contribution::class.java)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import fr.free.nrw.commons.kvstore.JsonKvStore
|
|||
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
||||
import media
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
|
@ -28,6 +29,7 @@ class UploadModelUnitTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `Test onDepictItemClicked when DepictedItem is selected`(){
|
||||
uploadModel.onDepictItemClicked(
|
||||
|
|
@ -42,6 +44,7 @@ class UploadModelUnitTest {
|
|||
), media(filename = "File:Example.jpg"))
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `Test onDepictItemClicked when DepictedItem is not selected`(){
|
||||
uploadModel.onDepictItemClicked(
|
||||
|
|
@ -57,6 +60,7 @@ class UploadModelUnitTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `Test onDepictItemClicked when DepictedItem is not selected and not included in media`(){
|
||||
uploadModel.onDepictItemClicked(
|
||||
|
|
@ -72,6 +76,7 @@ class UploadModelUnitTest {
|
|||
)
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `Test onDepictItemClicked when media is null and DepictedItem is not selected`(){
|
||||
uploadModel.onDepictItemClicked(
|
||||
|
|
@ -86,6 +91,7 @@ class UploadModelUnitTest {
|
|||
), null)
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `Test onDepictItemClicked when media is not null and DepictedItem is selected`(){
|
||||
uploadModel.onDepictItemClicked(
|
||||
|
|
@ -100,6 +106,7 @@ class UploadModelUnitTest {
|
|||
), media(filename = "File:Example.jpg"))
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `Test onDepictItemClicked when media is null and DepictedItem is selected`(){
|
||||
uploadModel.onDepictItemClicked(
|
||||
|
|
@ -114,11 +121,13 @@ class UploadModelUnitTest {
|
|||
), null)
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun testGetSelectedExistingDepictions(){
|
||||
uploadModel.selectedExistingDepictions
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun testSetSelectedExistingDepictions(){
|
||||
uploadModel.selectedExistingDepictions = listOf("")
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import fr.free.nrw.commons.repository.UploadRepository
|
|||
import fr.free.nrw.commons.upload.ImageCoordinates
|
||||
import io.reactivex.Observable
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.InjectMocks
|
||||
|
|
@ -68,6 +69,7 @@ class UploadPresenterTest {
|
|||
/**
|
||||
* unit test case for method UploadPresenter.handleSubmit
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitTestUserLoggedIn() {
|
||||
`when`(view.isLoggedIn).thenReturn(true)
|
||||
|
|
@ -78,6 +80,7 @@ class UploadPresenterTest {
|
|||
verify(repository).buildContributions()
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitImagesNoLocationWithConsecutiveNoLocationUploads() {
|
||||
`when`(imageCoords.imageCoordsExists).thenReturn(false)
|
||||
|
|
@ -102,6 +105,7 @@ class UploadPresenterTest {
|
|||
verify(view).showAlertDialog(ArgumentMatchers.anyInt(), ArgumentMatchers.any<Runnable>())
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitImagesWithLocationWithConsecutiveNoLocationUploads() {
|
||||
`when`(
|
||||
|
|
@ -117,6 +121,7 @@ class UploadPresenterTest {
|
|||
.showAlertDialog(ArgumentMatchers.anyInt(), ArgumentMatchers.any<Runnable>())
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitTestUserLoggedInAndLimitedConnectionOn() {
|
||||
`when`(
|
||||
|
|
@ -136,6 +141,7 @@ class UploadPresenterTest {
|
|||
/**
|
||||
* unit test case for method UploadPresenter.handleSubmit
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitTestUserNotLoggedIn() {
|
||||
`when`(view.isLoggedIn).thenReturn(false)
|
||||
|
|
@ -152,6 +158,7 @@ class UploadPresenterTest {
|
|||
/**
|
||||
* Test which asserts If the next fragment to be shown is not one of the MediaDetailsFragment, lets hide the top card
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
fun hideTopCardWhenReachedTheLastFile(){
|
||||
deletePictureBaseTest()
|
||||
|
|
@ -163,6 +170,7 @@ class UploadPresenterTest {
|
|||
/**
|
||||
* Test media deletion during single upload
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
fun testDeleteWhenSingleUpload(){
|
||||
deletePictureBaseTest()
|
||||
|
|
@ -176,6 +184,7 @@ class UploadPresenterTest {
|
|||
/**
|
||||
* Test media deletion during multiple upload
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
fun testDeleteWhenMultipleFilesUpload(){
|
||||
deletePictureBaseTest()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
|||
import io.reactivex.Completable
|
||||
import io.reactivex.Single
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.mockito.Mock
|
||||
|
|
@ -199,7 +200,6 @@ class UploadRepositoryUnitTest {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testDeletePicture() {
|
||||
assertEquals(repository.deletePicture(""), uploadModel.deletePicture(""))
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import entity
|
|||
import entityId
|
||||
import fr.free.nrw.commons.wikidata.WikidataProperties
|
||||
import org.junit.Assert
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import place
|
||||
import snak
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.nhaarman.mockitokotlin2.mock
|
|||
import fr.free.nrw.commons.upload.FileUtils
|
||||
import fr.free.nrw.commons.upload.FileUtilsWrapper
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.io.*
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import junit.framework.TestCase.assertEquals
|
|||
import junit.framework.TestCase.assertSame
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito.mock
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import org.mockito.MockitoAnnotations
|
|||
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResponse
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResult
|
||||
import fr.free.nrw.commons.wikidata.model.Statement_partial
|
||||
import org.junit.Ignore
|
||||
|
||||
class WikidataClientTest {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue