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] #4009 - add tests for tracking settings, optimise architect…
…ure to make it testable through unit tests
- Loading branch information
Showing
5 changed files
with
92 additions
and
62 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
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
53 changes: 53 additions & 0 deletions
53
...pboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java
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,53 @@ | ||
package com.mapbox.mapboxsdk.maps; | ||
|
||
import com.mapbox.mapboxsdk.constants.MyBearingTracking; | ||
import com.mapbox.mapboxsdk.constants.MyLocationTracking; | ||
|
||
import org.junit.Test; | ||
import org.mockito.InjectMocks; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class TrackingSettingsTest { | ||
|
||
@InjectMocks | ||
MapView mMapView = mock(MapView.class); | ||
|
||
@Test | ||
public void testSanity() { | ||
TrackingSettings trackingSettings = new TrackingSettings(mMapView, new UiSettings(mMapView)); | ||
assertNotNull("trackingsettings should not be null", trackingSettings); | ||
} | ||
|
||
@Test | ||
public void testMyLocationTrackingMode() { | ||
TrackingSettings trackingSettings = new TrackingSettings(mMapView, new UiSettings(mMapView)); | ||
trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); | ||
assertEquals("MyLocationTrackingMode should match", MyLocationTracking.TRACKING_FOLLOW, trackingSettings.getMyLocationTrackingMode()); | ||
} | ||
|
||
@Test | ||
public void testMyBearingTrackingMode() { | ||
TrackingSettings trackingSettings = new TrackingSettings(mMapView, new UiSettings(mMapView)); | ||
trackingSettings.setMyBearingTrackingMode(MyBearingTracking.COMPASS); | ||
assertEquals("MyLocationTrackingMode should match", MyBearingTracking.COMPASS, trackingSettings.getMyBearingTrackingMode()); | ||
} | ||
|
||
@Test | ||
public void testDismissTrackingModesOnGesture() { | ||
TrackingSettings trackingSettings = new TrackingSettings(mMapView, new UiSettings(mMapView)); | ||
trackingSettings.setDismissTrackingOnGesture(false); | ||
assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture()); | ||
} | ||
|
||
@Test | ||
public void testValidateGesturesForTrackingModes(){ | ||
TrackingSettings trackingSettings = new TrackingSettings(mMapView, new UiSettings(mMapView)); | ||
trackingSettings.setDismissTrackingOnGesture(false); | ||
trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); | ||
assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isDismissTrackingOnGesture()); | ||
} | ||
} |
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