Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kiryldz committed Jul 5, 2021
1 parent 93f1f14 commit 5e4b83a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal class CameraAnimationsPluginImpl : CameraAnimationsPlugin {

private val lifecycleListeners = CopyOnWriteArraySet<CameraAnimationsLifecycleListener>()

override var debugMode: Boolean = true
override var debugMode: Boolean = false

private var center by Delegates.observable<Point?>(null) { _, old, new ->
new?.let {
Expand Down Expand Up @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@
@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);
}

@Implementation
public static void d(@Nullable String tag, @NonNull String message) {
logCount++;
Log.d(message, tag);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5e4b83a

Please sign in to comment.