Merge "Check instance before casting"

This commit is contained in:
TreeHugger Robot
2018-10-02 23:41:35 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 2 deletions

View File

@@ -94,4 +94,22 @@ public class SpecialAppAccessPreferenceControllerTest {
.isEqualTo(mContext.getResources().getQuantityString(
R.plurals.special_access_summary, 1, 1));
}
@Test
public void updateState_wrongExtraInfo_shouldNotIncludeInSummary() {
final ArrayList<ApplicationsState.AppEntry> apps = new ArrayList<>();
final ApplicationsState.AppEntry entry = mock(ApplicationsState.AppEntry.class);
entry.hasLauncherEntry = true;
entry.info = new ApplicationInfo();
entry.extraInfo = new AppStateNotificationBridge.NotificationsSentState();
apps.add(entry);
when(mSession.getAllApps()).thenReturn(apps);
mController.displayPreference(mScreen);
mController.onExtraInfoUpdated();
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getResources().getQuantityString(
R.plurals.special_access_summary, 0, 0));
}
}