Merge "Fix NPE in accountPrefController"

This commit is contained in:
TreeHugger Robot
2017-01-10 22:17:40 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 1 deletions

View File

@@ -189,6 +189,24 @@ public class AccountPreferenceControllerTest {
verify(mScreen, times(2)).removePreference(preferenceGroup);
}
@Test
@Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_noPreferenceScreen_shouldNotCrash() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.isLinkedUser()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
AccessiblePreferenceCategory preferenceGroup = mock(AccessiblePreferenceCategory.class);
when(mAccountHelper.createAccessiblePreferenceCategory(any(Context.class))).thenReturn(
preferenceGroup);
mController.onResume();
// Should not crash
}
@Test
public void updateRawDataToIndex_ManagedProfile_shouldNotUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();