Merge "Add NPE check for battery header update."

This commit is contained in:
Lei Yu
2017-02-27 17:56:24 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 2 deletions

View File

@@ -362,6 +362,14 @@ public class PowerUsageSummaryTest {
verify(mSummary1).setText(R.string.estimated_time_left);
}
@Test
public void testUpdateHeaderPreference_AsyncUpdate_ShouldNotCrash() {
when(mPowerUsageSummary.getContext()).thenReturn(null);
mBatteryInfo.remainingTimeUs = REMAINING_TIME_US;
//Should not crash
mPowerUsageSummary.updateHeaderPreference(mBatteryInfo);
}
private void testToggleAllApps(final boolean isShowApps) {
mFragment.mShowAllApps = isShowApps;