use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testNitzSignalInputFilterPredicateImpl_nullSecondArgumentRejected.
@Test
public void testNitzSignalInputFilterPredicateImpl_nullSecondArgumentRejected() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
TrivalentPredicate[] triPredicates = {};
NitzSignalInputFilterPredicateImpl impl = new NitzSignalInputFilterPredicateImpl(triPredicates);
try {
impl.mustProcessNitzSignal(nitzSignal, null);
fail();
} catch (NullPointerException expected) {
}
}
use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testNitzSignalInputFilterPredicateImpl_trueIsHonored.
@Test
public void testNitzSignalInputFilterPredicateImpl_trueIsHonored() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
TrivalentPredicate nullPredicate = (x, y) -> null;
TrivalentPredicate truePredicate = (x, y) -> true;
TrivalentPredicate exceptionPredicate = (x, y) -> {
throw new RuntimeException();
};
TrivalentPredicate[] triPredicates = { nullPredicate, truePredicate, exceptionPredicate };
NitzSignalInputFilterPredicateImpl impl = new NitzSignalInputFilterPredicateImpl(triPredicates);
assertTrue(impl.mustProcessNitzSignal(null, nitzSignal));
}
use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testNitzSignalInputFilterPredicateImpl_defaultIsTrue.
@Test
public void testNitzSignalInputFilterPredicateImpl_defaultIsTrue() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
NitzSignalInputFilterPredicateImpl impl = new NitzSignalInputFilterPredicateImpl(new TrivalentPredicate[0]);
assertTrue(impl.mustProcessNitzSignal(null, nitzSignal));
}
use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testTrivalentPredicate_rateLimitCheck_utcTimeDifferences.
@Test
public void testTrivalentPredicate_rateLimitCheck_utcTimeDifferences() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
int nitzSpacingThreshold = mFakeDeviceState.getNitzUpdateSpacingMillis();
int nitzUtcDiffThreshold = mFakeDeviceState.getNitzUpdateDiffMillis();
NitzData baseNitzData = scenario.createNitzData();
TrivalentPredicate triPredicate = createRateLimitCheck(mFakeDeviceState);
long baseElapsedRealtimeMillis = mFakeDeviceState.elapsedRealtime();
TimestampedValue<NitzData> baseSignal = new TimestampedValue<>(baseElapsedRealtimeMillis, baseNitzData);
// Create a new NitzSignal that should be filtered.
int elapsedTimeIncrement = nitzSpacingThreshold - 1;
TimestampedValue<NitzData> intermediateSignal = createIncrementedNitzSignal(baseSignal, elapsedTimeIncrement);
NitzData intermediateNitzData = intermediateSignal.getValue();
assertFalse(triPredicate.mustProcessNitzSignal(baseSignal, intermediateSignal));
// Two signals spaced apart so that the second would normally be filtered and it contains
// a UTC time that is not sufficiently different.
{
NitzData incrementedUtcTimeNitzData = NitzData.createForTests(intermediateNitzData.getLocalOffsetMillis(), intermediateNitzData.getDstAdjustmentMillis(), intermediateNitzData.getCurrentTimeInMillis() + nitzUtcDiffThreshold - 1, intermediateNitzData.getEmulatorHostTimeZone());
TimestampedValue<NitzData> incrementedNitzSignal = new TimestampedValue<>(intermediateSignal.getReferenceTimeMillis(), incrementedUtcTimeNitzData);
assertFalse(triPredicate.mustProcessNitzSignal(baseSignal, incrementedNitzSignal));
}
// Two signals spaced apart so that the second would normally be filtered but it contains
// a UTC time that is sufficiently different.
{
NitzData incrementedUtcTimeNitzData = NitzData.createForTests(intermediateNitzData.getLocalOffsetMillis(), intermediateNitzData.getDstAdjustmentMillis(), intermediateNitzData.getCurrentTimeInMillis() + nitzUtcDiffThreshold + 1, intermediateNitzData.getEmulatorHostTimeZone());
TimestampedValue<NitzData> incrementedNitzSignal = new TimestampedValue<>(intermediateSignal.getReferenceTimeMillis(), incrementedUtcTimeNitzData);
assertTrue(triPredicate.mustProcessNitzSignal(baseSignal, incrementedNitzSignal));
}
// Two signals spaced apart so that the second would normally be filtered and it contains
// a UTC time that is not sufficiently different.
{
NitzData decrementedUtcTimeNitzData = NitzData.createForTests(intermediateNitzData.getLocalOffsetMillis(), intermediateNitzData.getDstAdjustmentMillis(), intermediateNitzData.getCurrentTimeInMillis() - nitzUtcDiffThreshold + 1, intermediateNitzData.getEmulatorHostTimeZone());
TimestampedValue<NitzData> decrementedNitzSignal = new TimestampedValue<>(intermediateSignal.getReferenceTimeMillis(), decrementedUtcTimeNitzData);
assertFalse(triPredicate.mustProcessNitzSignal(baseSignal, decrementedNitzSignal));
}
// Two signals spaced apart so that the second would normally be filtered but it contains
// a UTC time that is sufficiently different.
{
NitzData decrementedUtcTimeNitzData = NitzData.createForTests(intermediateNitzData.getLocalOffsetMillis(), intermediateNitzData.getDstAdjustmentMillis(), intermediateNitzData.getCurrentTimeInMillis() + nitzUtcDiffThreshold + 1, intermediateNitzData.getEmulatorHostTimeZone());
TimestampedValue<NitzData> decrementedNitzSignal = new TimestampedValue<>(intermediateSignal.getReferenceTimeMillis(), decrementedUtcTimeNitzData);
assertTrue(triPredicate.mustProcessNitzSignal(baseSignal, decrementedNitzSignal));
}
}
use of com.android.internal.telephony.nitz.NitzStateMachineTestSupport.Scenario in project android_frameworks_opt_telephony by LineageOS.
the class NitzSignalInputFilterPredicateFactoryTest method testNitzSignalInputFilterPredicateImpl_falseIsHonored.
@Test
public void testNitzSignalInputFilterPredicateImpl_falseIsHonored() {
Scenario scenario = UNIQUE_US_ZONE_SCENARIO1;
TimestampedValue<NitzData> nitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime());
TrivalentPredicate nullPredicate = (x, y) -> null;
TrivalentPredicate falsePredicate = (x, y) -> false;
TrivalentPredicate exceptionPredicate = (x, y) -> {
throw new RuntimeException();
};
TrivalentPredicate[] triPredicates = { nullPredicate, falsePredicate, exceptionPredicate };
NitzSignalInputFilterPredicateImpl impl = new NitzSignalInputFilterPredicateImpl(triPredicates);
assertFalse(impl.mustProcessNitzSignal(null, nitzSignal));
}
Aggregations