Skip to content

Commit df1f7a6

Browse files
antonisclaude
andcommitted
fix(test): Make partial overlap test actually clip the delay interval
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1a28507 commit df1f7a6

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

sentry-android-core/src/test/java/io/sentry/android/core/internal/util/SentryFrameMetricsCollectorTest.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,18 @@ class SentryFrameMetricsCollectorTest {
676676
val choreographer = collector.getProperty<Choreographer>("choreographer")
677677
choreographer.injectForField("mLastFrameTimeNanos", TimeUnit.SECONDS.toNanos(5))
678678

679-
// query a range that only partially overlaps the frozen frame
680-
// the frame starts around 50ns (INTENDED_VSYNC_TIMESTAMP), so querying from a later point
681-
// should reduce the delay proportionally
682-
val result = collector.getFramesDelay(0, TimeUnit.SECONDS.toNanos(5))
683-
assertTrue(result.delaySeconds > 0)
684-
assertEquals(1, result.framesContributingToDelayCount)
679+
// The frame's delay interval is roughly [~16ms, ~1000ms].
680+
// Query from 500ms so the range clips the delay interval in half.
681+
val queryStart = TimeUnit.MILLISECONDS.toNanos(500)
682+
val queryEnd = TimeUnit.SECONDS.toNanos(5)
683+
684+
val fullResult = collector.getFramesDelay(0, queryEnd)
685+
val partialResult = collector.getFramesDelay(queryStart, queryEnd)
686+
687+
// partial overlap should yield less delay than the full range
688+
assertTrue(partialResult.delaySeconds > 0)
689+
assertTrue(partialResult.delaySeconds < fullResult.delaySeconds)
690+
assertEquals(1, partialResult.framesContributingToDelayCount)
685691
}
686692

687693
@Test

0 commit comments

Comments
 (0)