Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void setEnabled(boolean enabled) {
scaleBarWidget.setVisibility(enabled ? View.VISIBLE : View.GONE);
if (enabled) {
mapboxMap.addOnCameraMoveListener(cameraMoveListener);
invalidateScaleBar();
} else {
mapboxMap.removeOnCameraMoveListener(cameraMoveListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Projection
import io.mockk.MockKAnnotations
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.verify
Expand Down Expand Up @@ -102,4 +101,17 @@ class ScaleBarPluginTest {
verify { scaleBarWidget.visibility = View.VISIBLE }
verify(exactly = 1) { mapboxMap.addOnCameraMoveListener(scaleBarPlugin.cameraMoveListener) }
}

@Test
fun toggled_invalidateWidget() {
val scaleBarPlugin = ScaleBarPlugin(mapView, mapboxMap)
scaleBarPlugin.create(scaleBarOptions)
verify(exactly = 1) { mapboxMap.cameraPosition }
verify(exactly = 1) { scaleBarWidget.setDistancePerPixel(100_000.0) }
scaleBarPlugin.isEnabled = false
scaleBarPlugin.isEnabled = true

verify(exactly = 2) { mapboxMap.cameraPosition }
verify(exactly = 2) { scaleBarWidget.setDistancePerPixel(100_000.0) }
}
}