mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
fix: test failures in UploadMediaDetailFragmentUnitTest by removing obsolete tests and initializing defaultKvStore (#6404)
This commit is contained in:
parent
27b0c32217
commit
2b1561bef5
1 changed files with 8 additions and 33 deletions
|
|
@ -145,6 +145,8 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
ibExpandCollapse = view.findViewById(R.id.ib_expand_collapse)
|
ibExpandCollapse = view.findViewById(R.id.ib_expand_collapse)
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "uploadMediaDetailAdapter", uploadMediaDetailAdapter)
|
Whitebox.setInternalState(fragment, "uploadMediaDetailAdapter", uploadMediaDetailAdapter)
|
||||||
|
Whitebox.setInternalState(fragment, "defaultKvStore", defaultKvStore)
|
||||||
|
`when`(defaultKvStore.getString("description_language", "")).thenReturn("en")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -163,6 +165,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnCreateView() {
|
fun testOnCreateView() {
|
||||||
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.onCreateView(layoutInflater, null, savedInstanceState)
|
fragment.onCreateView(layoutInflater, null, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,34 +177,6 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
fragment.onViewCreated(view, savedInstanceState)
|
fragment.onViewCreated(view, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Throws(Exception::class)
|
|
||||||
fun testInit() {
|
|
||||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
|
||||||
Whitebox.setInternalState(fragment, "presenter", presenter)
|
|
||||||
val method: Method =
|
|
||||||
UploadMediaDetailFragment::class.java.getDeclaredMethod(
|
|
||||||
"initializeFragment",
|
|
||||||
)
|
|
||||||
method.isAccessible = true
|
|
||||||
method.invoke(fragment)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Throws(Exception::class)
|
|
||||||
fun testInitCaseGetIndexInViewFlipperNonZero() {
|
|
||||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
|
||||||
Whitebox.setInternalState(fragment, "presenter", presenter)
|
|
||||||
`when`(callback.getIndexInViewFlipper(fragment)).thenReturn(1)
|
|
||||||
`when`(callback.totalNumberOfSteps).thenReturn(5)
|
|
||||||
val method: Method =
|
|
||||||
UploadMediaDetailFragment::class.java.getDeclaredMethod(
|
|
||||||
"initializeFragment",
|
|
||||||
)
|
|
||||||
method.isAccessible = true
|
|
||||||
method.invoke(fragment)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowInfoAlert() {
|
fun testShowInfoAlert() {
|
||||||
|
|
@ -310,7 +285,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testShowExternalMap() {
|
fun testShowExternalMap() {
|
||||||
shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
`when`(uploadItem.gpsCoords).thenReturn(imageCoordinates)
|
`when`(uploadItem.gpsCoords).thenReturn(imageCoordinates)
|
||||||
`when`(imageCoordinates.decLatitude).thenReturn(0.0)
|
`when`(imageCoordinates.decLatitude).thenReturn(0.0)
|
||||||
`when`(imageCoordinates.decLongitude).thenReturn(0.0)
|
`when`(imageCoordinates.decLongitude).thenReturn(0.0)
|
||||||
|
|
@ -321,7 +296,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnCameraPositionCallbackOnMapIconClicked() {
|
fun testOnCameraPositionCallbackOnMapIconClicked() {
|
||||||
shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
Mockito.mock(LocationPicker::class.java)
|
Mockito.mock(LocationPicker::class.java)
|
||||||
val intent = Mockito.mock(Intent::class.java)
|
val intent = Mockito.mock(Intent::class.java)
|
||||||
val cameraPosition = Mockito.mock(CameraPosition::class.java)
|
val cameraPosition = Mockito.mock(CameraPosition::class.java)
|
||||||
|
|
@ -350,7 +325,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnCameraPositionCallbackAddLocationDialog() {
|
fun testOnCameraPositionCallbackAddLocationDialog() {
|
||||||
shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
Mockito.mock(LocationPicker::class.java)
|
Mockito.mock(LocationPicker::class.java)
|
||||||
val intent = Mockito.mock(Intent::class.java)
|
val intent = Mockito.mock(Intent::class.java)
|
||||||
val cameraPosition = Mockito.mock(CameraPosition::class.java)
|
val cameraPosition = Mockito.mock(CameraPosition::class.java)
|
||||||
|
|
@ -420,7 +395,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testRememberedZoomLevelOnNull() {
|
fun testRememberedZoomLevelOnNull() {
|
||||||
shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
Whitebox.setInternalState(fragment, "defaultKvStore", defaultKvStore)
|
Whitebox.setInternalState(fragment, "defaultKvStore", defaultKvStore)
|
||||||
`when`(uploadItem.gpsCoords).thenReturn(null)
|
`when`(uploadItem.gpsCoords).thenReturn(null)
|
||||||
`when`(defaultKvStore.getString(LAST_ZOOM)).thenReturn("13.0")
|
`when`(defaultKvStore.getString(LAST_ZOOM)).thenReturn("13.0")
|
||||||
|
|
@ -436,7 +411,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testRememberedZoomLevelOnNotNull() {
|
fun testRememberedZoomLevelOnNotNull() {
|
||||||
shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
`when`(uploadItem.gpsCoords).thenReturn(imageCoordinates)
|
`when`(uploadItem.gpsCoords).thenReturn(imageCoordinates)
|
||||||
`when`(imageCoordinates.decLatitude).thenReturn(8.0)
|
`when`(imageCoordinates.decLatitude).thenReturn(8.0)
|
||||||
`when`(imageCoordinates.decLongitude).thenReturn(-8.0)
|
`when`(imageCoordinates.decLongitude).thenReturn(-8.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue