Align system time 12-24 hour format in the time slot information

align the time format configuration in the Settings -> System ->
Date/Time to show 12- or 24- hour format in the usage time slot

screenshot: https://screenshot.googleplex.com/3w2SFvBLpC5oHBs
screenshot: https://screenshot.googleplex.com/86uCq6R4PKEg9RD
screenshot: https://screenshot.googleplex.com/3easrEFMQdZEjGP
screenshot: https://screenshot.googleplex.com/7dPWVJNTbSShFPa

Bug: 187783891
Test: make SettingsRoboTests
Change-Id: I9af0a69bd7c67562526bd5ee74a657635068ef44
This commit is contained in:
ykhung
2021-05-18 14:01:23 +08:00
committed by YUKAI HUNG
parent db6c7211e4
commit 1ea5208fa8
6 changed files with 90 additions and 57 deletions

View File

@@ -41,6 +41,7 @@ import org.robolectric.RuntimeEnvironment;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.TimeZone;
@RunWith(RobolectricTestRunner.class)
public final class BatteryChartViewTest {
@@ -227,4 +228,20 @@ public final class BatteryChartViewTest {
verify(mBatteryChartView.mHandler)
.postDelayed(mBatteryChartView.mUpdateClickableStateRun, 500L);
}
@Test
public void testSetLatestTimestamp_generateExpectedTimestamps() {
final long timestamp = 1619196786769L;
ConvertUtils.sSimpleDateFormatForHour = null;
// Invokes the method first to create the SimpleDateFormat.
ConvertUtils.utcToLocalTimeHour(/*timestamp=*/ 0, /*is24HourFormat=*/ false);
ConvertUtils.sSimpleDateFormatForHour
.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
final String[] expectedTimestamps =
new String[] {"9 am", "5 pm", "1 am", "9 am"};
mBatteryChartView.setLatestTimestamp(timestamp);
assertThat(mBatteryChartView.mTimestamps).isEqualTo(expectedTimestamps);
}
}