Fix #5182 Switch From Mapbox to MapLibre (#5184)

* Fix #5182 Switch From Mapbox to MapLibre

* Fix #5182 Switch From Mapbox to MapLibre - Resolved requestFeature() issue

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on two screens

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on additional screens

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on notification screen

* Fix #5182 Switch From Mapbox to MapLibre - Test errors
This commit is contained in:
Kartikay Kaushik 2023-03-30 20:31:58 -04:00 committed by GitHub
parent 2989b73dee
commit 8f8dcc0d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 63 additions and 77 deletions

View file

@ -10,6 +10,7 @@ import androidx.appcompat.widget.AppCompatTextView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
@ -24,6 +25,7 @@ import fr.free.nrw.commons.kvstore.JsonKvStore
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_ZOOM
import org.junit.Assert
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@ -37,6 +39,7 @@ import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Method
@RunWith(RobolectricTestRunner::class)
@ -136,7 +139,17 @@ class LocationPickerActivityUnitTests {
MapboxMap::class.java
)
method.isAccessible = true
method.invoke(activity, mapboxMap)
try {
method.invoke(activity, mapboxMap)
fail("Expected an exception to be thrown")
} catch (e: InvocationTargetException) {
assertTrue(e.targetException is MapboxConfigurationException)
assertEquals(
"\nUsing MapView requires calling Mapbox.getInstance(Context context, String apiKey,"
+ " WellKnownTileServer wellKnownTileServer) before inflating or creating the view.",
e.targetException.message
)
}
}
@Test
@ -234,9 +247,9 @@ class LocationPickerActivityUnitTests {
method.isAccessible = true
method.invoke(activity)
verify(applicationKvStore, times(1))
.putString(LAST_LOCATION, position.target.latitude.toString()
.putString(LAST_LOCATION, position.target!!.latitude.toString()
+ ","
+ position.target.longitude
+ position.target!!.longitude
)
verify(applicationKvStore, times(1))
.putString(LAST_ZOOM, position.zoom.toString())

View file

@ -98,17 +98,6 @@ class SettingsFragmentUnitTests {
method.invoke(fragment)
}
@Test
@Throws(Exception::class)
fun testTelemetryOptInOut() {
val method: Method = SettingsFragment::class.java.getDeclaredMethod(
"telemetryOptInOut",
Boolean::class.java
)
method.isAccessible = true
method.invoke(fragment, true)
}
@Test
@Throws(Exception::class)
fun testCheckPermissionsAndSendLogs() {