Skip to content

Commit fcce060

Browse files
committed
Adding mocks for PackageManager.
1 parent dbd831e commit fcce060

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/internal/common

firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/internal/common/CommonUtilsTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public void testGetTotalRamInBytes() {
152152
@Test
153153
public void testIsRooted() {
154154
final Context mockContext = mock(Context.class);
155+
when(mockContext.getPackageManager()).thenReturn(mock(PackageManager.class));
155156
// No good way to test the alternate case,
156157
// just want to ensure we can complete the call without an exception here.
157158
final boolean isRooted = CommonUtils.isRooted(mockContext);
@@ -178,6 +179,8 @@ private boolean isBitSet(int data, int mask) {
178179
public void testGetDeviceState() {
179180

180181
final Context mockContext = mock(Context.class);
182+
when(mockContext.getPackageManager()).thenReturn(mock(PackageManager.class));
183+
181184
final int state = CommonUtils.getDeviceState(mockContext);
182185
Log.d(Logger.TAG, "testGetDeviceState: state=" + state);
183186

0 commit comments

Comments
 (0)