From 5e4b83a9afe28a597ceb23e57d560dacb5781566 Mon Sep 17 00:00:00 2001 From: Kiryl Dzehtsiarenka Date: Mon, 5 Jul 2021 11:35:15 +0300 Subject: [PATCH] PR fixes --- .../animation/CameraAnimationsPluginImpl.kt | 4 ++-- .../java/com/mapbox/common/ShadowLogger.java | 3 --- .../CameraAnimationsPluginImplTest.kt | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/plugin-animation/src/main/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImpl.kt b/plugin-animation/src/main/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImpl.kt index 47f4f4b630..0541b79ed3 100644 --- a/plugin-animation/src/main/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImpl.kt +++ b/plugin-animation/src/main/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImpl.kt @@ -57,7 +57,7 @@ internal class CameraAnimationsPluginImpl : CameraAnimationsPlugin { private val lifecycleListeners = CopyOnWriteArraySet() - override var debugMode: Boolean = true + override var debugMode: Boolean = false private var center by Delegates.observable(null) { _, old, new -> new?.let { @@ -809,7 +809,7 @@ internal class CameraAnimationsPluginImpl : CameraAnimationsPlugin { * Static variables and methods. */ companion object { - private const val TAG = "Mbgl-CameraManager" + internal const val TAG = "Mbgl-CameraManager" } } diff --git a/plugin-animation/src/test/java/com/mapbox/common/ShadowLogger.java b/plugin-animation/src/test/java/com/mapbox/common/ShadowLogger.java index 6ce103a682..65e1acc120 100644 --- a/plugin-animation/src/test/java/com/mapbox/common/ShadowLogger.java +++ b/plugin-animation/src/test/java/com/mapbox/common/ShadowLogger.java @@ -11,8 +11,6 @@ @Implements(Logger.class) public class ShadowLogger { - public static int logCount = 0; - @Implementation public static void e(@Nullable String tag, @NonNull String message) { Log.e(message, tag); @@ -20,7 +18,6 @@ public static void e(@Nullable String tag, @NonNull String message) { @Implementation public static void d(@Nullable String tag, @NonNull String message) { - logCount++; Log.d(message, tag); } diff --git a/plugin-animation/src/test/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImplTest.kt b/plugin-animation/src/test/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImplTest.kt index 9b5709668f..0c3756bfd0 100644 --- a/plugin-animation/src/test/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImplTest.kt +++ b/plugin-animation/src/test/java/com/mapbox/maps/plugin/animation/CameraAnimationsPluginImplTest.kt @@ -13,6 +13,7 @@ import com.mapbox.maps.CameraOptions import com.mapbox.maps.CameraState import com.mapbox.maps.EdgeInsets import com.mapbox.maps.ScreenCoordinate +import com.mapbox.maps.plugin.animation.CameraAnimationsPluginImpl.Companion.TAG import com.mapbox.maps.plugin.animation.CameraAnimatorOptions.Companion.cameraAnimatorOptions import com.mapbox.maps.plugin.animation.MapAnimationOptions.Companion.mapAnimationOptions import com.mapbox.maps.plugin.animation.animator.CameraBearingAnimator @@ -49,7 +50,6 @@ class CameraAnimationsPluginImplTest { @Before fun setUp() { ShadowLog.stream = System.out - ShadowLogger.logCount = 0 cameraAnimatorsFactory = mockk(relaxed = true) bearingAnimator = mockk(relaxed = true) centerAnimator = mockk(relaxed = true) @@ -964,18 +964,25 @@ class CameraAnimationsPluginImplTest { } @Test - fun debugModeTest() { - // debug mode is enabled by default for backward compatibility + fun debugModeTrueTest() { + mockkStatic(ShadowLogger::class) + cameraAnimationsPluginImpl.debugMode = true shadowOf(getMainLooper()).pause() cameraAnimationsPluginImpl.easeTo(cameraOptions, mapAnimationOptions { duration(DURATION) }) shadowOf(getMainLooper()).idle() - assertNotEquals(0, ShadowLogger.logCount) - ShadowLogger.logCount = 0 + verify { ShadowLogger.d(TAG, any()) } + unmockkStatic(ShadowLogger::class) + } + + @Test + fun debugModeFalseTest() { + mockkStatic(ShadowLogger::class) cameraAnimationsPluginImpl.debugMode = false shadowOf(getMainLooper()).pause() cameraAnimationsPluginImpl.easeTo(cameraOptions, mapAnimationOptions { duration(DURATION) }) shadowOf(getMainLooper()).idle() - assertEquals(0, ShadowLogger.logCount) + verify(exactly = 0) { ShadowLogger.d(TAG, any()) } + unmockkStatic(ShadowLogger::class) } class LifecycleListener : CameraAnimationsLifecycleListener {