Loading src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java +2 −1 Original line number Diff line number Diff line Loading @@ -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); Loading tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -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(); } Loading @@ -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(); Loading @@ -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); Loading tests/robotests/src/com/android/settings/testutils/shadow/ShadowThreadUtils.java +0 −13 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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(); Loading Loading
src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java +2 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -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(); } Loading @@ -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(); Loading @@ -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); Loading
tests/robotests/src/com/android/settings/testutils/shadow/ShadowThreadUtils.java +0 −13 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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(); Loading