Merge "Fix robolectric error"
This commit is contained in:
@@ -201,7 +201,8 @@ public class BatteryFixSlice implements CustomSliceable {
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private static List<BatteryTip> refreshBatteryTips(Context context) {
|
||||
@VisibleForTesting
|
||||
static List<BatteryTip> refreshBatteryTips(Context context) {
|
||||
final BatteryStatsHelperLoader statsLoader = new BatteryStatsHelperLoader(context);
|
||||
final BatteryStatsHelper statsHelper = statsLoader.loadInBackground();
|
||||
final BatteryTipLoader loader = new BatteryTipLoader(context, statsHelper);
|
||||
|
@@ -81,13 +81,13 @@ public class BatteryFixSliceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBatteryTipAvailabilityCache_hasImportantTip_shouldReturnTrue() {
|
||||
public void refreshBatteryTips_hasImportantTip_shouldReturnTrue() {
|
||||
final List<BatteryTip> tips = new ArrayList<>();
|
||||
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
|
||||
tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
|
||||
ShadowBatteryTipLoader.setBatteryTips(tips);
|
||||
|
||||
BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
|
||||
BatteryFixSlice.refreshBatteryTips(mContext);
|
||||
|
||||
assertThat(BatteryFixSlice.isBatteryTipAvailableFromCache(mContext)).isTrue();
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class BatteryFixSliceTest {
|
||||
tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false));
|
||||
ShadowBatteryTipLoader.setBatteryTips(tips);
|
||||
|
||||
BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
|
||||
BatteryFixSlice.refreshBatteryTips(mContext);
|
||||
final Slice slice = mSlice.getSlice();
|
||||
|
||||
assertThat(SliceMetadata.from(mContext, slice).isErrorSlice()).isTrue();
|
||||
@@ -115,7 +115,7 @@ public class BatteryFixSliceTest {
|
||||
tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
|
||||
// Create fake cache data
|
||||
ShadowBatteryTipLoader.setBatteryTips(tips);
|
||||
BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
|
||||
BatteryFixSlice.refreshBatteryTips(mContext);
|
||||
// Create fake background worker data
|
||||
BatteryFixSlice.BatteryTipWorker batteryTipWorker = mock(
|
||||
BatteryFixSlice.BatteryTipWorker.class);
|
||||
|
@@ -16,16 +16,12 @@
|
||||
|
||||
package com.android.settings.testutils.shadow;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.annotation.Resetter;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@Implements(ThreadUtils.class)
|
||||
public class ShadowThreadUtils {
|
||||
|
||||
@@ -42,15 +38,6 @@ public class ShadowThreadUtils {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected static void postOnBackgroundThread(Callable callable) {
|
||||
try {
|
||||
callable.call();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected static void postOnMainThread(Runnable runnable) {
|
||||
runnable.run();
|
||||
|
Reference in New Issue
Block a user