-
Notifications
You must be signed in to change notification settings - Fork 7
/
AnrSampleTest.kt
40 lines (34 loc) · 1.21 KB
/
AnrSampleTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package io.embrace.android.embracesdk
import com.squareup.moshi.JsonDataException
import io.embrace.android.embracesdk.payload.AnrSample
import io.embrace.android.embracesdk.payload.ThreadInfo
import org.junit.Assert.assertEquals
import org.junit.Test
internal class AnrSampleTest {
private val threadInfo = ThreadInfo(
13,
Thread.State.RUNNABLE,
"my-thread",
5,
listOf(
"java.base/java.lang.Thread.getStackTrace(Thread.java:1602)",
"io.embrace.android.embracesdk.ThreadInfoTest.testThreadInfoSerialization(ThreadInfoTest.kt:18)"
)
)
@Test
fun testAnrTickSerialization() {
val obj = AnrSample(156098234092, listOf(threadInfo), 2)
assertJsonMatchesGoldenFile("anr_tick_expected.json", obj)
}
@Test
fun testAnrTickDeserialization() {
val obj = deserializeJsonFromResource<AnrSample>("anr_tick_expected.json")
assertEquals(2L, obj.sampleOverheadMs)
assertEquals(156098234092, obj.timestamp)
assertEquals(listOf(threadInfo), obj.threads)
}
@Test(expected = JsonDataException::class)
fun testThreadInfoEmptyObject() {
deserializeEmptyJsonString<AnrSample>()
}
}