Merge "Fix crash in Monkey test." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d95668db99
@@ -91,6 +91,9 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateBatteryTips(List<BatteryTip> batteryTips) {
|
public void updateBatteryTips(List<BatteryTip> batteryTips) {
|
||||||
|
if (batteryTips == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mBatteryTips == null) {
|
if (mBatteryTips == null) {
|
||||||
mBatteryTips = batteryTips;
|
mBatteryTips = batteryTips;
|
||||||
} else {
|
} else {
|
||||||
@@ -100,7 +103,6 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO(b/70570352): try to reuse the existing preference rather than remove and add.
|
|
||||||
mPreferenceGroup.removeAll();
|
mPreferenceGroup.removeAll();
|
||||||
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
||||||
final BatteryTip batteryTip = mBatteryTips.get(i);
|
final BatteryTip batteryTip = mBatteryTips.get(i);
|
||||||
|
@@ -149,6 +149,19 @@ public class BatteryTipPreferenceControllerTest {
|
|||||||
assertOnlyContainsSummaryTip(mPreferenceGroup);
|
assertOnlyContainsSummaryTip(mPreferenceGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRestoreFromNull_shouldNotCrash() {
|
||||||
|
final Bundle bundle = new Bundle();
|
||||||
|
// Battery tip list is null at this time
|
||||||
|
mBatteryTipPreferenceController.saveInstanceState(bundle);
|
||||||
|
|
||||||
|
final BatteryTipPreferenceController controller = new BatteryTipPreferenceController(
|
||||||
|
mContext, KEY_PREF, mSettingsActivity, mFragment, mBatteryTipListener);
|
||||||
|
|
||||||
|
// Should not crash
|
||||||
|
controller.restoreInstanceState(bundle);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandlePreferenceTreeClick_noDialog_invokeCallback() {
|
public void testHandlePreferenceTreeClick_noDialog_invokeCallback() {
|
||||||
when(mBatteryTip.getType()).thenReturn(SMART_BATTERY_MANAGER);
|
when(mBatteryTip.getType()).thenReturn(SMART_BATTERY_MANAGER);
|
||||||
|
Reference in New Issue
Block a user