Add time unit into battery usage chart and refine some UI
- add time unit into battery chart for 12/24 hours - refine the radius size for chart bar - use fixed font size for timestamp and percentage screenshots: 24-hour format: https://screenshot.googleplex.com/3VNedE2nAx6LrXu 12-hour format: https://screenshot.googleplex.com/3tpTXjYfrasrenW fixed-size: https://screenshot.googleplex.com/nPRKm7XCkmFzW6K Bug: 194836607 Test: make SettingsRoboTests Change-Id: I5b35b0fa808eb8a5f607962ee973c2896529b078
This commit is contained in:
@@ -50,7 +50,6 @@ import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -65,7 +64,6 @@ import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public final class BatteryChartPreferenceControllerTest {
|
||||
@@ -125,37 +123,6 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
createBatteryHistoryMap());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testOnResume_uiModeIsChanged_clearBatteryDiffEntryCache() {
|
||||
doReturn(mResources).when(mContext).getResources();
|
||||
doReturn(mConfiguration).when(mResources).getConfiguration();
|
||||
mConfiguration.uiMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
|
||||
// Ensures the testing environment is correct.
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
mBatteryChartPreferenceController.onResume();
|
||||
// Changes the uiMode in the configuration.
|
||||
mConfiguration.uiMode = Configuration.UI_MODE_NIGHT_YES;
|
||||
|
||||
mBatteryChartPreferenceController.onResume();
|
||||
assertThat(BatteryDiffEntry.sResourceCache).isEmpty();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testOnResume_uiModeIsNotChanged_notClearBatteryDiffEntryCache() {
|
||||
doReturn(mResources).when(mContext).getResources();
|
||||
doReturn(mConfiguration).when(mResources).getConfiguration();
|
||||
mConfiguration.uiMode = Configuration.UI_MODE_NIGHT_UNDEFINED;
|
||||
// Ensures the testing environment is correct.
|
||||
assertThat(BatteryDiffEntry.sResourceCache).hasSize(1);
|
||||
|
||||
mBatteryChartPreferenceController.onResume();
|
||||
assertThat(BatteryDiffEntry.sResourceCache).isNotEmpty();
|
||||
verify(mMetricsFeatureProvider)
|
||||
.action(mContext, SettingsEnums.OPEN_BATTERY_USAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnDestroy_activityIsChanging_clearBatteryEntryCache() {
|
||||
doReturn(true).when(mSettingsActivity).isChangingConfigurations();
|
||||
@@ -579,12 +546,12 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
// Verifies the title in the preference group.
|
||||
verify(mBatteryChartPreferenceController.mAppListPrefGroup)
|
||||
.setTitle(captor.capture());
|
||||
assertThat(captor.getValue()).isEqualTo("App usage for 4 - 7");
|
||||
assertThat(captor.getValue()).isNotEqualTo("App usage for past 24 hr");
|
||||
// Verifies the title in the expandable divider.
|
||||
captor = ArgumentCaptor.forClass(String.class);
|
||||
verify(mBatteryChartPreferenceController.mExpandDividerPreference)
|
||||
.setTitle(captor.capture());
|
||||
assertThat(captor.getValue()).isEqualTo("System usage for 4 - 7");
|
||||
assertThat(captor.getValue()).isNotEqualTo("System usage for past 24 hr");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -722,9 +689,6 @@ public final class BatteryChartPreferenceControllerTest {
|
||||
new long[] {1619196786769L, 0L, 1619247636826L};
|
||||
ConvertUtils.utcToLocalTimeHour(
|
||||
mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
|
||||
// Simulates the locale in GMT.
|
||||
ConvertUtils.sSimpleDateFormatForHour
|
||||
.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
private BatteryChartPreferenceController createController() {
|
||||
|
Reference in New Issue
Block a user