Search in sources :

Example 1 with FakeDeviceState

use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState in project android_frameworks_opt_telephony by LineageOS.

the class NitzStateMachineImplTest method setUp.

@Before
public void setUp() throws Exception {
    TelephonyTest.logd("NitzStateMachineImplTest +Setup!");
    super.setUp("NitzStateMachineImplTest");
    // In tests we use a fake impls for NewTimeServiceHelper and DeviceState.
    mFakeDeviceState = new FakeDeviceState();
    mFakeTimeServiceHelper = new FakeTimeServiceHelper(mFakeDeviceState);
    // In tests we disable NITZ signal input filtering. The real NITZ signal filter is tested
    // independently. This makes constructing test data simpler: we can be sure the signals
    // won't be filtered for reasons like rate-limiting.
    NitzSignalInputFilterPredicate mFakeNitzSignalInputFilter = (oldSignal, newSignal) -> true;
    // In tests a real TimeZoneSuggesterImpl is used with the real TimeZoneLookupHelper and real
    // country time zone data. A fake device state is used (which allows tests to fake the
    // system clock / user settings). The tests can perform the expected lookups and confirm the
    // state machine takes the correct action. Picking real examples from the past is easier
    // than inventing countries / scenarios and configuring fakes.
    TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper();
    mRealTimeZoneSuggester = new TimeZoneSuggesterImpl(mFakeDeviceState, timeZoneLookupHelper);
    mNitzStateMachineImpl = new NitzStateMachineImpl(SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, mFakeTimeServiceHelper);
    TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!");
}
Also used : NitzStateMachineTestSupport.createEmptyTimeZoneSuggestion(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.createEmptyTimeZoneSuggestion) TelephonyTest(com.android.internal.telephony.TelephonyTest) FakeDeviceState(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState) ARBITRARY_SYSTEM_CLOCK_TIME(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.ARBITRARY_SYSTEM_CLOCK_TIME) UNIQUE_US_ZONE_SCENARIO1(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.UNIQUE_US_ZONE_SCENARIO1) NitzData(com.android.internal.telephony.NitzData) QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET(android.app.timezonedetector.TelephonyTimeZoneSuggestion.QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET) After(org.junit.After) UNITED_KINGDOM_SCENARIO(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.UNITED_KINGDOM_SCENARIO) NitzSignalInputFilterPredicate(com.android.internal.telephony.nitz.NitzStateMachineImpl.NitzSignalInputFilterPredicate) LinkedList(java.util.LinkedList) Scenario(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario) Before(org.junit.Before) TelephonyTimeSuggestion(android.app.timedetector.TelephonyTimeSuggestion) PrintWriter(java.io.PrintWriter) IndentingPrintWriter(com.android.internal.telephony.IndentingPrintWriter) NitzStateMachineTestSupport.createEmptyTimeSuggestion(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.createEmptyTimeSuggestion) Assert.assertNotNull(org.junit.Assert.assertNotNull) TelephonyTimeZoneSuggestion(android.app.timezonedetector.TelephonyTimeZoneSuggestion) TimestampedValue(android.os.TimestampedValue) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) NitzStateMachineTestSupport.createTimeSuggestionFromNitzSignal(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.createTimeSuggestionFromNitzSignal) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) TimeUnit(java.util.concurrent.TimeUnit) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY(android.app.timezonedetector.TelephonyTimeZoneSuggestion.MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY) Assert.assertEquals(org.junit.Assert.assertEquals) FakeDeviceState(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState) NitzSignalInputFilterPredicate(com.android.internal.telephony.nitz.NitzStateMachineImpl.NitzSignalInputFilterPredicate) Before(org.junit.Before)

Example 2 with FakeDeviceState

use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState in project android_frameworks_opt_telephony by LineageOS.

the class TimeZoneSuggesterImplTest method setUp.

@Before
public void setUp() throws Exception {
    TelephonyTest.logd("TimeZoneSuggesterImplTest +Setup!");
    super.setUp("TimeZoneSuggesterImplTest");
    // In tests a fake impl is used for DeviceState, which allows historic data to be used.
    mFakeDeviceState = new FakeDeviceState();
    // In tests the real TimeZoneLookupHelper implementation is used: this makes it easy to
    // construct tests using known historic examples.
    TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper();
    mTimeZoneSuggester = new TimeZoneSuggesterImpl(mFakeDeviceState, timeZoneLookupHelper);
    TelephonyTest.logd("TimeZoneSuggesterImplTest -Setup!");
}
Also used : FakeDeviceState(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState) Before(org.junit.Before)

Example 3 with FakeDeviceState

use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState in project android_frameworks_opt_telephony by LineageOS.

the class NitzSignalInputFilterPredicateFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp("NitzSignalInputFilterPredicateFactoryTest");
    mFakeDeviceState = new FakeDeviceState();
}
Also used : FakeDeviceState(com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState) Before(org.junit.Before)

Aggregations

FakeDeviceState (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.FakeDeviceState)3 Before (org.junit.Before)3 TelephonyTimeSuggestion (android.app.timedetector.TelephonyTimeSuggestion)1 TelephonyTimeZoneSuggestion (android.app.timezonedetector.TelephonyTimeZoneSuggestion)1 MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY (android.app.timezonedetector.TelephonyTimeZoneSuggestion.MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY)1 QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET (android.app.timezonedetector.TelephonyTimeZoneSuggestion.QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET)1 TimestampedValue (android.os.TimestampedValue)1 IndentingPrintWriter (com.android.internal.telephony.IndentingPrintWriter)1 NitzData (com.android.internal.telephony.NitzData)1 TelephonyTest (com.android.internal.telephony.TelephonyTest)1 NitzSignalInputFilterPredicate (com.android.internal.telephony.nitz.NitzStateMachineImpl.NitzSignalInputFilterPredicate)1 ARBITRARY_SYSTEM_CLOCK_TIME (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.ARBITRARY_SYSTEM_CLOCK_TIME)1 Scenario (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario)1 UNIQUE_US_ZONE_SCENARIO1 (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.UNIQUE_US_ZONE_SCENARIO1)1 UNITED_KINGDOM_SCENARIO (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.UNITED_KINGDOM_SCENARIO)1 NitzStateMachineTestSupport.createEmptyTimeSuggestion (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.createEmptyTimeSuggestion)1 NitzStateMachineTestSupport.createEmptyTimeZoneSuggestion (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.createEmptyTimeZoneSuggestion)1 NitzStateMachineTestSupport.createTimeSuggestionFromNitzSignal (com.android.internal.telephony.nitz.NitzStateMachineTestSupport.createTimeSuggestionFromNitzSignal)1 PrintWriter (java.io.PrintWriter)1 LinkedList (java.util.LinkedList)1