mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Update Test Dependency version (#4405)
* Update Version and Unit Test * fix failing tests * update robolectric
This commit is contained in:
parent
117a7805ad
commit
2f4c30416d
18 changed files with 122 additions and 82 deletions
|
|
@ -79,18 +79,15 @@ dependencies {
|
||||||
//Mocking
|
//Mocking
|
||||||
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
|
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
|
||||||
testImplementation 'org.mockito:mockito-inline:2.13.0'
|
testImplementation 'org.mockito:mockito-inline:2.13.0'
|
||||||
testImplementation 'org.mockito:mockito-core:2.23.0'
|
testImplementation 'org.mockito:mockito-core:2.25.1'
|
||||||
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
|
testImplementation "org.powermock:powermock-module-junit4:2.0.2"
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"
|
testImplementation "org.powermock:powermock-api-mockito2:2.0.2"
|
||||||
|
|
||||||
// Unit testing
|
// Unit testing
|
||||||
testImplementation 'junit:junit:4.13.1'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.robolectric:robolectric:4.3'
|
testImplementation 'org.robolectric:robolectric:4.5.1'
|
||||||
testImplementation 'androidx.test:core:1.3.0'
|
testImplementation 'androidx.test:core:1.3.0'
|
||||||
testImplementation "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION"
|
testImplementation "com.squareup.okhttp3:mockwebserver:$OKHTTP_VERSION"
|
||||||
testImplementation "org.powermock:powermock-module-junit4:2.0.0-beta.5"
|
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:2.0.0-beta.5"
|
|
||||||
testImplementation 'org.mockito:mockito-core:2.23.0'
|
|
||||||
testImplementation "com.jraska.livedata:testing-ktx:1.1.2"
|
testImplementation "com.jraska.livedata:testing-ktx:1.1.2"
|
||||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.bookmarks.pictures
|
||||||
import android.content.ContentProviderClient
|
import android.content.ContentProviderClient
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Looper.getMainLooper
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.GridView
|
import android.widget.GridView
|
||||||
|
|
@ -28,13 +29,16 @@ import org.powermock.reflect.Whitebox
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.Shadows.shadowOf
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.annotation.LooperMode
|
||||||
import org.wikipedia.AppAdapter
|
import org.wikipedia.AppAdapter
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||||
|
@LooperMode(LooperMode.Mode.PAUSED)
|
||||||
class BookmarkPicturesFragmentUnitTests {
|
class BookmarkPicturesFragmentUnitTests {
|
||||||
|
|
||||||
private lateinit var fragment: BookmarkPicturesFragment
|
private lateinit var fragment: BookmarkPicturesFragment
|
||||||
|
|
@ -134,6 +138,7 @@ class BookmarkPicturesFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testSetAdapter() {
|
fun testSetAdapter() {
|
||||||
|
shadowOf(getMainLooper()).idle()
|
||||||
val method: Method =
|
val method: Method =
|
||||||
BookmarkPicturesFragment::class.java.getDeclaredMethod("setAdapter", List::class.java)
|
BookmarkPicturesFragment::class.java.getDeclaredMethod("setAdapter", List::class.java)
|
||||||
method.isAccessible = true
|
method.isAccessible = true
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import fr.free.nrw.commons.explore.paging.LoadingState
|
||||||
import fr.free.nrw.commons.explore.paging.PagingDataSource
|
import fr.free.nrw.commons.explore.paging.PagingDataSource
|
||||||
import fr.free.nrw.commons.explore.paging.PagingDataSourceFactory
|
import fr.free.nrw.commons.explore.paging.PagingDataSourceFactory
|
||||||
import io.reactivex.processors.PublishProcessor
|
import io.reactivex.processors.PublishProcessor
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.CoreMatchers.instanceOf
|
||||||
import org.hamcrest.Matchers.instanceOf
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Ignore
|
import org.junit.Ignore
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -38,7 +38,7 @@ class PagingDataSourceFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `create returns a dataSource`() {
|
fun `create returns a dataSource`() {
|
||||||
assertThat(
|
Assert.assertThat(
|
||||||
factory.create(),
|
factory.create(),
|
||||||
instanceOf(PagingDataSource::class.java)
|
instanceOf(PagingDataSource::class.java)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package fr.free.nrw.commons.explore.categroies
|
package fr.free.nrw.commons.explore.categories
|
||||||
|
|
||||||
import com.nhaarman.mockitokotlin2.mock
|
import com.nhaarman.mockitokotlin2.mock
|
||||||
import com.nhaarman.mockitokotlin2.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.category.CategoryClient
|
import fr.free.nrw.commons.category.CategoryClient
|
||||||
import fr.free.nrw.commons.explore.categories.search.PageableSearchCategoriesDataSource
|
import fr.free.nrw.commons.explore.categories.search.PageableSearchCategoriesDataSource
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.junit.Assert
|
||||||
import org.hamcrest.Matchers
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class PageableSearchCategoriesDataSourceTest {
|
class PageableSearchCategoriesDataSourceTest {
|
||||||
|
|
@ -18,6 +17,6 @@ class PageableSearchCategoriesDataSourceTest {
|
||||||
val pageableCategoriesDataSource =
|
val pageableCategoriesDataSource =
|
||||||
PageableSearchCategoriesDataSource(mock(), categoryClient)
|
PageableSearchCategoriesDataSource(mock(), categoryClient)
|
||||||
pageableCategoriesDataSource.onQueryUpdated("test")
|
pageableCategoriesDataSource.onQueryUpdated("test")
|
||||||
assertThat(pageableCategoriesDataSource.loadFunction(0, 1), Matchers.`is`(emptyList()))
|
Assert.assertEquals(pageableCategoriesDataSource.loadFunction(0, 1), emptyList<String>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,8 +6,7 @@ import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
||||||
import fr.free.nrw.commons.media.MediaClient
|
import fr.free.nrw.commons.media.MediaClient
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.junit.Assert
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -32,7 +31,7 @@ class PageableCategoriesMediaDataSourceTest {
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(mediaClient.getMediaListFromCategory("test"))
|
whenever(mediaClient.getMediaListFromCategory("test"))
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
assertThat(dataSource.loadFunction(-1, 0), `is`(emptyList()))
|
Assert.assertEquals(dataSource.loadFunction(-1, 0), emptyList<String>())
|
||||||
verify(mediaClient).resetCategoryContinuation("test")
|
verify(mediaClient).resetCategoryContinuation("test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +42,7 @@ class PageableCategoriesMediaDataSourceTest {
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(mediaClient.getMediaListFromCategory("test"))
|
whenever(mediaClient.getMediaListFromCategory("test"))
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
assertThat(dataSource.loadFunction(-1, 1), `is`(emptyList()))
|
Assert.assertEquals(dataSource.loadFunction(-1, 1), emptyList<String>())
|
||||||
verify(mediaClient, never()).resetCategoryContinuation("test")
|
verify(mediaClient, never()).resetCategoryContinuation("test")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.category.CategoryClient
|
import fr.free.nrw.commons.category.CategoryClient
|
||||||
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.junit.Assert
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -31,7 +30,7 @@ class PageableParentCategoriesDataSourceTest{
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(categoryClient.getParentCategoryList("test"))
|
whenever(categoryClient.getParentCategoryList("test"))
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
assertThat(dataSource.loadFunction(-1, 0), `is`(emptyList()))
|
Assert.assertEquals(dataSource.loadFunction(-1, 0), emptyList<String>())
|
||||||
verify(categoryClient).resetParentCategoryContinuation("test")
|
verify(categoryClient).resetParentCategoryContinuation("test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +41,7 @@ class PageableParentCategoriesDataSourceTest{
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(categoryClient.getParentCategoryList("test"))
|
whenever(categoryClient.getParentCategoryList("test"))
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
assertThat(dataSource.loadFunction(-1, 1), `is`(emptyList()))
|
Assert.assertEquals(dataSource.loadFunction(-1, 1), emptyList<String>())
|
||||||
verify(categoryClient, never()).resetParentCategoryContinuation("test")
|
verify(categoryClient, never()).resetParentCategoryContinuation("test")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.category.CategoryClient
|
import fr.free.nrw.commons.category.CategoryClient
|
||||||
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.junit.Assert
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -31,7 +30,7 @@ class PageableSubCategoriesDataSourceTest{
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(categoryClient.getSubCategoryList("test"))
|
whenever(categoryClient.getSubCategoryList("test"))
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
assertThat(dataSource.loadFunction(-1, 0), `is`(emptyList()))
|
Assert.assertEquals(dataSource.loadFunction(-1, 0), emptyList<String>())
|
||||||
verify(categoryClient).resetSubCategoryContinuation("test")
|
verify(categoryClient).resetSubCategoryContinuation("test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +41,7 @@ class PageableSubCategoriesDataSourceTest{
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(categoryClient.getSubCategoryList("test"))
|
whenever(categoryClient.getSubCategoryList("test"))
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
assertThat(dataSource.loadFunction(-1, 1), `is`(emptyList()))
|
Assert.assertEquals(dataSource.loadFunction(-1, 1), emptyList<String>())
|
||||||
verify(categoryClient, never()).resetSubCategoryContinuation("test")
|
verify(categoryClient, never()).resetSubCategoryContinuation("test")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import com.nhaarman.mockitokotlin2.mock
|
||||||
import com.nhaarman.mockitokotlin2.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.explore.depictions.search.PageableDepictionsDataSource
|
import fr.free.nrw.commons.explore.depictions.search.PageableDepictionsDataSource
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.junit.Assert
|
||||||
import org.hamcrest.Matchers
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class PageableDepictionsDataSourceTest {
|
class PageableDepictionsDataSourceTest {
|
||||||
|
|
@ -17,9 +16,9 @@ class PageableDepictionsDataSourceTest {
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
val pageableDepictionsDataSource = PageableDepictionsDataSource(mock(), depictsClient)
|
val pageableDepictionsDataSource = PageableDepictionsDataSource(mock(), depictsClient)
|
||||||
pageableDepictionsDataSource.onQueryUpdated("test")
|
pageableDepictionsDataSource.onQueryUpdated("test")
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
pageableDepictionsDataSource.loadFunction.invoke(0, 1),
|
pageableDepictionsDataSource.loadFunction.invoke(0, 1),
|
||||||
Matchers.`is`(emptyList())
|
emptyList<String>()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import depictedItem
|
||||||
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
||||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.junit.Assert
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -30,6 +29,6 @@ class PageableChildDepictionsDataSourceTest {
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(okHttpJsonApiClient.getChildDepictions("test", 0, 1))
|
whenever(okHttpJsonApiClient.getChildDepictions("test", 0, 1))
|
||||||
.thenReturn(Single.just(listOf(depictedItem())))
|
.thenReturn(Single.just(listOf(depictedItem())))
|
||||||
assertThat(dataSource.loadFunction(1, 0), `is`(listOf(depictedItem())))
|
Assert.assertEquals(dataSource.loadFunction(1, 0), listOf(depictedItem()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import com.nhaarman.mockitokotlin2.mock
|
||||||
import com.nhaarman.mockitokotlin2.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.media.MediaClient
|
import fr.free.nrw.commons.media.MediaClient
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.junit.Assert
|
||||||
import org.hamcrest.Matchers.`is`
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class PageableDepictedMediaDataSourceTest{
|
class PageableDepictedMediaDataSourceTest{
|
||||||
|
|
@ -16,6 +15,6 @@ class PageableDepictedMediaDataSourceTest{
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
val pageableDepictedMediaDataSource = PageableDepictedMediaDataSource(mock(), mediaClient)
|
val pageableDepictedMediaDataSource = PageableDepictedMediaDataSource(mock(), mediaClient)
|
||||||
pageableDepictedMediaDataSource.onQueryUpdated("test")
|
pageableDepictedMediaDataSource.onQueryUpdated("test")
|
||||||
assertThat(pageableDepictedMediaDataSource.loadFunction(0,1), `is`(emptyList()))
|
Assert.assertEquals(pageableDepictedMediaDataSource.loadFunction(0,1), emptyList<String>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import depictedItem
|
||||||
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
import fr.free.nrw.commons.explore.paging.LiveDataConverter
|
||||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.junit.Assert
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -31,7 +30,7 @@ class PageableParentDepictionsDataSourceTest {
|
||||||
dataSource.onQueryUpdated("test")
|
dataSource.onQueryUpdated("test")
|
||||||
whenever(okHttpJsonApiClient.getParentDepictions("test", 0, 1))
|
whenever(okHttpJsonApiClient.getParentDepictions("test", 0, 1))
|
||||||
.thenReturn(Single.just(listOf(depictedItem())))
|
.thenReturn(Single.just(listOf(depictedItem())))
|
||||||
assertThat(dataSource.loadFunction(1, 0), `is`(listOf(depictedItem())))
|
Assert.assertEquals(dataSource.loadFunction(1, 0), listOf(depictedItem()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import com.nhaarman.mockitokotlin2.mock
|
||||||
import com.nhaarman.mockitokotlin2.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.media.MediaClient
|
import fr.free.nrw.commons.media.MediaClient
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.junit.Assert
|
||||||
import org.hamcrest.Matchers.`is`
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -28,6 +27,6 @@ class PageableMediaDataSourceTest {
|
||||||
.thenReturn(Single.just(emptyList()))
|
.thenReturn(Single.just(emptyList()))
|
||||||
val pageableMediaDataSource = PageableMediaDataSource(mock(), mediaClient)
|
val pageableMediaDataSource = PageableMediaDataSource(mock(), mediaClient)
|
||||||
pageableMediaDataSource.onQueryUpdated("test")
|
pageableMediaDataSource.onQueryUpdated("test")
|
||||||
assertThat(pageableMediaDataSource.loadFunction(0,1), `is`(emptyList()))
|
Assert.assertEquals(pageableMediaDataSource.loadFunction(0,1), emptyList<String>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.media
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Looper
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco
|
import com.facebook.drawee.backends.pipeline.Fresco
|
||||||
|
|
@ -23,13 +24,16 @@ import org.mockito.MockitoAnnotations
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.Shadows
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.annotation.LooperMode
|
||||||
import org.wikipedia.AppAdapter
|
import org.wikipedia.AppAdapter
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||||
|
@LooperMode(LooperMode.Mode.PAUSED)
|
||||||
class MediaDetailPagerFragmentUnitTests {
|
class MediaDetailPagerFragmentUnitTests {
|
||||||
|
|
||||||
private lateinit var fragment: MediaDetailPagerFragment
|
private lateinit var fragment: MediaDetailPagerFragment
|
||||||
|
|
@ -98,6 +102,7 @@ class MediaDetailPagerFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnCreateSaveInstanceNotNull() {
|
fun testOnCreateSaveInstanceNotNull() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onCreate(outState)
|
fragment.onCreate(outState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,6 +126,7 @@ class MediaDetailPagerFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testSetWallpaperCaseNonNull() {
|
fun testSetWallpaperCaseNonNull() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
`when`(media.imageUrl).thenReturn("url")
|
`when`(media.imageUrl).thenReturn("url")
|
||||||
val method: Method = MediaDetailPagerFragment::class.java.getDeclaredMethod(
|
val method: Method = MediaDetailPagerFragment::class.java.getDeclaredMethod(
|
||||||
"setWallpaper",
|
"setWallpaper",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.free.nrw.commons.navtab
|
package fr.free.nrw.commons.navtab
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Looper
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
|
|
@ -12,10 +13,13 @@ import org.junit.runner.RunWith
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.Shadows
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.annotation.LooperMode
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||||
|
@LooperMode(LooperMode.Mode.PAUSED)
|
||||||
class MoreBottomSheetFragmentUnitTests {
|
class MoreBottomSheetFragmentUnitTests {
|
||||||
|
|
||||||
private lateinit var fragment: MoreBottomSheetFragment
|
private lateinit var fragment: MoreBottomSheetFragment
|
||||||
|
|
@ -45,48 +49,56 @@ class MoreBottomSheetFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnAttach() {
|
fun testOnAttach() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onAttach(context)
|
fragment.onAttach(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnLogoutClicked() {
|
fun testOnLogoutClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onLogoutClicked()
|
fragment.onLogoutClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnFeedbackClicked() {
|
fun testOnFeedbackClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onFeedbackClicked()
|
fragment.onFeedbackClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnAboutClicked() {
|
fun testOnAboutClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onAboutClicked()
|
fragment.onAboutClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnTutorialClicked() {
|
fun testOnTutorialClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onTutorialClicked()
|
fragment.onTutorialClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnSettingsClicked() {
|
fun testOnSettingsClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onSettingsClicked()
|
fragment.onSettingsClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnProfileClicked() {
|
fun testOnProfileClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onProfileClicked()
|
fragment.onProfileClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnPeerReviewClicked() {
|
fun testOnPeerReviewClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onPeerReviewClicked()
|
fragment.onPeerReviewClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.free.nrw.commons.navtab
|
package fr.free.nrw.commons.navtab
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Looper
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
|
|
@ -12,10 +13,13 @@ import org.junit.runner.RunWith
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.Shadows
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.annotation.LooperMode
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||||
|
@LooperMode(LooperMode.Mode.PAUSED)
|
||||||
class MoreBottomSheetLoggedOutFragmentUnitTests {
|
class MoreBottomSheetLoggedOutFragmentUnitTests {
|
||||||
|
|
||||||
private lateinit var fragment: MoreBottomSheetLoggedOutFragment
|
private lateinit var fragment: MoreBottomSheetLoggedOutFragment
|
||||||
|
|
@ -45,30 +49,35 @@ class MoreBottomSheetLoggedOutFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnTutorialClicked() {
|
fun testOnTutorialClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onTutorialClicked()
|
fragment.onTutorialClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnSettingsClicked() {
|
fun testOnSettingsClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onSettingsClicked()
|
fragment.onSettingsClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnAboutClicked() {
|
fun testOnAboutClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onAboutClicked()
|
fragment.onAboutClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnFeedbackClicked() {
|
fun testOnFeedbackClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onFeedbackClicked()
|
fragment.onFeedbackClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnLogoutClicked() {
|
fun testOnLogoutClicked() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onLogoutClicked()
|
fragment.onLogoutClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.profile.achievements
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.os.Looper
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
|
|
@ -22,7 +23,9 @@ import org.powermock.reflect.Whitebox
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
import org.robolectric.Shadows
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
import org.robolectric.annotation.LooperMode
|
||||||
import org.robolectric.fakes.RoboMenuItem
|
import org.robolectric.fakes.RoboMenuItem
|
||||||
import org.wikipedia.AppAdapter
|
import org.wikipedia.AppAdapter
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
@ -30,6 +33,7 @@ import java.lang.reflect.Method
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner::class)
|
@RunWith(RobolectricTestRunner::class)
|
||||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||||
|
@LooperMode(LooperMode.Mode.PAUSED)
|
||||||
class AchievementsFragmentUnitTests {
|
class AchievementsFragmentUnitTests {
|
||||||
|
|
||||||
private lateinit var fragment: AchievementsFragment
|
private lateinit var fragment: AchievementsFragment
|
||||||
|
|
@ -142,6 +146,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowAlert() {
|
fun testShowAlert() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showAlert(bitmap)
|
fragment.showAlert(bitmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,60 +154,70 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowInfoDialog() {
|
fun testShowInfoDialog() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showInfoDialog()
|
fragment.showInfoDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowUploadInfo() {
|
fun testShowUploadInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showUploadInfo()
|
fragment.showUploadInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowRevertedInfo() {
|
fun testShowRevertedInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showRevertedInfo()
|
fragment.showRevertedInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowUsedByWikiInfo() {
|
fun testShowUsedByWikiInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showUsedByWikiInfo()
|
fragment.showUsedByWikiInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowImagesViaNearbyInfo() {
|
fun testShowImagesViaNearbyInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showImagesViaNearbyInfo()
|
fragment.showImagesViaNearbyInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowFeaturedImagesInfo() {
|
fun testShowFeaturedImagesInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showFeaturedImagesInfo()
|
fragment.showFeaturedImagesInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowThanksReceivedInfo() {
|
fun testShowThanksReceivedInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showThanksReceivedInfo()
|
fragment.showThanksReceivedInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowQualityImagesInfo() {
|
fun testShowQualityImagesInfo() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showQualityImagesInfo()
|
fragment.showQualityImagesInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnOptionsItemSelected() {
|
fun testOnOptionsItemSelected() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onOptionsItemSelected(menuItem)
|
fragment.onOptionsItemSelected(menuItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testLaunchAlert() {
|
fun testLaunchAlert() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"launchAlert",
|
"launchAlert",
|
||||||
String::class.java,
|
String::class.java,
|
||||||
|
|
@ -215,6 +230,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testHideProgressBar() {
|
fun testHideProgressBar() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"hideProgressBar",
|
"hideProgressBar",
|
||||||
Achievements::class.java
|
Achievements::class.java
|
||||||
|
|
@ -226,6 +242,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testSetAchievementsUploadCount() {
|
fun testSetAchievementsUploadCount() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"setAchievementsUploadCount",
|
"setAchievementsUploadCount",
|
||||||
Achievements::class.java,
|
Achievements::class.java,
|
||||||
|
|
@ -238,6 +255,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testCheckAccount() {
|
fun testCheckAccount() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"checkAccount"
|
"checkAccount"
|
||||||
)
|
)
|
||||||
|
|
@ -248,6 +266,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testSetUploadCount() {
|
fun testSetUploadCount() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"setUploadCount",
|
"setUploadCount",
|
||||||
Achievements::class.java
|
Achievements::class.java
|
||||||
|
|
@ -259,6 +278,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnError() {
|
fun testOnError() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"onError"
|
"onError"
|
||||||
)
|
)
|
||||||
|
|
@ -269,6 +289,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowSnackBarWithRetryTrue() {
|
fun testShowSnackBarWithRetryTrue() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"showSnackBarWithRetry", Boolean::class.java
|
"showSnackBarWithRetry", Boolean::class.java
|
||||||
)
|
)
|
||||||
|
|
@ -279,6 +300,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowSnackBarWithRetryFalse() {
|
fun testShowSnackBarWithRetryFalse() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"showSnackBarWithRetry", Boolean::class.java
|
"showSnackBarWithRetry", Boolean::class.java
|
||||||
)
|
)
|
||||||
|
|
@ -289,6 +311,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testSetWikidataEditCount() {
|
fun testSetWikidataEditCount() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"setWikidataEditCount"
|
"setWikidataEditCount"
|
||||||
)
|
)
|
||||||
|
|
@ -299,6 +322,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testSetAchievements() {
|
fun testSetAchievements() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"setAchievements"
|
"setAchievements"
|
||||||
)
|
)
|
||||||
|
|
@ -309,6 +333,7 @@ class AchievementsFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShareScreen() {
|
fun testShareScreen() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
val method: Method = AchievementsFragment::class.java.getDeclaredMethod(
|
||||||
"shareScreen", Bitmap::class.java
|
"shareScreen", Bitmap::class.java
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,7 @@ import depictedItem
|
||||||
import entity
|
import entity
|
||||||
import entityId
|
import entityId
|
||||||
import fr.free.nrw.commons.wikidata.WikidataProperties
|
import fr.free.nrw.commons.wikidata.WikidataProperties
|
||||||
import org.hamcrest.CoreMatchers.`is`
|
import org.junit.Assert
|
||||||
import org.hamcrest.CoreMatchers.not
|
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
|
||||||
import org.hamcrest.Matchers.nullValue
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import place
|
import place
|
||||||
import snak
|
import snak
|
||||||
|
|
@ -22,37 +19,37 @@ class DepictedItemTest {
|
||||||
fun `name and description get user language label`() {
|
fun `name and description get user language label`() {
|
||||||
val depictedItem =
|
val depictedItem =
|
||||||
DepictedItem(entity(mapOf("en" to "label"), mapOf("en" to "description")))
|
DepictedItem(entity(mapOf("en" to "label"), mapOf("en" to "description")))
|
||||||
assertThat(depictedItem.name, `is`("label"))
|
Assert.assertEquals(depictedItem.name, "label")
|
||||||
assertThat(depictedItem.description, `is`("description"))
|
Assert.assertEquals(depictedItem.description, "description")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `name and descriptions get first language label if user language not present`() {
|
fun `name and descriptions get first language label if user language not present`() {
|
||||||
val depictedItem = DepictedItem(entity(mapOf("" to "label"), mapOf("" to "description")))
|
val depictedItem = DepictedItem(entity(mapOf("" to "label"), mapOf("" to "description")))
|
||||||
assertThat(depictedItem.name, `is`("label"))
|
Assert.assertEquals(depictedItem.name, "label")
|
||||||
assertThat(depictedItem.description, `is`("description"))
|
Assert.assertEquals(depictedItem.description, "description")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `name and descriptions get empty if nothing present`() {
|
fun `name and descriptions get empty if nothing present`() {
|
||||||
val depictedItem = DepictedItem(entity())
|
val depictedItem = DepictedItem(entity())
|
||||||
assertThat(depictedItem.name, `is`(""))
|
Assert.assertEquals(depictedItem.name, "")
|
||||||
assertThat(depictedItem.description, `is`(""))
|
Assert.assertEquals(depictedItem.description, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `image is empty with null statements`() {
|
fun `image is empty with null statements`() {
|
||||||
assertThat(DepictedItem(entity(statements = null)).imageUrl, nullValue())
|
Assert.assertEquals(DepictedItem(entity(statements = null)).imageUrl, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `image is empty with no image statement`() {
|
fun `image is empty with no image statement`() {
|
||||||
assertThat(DepictedItem(entity()).imageUrl, nullValue())
|
Assert.assertEquals(DepictedItem(entity()).imageUrl, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `image is empty with dataValue not of ValueString type`() {
|
fun `image is empty with dataValue not of ValueString type`() {
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
DepictedItem(
|
DepictedItem(
|
||||||
entity(
|
entity(
|
||||||
statements = mapOf(
|
statements = mapOf(
|
||||||
|
|
@ -60,13 +57,13 @@ class DepictedItemTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).imageUrl,
|
).imageUrl,
|
||||||
nullValue()
|
null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `image is not empty with dataValue of ValueString type`() {
|
fun `image is not empty with dataValue of ValueString type`() {
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
DepictedItem(
|
DepictedItem(
|
||||||
entity(
|
entity(
|
||||||
statements = mapOf(
|
statements = mapOf(
|
||||||
|
|
@ -76,13 +73,12 @@ class DepictedItemTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).imageUrl,
|
).imageUrl,
|
||||||
`is`("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/_example_/70px-_example_")
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/_example_/70px-_example_")
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `instancesOf maps EntityIds to ids`() {
|
fun `instancesOf maps EntityIds to ids`() {
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
DepictedItem(
|
DepictedItem(
|
||||||
entity(
|
entity(
|
||||||
statements = mapOf(
|
statements = mapOf(
|
||||||
|
|
@ -94,17 +90,17 @@ class DepictedItemTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).instanceOfs,
|
).instanceOfs,
|
||||||
`is`(listOf("1", "2")))
|
listOf("1", "2"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `instancesOf is empty with no values`() {
|
fun `instancesOf is empty with no values`() {
|
||||||
assertThat(DepictedItem(entity()).instanceOfs, `is`(emptyList()))
|
Assert.assertEquals(DepictedItem(entity()).instanceOfs, emptyList<String>())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `commonsCategory maps ValueString to strings`() {
|
fun `commonsCategory maps ValueString to strings`() {
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
DepictedItem(
|
DepictedItem(
|
||||||
entity(
|
entity(
|
||||||
statements = mapOf(
|
statements = mapOf(
|
||||||
|
|
@ -115,64 +111,64 @@ class DepictedItemTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).commonsCategories,
|
).commonsCategories,
|
||||||
`is`(listOf("1", "2")))
|
listOf("1", "2"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `commonsCategory is empty with no values`() {
|
fun `commonsCategory is empty with no values`() {
|
||||||
assertThat(DepictedItem(entity()).commonsCategories, `is`(emptyList()))
|
Assert.assertEquals(DepictedItem(entity()).commonsCategories, emptyList<String>())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `isSelected is false at creation`() {
|
fun `isSelected is false at creation`() {
|
||||||
assertThat(DepictedItem(entity()).isSelected, `is`(false))
|
Assert.assertEquals(DepictedItem(entity()).isSelected, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `id is entityId`() {
|
fun `id is entityId`() {
|
||||||
assertThat(DepictedItem(entity(id = "1")).id, `is`("1"))
|
Assert.assertEquals(DepictedItem(entity(id = "1")).id, "1")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `place constructor uses place name and longDescription`() {
|
fun `place constructor uses place name and longDescription`() {
|
||||||
val depictedItem = DepictedItem(entity(), place(name = "1", longDescription = "2"))
|
val depictedItem = DepictedItem(entity(), place(name = "1", longDescription = "2"))
|
||||||
assertThat(depictedItem.name, `is`("1"))
|
Assert.assertEquals(depictedItem.name, "1")
|
||||||
assertThat(depictedItem.description, `is`("2"))
|
Assert.assertEquals(depictedItem.description, "2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `same object is Equal`() {
|
fun `same object is Equal`() {
|
||||||
val depictedItem = depictedItem()
|
val depictedItem = depictedItem()
|
||||||
assertThat(depictedItem == depictedItem, `is`(true))
|
Assert.assertEquals(depictedItem == depictedItem, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `different type is not Equal`() {
|
fun `different type is not Equal`() {
|
||||||
assertThat(depictedItem().equals(Unit), `is`(false))
|
Assert.assertEquals(depictedItem().equals(Unit), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `if names are equal is Equal`() {
|
fun `if names are equal is Equal`() {
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
depictedItem(name="a", id = "0") == depictedItem(name="a", id = "1"),
|
depictedItem(name="a", id = "0") == depictedItem(name="a", id = "1"),
|
||||||
`is`(true))
|
true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `if names are not equal is not Equal`() {
|
fun `if names are not equal is not Equal`() {
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
depictedItem(name="a") == depictedItem(name="b"),
|
depictedItem(name="a") == depictedItem(name="b"),
|
||||||
`is`(false))
|
false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `hashCode returns same values for objects with same name`() {
|
fun `hashCode returns same values for objects with same name`() {
|
||||||
assertThat(depictedItem(name="a").hashCode(), `is`(depictedItem(name="a").hashCode()))
|
Assert.assertEquals(depictedItem(name="a").hashCode(), depictedItem(name="a").hashCode())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `hashCode returns different values for objects with different name`() {
|
fun `hashCode returns different values for objects with different name`() {
|
||||||
assertThat(depictedItem(name="a").hashCode(), not(depictedItem(name="b").hashCode()))
|
Assert.assertNotEquals(depictedItem(name="a").hashCode(), depictedItem(name="b").hashCode())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package fr.free.nrw.commons.utils
|
package fr.free.nrw.commons.utils
|
||||||
|
|
||||||
import org.hamcrest.core.IsEqual.equalTo
|
import org.junit.Assert
|
||||||
import org.junit.Assert.assertThat
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class CommonsDateUtilTest {
|
class CommonsDateUtilTest {
|
||||||
|
|
@ -12,9 +11,9 @@ class CommonsDateUtilTest {
|
||||||
.getIso8601DateFormatTimestamp()
|
.getIso8601DateFormatTimestamp()
|
||||||
val parsedDate = iso8601DateFormatTimestamp
|
val parsedDate = iso8601DateFormatTimestamp
|
||||||
.parse("2020-04-07T14:21:57Z")
|
.parse("2020-04-07T14:21:57Z")
|
||||||
assertThat(
|
Assert.assertEquals(
|
||||||
"2020-04-07T14:21:57Z",
|
"2020-04-07T14:21:57Z",
|
||||||
equalTo(iso8601DateFormatTimestamp.format(parsedDate))
|
iso8601DateFormatTimestamp.format(parsedDate)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue