|
14 | 14 | import com.mapbox.mapboxsdk.annotations.PolygonOptions;
|
15 | 15 | import com.mapbox.mapboxsdk.annotations.Polyline;
|
16 | 16 | import com.mapbox.mapboxsdk.annotations.PolylineOptions;
|
| 17 | +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; |
17 | 18 | import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
18 | 19 | import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException;
|
19 | 20 | import com.mapbox.mapboxsdk.geometry.LatLng;
|
|
31 | 32 | import java.util.ArrayList;
|
32 | 33 | import java.util.List;
|
33 | 34 |
|
| 35 | +import timber.log.Timber; |
| 36 | + |
34 | 37 | import static android.support.test.espresso.Espresso.onView;
|
35 | 38 | import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
36 | 39 | import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
| 40 | +import static com.mapbox.mapboxsdk.testapp.utils.TestConstants.LAT_LNG_DELTA; |
37 | 41 | import static junit.framework.TestCase.assertFalse;
|
38 | 42 | import static junit.framework.TestCase.assertNotNull;
|
39 | 43 | import static org.junit.Assert.assertEquals;
|
@@ -90,8 +94,33 @@ public void onViewAction(UiController uiController, View view) {
|
90 | 94 | }
|
91 | 95 |
|
92 | 96 | //
|
93 |
| - // CameraForLatLngBounds |
| 97 | + // Camera tests |
94 | 98 | //
|
| 99 | + @Test |
| 100 | + public void testCameraPositionOnFinish() { |
| 101 | + ViewUtils.checkViewIsDisplayed(R.id.mapView); |
| 102 | + onView(withId(R.id.mapView)).perform(new MapboxMapAction(new InvokeViewAction() { |
| 103 | + @Override |
| 104 | + public void onViewAction(UiController uiController, View view) { |
| 105 | + |
| 106 | + final LatLng latLng = new LatLng(30.0, 30.0); |
| 107 | + mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(latLng), new MapboxMap.CancelableCallback() { |
| 108 | + @Override |
| 109 | + public void onCancel() { |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + public void onFinish() { |
| 114 | + LatLng cameraPositionLatLng = mapboxMap.getCameraPosition().target; |
| 115 | + Timber.d(cameraPositionLatLng.toString()); |
| 116 | + assertEquals(cameraPositionLatLng.getLatitude(), latLng.getLatitude(), LAT_LNG_DELTA); |
| 117 | + assertEquals(cameraPositionLatLng.getLongitude(), latLng.getLongitude(), LAT_LNG_DELTA); |
| 118 | + } |
| 119 | + }); |
| 120 | + } |
| 121 | + })); |
| 122 | + } |
| 123 | + |
95 | 124 | @Test
|
96 | 125 | public void testCameraForLatLngBounds() {
|
97 | 126 | ViewUtils.checkViewIsDisplayed(R.id.mapView);
|
|
0 commit comments