Loading src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java +5 −5 Original line number Diff line number Diff line Loading @@ -99,10 +99,10 @@ public final class DataProcessor { static boolean sDebug = false; @VisibleForTesting static long sFakeCurrentTimeMillis = 0; static long sTestCurrentTimeMillis = 0; @VisibleForTesting static Set<String> sFakeSystemAppsSet; static Set<String> sTestSystemAppsSet; @VisibleForTesting static IUsageStatsManager sUsageStatsManager = Loading Loading @@ -539,7 +539,7 @@ public final class DataProcessor { } while (nextDay < endTime) { dailyTimestampList.add(nextDay); nextDay += DateUtils.DAY_IN_MILLIS; nextDay = getTimestampOfNextDay(nextDay); } final long lastDailyTimestamp = dailyTimestampList.get(dailyTimestampList.size() - 1); // Only if the timestamp diff in the last day is bigger than MIN_TIME_SLOT, add the Loading Loading @@ -1900,12 +1900,12 @@ public final class DataProcessor { } private static Set<String> getSystemAppsSet(Context context) { return sFakeSystemAppsSet != null ? sFakeSystemAppsSet return sTestSystemAppsSet != null ? sTestSystemAppsSet : AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId(), false); } private static long getCurrentTimeMillis() { return sFakeCurrentTimeMillis > 0 ? sFakeCurrentTimeMillis : System.currentTimeMillis(); return sTestCurrentTimeMillis > 0 ? sTestCurrentTimeMillis : System.currentTimeMillis(); } private static void log(Context context, final String content, final long timestamp, Loading tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public final class BatteryChartPreferenceControllerTest { Locale.setDefault(new Locale("en_US")); org.robolectric.shadows.ShadowSettings.set24HourTimeFormat(false); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); DataProcessor.sFakeSystemAppsSet = Set.of(); DataProcessor.sTestSystemAppsSet = Set.of(); mFeatureFactory = FakeFeatureFactory.setupForTest(); mContext = spy(RuntimeEnvironment.application); doReturn(mContext).when(mContext).getApplicationContext(); Loading Loading @@ -405,7 +405,7 @@ public final class BatteryChartPreferenceControllerTest { entryMap.put("fake_entry_key" + index, entry); batteryHistoryMap.put(generateTimestamp(index), entryMap); } DataProcessor.sFakeCurrentTimeMillis = DataProcessor.sTestCurrentTimeMillis = generateTimestamp(numOfHours - 1) + DateUtils.MINUTE_IN_MILLIS; return batteryHistoryMap; } Loading tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -308,7 +308,7 @@ public final class DataProcessManagerTest { final int[] levels = {100, 99, 98}; final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = createHistoryMap(timestamps, levels); DataProcessor.sFakeCurrentTimeMillis = timestamps[timestamps.length - 1]; DataProcessor.sTestCurrentTimeMillis = timestamps[timestamps.length - 1]; assertThat(DataProcessManager.getBatteryLevelData( mContext, /*handler=*/ null, batteryHistoryMap, /*asyncResponseDelegate=*/ null)) Loading @@ -322,7 +322,7 @@ public final class DataProcessManagerTest { final int[] levels = {100, 99}; final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = createHistoryMap(timestamps, levels); DataProcessor.sFakeCurrentTimeMillis = timestamps[timestamps.length - 1]; DataProcessor.sTestCurrentTimeMillis = timestamps[timestamps.length - 1]; final BatteryLevelData resultData = DataProcessManager.getBatteryLevelData( Loading tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java +227 −35 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/com/android/settings/fuelgauge/batteryusage/DataProcessor.java +5 −5 Original line number Diff line number Diff line Loading @@ -99,10 +99,10 @@ public final class DataProcessor { static boolean sDebug = false; @VisibleForTesting static long sFakeCurrentTimeMillis = 0; static long sTestCurrentTimeMillis = 0; @VisibleForTesting static Set<String> sFakeSystemAppsSet; static Set<String> sTestSystemAppsSet; @VisibleForTesting static IUsageStatsManager sUsageStatsManager = Loading Loading @@ -539,7 +539,7 @@ public final class DataProcessor { } while (nextDay < endTime) { dailyTimestampList.add(nextDay); nextDay += DateUtils.DAY_IN_MILLIS; nextDay = getTimestampOfNextDay(nextDay); } final long lastDailyTimestamp = dailyTimestampList.get(dailyTimestampList.size() - 1); // Only if the timestamp diff in the last day is bigger than MIN_TIME_SLOT, add the Loading Loading @@ -1900,12 +1900,12 @@ public final class DataProcessor { } private static Set<String> getSystemAppsSet(Context context) { return sFakeSystemAppsSet != null ? sFakeSystemAppsSet return sTestSystemAppsSet != null ? sTestSystemAppsSet : AppListRepositoryUtil.getSystemPackageNames(context, context.getUserId(), false); } private static long getCurrentTimeMillis() { return sFakeCurrentTimeMillis > 0 ? sFakeCurrentTimeMillis : System.currentTimeMillis(); return sTestCurrentTimeMillis > 0 ? sTestCurrentTimeMillis : System.currentTimeMillis(); } private static void log(Context context, final String content, final long timestamp, Loading
tests/robotests/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceControllerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public final class BatteryChartPreferenceControllerTest { Locale.setDefault(new Locale("en_US")); org.robolectric.shadows.ShadowSettings.set24HourTimeFormat(false); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); DataProcessor.sFakeSystemAppsSet = Set.of(); DataProcessor.sTestSystemAppsSet = Set.of(); mFeatureFactory = FakeFeatureFactory.setupForTest(); mContext = spy(RuntimeEnvironment.application); doReturn(mContext).when(mContext).getApplicationContext(); Loading Loading @@ -405,7 +405,7 @@ public final class BatteryChartPreferenceControllerTest { entryMap.put("fake_entry_key" + index, entry); batteryHistoryMap.put(generateTimestamp(index), entryMap); } DataProcessor.sFakeCurrentTimeMillis = DataProcessor.sTestCurrentTimeMillis = generateTimestamp(numOfHours - 1) + DateUtils.MINUTE_IN_MILLIS; return batteryHistoryMap; } Loading
tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -308,7 +308,7 @@ public final class DataProcessManagerTest { final int[] levels = {100, 99, 98}; final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = createHistoryMap(timestamps, levels); DataProcessor.sFakeCurrentTimeMillis = timestamps[timestamps.length - 1]; DataProcessor.sTestCurrentTimeMillis = timestamps[timestamps.length - 1]; assertThat(DataProcessManager.getBatteryLevelData( mContext, /*handler=*/ null, batteryHistoryMap, /*asyncResponseDelegate=*/ null)) Loading @@ -322,7 +322,7 @@ public final class DataProcessManagerTest { final int[] levels = {100, 99}; final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = createHistoryMap(timestamps, levels); DataProcessor.sFakeCurrentTimeMillis = timestamps[timestamps.length - 1]; DataProcessor.sTestCurrentTimeMillis = timestamps[timestamps.length - 1]; final BatteryLevelData resultData = DataProcessManager.getBatteryLevelData( Loading
tests/robotests/src/com/android/settings/fuelgauge/batteryusage/DataProcessorTest.java +227 −35 File changed.Preview size limit exceeded, changes collapsed. Show changes