mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Convert upload to kotlin (part 1) (#6024)
* Convert upload dagger module to kotlin * Code cleanup and convert the upload contract to kotlin * Code cleanup and convert CategoriesContract to kotlin * Code cleanup and convert MediaLicenseContract to kotlin * Code cleanup and convert UploadMediaDetailsContract to kotlin * Code cleanup, fixed nullability and converted DepictsContract to kotlin * Removed unused class * Convert FileMetadataUtils to kotlin * Convert EXIFReader to kotlin * Convert FileUtils to kotlin * Convert FileUtilsWrapper to kotlin * Convert ImageProcessingService to kotlin * Convert PageContentsCreator to kotlin * Convert PendingUploadsPresenter and contract to Kotlin with some code-cleanup * Convert ReadFBMD to kotlin * Convert SimilarImageInterface to kotlin * Removed unused classes * Fix merge/rebase issue --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
cb007608d9
commit
2c8c441f25
55 changed files with 1595 additions and 1835 deletions
|
|
@ -5,7 +5,6 @@ import android.content.Intent
|
|||
import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.work.Configuration
|
||||
import androidx.work.testing.WorkManagerTestInitHelper
|
||||
import fr.free.nrw.commons.CommonsApplication
|
||||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
|
|
@ -75,7 +74,7 @@ class UploadActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testIsLoggedIn() {
|
||||
activity.isLoggedIn
|
||||
activity.isLoggedIn()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -139,7 +138,7 @@ class UploadActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testGetUploadableFiles() {
|
||||
activity.uploadableFiles
|
||||
activity.getUploadableFiles()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -8,14 +8,13 @@ import com.nhaarman.mockitokotlin2.anyOrNull
|
|||
import com.nhaarman.mockitokotlin2.argumentCaptor
|
||||
import com.nhaarman.mockitokotlin2.eq
|
||||
import com.nhaarman.mockitokotlin2.mock
|
||||
import com.nhaarman.mockitokotlin2.times
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import fr.free.nrw.commons.CommonsApplication.Companion.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.utils.TimeProvider
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwException
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwServiceError
|
||||
import io.reactivex.Observable
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class UploadPresenterTest {
|
|||
uploadPresenter.onAttachView(view)
|
||||
`when`(repository.buildContributions()).thenReturn(Observable.just(contribution))
|
||||
uploadableFiles.add(uploadableFile)
|
||||
`when`(view.uploadableFiles).thenReturn(uploadableFiles)
|
||||
`when`(view.getUploadableFiles()).thenReturn(uploadableFiles)
|
||||
`when`(uploadableFile.getFilePath()).thenReturn("data://test")
|
||||
}
|
||||
|
||||
|
|
@ -71,9 +71,9 @@ class UploadPresenterTest {
|
|||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitTestUserLoggedIn() {
|
||||
`when`(view.isLoggedIn).thenReturn(true)
|
||||
`when`(view.isLoggedIn()).thenReturn(true)
|
||||
uploadPresenter.handleSubmit()
|
||||
verify(view).isLoggedIn
|
||||
verify(view).isLoggedIn()
|
||||
verify(view).showProgress(true)
|
||||
verify(repository).buildContributions()
|
||||
verify(repository).buildContributions()
|
||||
|
|
@ -130,9 +130,9 @@ class UploadPresenterTest {
|
|||
false,
|
||||
),
|
||||
).thenReturn(true)
|
||||
`when`(view.isLoggedIn).thenReturn(true)
|
||||
`when`(view.isLoggedIn()).thenReturn(true)
|
||||
uploadPresenter.handleSubmit()
|
||||
verify(view).isLoggedIn
|
||||
verify(view).isLoggedIn()
|
||||
verify(view).showProgress(true)
|
||||
verify(repository).buildContributions()
|
||||
verify(repository).buildContributions()
|
||||
|
|
@ -144,9 +144,9 @@ class UploadPresenterTest {
|
|||
@Ignore
|
||||
@Test
|
||||
fun handleSubmitTestUserNotLoggedIn() {
|
||||
`when`(view.isLoggedIn).thenReturn(false)
|
||||
`when`(view.isLoggedIn()).thenReturn(false)
|
||||
uploadPresenter.handleSubmit()
|
||||
verify(view).isLoggedIn
|
||||
verify(view).isLoggedIn()
|
||||
verify(view).askUserToLogIn()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
|||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.nhaarman.mockitokotlin2.times
|
||||
import fr.free.nrw.commons.Media
|
||||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.R
|
||||
|
|
@ -184,14 +183,14 @@ class UploadCategoriesFragmentUnitTests {
|
|||
@Throws(Exception::class)
|
||||
fun testGetExistingCategories() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.existingCategories
|
||||
fragment.getExistingCategories()
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testGetFragmentContext() {
|
||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||
fragment.fragmentContext
|
||||
fragment.getFragmentContext()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ class DepictsFragmentUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testGetFragmentContext() {
|
||||
fragment.fragmentContext
|
||||
fragment.getFragmentContext()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue