-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes and updates related with API 35 source code.
- Loading branch information
Showing
6 changed files
with
99 additions
and
9 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
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
80 changes: 80 additions & 0 deletions
80
.../src/test/kotlin/com/datadog/android/sessionreplay/internal/utils/BitmapPoolHelperTest.kt
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,80 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.sessionreplay.internal.utils | ||
|
||
import android.graphics.Bitmap | ||
import com.datadog.android.sessionreplay.forge.ForgeConfigurator | ||
import com.datadog.android.sessionreplay.internal.recorder.resources.BitmapPoolHelper | ||
import fr.xgouchet.elmyr.Forge | ||
import fr.xgouchet.elmyr.annotation.IntForgery | ||
import fr.xgouchet.elmyr.junit5.ForgeConfiguration | ||
import fr.xgouchet.elmyr.junit5.ForgeExtension | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.junit.jupiter.api.extension.Extensions | ||
import org.mockito.Mock | ||
import org.mockito.junit.jupiter.MockitoExtension | ||
import org.mockito.junit.jupiter.MockitoSettings | ||
import org.mockito.kotlin.whenever | ||
import org.mockito.quality.Strictness | ||
|
||
@Extensions( | ||
ExtendWith(MockitoExtension::class), | ||
ExtendWith(ForgeExtension::class) | ||
) | ||
@MockitoSettings(strictness = Strictness.LENIENT) | ||
@ForgeConfiguration(ForgeConfigurator::class) | ||
internal class BitmapPoolHelperTest { | ||
|
||
lateinit var testedHelper: BitmapPoolHelper | ||
|
||
@Mock | ||
lateinit var mockBitmap: Bitmap | ||
|
||
@IntForgery | ||
var fakeWidth: Int = 0 | ||
|
||
@IntForgery | ||
var fakeHeight: Int = 0 | ||
private lateinit var fakeConfig: Bitmap.Config | ||
|
||
@BeforeEach | ||
fun `set up`(forge: Forge) { | ||
fakeConfig = forge.aValueFrom(Bitmap.Config::class.java) | ||
testedHelper = BitmapPoolHelper() | ||
whenever(mockBitmap.width).thenReturn(fakeWidth) | ||
whenever(mockBitmap.height).thenReturn(fakeHeight) | ||
whenever(mockBitmap.config).thenReturn(fakeConfig) | ||
} | ||
|
||
@Test | ||
fun `M generate bitmap key W generateKey`( | ||
forge: Forge | ||
) { | ||
// When | ||
val key = testedHelper.generateKey(mockBitmap) | ||
|
||
// Then | ||
assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-$fakeConfig") | ||
} | ||
|
||
@Test | ||
fun `M generate bitmap key W generateKey { config is null }`( | ||
forge: Forge | ||
) { | ||
// Given | ||
whenever(mockBitmap.config).thenReturn(null) | ||
|
||
// When | ||
val key = testedHelper.generateKey(mockBitmap) | ||
|
||
// Then | ||
assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-${null}") | ||
} | ||
} |