Skip to content

Commit

Permalink
Merge pull request #2371 from DataDog/jmoskovich/merge-2.15.1-to-develop
Browse files Browse the repository at this point in the history
Merge 2.15.1 into develop
  • Loading branch information
jonathanmos authored Nov 5, 2024
2 parents b1d6ebb + 4f1d03d commit aa999c9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.15.1 / 2024-11-04

* [MAINTENANCE] Fix `resolveResourceId` not correctly calling job finished when drawable cloning
failed [#2367](https://github.com/DataDog/dd-sdk-android/pull/2367)

# 2.15.0 / 2024-10-28

* [FEATURE] Add `TimeBank` in Session Replay recorder for dynamic optimisation See [#2247](https://github.com/DataDog/dd-sdk-android/pull/2247)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ internal class ResourceResolver(
return
}

val copiedDrawable = drawableCopier.copy(originalDrawable, resources) ?: return
val copiedDrawable = drawableCopier.copy(originalDrawable, resources)
if (copiedDrawable == null) {
resourceResolverCallback.onFailure()
return
}

val bitmapFromDrawable =
if (copiedDrawable is BitmapDrawable && shouldUseDrawableBitmap(copiedDrawable)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.kotlin.any
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
Expand Down Expand Up @@ -269,6 +270,32 @@ internal class ResourceResolverTest {
verify(mockSerializerCallback).onFailure()
}

@Test
fun `M call onFailure W copy bitmap return null`() {
// Given
whenever(
mockDrawableCopier.copy(
originalDrawable = mockDrawable,
resources = mockResources
)
).doReturn(null)

// When
testedResourceResolver.resolveResourceId(
resources = mockResources,
applicationContext = mockApplicationContext,
displayMetrics = mockDisplayMetrics,
originalDrawable = mockDrawable,
drawableCopier = mockDrawableCopier,
drawableWidth = mockDrawable.intrinsicWidth,
drawableHeight = mockDrawable.intrinsicHeight,
resourceResolverCallback = mockSerializerCallback
)

// Then
verify(mockSerializerCallback).onFailure()
}

@Test
fun `M calculate resourceId W resolveResourceId() { cache miss }`() {
// Given
Expand Down

0 comments on commit aa999c9

Please sign in to comment.