2323import static org .mockito .Mockito .mock ;
2424import static org .mockito .Mockito .when ;
2525
26+ import android .annotation .SuppressLint ;
2627import android .content .Context ;
2728import android .content .Intent ;
2829import android .os .BatteryManager ;
2930import com .google .firebase .crashlytics .internal .CrashlyticsTestCase ;
3031import org .junit .Test ;
3132
33+ @ SuppressLint ("UnspecifiedRegisterReceiverFlag" )
3234public class BatteryStateTest extends CrashlyticsTestCase {
3335 // Tolerance for float comparisons.
3436 static final float EPSILON = 0.0001f ;
@@ -44,8 +46,7 @@ private Intent makeIntent(int status, int level, int scale) {
4446 @ Test
4547 public void testGetBatteryLevel () {
4648 Context mockContext = mock (Context .class );
47- when (mockContext .registerReceiver (isNull (), any (), Context .RECEIVER_EXPORTED ))
48- .thenReturn (makeIntent (0 , 50 , 200 ));
49+ when (mockContext .registerReceiver (isNull (), any ())).thenReturn (makeIntent (0 , 50 , 200 ));
4950
5051 BatteryState state = BatteryState .get (mockContext );
5152
@@ -57,7 +58,7 @@ public void testGetBatteryLevel() {
5758 @ Test
5859 public void testNullIntent () {
5960 final Context mockContext = mock (Context .class );
60- when (mockContext .registerReceiver (isNull (), any (), Context . RECEIVER_EXPORTED )).thenReturn (null );
61+ when (mockContext .registerReceiver (isNull (), any ())).thenReturn (null );
6162
6263 BatteryState state = BatteryState .get (mockContext );
6364
@@ -69,7 +70,7 @@ public void testNullIntent() {
6970 @ Test
7071 public void testTooManyReceivers () {
7172 Context mockContext = mock (Context .class );
72- when (mockContext .registerReceiver (isNull (), any (), Context . RECEIVER_EXPORTED ))
73+ when (mockContext .registerReceiver (isNull (), any ()))
7374 .thenThrow (new IllegalStateException ("Too many receivers" ));
7475
7576 BatteryState state = BatteryState .get (mockContext );
@@ -82,8 +83,7 @@ public void testTooManyReceivers() {
8283 @ Test
8384 public void testEmptyIntent () {
8485 final Context mockContext = mock (Context .class );
85- when (mockContext .registerReceiver (isNull (), any (), Context .RECEIVER_EXPORTED ))
86- .thenReturn (new Intent ());
86+ when (mockContext .registerReceiver (isNull (), any ())).thenReturn (new Intent ());
8787
8888 BatteryState state = BatteryState .get (mockContext );
8989
@@ -94,8 +94,7 @@ public void testEmptyIntent() {
9494
9595 private void doVelocityTest (int velocity , Intent intent ) {
9696 final Context mockContext = mock (Context .class );
97- when (mockContext .registerReceiver (isNull (), any (), Context .RECEIVER_EXPORTED ))
98- .thenReturn (intent );
97+ when (mockContext .registerReceiver (isNull (), any ())).thenReturn (intent );
9998 BatteryState state = BatteryState .get (mockContext );
10099 assertEquals (velocity , state .getBatteryVelocity ());
101100 }
0 commit comments