Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Langston Smith committed Aug 2, 2019
1 parent 7a92fe2 commit ca202fc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ public LocationComponentOptions build() {

if (locationComponentOptions.layerAbove() != null && locationComponentOptions.layerBelow() != null) {
throw new IllegalArgumentException("You cannot set both layerAbove and layerBelow options."
+ "Choose one or the other.");
+ " Choose one or the other.");
}

if (locationComponentOptions.pulseEnabled() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class LocationAnimatorCoordinatorTest {
val context: Context = mockk(relaxed = true)

locationComponentOptions = LocationComponentOptions.builder(context)
.pulsingCircleEnabled(true)
.build()

locationAnimatorCoordinator = LocationAnimatorCoordinator(projection,
Expand All @@ -58,8 +57,7 @@ class LocationAnimatorCoordinatorTest {
ANIMATOR_CAMERA_COMPASS_BEARING,
ANIMATOR_LAYER_ACCURACY,
ANIMATOR_ZOOM,
ANIMATOR_TILT,
ANIMATOR_PULSING_CIRCLE
ANIMATOR_TILT
))
}

Expand Down Expand Up @@ -357,12 +355,6 @@ class LocationAnimatorCoordinatorTest {
assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_TILT] != null)
}

@Test
fun startPulsingCircle_animatorCreated() {
locationAnimatorCoordinator.startLocationComponentCirclePulsing(locationComponentOptions)
assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_PULSING_CIRCLE] != null)
}

@Test
fun feedNewTiltLevel_animatorValue() {
val tilt = 30.0f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.support.annotation.NonNull;

import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.location.modes.PulseMode;
import com.mapbox.mapboxsdk.maps.Style;

import org.junit.Before;
Expand Down Expand Up @@ -66,6 +68,44 @@ public void sanity() throws Exception {
assertNotNull(locationComponentActivationOptions);
}

@Test
public void sanityWithDefaultPulsingCircle() throws Exception {
when(style.isFullyLoaded()).thenReturn(true);

LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
.accuracyAlpha(0.5f)
.pulsingCircleEnabled(true)
.build();
assertNotNull(locationComponentOptions);

LocationComponentActivationOptions locationComponentActivationOptions =
LocationComponentActivationOptions.builder(context, style)
.locationComponentOptions(locationComponentOptions)
.useDefaultLocationEngine(true)
.build();
assertNotNull(locationComponentActivationOptions);
}

@Test
public void sanityWithCustomizedPulsingCircle() throws Exception {
when(style.isFullyLoaded()).thenReturn(true);

LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
.accuracyAlpha(0.5f)
.pulsingCircleEnabled(true)
.pulsingCircleColor(Color.RED)
.pulsingCircleInterpolator(PulseMode.LINEAR)
.build();
assertNotNull(locationComponentOptions);

LocationComponentActivationOptions locationComponentActivationOptions =
LocationComponentActivationOptions.builder(context, style)
.locationComponentOptions(locationComponentOptions)
.useDefaultLocationEngine(true)
.build();
assertNotNull(locationComponentActivationOptions);
}

@Test
public void includingBothStyleResAndComponentOptions_causesExceptionToBeThrown() throws Exception {

Expand Down

0 comments on commit ca202fc

Please sign in to comment.