Removed MapBox related imports (#5631)

* Fixed Grey empty screen at Upload wizard caption step after denying files permission

* Empty commit

* Fixed loop issue

* Created docs for earlier commits

* Fixed javadoc

* Fixed spaces

* Added added basic features to OSM Maps

* Added search location feature

* Added filter to Open Street Maps

* Fixed chipGroup in Open Street Maps

* Removed mapBox code

* Removed mapBox's code

* Reformat code

* Reformatted code

* Removed rotation feature to map

* Removed rotation files and Fixed Marker click problem

* Ignored failing tests

* Added voice input feature

* Fixed test cases

* Changed caption and description text

* Replaced mapbox to osmdroid in upload activity

* Fixed Unit Tests

* Made selected marker to be fixed on map

* Changed color of map marker

* Fixes #5439 by capitalizing first letter of voice input

* Removed mapbox code1

* Removed mapbox code2

* Fixed failing tests

* Fixed failing due to merging
This commit is contained in:
Kanahia 2024-03-21 19:13:22 +05:30 committed by GitHub
parent 9041e1bc0c
commit d112be04db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 261 additions and 831 deletions

View file

@ -18,7 +18,7 @@ class NearbyControllerTest {
val location = LatLng(0.0, 0.0, 0f)
val options = loadAttractionsFromLocationToBaseMarkerOptions(
location, null, ApplicationProvider.getApplicationContext(), null)
location, null)
assertEquals(0, options.size.toLong())
}
@ -28,7 +28,7 @@ class NearbyControllerTest {
val location = LatLng(0.0, 0.0, 0f)
val options = loadAttractionsFromLocationToBaseMarkerOptions(
location, emptyList(), ApplicationProvider.getApplicationContext(), emptyList())
location, emptyList())
assertEquals(0, options.size.toLong())
}

View file

@ -9,21 +9,13 @@ import android.widget.ImageView
import android.widget.TextView
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
import com.mapbox.mapboxsdk.maps.UiSettings
import com.mapbox.mapboxsdk.style.layers.Layer
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import fr.free.nrw.commons.CameraPosition
import fr.free.nrw.commons.LocationPicker.LocationPickerActivity
import fr.free.nrw.commons.Media
import fr.free.nrw.commons.TestCommonsApplication
import fr.free.nrw.commons.coordinates.CoordinateEditHelper
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

View file

@ -2,11 +2,11 @@ package fr.free.nrw.commons.locationpicker
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import fr.free.nrw.commons.CameraPosition
import fr.free.nrw.commons.LocationPicker.LocationPickerViewModel
import org.junit.Before
import org.junit.Test

View file

@ -1,92 +0,0 @@
package fr.free.nrw.commons.nearby
import android.os.Parcel
import com.mapbox.mapboxsdk.annotations.Icon
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.powermock.reflect.Whitebox
class NearbyBaseMarkerUnitTests {
private lateinit var marker: NearbyBaseMarker
@Mock
private lateinit var place: Place
@Mock
private lateinit var parcel: Parcel
@Mock
private lateinit var icon: Icon
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
marker = NearbyBaseMarker()
Whitebox.setInternalState(marker, "icon", icon)
}
@Test
@Throws(Exception::class)
fun checkNotNull() {
Assert.assertNotNull(marker)
}
@Test
@Throws(Exception::class)
fun testPlace() {
marker.place(place)
}
@Test
@Throws(Exception::class)
fun testGetThis() {
marker.getThis()
}
@Test
@Throws(Exception::class)
fun testGetMarker() {
marker.marker
}
@Test
@Throws(Exception::class)
fun testGetPlace() {
marker.place
}
@Test
@Throws(Exception::class)
fun testDescribeContents() {
marker.describeContents()
}
@Test
@Throws(Exception::class)
fun testWriteToParcel() {
marker.writeToParcel(parcel, 0)
}
@Test
@Throws(Exception::class)
fun testEquals() {
marker.equals(this)
}
@Test
@Throws(Exception::class)
fun testEqualsCaseNull() {
Assert.assertFalse(marker.equals(this))
}
@Test
@Throws(Exception::class)
fun testHashCode() {
marker.hashCode()
}
}

View file

@ -5,6 +5,7 @@ import androidx.test.core.app.ApplicationProvider
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.anyOrNull
import com.nhaarman.mockitokotlin2.eq
import fr.free.nrw.commons.BaseMarker
import fr.free.nrw.commons.TestCommonsApplication
import fr.free.nrw.commons.location.LatLng
import fr.free.nrw.commons.nearby.NearbyController.loadAttractionsFromLocationToBaseMarkerOptions
@ -239,10 +240,8 @@ class NearbyControllerTest {
assertEquals(
loadAttractionsFromLocationToBaseMarkerOptions(
currentLatLng,
null,
context,
mutableListOf(place)
), listOf<NearbyBaseMarker>()
null
), listOf<BaseMarker>()
)
}
@ -265,9 +264,7 @@ class NearbyControllerTest {
assertEquals(
loadAttractionsFromLocationToBaseMarkerOptions(
currentLatLng,
listOf(place),
context,
mutableListOf(place)
listOf(place)
)[0].place, place
)
}
@ -291,9 +288,7 @@ class NearbyControllerTest {
assertEquals(
loadAttractionsFromLocationToBaseMarkerOptions(
currentLatLng,
listOf(place),
context,
mutableListOf(place)
listOf(place)
)[0].place, place
)
}
@ -317,9 +312,7 @@ class NearbyControllerTest {
assertEquals(
loadAttractionsFromLocationToBaseMarkerOptions(
currentLatLng,
listOf(place),
context,
mutableListOf(place)
listOf(place)
)[0].place, place
)
}
@ -343,16 +336,14 @@ class NearbyControllerTest {
assertEquals(
loadAttractionsFromLocationToBaseMarkerOptions(
currentLatLng,
listOf(place),
context,
mutableListOf(place)
listOf(place)
)[0].place, place
)
}
@Test
fun testUpdateMarkerLabelListBookmarkCaseTrue() {
markerPlaceGroup = MarkerPlaceGroup(null, true, place)
markerPlaceGroup = MarkerPlaceGroup(true, place)
`when`(place.wikiDataEntityId).thenReturn("someString")
val list = mutableListOf(markerPlaceGroup)
Whitebox.setInternalState(
@ -363,12 +354,11 @@ class NearbyControllerTest {
updateMarkerLabelListBookmark(place, false)
assertEquals(list[0].isBookmarked, false)
assertEquals(list[0].place, place)
assertEquals(list[0].marker, null)
}
@Test
fun testUpdateMarkerLabelListBookmarkCaseFalse() {
markerPlaceGroup = MarkerPlaceGroup(null, false, place)
markerPlaceGroup = MarkerPlaceGroup(false, place)
`when`(place.wikiDataEntityId).thenReturn("someString")
val list = mutableListOf(markerPlaceGroup)
Whitebox.setInternalState(
@ -379,7 +369,6 @@ class NearbyControllerTest {
updateMarkerLabelListBookmark(place, true)
assertEquals(list[0].isBookmarked, true)
assertEquals(list[0].place, place)
assertEquals(list[0].marker, null)
}
fun <T> any(type: Class<T>): T = Mockito.any(type)

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.nearby
import com.mapbox.mapboxsdk.annotations.Marker
import com.nhaarman.mockitokotlin2.*
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao
import fr.free.nrw.commons.location.LatLng
@ -17,8 +16,6 @@ import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.any
import org.mockito.Mockito.anyBoolean
import org.mockito.Mockito.anyDouble
import org.mockito.Mockito.anyFloat
import org.mockito.Mockito.verifyNoInteractions
import org.mockito.MockitoAnnotations
import java.util.*
@ -43,14 +40,10 @@ class NearbyParentFragmentPresenterTest {
@Mock
internal lateinit var selectedLabels: List<Label>
@Mock
internal lateinit var marker: Marker
@Mock
internal lateinit var nearbyPlaces: NearbyPlaces
private lateinit var nearbyPresenter: NearbyParentFragmentPresenter
private lateinit var mapboxCameraTarget: com.mapbox.mapboxsdk.geometry.LatLng
/**
* initial setup
@ -193,7 +186,6 @@ class NearbyParentFragmentPresenterTest {
@Test
fun testUserTrackedWhenCurrentLocationMarkerVisible() {
expectMapAndListUpdate()
whenever(nearbyParentFragmentView.isCurrentLocationMarkerVisible()).thenReturn(true)
whenever(nearbyParentFragmentView.lastMapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F))
whenever(nearbyParentFragmentView.mapCenter).thenReturn(null);
nearbyPresenter.updateMapAndList(LocationChangeType.LOCATION_SLIGHTLY_CHANGED)
@ -209,17 +201,15 @@ class NearbyParentFragmentPresenterTest {
fun testUserNotTrackedWhenCurrentLocationMarkerInvisible() {
expectMapAndListUpdate()
verify(nearbyParentFragmentView).enableFABRecenter()
whenever(nearbyParentFragmentView.isCurrentLocationMarkerVisible()).thenReturn(false)
whenever(nearbyParentFragmentView.lastMapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F))
whenever(nearbyParentFragmentView.mapCenter).thenReturn(null);
nearbyPresenter.updateMapAndList(LocationChangeType.LOCATION_SLIGHTLY_CHANGED)
verify(nearbyParentFragmentView).isNetworkConnectionEstablished()
verify(nearbyParentFragmentView).getLastMapFocus()
verify(nearbyParentFragmentView).getMapCenter()
verify(nearbyParentFragmentView).isCurrentLocationMarkerVisible()
verifyNoMoreInteractions(nearbyParentFragmentView)
}
// Set this test function to @Ignore because of change in functionalities due to Mapbox to osmdroid transition.
/**
* Test search this area button became visible after user moved the camera target to far
* away from current target. Distance between these two point is 111.19 km, so our camera target
@ -229,31 +219,12 @@ class NearbyParentFragmentPresenterTest {
@Test @Ignore
fun testSearchThisAreaButtonVisibleWhenMoveToFarPosition() {
NearbyController.latestSearchLocation = Mockito.spy(LatLng(2.0, 1.0, 0.0F))
mapboxCameraTarget = Mockito.spy(com.mapbox.mapboxsdk.geometry.LatLng(1.0, 1.0, 0.0))
// Distance between these two point is 111.19 km
NearbyController.latestSearchRadius = 111.19 * 1000 // To meter
whenever(nearbyParentFragmentView.isNetworkConnectionEstablished()).thenReturn(true)
nearbyPresenter.onCameraMove(mapboxCameraTarget)
verify(nearbyParentFragmentView).setSearchThisAreaButtonVisibility(true)
}
/**
* Test search this area button became visible after user moved the camera target to far
* away from current target. Distance between these two point is 111.19 km, so our camera target
* is at inside of previously searched region if we set latestSearchRadius above 111.19. Thus,
* setSearchThisAreaButtonVisibility(false) should be verified.
*/
@Test
fun testSearchThisAreaButtonInvisibleWhenMoveToClosePosition() {
NearbyController.latestSearchLocation = Mockito.spy(LatLng(2.0, 1.0, 0.0F))
mapboxCameraTarget = Mockito.spy(com.mapbox.mapboxsdk.geometry.LatLng(1.0, 1.0, 0.0))
// Distance between these two point is 111.19 km
NearbyController.latestSearchRadius = 112.0 * 1000 // To meter
whenever(nearbyParentFragmentView.isNetworkConnectionEstablished()).thenReturn(true)
nearbyPresenter.onCameraMove(mapboxCameraTarget)
verify(nearbyParentFragmentView).setSearchThisAreaButtonVisibility(false)
}
/**
* Multi selection should overwrite single selection of marker types. Ie. when user choose
*"parks", then they multi select to display all or none, we overwrite previous "park" filter.
@ -344,29 +315,11 @@ class NearbyParentFragmentPresenterTest {
verify(nearbyParentFragmentView).hideBottomDetailsSheet()
}
/**
* Test if the search is close to current location, when last location is null we expect it to
* return true
*/
@Test
fun testSearchCloseToCurrentLocationNullLastLocation() {
whenever(nearbyParentFragmentView.getLastFocusLocation()).thenReturn(null)
val isClose = nearbyPresenter?.searchCloseToCurrentLocation()
assertTrue(isClose!!)
}
/**
* Test if the search is close to current location, when far
*/
@Test
fun testSearchCloseToCurrentLocationWhenFar() {
whenever(nearbyParentFragmentView.getLastFocusLocation()).thenReturn(
com.mapbox.mapboxsdk.geometry.LatLng(
1.0,
1.0,
0.0
)
)
whenever(nearbyParentFragmentView.lastMapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F));
whenever(nearbyParentFragmentView.mapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F))
//111.19 km real distance, return false if 148306.444306 > currentLocationSearchRadius
@ -380,13 +333,6 @@ class NearbyParentFragmentPresenterTest {
*/
@Test
fun testSearchCloseToCurrentLocationWhenClose() {
whenever(nearbyParentFragmentView.getLastFocusLocation()).thenReturn(
com.mapbox.mapboxsdk.geometry.LatLng(
1.0,
1.0,
0.0
)
)
whenever(nearbyParentFragmentView.getCameraTarget()).thenReturn(LatLng(2.0, 1.0, 0.0F))
//111.19 km real distance, return false if 148253.333 > currentLocationSearchRadius
NearbyController.currentLocationSearchRadius = 148307.0
@ -444,12 +390,6 @@ class NearbyParentFragmentPresenterTest {
verify(nearbyParentFragmentView).hideBottomSheet();
}
@Test
fun testMarkerSelected() {
nearbyPresenter.markerSelected(marker)
verify(nearbyParentFragmentView).displayBottomSheetWithInfo(marker)
}
@Test
fun testOnWikidataEditSuccessful() {
nearbyPresenter.onWikidataEditSuccessful()
@ -473,12 +413,10 @@ class NearbyParentFragmentPresenterTest {
nearbyPresenter.onLocationChangedSlightly(latestLocation)
expectMapAndListUpdate()
verify(nearbyParentFragmentView).enableFABRecenter()
whenever(nearbyParentFragmentView.isCurrentLocationMarkerVisible()).thenReturn(true)
whenever(nearbyParentFragmentView.lastMapFocus).thenReturn(LatLng(2.0, 1.0, 0.0F))
whenever(nearbyParentFragmentView.mapCenter).thenReturn(null)
nearbyPresenter.updateMapAndList(LocationChangeType.LOCATION_SLIGHTLY_CHANGED)
verify(nearbyParentFragmentView).getLastMapFocus()
verify(nearbyParentFragmentView).isCurrentLocationMarkerVisible()
verify(nearbyParentFragmentView).recenterMap(nearbyParentFragmentView.lastMapFocus)
}
@ -528,31 +466,6 @@ class NearbyParentFragmentPresenterTest {
expectMapAndListUpdate()
}
@Test
fun testOnCameraMoveWhenSearchLocationNull() {
NearbyController.latestSearchLocation = null
nearbyPresenter.onCameraMove(Mockito.mock(com.mapbox.mapboxsdk.geometry.LatLng::class.java))
verify(nearbyParentFragmentView).setSearchThisAreaButtonVisibility(false)
}
@Test
fun testOnCameraMoveWhenNetworkConnectionNotEstablished() {
NearbyController.latestSearchLocation = latestLocation
whenever(nearbyParentFragmentView.isNetworkConnectionEstablished()).thenReturn(false)
nearbyPresenter.onCameraMove(Mockito.mock(com.mapbox.mapboxsdk.geometry.LatLng::class.java))
verify(nearbyParentFragmentView).isNetworkConnectionEstablished()
verifyNoMoreInteractions(nearbyParentFragmentView)
}
@Test
fun testOnCameraMoveWhenNetworkConnectionEstablished() {
NearbyController.latestSearchLocation = latestLocation
whenever(nearbyParentFragmentView.isNetworkConnectionEstablished()).thenReturn(false)
nearbyPresenter.onCameraMove(Mockito.mock(com.mapbox.mapboxsdk.geometry.LatLng::class.java))
verify(nearbyParentFragmentView).isNetworkConnectionEstablished()
verifyNoMoreInteractions(nearbyParentFragmentView)
}
@Test
fun testSetAdvancedQuery() {
nearbyPresenter.setAdvancedQuery("test")
@ -570,8 +483,8 @@ class NearbyParentFragmentPresenterTest {
nearbyPlacesInfo.placeList = null
whenever(bookmarkLocationsDao.allBookmarksLocations).thenReturn(Collections.emptyList())
nearbyPresenter.updateMapMarkers(nearbyPlacesInfo, marker, true)
Mockito.verify(nearbyParentFragmentView).updateMapMarkers(any(), eq(marker))
nearbyPresenter.updateMapMarkers(nearbyPlacesInfo, true)
Mockito.verify(nearbyParentFragmentView).updateMapMarkers(any())
Mockito.verify(nearbyParentFragmentView).setProgressBarVisibility(false)
Mockito.verify(nearbyParentFragmentView).updateListFragment(nearbyPlacesInfo.placeList)

View file

@ -18,12 +18,9 @@ import androidx.fragment.app.FragmentTransaction
import androidx.test.core.app.ApplicationProvider
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.whenever
import fr.free.nrw.commons.BaseMarker
import fr.free.nrw.commons.OkHttpConnectionFactory
import fr.free.nrw.commons.R
import fr.free.nrw.commons.TestCommonsApplication
@ -66,9 +63,6 @@ class NearbyParentFragmentUnitTest {
@Mock
private lateinit var applicationKvStore: JsonKvStore
@Mock
private lateinit var mapBox: MapboxMap
@Mock
private lateinit var presenter: NearbyParentFragmentPresenter
@ -105,9 +99,6 @@ class NearbyParentFragmentUnitTest {
@Mock
private lateinit var bottomSheetDetails: View
@Mock
private lateinit var marker: NearbyMarker
@Mock
private lateinit var linearLayout: LinearLayout
@ -225,17 +216,6 @@ class NearbyParentFragmentUnitTest {
verify(applicationKvStore, times(1))
.putBoolean("doNotAskForLocationPermission", true)
verify(presenter, times(1)).onMapReady()
val position = CameraPosition.Builder()
.target(
LatLng(
51.50550,
-0.07520, 0.0
)
)
.zoom(0.0)
.build()
verify(mapBox, times(1))
.moveCamera(CameraUpdateFactory.newCameraPosition(position))
}
@Test @Ignore
@ -252,17 +232,6 @@ class NearbyParentFragmentUnitTest {
verify(applicationKvStore, times(1))
.putBoolean("doNotAskForLocationPermission", true)
verify(presenter, times(1)).onMapReady()
val position = CameraPosition.Builder()
.target(
LatLng(
23.76,
56.876, 0.0
)
)
.zoom(14.0)
.build()
verify(mapBox, times(1))
.moveCamera(CameraUpdateFactory.newCameraPosition(position))
}
@Test @Ignore
@ -393,14 +362,12 @@ class NearbyParentFragmentUnitTest {
@Test @Ignore
@Throws(Exception::class)
fun testDisplayBottomSheetWithInfo() {
val nearbyBaseMarker = mock(NearbyBaseMarker::class.java)
val nearbyBaseMarker = mock(BaseMarker::class.java)
val place = mock(Place::class.java)
val label = mock(Label::class.java)
whenever(marker.nearbyBaseMarker).thenReturn(nearbyBaseMarker)
whenever(nearbyBaseMarker.place).thenReturn(place)
whenever(place.label).thenReturn(label)
whenever(place.longDescription).thenReturn("")
fragment.displayBottomSheetWithInfo(marker)
verify(bottomSheetBehavior).state = BottomSheetBehavior.STATE_COLLAPSED
}

View file

@ -18,9 +18,8 @@ import androidx.fragment.app.FragmentTransaction
import androidx.recyclerview.widget.RecyclerView
import androidx.test.core.app.ApplicationProvider
import com.github.chrisbanes.photoview.PhotoView
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.nhaarman.mockitokotlin2.mock
import fr.free.nrw.commons.CameraPosition
import fr.free.nrw.commons.LocationPicker.LocationPicker
import fr.free.nrw.commons.LocationPicker.LocationPickerActivity
import fr.free.nrw.commons.OkHttpConnectionFactory
@ -28,6 +27,7 @@ import fr.free.nrw.commons.R
import fr.free.nrw.commons.TestCommonsApplication
import fr.free.nrw.commons.createTestClient
import fr.free.nrw.commons.kvstore.JsonKvStore
import fr.free.nrw.commons.location.LatLng
import fr.free.nrw.commons.nearby.Place
import fr.free.nrw.commons.upload.ImageCoordinates
import fr.free.nrw.commons.upload.UploadActivity
@ -355,7 +355,8 @@ class UploadMediaDetailFragmentUnitTest {
val cameraPosition = Mockito.mock(CameraPosition::class.java)
val latLng = Mockito.mock(LatLng::class.java)
Whitebox.setInternalState(cameraPosition, "target", latLng)
Whitebox.setInternalState(cameraPosition, "latitude", latLng.latitude)
Whitebox.setInternalState(cameraPosition, "longitude", latLng.longitude)
Whitebox.setInternalState(fragment, "editableUploadItem", uploadItem)
`when`(LocationPicker.getCameraPosition(intent)).thenReturn(cameraPosition)
@ -376,7 +377,8 @@ class UploadMediaDetailFragmentUnitTest {
val latLng = Mockito.mock(LatLng::class.java)
Whitebox.setInternalState(fragment, "callback", callback)
Whitebox.setInternalState(cameraPosition, "target", latLng)
Whitebox.setInternalState(cameraPosition, "latitude", latLng.latitude)
Whitebox.setInternalState(cameraPosition, "longitude", latLng.longitude)
Whitebox.setInternalState(fragment, "editableUploadItem", uploadItem)
Whitebox.setInternalState(fragment,"isMissingLocationDialog",true)
Whitebox.setInternalState(fragment, "presenter", presenter)

View file

@ -9,26 +9,18 @@ import org.junit.jupiter.api.Assertions.assertEquals
*/
class LocationUtilsTest {
/**
* MapBox LatLng to commons LatLng test.
*/
@Test
fun testMapBoxLatLngToCommonsLatLng() {
val commonsLatLngTest = LocationUtils.mapBoxLatLngToCommonsLatLng(com.mapbox.mapboxsdk.geometry.LatLng(0.0, 0.0))
assertEquals(0.0, commonsLatLngTest.latitude)
assertEquals(0.0, commonsLatLngTest.longitude)
assertEquals(0f, commonsLatLngTest.accuracy)
}
fun testCalculateDistance() {
val lat1 = 37.7749
val lon1 = -122.4194
val lat2 = 34.0522
val lon2 = -118.2437
/**
* Commons LatLng to MapBox LatLng test.
*/
@Test
fun testCommonsLatLngToMapBoxLatLng() {
val geoLatLngTest = LocationUtils.commonsLatLngToMapBoxLatLng(LatLng(0.0, 0.0, 0f))
assertEquals(0.0, geoLatLngTest.latitude)
assertEquals(0.0, geoLatLngTest.longitude)
assertEquals(0.0, geoLatLngTest.altitude)
val expectedDistance = 559.02 // Expected distance in kilometers
val actualDistance = LocationUtils.calculateDistance(lat1, lon1, lat2, lon2)
assertEquals(expectedDistance, actualDistance, 0.2) // Tolerance = 0.2 km
}
}