Search in sources :

Example 11 with CountryResult

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);
}
Also used : CountryResult(com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult) NitzData(com.android.internal.telephony.NitzData) OffsetResult(android.timezone.CountryTimeZones.OffsetResult) Test(org.junit.Test)

Example 12 with CountryResult

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));
}
Also used : CountryResult(com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult) Test(org.junit.Test)

Aggregations

CountryResult (com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult)12 Test (org.junit.Test)10 OffsetResult (android.timezone.CountryTimeZones.OffsetResult)8 NitzData (com.android.internal.telephony.NitzData)3 NonNull (android.annotation.NonNull)2 TelephonyTimeZoneSuggestion (android.app.timezonedetector.TelephonyTimeZoneSuggestion)2 List (java.util.List)1