@@ -120,15 +120,15 @@ class FatalIssueReporterProcessorTest {
120
120
121
121
@Test
122
122
fun persistAppExitReport_whenUserPerceivedAnr_shouldMatchAnrReason () {
123
- assertAnrReason (
123
+ assertAnrContents (
124
124
descriptionFromAppExit = " Input Dispatching Timed Out" ,
125
125
expectedMessage = " User Perceived ANR" ,
126
126
)
127
127
}
128
128
129
129
@Test
130
130
fun persistAppExitReport_whenBroadcastReceiverAnr_shouldMatchAnrReason () {
131
- assertAnrReason (
131
+ assertAnrContents (
132
132
descriptionFromAppExit =
133
133
" Broadcast of Intent { act=android.intent.action.MAIN " +
134
134
" cmp=com.example.app/.MainActivity}" ,
@@ -138,7 +138,7 @@ class FatalIssueReporterProcessorTest {
138
138
139
139
@Test
140
140
fun persistAppExitReport_whenExecutingServiceAnr_shouldMatchAnrReason () {
141
- assertAnrReason (
141
+ assertAnrContents (
142
142
descriptionFromAppExit =
143
143
" Executing service. { act=android.intent.action.MAIN \" +\n " +
144
144
" \" cmp=com.example.app/.MainActivity}" ,
@@ -148,71 +148,71 @@ class FatalIssueReporterProcessorTest {
148
148
149
149
@Test
150
150
fun persistAppExitReport_whenStartServiceForegroundAnr_shouldMatchAnrReason () {
151
- assertAnrReason (
151
+ assertAnrContents (
152
152
descriptionFromAppExit = " Service.StartForeground() not called.{ act=android.intent.action.MAIN}" ,
153
153
expectedMessage = " Service.startForeground() Not Called ANR" ,
154
154
)
155
155
}
156
156
157
157
@Test
158
158
fun persistAppExitReport_whenContentProviderTimeoutAnr_shouldMatchAnrReason () {
159
- assertAnrReason (
159
+ assertAnrContents (
160
160
descriptionFromAppExit = " My Application. Content Provider Timeout" ,
161
161
expectedMessage = " Content Provider ANR" ,
162
162
)
163
163
}
164
164
165
165
@Test
166
166
fun persistAppExitReport_whenAppRegisteredTimeoutAnr_shouldMatchAnrReason () {
167
- assertAnrReason (
167
+ assertAnrContents (
168
168
descriptionFromAppExit = " My Application. App Registered Timeout" ,
169
169
expectedMessage = " App Registered ANR" ,
170
170
)
171
171
}
172
172
173
173
@Test
174
174
fun persistAppExitReport_whenShortFgsTimeoutAnr_shouldMatchAnrReason () {
175
- assertAnrReason (
175
+ assertAnrContents (
176
176
descriptionFromAppExit = " Foreground service ANR. Short FGS Timeout. Duration=5000ms" ,
177
177
expectedMessage = " Short Foreground Service Timeout ANR" ,
178
178
)
179
179
}
180
180
181
181
@Test
182
182
fun persistAppExitReport_whenSystemJobServiceTimeoutAnr_shouldMatchAnrReason () {
183
- assertAnrReason (
183
+ assertAnrContents (
184
184
descriptionFromAppExit = " SystemJobService. Job Service Timeout" ,
185
185
expectedMessage = " Job Service ANR" ,
186
186
)
187
187
}
188
188
189
189
@Test
190
190
fun persistAppExitReport_whenAppStartupTimeOut_shouldMatchAnrReason () {
191
- assertAnrReason (
191
+ assertAnrContents (
192
192
descriptionFromAppExit = " App start timeout. Timeout=5000ms" ,
193
193
expectedMessage = " App Start ANR" ,
194
194
)
195
195
}
196
196
197
197
@Test
198
198
fun persistAppExitReport_whenServiceStartTimeout_shouldMatchAnrReason () {
199
- assertAnrReason (
199
+ assertAnrContents (
200
200
descriptionFromAppExit = " Service start timeout. Timeout=5000ms" ,
201
201
expectedMessage = " Service Start ANR" ,
202
202
)
203
203
}
204
204
205
205
@Test
206
206
fun persistAppExitReport_whenBackgroundAnr_shouldMatchAnrReason () {
207
- assertAnrReason (
207
+ assertAnrContents (
208
208
descriptionFromAppExit = " It's full moon ANR" ,
209
209
expectedMessage = " Undetermined ANR" ,
210
210
)
211
211
}
212
212
213
213
@Test
214
214
fun persistAppExitReport_whenGenericAnrTimeout_shouldMatchAnrReason () {
215
- assertAnrReason (
215
+ assertAnrContents (
216
216
descriptionFromAppExit =
217
217
" bg anr: Process " +
218
218
" ProcessRecord{9707291 4609:io.bitdrift.gradletestapp/u0a207} " +
@@ -259,7 +259,7 @@ class FatalIssueReporterProcessorTest {
259
259
.persistFatalIssue(any(), any(), any())
260
260
}
261
261
262
- private fun assertAnrReason (
262
+ private fun assertAnrContents (
263
263
descriptionFromAppExit : String ,
264
264
expectedMessage : String ,
265
265
) {
@@ -279,6 +279,12 @@ class FatalIssueReporterProcessorTest {
279
279
assertThat(report.errors(0 )).isNotNull
280
280
report.errors(0 )?.let { error ->
281
281
assertThat(error.name).isEqualTo(expectedMessage)
282
+ val frame = error.stackTrace(0 )
283
+ assertThat(frame).isNotNull
284
+ assertThat(frame!! .sourceFile!! .line).isEqualTo(106 )
285
+ assertThat(frame.sourceFile!! .path).isEqualTo(" FatalIssueGenerator.kt" )
286
+ assertThat(frame.symbolName).isEqualTo(" startProcessing" )
287
+ assertThat(frame.className).isEqualTo(" io.bitdrift.capture.FatalIssueGenerator" )
282
288
}
283
289
}
284
290
0 commit comments