Skip to content

Commit 12a6347

Browse files
committed
Fix tests
1 parent c648064 commit 12a6347

File tree

1 file changed

+0
-77
lines changed

1 file changed

+0
-77
lines changed

sentry-android-core/src/test/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegrationTest.kt

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -219,83 +219,6 @@ class SystemEventsBreadcrumbsIntegrationTest {
219219
verifyNoMoreInteractions(fixture.scopes)
220220
}
221221

222-
@Test
223-
fun `battery changes with identical values do not generate breadcrumbs`() {
224-
val sut = fixture.getSut()
225-
sut.register(fixture.scopes, fixture.options)
226-
227-
val intent1 =
228-
Intent().apply {
229-
action = Intent.ACTION_BATTERY_CHANGED
230-
putExtra(BatteryManager.EXTRA_LEVEL, 80)
231-
putExtra(BatteryManager.EXTRA_SCALE, 100)
232-
putExtra(BatteryManager.EXTRA_PLUGGED, BatteryManager.BATTERY_PLUGGED_USB)
233-
}
234-
val intent2 =
235-
Intent().apply {
236-
action = Intent.ACTION_BATTERY_CHANGED
237-
putExtra(BatteryManager.EXTRA_LEVEL, 80)
238-
putExtra(BatteryManager.EXTRA_SCALE, 100)
239-
putExtra(BatteryManager.EXTRA_PLUGGED, BatteryManager.BATTERY_PLUGGED_USB)
240-
}
241-
242-
// Receive first battery change
243-
sut.receiver!!.onReceive(fixture.context, intent1)
244-
245-
// Receive second battery change with identical values
246-
sut.receiver!!.onReceive(fixture.context, intent2)
247-
248-
// should only add the first crumb since values are identical
249-
verify(fixture.scopes)
250-
.addBreadcrumb(
251-
check<Breadcrumb> {
252-
assertEquals(it.data["level"], 80f)
253-
assertEquals(it.data["charging"], true)
254-
},
255-
anyOrNull(),
256-
)
257-
verifyNoMoreInteractions(fixture.scopes)
258-
}
259-
260-
@Test
261-
fun `battery changes with minor level differences do not generate breadcrumbs`() {
262-
val sut = fixture.getSut()
263-
sut.register(fixture.scopes, fixture.options)
264-
265-
val intent1 =
266-
Intent().apply {
267-
action = Intent.ACTION_BATTERY_CHANGED
268-
putExtra(BatteryManager.EXTRA_LEVEL, 80001) // 80.001%
269-
putExtra(BatteryManager.EXTRA_SCALE, 100000)
270-
putExtra(BatteryManager.EXTRA_PLUGGED, BatteryManager.BATTERY_PLUGGED_USB)
271-
}
272-
val intent2 =
273-
Intent().apply {
274-
action = Intent.ACTION_BATTERY_CHANGED
275-
putExtra(BatteryManager.EXTRA_LEVEL, 80002) // 80.002%
276-
putExtra(BatteryManager.EXTRA_SCALE, 100000)
277-
putExtra(BatteryManager.EXTRA_PLUGGED, BatteryManager.BATTERY_PLUGGED_USB)
278-
}
279-
280-
// Receive first battery change
281-
sut.receiver!!.onReceive(fixture.context, intent1)
282-
283-
// Receive second battery change with very minor level difference (rounds to same 3 decimal
284-
// places)
285-
sut.receiver!!.onReceive(fixture.context, intent2)
286-
287-
// should only add the first crumb since both round to 80.000%
288-
verify(fixture.scopes)
289-
.addBreadcrumb(
290-
check<Breadcrumb> {
291-
assertEquals(it.data["level"], 80.001f)
292-
assertEquals(it.data["charging"], true)
293-
},
294-
anyOrNull(),
295-
)
296-
verifyNoMoreInteractions(fixture.scopes)
297-
}
298-
299222
@Test
300223
fun `battery changes with identical values do not generate breadcrumbs`() {
301224
val sut = fixture.getSut()

0 commit comments

Comments
 (0)