Merge "Add time unit into battery usage chart and refine some UI" into sc-v2-dev am: cb2ec5399c
am: cdc43dfc73
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15530296 Change-Id: I6c7be98e5752bcdfffb00b94333ed052ac2f9f9e
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() {
|
||||
|
@@ -33,7 +33,6 @@ import android.view.accessibility.AccessibilityManager;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -44,7 +43,6 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public final class BatteryChartViewTest {
|
||||
@@ -233,21 +231,4 @@ public final class BatteryChartViewTest {
|
||||
verify(mBatteryChartView.mHandler)
|
||||
.postDelayed(mBatteryChartView.mUpdateClickableStateRun, 500L);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSetLatestTimestamp_generateExpectedTimestamps() {
|
||||
final long timestamp = 1619196786769L;
|
||||
ConvertUtils.sSimpleDateFormatForHour = null;
|
||||
// Invokes the method first to create the SimpleDateFormat.
|
||||
ConvertUtils.utcToLocalTimeHour(
|
||||
mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
|
||||
ConvertUtils.sSimpleDateFormatForHour
|
||||
.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||
final String[] expectedTimestamps = new String[] {"00", "06", "12", "18", "00"};
|
||||
|
||||
mBatteryChartView.setLatestTimestamp(timestamp);
|
||||
|
||||
assertThat(mBatteryChartView.mTimestamps).isEqualTo(expectedTimestamps);
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,6 @@ import android.os.UserHandle;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -317,71 +316,6 @@ public final class ConvertUtilsTest {
|
||||
.isEqualTo(entry.mConsumePower * ratio);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testUtcToLocalTime_returnExpectedResult() {
|
||||
ConvertUtils.sZoneId = null;
|
||||
ConvertUtils.sLocale = null;
|
||||
final long timestamp = 1619196786769L;
|
||||
final String expectedZoneId = "America/Los_Angeles";
|
||||
ConvertUtils.sSimpleDateFormat = null;
|
||||
// Invokes the method first to create the SimpleDateFormat.
|
||||
ConvertUtils.utcToLocalTime(mContext, /*timestamp=*/ 0);
|
||||
ConvertUtils.sSimpleDateFormat
|
||||
.setTimeZone(TimeZone.getTimeZone(expectedZoneId));
|
||||
mContext.getResources().getConfiguration().setLocales(
|
||||
new LocaleList(new Locale("en_US")));
|
||||
|
||||
assertThat(ConvertUtils.utcToLocalTime(mContext, timestamp))
|
||||
.isEqualTo("Apr 24,2021 00:53:06");
|
||||
assertThat(ConvertUtils.sZoneId).isNotEqualTo(expectedZoneId);
|
||||
assertThat(ConvertUtils.sLocale).isEqualTo(new Locale("en_US"));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testUtcToLocalTimeHour_12HourFormat_returnExpectedResult() {
|
||||
ConvertUtils.sZoneIdForHour = null;
|
||||
ConvertUtils.sLocaleForHour = null;
|
||||
final long timestamp = 1619000086769L;
|
||||
final String expectedZoneId = "America/Los_Angeles";
|
||||
ConvertUtils.sSimpleDateFormatForHour = null;
|
||||
// Invokes the method first to create the SimpleDateFormat.
|
||||
ConvertUtils.utcToLocalTimeHour(
|
||||
mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
|
||||
ConvertUtils.sSimpleDateFormatForHour
|
||||
.setTimeZone(TimeZone.getTimeZone(expectedZoneId));
|
||||
mContext.getResources().getConfiguration().setLocales(
|
||||
new LocaleList(new Locale("en_US")));
|
||||
|
||||
assertThat(ConvertUtils.utcToLocalTimeHour(
|
||||
mContext, timestamp, /*is24HourFormat=*/ false)).isEqualTo("6");
|
||||
assertThat(ConvertUtils.sZoneIdForHour).isNotEqualTo(expectedZoneId);
|
||||
assertThat(ConvertUtils.sLocaleForHour).isEqualTo(new Locale("en_US"));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testUtcToLocalTimeHour_24HourFormat_returnExpectedResult() {
|
||||
ConvertUtils.sZoneIdForHour = null;
|
||||
ConvertUtils.sLocaleForHour = null;
|
||||
final long timestamp = 1619000086769L;
|
||||
final String expectedZoneId = "America/Los_Angeles";
|
||||
ConvertUtils.sSimpleDateFormatForHour = null;
|
||||
// Invokes the method first to create the SimpleDateFormat.
|
||||
ConvertUtils.utcToLocalTimeHour(
|
||||
mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
|
||||
ConvertUtils.sSimpleDateFormatForHour
|
||||
.setTimeZone(TimeZone.getTimeZone(expectedZoneId));
|
||||
mContext.getResources().getConfiguration().setLocales(
|
||||
new LocaleList(new Locale("en_US")));
|
||||
|
||||
assertThat(ConvertUtils.utcToLocalTimeHour(
|
||||
mContext, timestamp, /*is24HourFormat=*/ true)).isEqualTo("18");
|
||||
assertThat(ConvertUtils.sZoneIdForHour).isNotEqualTo(expectedZoneId);
|
||||
assertThat(ConvertUtils.sLocaleForHour).isEqualTo(new Locale("en_US"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLocale_nullContext_returnDefaultLocale() {
|
||||
assertThat(ConvertUtils.getLocale(/*context=*/ null))
|
||||
|
Reference in New Issue
Block a user