use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhoneTest method testVoiceMailCount.
@FlakyTest
@Test
@Ignore
public void testVoiceMailCount() {
// initial value
assertEquals(0, mPhoneUT.getVoiceMessageCount());
// old sharedPreference set (testing upgrade from M to N scenario)
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
SharedPreferences.Editor editor = sharedPreferences.edit();
String imsi = "1234567890";
editor.putString("vm_id_key", imsi);
editor.putInt("vm_count_key", 5);
editor.apply();
doReturn(imsi).when(mSimRecords).getIMSI();
// updateVoiceMail should read old shared pref and delete it and new sharedPref should be
// updated now
doReturn(-1).when(mSimRecords).getVoiceMessageCount();
mPhoneUT.updateVoiceMail();
assertEquals(5, mPhoneUT.getVoiceMessageCount());
assertEquals(null, sharedPreferences.getString("vm_id_key", null));
assertEquals(5, sharedPreferences.getInt("vm_count_key" + mPhoneUT.getSubId(), 0));
// sim records return count as 0, that overrides shared preference
doReturn(0).when(mSimRecords).getVoiceMessageCount();
mPhoneUT.updateVoiceMail();
assertEquals(0, mPhoneUT.getVoiceMessageCount());
// sim records return count as -1
doReturn(-1).when(mSimRecords).getVoiceMessageCount();
mPhoneUT.updateVoiceMail();
assertEquals(-1, mPhoneUT.getVoiceMessageCount());
// sim records return count as -1 and sharedPreference says 0
mPhoneUT.setVoiceMessageCount(0);
mPhoneUT.updateVoiceMail();
assertEquals(-1, mPhoneUT.getVoiceMessageCount());
// sim records return count as -1 and sharedPreference says 2
mPhoneUT.setVoiceMessageCount(2);
mPhoneUT.updateVoiceMail();
assertEquals(2, mPhoneUT.getVoiceMessageCount());
// sim records return count as 0 and sharedPreference says 2
doReturn(0).when(mSimRecords).getVoiceMessageCount();
mPhoneUT.setVoiceMessageCount(2);
mPhoneUT.updateVoiceMail();
assertEquals(0, mPhoneUT.getVoiceMessageCount());
}
use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.
the class TelephonyNetworkFactoryTest method testActive.
/**
* Test that phone active changes cause the DcTracker to get poked.
*/
@FlakyTest
@Test
@SmallTest
public void testActive() throws Exception {
mTestName = "testActive";
final int phoneId = 0;
final int subId = 0;
createMockedTelephonyComponents();
doReturn(false).when(mPhoneSwitcher).shouldApplyNetworkRequest(any(), anyInt());
doReturn(subId).when(mSubscriptionController).getSubIdUsingPhoneId(phoneId);
// fake onSubscriptionChangedListener being triggered.
mTelephonyNetworkFactoryUT.mInternalHandler.sendEmptyMessage(TelephonyNetworkFactory.EVENT_SUBSCRIPTION_CHANGED);
log("addDefaultRequest");
makeDefaultInternetRequest();
processAllMessages();
assertEquals(0, mNetworkRequestList.size());
log("setPhoneActive true: phoneId = " + phoneId);
activatePhoneInPhoneSwitcher(phoneId, true);
processAllMessages();
assertEquals(1, mNetworkRequestList.size());
log("makeSubSpecificInternetRequest: subId = " + subId);
NetworkRequest subSpecificDefault = makeSubSpecificInternetRequest(subId);
processAllMessages();
assertEquals(2, mNetworkRequestList.size());
log("setPhoneActive false: phoneId = " + phoneId);
activatePhoneInPhoneSwitcher(phoneId, false);
processAllMessages();
assertEquals(0, mNetworkRequestList.size());
log("makeSubSpecificInternetRequest: subId = " + subId);
NetworkRequest subSpecificMms = makeSubSpecificMmsRequest(subId);
processAllMessages();
assertEquals(0, mNetworkRequestList.size());
log("setPhoneActive true: phoneId = " + phoneId);
activatePhoneInPhoneSwitcher(phoneId, true);
processAllMessages();
assertEquals(3, mNetworkRequestList.size());
log("releaseNetworkRequest: subSpecificDefault = " + subSpecificDefault);
releaseNetworkRequest(subSpecificDefault);
processAllMessages();
assertEquals(2, mNetworkRequestList.size());
log("setPhoneActive false: phoneId = " + phoneId);
activatePhoneInPhoneSwitcher(phoneId, false);
processAllMessages();
assertEquals(0, mNetworkRequestList.size());
log("releaseNetworkRequest: subSpecificMms = " + subSpecificMms);
releaseNetworkRequest(subSpecificMms);
processAllMessages();
assertEquals(0, mNetworkRequestList.size());
log("setPhoneActive true: phoneId = " + phoneId);
activatePhoneInPhoneSwitcher(phoneId, true);
processAllMessages();
assertEquals(1, mNetworkRequestList.size());
}
use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsDispatcherTest method testSendSmsToEmergencyNumber_notifiesBlockedNumberProvider.
@FlakyTest
@Ignore
@Test
@MediumTest
public void testSendSmsToEmergencyNumber_notifiesBlockedNumberProvider() throws Exception {
setupMockPackagePermissionChecks();
mContextFixture.setSystemService(Context.COUNTRY_DETECTOR, mCountryDetector);
when(mCountryDetector.detectCountry()).thenReturn(new Country("US", Country.COUNTRY_SOURCE_SIM));
mGsmSmsDispatcher.sendText(getEmergencyNumberFromSystemPropertiesOrDefault(), "121", /*scAddr*/
"test sms", null, null, null, null, false, -1, false, -1, false, 0L);
verify(mSimulatedCommandsVerifier).sendSMS(anyString(), anyString(), any(Message.class));
// Blocked number provider is notified about the emergency contact asynchronously.
TelephonyTestUtils.waitForMs(50);
assertEquals(1, mFakeBlockedNumberContentProvider.mNumEmergencyContactNotifications);
}
use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsDispatcherTest method testSendTextWithInvalidDestAddr.
@Test
@SmallTest
@FlakyTest
@Ignore
public void testSendTextWithInvalidDestAddr() throws Exception {
// unmock ActivityManager to be able to register receiver, create real PendingIntent and
// receive TEST_INTENT
restoreInstance(Singleton.class, "mInstance", mIActivityManagerSingleton);
restoreInstance(ActivityManager.class, "IActivityManagerSingleton", null);
Context realContext = TestApplication.getAppContext();
realContext.registerReceiver(mTestReceiver, new IntentFilter(TEST_INTENT));
PendingIntent pendingIntent = PendingIntent.getBroadcast(realContext, 0, new Intent(TEST_INTENT), 0);
// send invalid dest address: +
mReceivedTestIntent = false;
mGsmSmsDispatcher.sendText("+", "222", /*scAddr*/
TAG, pendingIntent, null, null, null, false, -1, false, -1, false, 0L);
waitForMs(500);
verify(mSimulatedCommandsVerifier, times(0)).sendSMS(anyString(), anyString(), any(Message.class));
synchronized (mLock) {
assertEquals(true, mReceivedTestIntent);
assertEquals(SmsManager.RESULT_ERROR_NULL_PDU, mTestReceiver.getResultCode());
}
}
use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testStartNetworkScanWithUnsupportedResponse.
@FlakyTest
@Test
public void testStartNetworkScanWithUnsupportedResponse() throws Exception {
// Use Radio HAL v1.5
try {
replaceInstance(RIL.class, "mRadioVersion", mRILUnderTest, mRadioVersionV15);
} catch (Exception e) {
}
NetworkScanRequest nsr = getNetworkScanRequestForTesting();
mRILUnderTest.startNetworkScan(nsr, obtainMessage());
// Verify the v1.5 HAL methed is called firstly
verify(mRadioProxy).startNetworkScan_1_5(mSerialNumberCaptor.capture(), any());
// Before we find a way to trigger real RadioResponse method, emulate the behaivor.
Consumer<RILRequest> unsupportedResponseEmulator = rr -> {
mRILUnderTest.setCompatVersion(rr.getRequest(), RIL.RADIO_HAL_VERSION_1_4);
mRILUnderTest.startNetworkScan(nsr, Message.obtain(rr.getResult()));
};
verifyRILUnsupportedResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_START_NETWORK_SCAN, unsupportedResponseEmulator);
// Verify the fallback method is invoked
verify(mRadioProxy).startNetworkScan_1_4(eq(mSerialNumberCaptor.getValue() + 1), any());
}
Aggregations