Skip to content

Commit

Permalink
Merge branch 'main' into feat/pickup-bundle-id-and-send-with-event
Browse files Browse the repository at this point in the history
  • Loading branch information
adinauer authored May 12, 2023
2 parents e98afc3 + 5a573d4 commit 0e8f2a6
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,32 @@ class EnvelopeTests : BaseUiTest() {
val maxTimestampAllowed = profilingTraceData.durationNs.toLong() + TimeUnit.SECONDS.toNanos(2)
val allMeasurements = profilingTraceData.measurementsMap.values

allMeasurements.filter { it.values.isNotEmpty() }.forEach { measurement ->
profilingTraceData.measurementsMap.entries.filter {
it.value.values.isNotEmpty()
}.forEach { entry ->
val name = entry.key
val measurement = entry.value

val values = measurement.values.sortedBy { it.relativeStartNs.toLong() }
// There should be no measurement before the profile starts
assertTrue(values.first().relativeStartNs.toLong() > 0)
assertTrue(
values.first().relativeStartNs.toLong() > 0,
"First measurement value for '$name' is <=0"
)
// There should be no measurement after the profile ends
assertTrue(values.last().relativeStartNs.toLong() < maxTimestampAllowed)
assertTrue(
values.last().relativeStartNs.toLong() < maxTimestampAllowed,
"Last measurement value for '$name' is outside bounds (was: ${values.last().relativeStartNs.toLong()}ns, max: ${maxTimestampAllowed}ns"
)

// Timestamps of measurements should differ at least 10 milliseconds from each other
(1 until values.size).forEach { i ->
assertTrue(values[i].relativeStartNs.toLong() > values[i - 1].relativeStartNs.toLong() + TimeUnit.MILLISECONDS.toNanos(10))
assertTrue(
values[i].relativeStartNs.toLong() > values[i - 1].relativeStartNs.toLong() + TimeUnit.MILLISECONDS.toNanos(
10
),
"Measurement value timestamp for '$name' does not differ at least 10ms"
)
}
}

Expand Down

0 comments on commit 0e8f2a6

Please sign in to comment.