Skip to content

Commit

Permalink
Merge pull request #1743 from DataDog/xgouchet/flaky/wireframe
Browse files Browse the repository at this point in the history
RUM-2259 Fix flaky test in WireframeUtils
  • Loading branch information
xgouchet authored Nov 30, 2023
2 parents be90fc0 + c1b0d1b commit f22729c
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ internal class WireframeUtilsTest {
forge.getForgery<MobileSegment.Wireframe>().apply {
whenever(mockBoundsUtils.resolveBounds(this)).thenReturn(fakeParentBounds)
}
val fakExpectedClip = MobileSegment.WireframeClip(
top = fakeExpectedClipTop.longOrNull(),
bottom = fakeExpectedClipBottom.longOrNull(),
right = fakeExpectedClipRight.longOrNull(),
left = fakeExpectedClipLeft.longOrNull()
val fakeExpectedClip = MobileSegment.WireframeClip(
top = fakeExpectedClipTop,
bottom = fakeExpectedClipBottom,
right = fakeExpectedClipRight,
left = fakeExpectedClipLeft
)

val fakeRandomParents: List<MobileSegment.Wireframe> = forge.aList {
Expand All @@ -88,9 +88,11 @@ internal class WireframeUtilsTest {
add(randomIndex, fakeParentWireframe)
}

// When
val resultClip = testedWireframeUtils.resolveWireframeClip(fakeWireframe, fakeParents)

// Then
assertThat(testedWireframeUtils.resolveWireframeClip(fakeWireframe, fakeParents))
.isEqualTo(fakExpectedClip)
assertThat(resultClip).isEqualTo(fakeExpectedClip)
}

@Test
Expand Down Expand Up @@ -659,14 +661,6 @@ internal class WireframeUtilsTest {
)
}

private fun Long.longOrNull(): Long? {
return if (this == 0L) {
null
} else {
this
}
}

private fun Long?.toLong(): Long {
return this ?: 0L
}
Expand Down

0 comments on commit f22729c

Please sign in to comment.