Define Utils.formatRelativeTime() and use it
Previously, relative times were formatted using formatElapsedTime() (appending translations of "ago" to them), sometimes resulting in grammatically hard-to-understand or unnatural localizations. Now we use ICU's RelativeDateTimeFormatter, which uses grammatically correct and natural localizations from CLDR data. Bug: 64507689 Bug: 64605781 Bug: 64556849 Bug: 64550172 Test: make -j RunSettingsRoboTests Change-Id: Ia2d098b190ab99e7748ef6f03b919f5c6174ba7d
This commit is contained in:
@@ -411,18 +411,11 @@ public class PowerUsageSummaryTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateLastFullChargePreference_showCorrectSummary() {
|
||||
final CharSequence formattedString = mRealContext.getText(
|
||||
R.string.power_last_full_charge_summary);
|
||||
final CharSequence timeSequence = Utils.formatElapsedTime(mRealContext,
|
||||
TIME_SINCE_LAST_FULL_CHARGE_MS, false);
|
||||
final CharSequence expectedSummary = TextUtils.expandTemplate(
|
||||
formattedString, timeSequence);
|
||||
doReturn(formattedString).when(mFragment).getText(R.string.power_last_full_charge_summary);
|
||||
doReturn(mRealContext).when(mFragment).getContext();
|
||||
|
||||
mFragment.updateLastFullChargePreference(TIME_SINCE_LAST_FULL_CHARGE_MS);
|
||||
|
||||
assertThat(mLastFullChargePref.getSubtitle()).isEqualTo(expectedSummary);
|
||||
assertThat(mLastFullChargePref.getSubtitle()).isEqualTo("2 hr. ago");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user