Search in sources :

Example 6 with TelephonyTimeSuggestion

use of android.app.timedetector.TelephonyTimeSuggestion in project android_frameworks_opt_telephony by LineageOS.

the class NitzStateMachineImplTest method test_countryThenNitz.

@Test
public void test_countryThenNitz() throws Exception {
    Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
    String networkCountryIsoCode = scenario.getNetworkCountryIsoCode();
    TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
    // Capture expected results from the real suggester and confirm we can tell the difference
    // between them.
    TelephonyTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion(SLOT_INDEX, networkCountryIsoCode, null);
    TelephonyTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion(SLOT_INDEX, networkCountryIsoCode, nitzSignal);
    assertNotNull(expectedTimeZoneSuggestion2);
    assertNotEquals(expectedTimeZoneSuggestion1, expectedTimeZoneSuggestion2);
    Script script = new Script().initializeSystemClock(ARBITRARY_SYSTEM_CLOCK_TIME).networkAvailable();
    // Simulate country being known.
    script.countryReceived(networkCountryIsoCode);
    script.verifyOnlyTimeZoneWasSuggestedAndReset(expectedTimeZoneSuggestion1);
    // Check NitzStateMachine exposed state.
    assertNull(mNitzStateMachineImpl.getCachedNitzData());
    // Simulate NITZ being received and verify the behavior.
    script.nitzReceived(nitzSignal);
    TelephonyTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal);
    script.verifyTimeAndTimeZoneSuggestedAndReset(expectedTimeSuggestion, expectedTimeZoneSuggestion2);
    // Check NitzStateMachine exposed state.
    assertEquals(nitzSignal.getValue(), mNitzStateMachineImpl.getCachedNitzData());
}
Also used : TelephonyTimeZoneSuggestion(android.app.timezonedetector.TelephonyTimeZoneSuggestion) TelephonyTimeSuggestion(android.app.timedetector.TelephonyTimeSuggestion) NitzData(com.android.internal.telephony.NitzData) Scenario(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test)

Example 7 with TelephonyTimeSuggestion

use of android.app.timedetector.TelephonyTimeSuggestion in project android_frameworks_opt_telephony by LineageOS.

the class NitzStateMachineImplTest method test_emptyCountryStringUsTime_nitzReceivedFirst.

@Test
public void test_emptyCountryStringUsTime_nitzReceivedFirst() throws Exception {
    Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
    TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
    Script script = new Script().initializeSystemClock(ARBITRARY_SYSTEM_CLOCK_TIME).networkAvailable();
    // Simulate receiving the NITZ signal.
    script.nitzReceived(nitzSignal);
    // Verify the state machine did the right thing.
    // No time zone should be set. A NITZ signal by itself is not enough.
    TelephonyTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal);
    script.verifyTimeAndTimeZoneSuggestedAndReset(expectedTimeSuggestion, EMPTY_TIME_ZONE_SUGGESTION);
    // Check NitzStateMachine exposed state.
    assertEquals(nitzSignal.getValue(), mNitzStateMachineImpl.getCachedNitzData());
    // Simulate an empty country being set.
    script.countryReceived("");
    // Capture output from the real suggester and confirm it meets the test's needs /
    // expectations.
    TelephonyTimeZoneSuggestion expectedTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion(SLOT_INDEX, "", /* countryIsoCode */
    nitzSignal);
    assertEquals(MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY, expectedTimeZoneSuggestion.getMatchType());
    assertEquals(QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET, expectedTimeZoneSuggestion.getQuality());
    // Verify the state machine did the right thing.
    script.verifyOnlyTimeZoneWasSuggestedAndReset(expectedTimeZoneSuggestion);
    // Check NitzStateMachine exposed state.
    assertEquals(nitzSignal.getValue(), mNitzStateMachineImpl.getCachedNitzData());
}
Also used : TelephonyTimeSuggestion(android.app.timedetector.TelephonyTimeSuggestion) TelephonyTimeZoneSuggestion(android.app.timezonedetector.TelephonyTimeZoneSuggestion) NitzData(com.android.internal.telephony.NitzData) Scenario(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test)

Aggregations

TelephonyTimeSuggestion (android.app.timedetector.TelephonyTimeSuggestion)7 TelephonyTimeZoneSuggestion (android.app.timezonedetector.TelephonyTimeZoneSuggestion)7 NitzData (com.android.internal.telephony.NitzData)7 TelephonyTest (com.android.internal.telephony.TelephonyTest)7 Scenario (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario)7 Test (org.junit.Test)7