use of com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult in project android_frameworks_opt_telephony by LineageOS.
the class TimeZoneLookupHelperTest method testNoDefaultBoostBehavior.
@Test
public void testNoDefaultBoostBehavior() {
long timeMillis = createUtcTime(2015, 6, 20, 1, 2, 3);
// An example known to not be explicitly boosted. Micronesia is spread out and there's no
// suitable default.
String countryIsoCode = "fm";
CountryResult expectedResult = new CountryResult("Pacific/Pohnpei", QUALITY_MULTIPLE_ZONES_DIFFERENT_OFFSETS, ARBITRARY_DEBUG_INFO);
assertEquals(expectedResult, mTimeZoneLookupHelper.lookupByCountry(countryIsoCode, timeMillis));
// Prove an OffsetResult can be found with the correct offset.
int chuukWinterOffset = (int) TimeUnit.HOURS.toMillis(10);
NitzData chuukNitzData = NitzData.createForTests(chuukWinterOffset, 0, timeMillis, null);
OffsetResult chuukOffsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(chuukNitzData, countryIsoCode);
assertEquals(zone("Pacific/Chuuk"), chuukOffsetResult.getTimeZone());
assertTrue(chuukOffsetResult.isOnlyMatch());
// NITZ data that makes no sense for FM: no boost means we should get nothing.
int nonsenseOffset = (int) TimeUnit.HOURS.toMillis(5);
NitzData nonsenseNitzData = NitzData.createForTests(nonsenseOffset, 0, timeMillis, null);
OffsetResult nonsenseOffsetResult = mTimeZoneLookupHelper.lookupByNitzCountry(nonsenseNitzData, countryIsoCode);
assertNull(nonsenseOffsetResult);
}
use of com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult in project android_frameworks_opt_telephony by LineageOS.
the class TimeZoneLookupHelperTest method testLookupByCountry_multipleZones.
@Test
public void testLookupByCountry_multipleZones() {
// US has many time zones that have different offsets.
CountryResult expectedResult = new CountryResult("America/New_York", QUALITY_MULTIPLE_ZONES_DIFFERENT_OFFSETS, ARBITRARY_DEBUG_INFO);
assertEquals(expectedResult, mTimeZoneLookupHelper.lookupByCountry("us", NH_SUMMER_TIME_MILLIS));
assertEquals(expectedResult, mTimeZoneLookupHelper.lookupByCountry("us", NH_WINTER_TIME_MILLIS));
}
Aggregations