This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - expose moveBy, replace CameraUpdateFactory hook to moveBy…
… for scrolling api
- Loading branch information
Showing
5 changed files
with
118 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ public interface CameraUpdate { | |
CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.mapbox.mapboxsdk.maps | ||
|
||
import android.support.test.espresso.UiController | ||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory | ||
import com.mapbox.mapboxsdk.geometry.LatLng | ||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke | ||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest | ||
import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity | ||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
|
||
class TransformTest: BaseActivityTest() { | ||
|
||
override fun getActivityClass(): Class<*> = SimpleMapActivity::class.java | ||
|
||
companion object { | ||
val initialCameraUpdate = CameraUpdateFactory.newLatLngZoom(LatLng(12.0,12.0), 12.0)!! | ||
val scrollByCameraUpdate = CameraUpdateFactory.scrollBy(400.0f,0.0f)!! | ||
} | ||
|
||
@Test | ||
fun cameraUpdateScrollByWithPadding() { | ||
validateTestSetup() | ||
invoke(mapboxMap) { uiController: UiController, mapboxMap: MapboxMap -> | ||
mapboxMap.moveCamera(initialCameraUpdate) | ||
mapboxMap.moveCamera(scrollByCameraUpdate) | ||
val expectedCameraPosition = mapboxMap.cameraPosition | ||
|
||
mapboxMap.moveCamera(initialCameraUpdate) | ||
mapboxMap.setPadding(250,250,0,0) | ||
mapboxMap.moveCamera(scrollByCameraUpdate) | ||
val actualCameraPosition = mapboxMap.cameraPosition | ||
|
||
assertEquals("Camera position latitude should match", | ||
expectedCameraPosition.target.latitude, | ||
actualCameraPosition.target.longitude, | ||
TestConstants.LAT_LNG_DELTA | ||
) | ||
|
||
assertEquals("Camera position longitude should match", | ||
expectedCameraPosition.target.longitude, | ||
actualCameraPosition.target.longitude, | ||
TestConstants.LAT_LNG_DELTA | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun mapboxMapScrollByWithPadding() { | ||
validateTestSetup() | ||
invoke(mapboxMap) { uiController: UiController, mapboxMap: MapboxMap -> | ||
mapboxMap.moveCamera(initialCameraUpdate) | ||
mapboxMap.scrollBy(400.0f, 0.0f) | ||
val expectedCameraPosition = mapboxMap.cameraPosition | ||
|
||
mapboxMap.moveCamera(initialCameraUpdate) | ||
mapboxMap.setPadding(250,250,0,0) | ||
mapboxMap.scrollBy(400.0f, 0.0f) | ||
val actualCameraPosition = mapboxMap.cameraPosition | ||
|
||
assertEquals("Camera position should match", expectedCameraPosition, actualCameraPosition) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters