Search in sources :

Example 26 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class RILTest method testWakeLockTimeout.

@FlakyTest
@Test
public void testWakeLockTimeout() {
    invokeMethod(mRILInstance, "obtainRequest", new Class<?>[] { Integer.TYPE, Message.class, WorkSource.class }, new Object[] { RIL_REQUEST_GET_SIM_STATUS, obtainMessage(), new WorkSource() });
    // The wake lock should be held when obtain a RIL request.
    assertTrue(mRILInstance.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
    moveTimeForward(DEFAULT_WAKE_LOCK_TIMEOUT_MS);
    processAllMessages();
    // The wake lock should be released after processed the time out event.
    assertFalse(mRILInstance.getWakeLock(RIL.FOR_WAKELOCK).isHeld());
}
Also used : WorkSource(android.os.WorkSource) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 27 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class RILTest method testWriteSmsToSim.

@FlakyTest
@Test
public void testWriteSmsToSim() throws Exception {
    String smscPdu = "smscPdu";
    String pdu = "pdu";
    int status = SmsManager.STATUS_ON_ICC_READ;
    SmsWriteArgs args = new SmsWriteArgs();
    args.status = 1;
    args.smsc = smscPdu;
    args.pdu = pdu;
    mRILUnderTest.writeSmsToSim(status, smscPdu, pdu, obtainMessage());
    verify(mRadioProxy).writeSmsToSim(mSerialNumberCaptor.capture(), eq(args));
    verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_WRITE_SMS_TO_SIM);
}
Also used : SmsWriteArgs(android.hardware.radio.V1_0.SmsWriteArgs) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 28 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class DcTrackerTest method testUserDisableData.

@Test
@MediumTest
@Ignore
@FlakyTest
public void testUserDisableData() throws Exception {
    // step 1: setup two DataCalls one for Metered: default, another one for Non-metered: IMS
    // set Default and MMS to be metered in the CarrierConfigManager
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    verify(mSimulatedCommandsVerifier, times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 5, 1, NETWORK_TYPE_LTE_BITMASK);
    logd("Sending DATA_DISABLED_CMD");
    doReturn(false).when(mDataEnabledSettings).isDataEnabled();
    doReturn(false).when(mDataEnabledSettings).isDataEnabled(anyInt());
    AsyncResult ar = new AsyncResult(null, new Pair<>(false, DataEnabledSettings.REASON_USER_DATA_ENABLED), null);
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_ENABLED_CHANGED, ar));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // Data connection is running on a different thread. Have to wait.
    waitForMs(200);
    // expected tear down all metered DataConnections
    verify(mSimulatedCommandsVerifier, times(1)).deactivateDataCall(eq(DataService.REQUEST_REASON_NORMAL), anyInt(), any(Message.class));
    assertTrue(mDct.isAnyDataConnected());
    assertEquals(DctConstants.State.IDLE, mDct.getState(PhoneConstants.APN_TYPE_DEFAULT));
    assertEquals(DctConstants.State.CONNECTED, mDct.getState(PhoneConstants.APN_TYPE_IMS));
}
Also used : DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) AsyncResult(android.os.AsyncResult) Ignore(org.junit.Ignore) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 29 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class DcTrackerTest method testNetworkStatusChangedRecoveryON.

@FlakyTest
@Test
@SmallTest
public void testNetworkStatusChangedRecoveryON() throws Exception {
    ContentResolver resolver = mContext.getContentResolver();
    Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
    Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 0);
    doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    verify(mSimulatedCommandsVerifier, timeout(TEST_TIMEOUT).times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
    logd("Sending EVENT_NETWORK_STATUS_CHANGED");
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.VALID_NETWORK, 1, null));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    logd("Sending EVENT_NETWORK_STATUS_CHANGED");
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    // Data connection is running on a different thread. Have to wait.
    waitForMs(200);
    verify(mSimulatedCommandsVerifier, times(1)).getDataCallList(any(Message.class));
}
Also used : DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) SignalStrength(android.telephony.SignalStrength) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 30 with FlakyTest

use of androidx.test.filters.FlakyTest in project android_frameworks_opt_telephony by LineageOS.

the class DcTrackerTest method testRecoveryStepPDPReset.

@FlakyTest
@Test
@SmallTest
public void testRecoveryStepPDPReset() throws Exception {
    ContentResolver resolver = mContext.getContentResolver();
    Settings.Global.putInt(resolver, Settings.Global.DATA_STALL_RECOVERY_ON_BAD_NETWORK, 1);
    Settings.Global.putLong(resolver, Settings.Global.MIN_DURATION_BETWEEN_RECOVERY_STEPS_IN_MS, 100);
    Settings.System.putInt(resolver, "radio.data.stall.recovery.action", 1);
    doReturn(new SignalStrength()).when(mPhone).getSignalStrength();
    mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS, new String[] { PhoneConstants.APN_TYPE_DEFAULT, PhoneConstants.APN_TYPE_MMS });
    mDct.enableApn(ApnSetting.TYPE_IMS, DcTracker.REQUEST_TYPE_NORMAL, null);
    mDct.enableApn(ApnSetting.TYPE_DEFAULT, DcTracker.REQUEST_TYPE_NORMAL, null);
    sendInitializationEvents();
    ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class);
    verify(mSimulatedCommandsVerifier, timeout(TEST_TIMEOUT).times(2)).setupDataCall(eq(AccessNetworkType.EUTRAN), dpCaptor.capture(), eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(), any(Message.class));
    verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);
    logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
    mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED, NetworkAgent.INVALID_NETWORK, 1, null));
    waitForLastHandlerAction(mDcTrackerTestHandler.getThreadHandler());
    waitForMs(200);
    // expected tear down all DataConnections
    verify(mSimulatedCommandsVerifier, times(1)).deactivateDataCall(eq(DataService.REQUEST_REASON_NORMAL), anyInt(), any(Message.class));
}
Also used : DataProfile(android.telephony.data.DataProfile) Message(android.os.Message) ContentResolver(android.content.ContentResolver) MockContentResolver(android.test.mock.MockContentResolver) SignalStrength(android.telephony.SignalStrength) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) TelephonyTest(com.android.internal.telephony.TelephonyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

FlakyTest (androidx.test.filters.FlakyTest)32 Test (org.junit.Test)32 SmallTest (android.test.suitebuilder.annotation.SmallTest)13 TelephonyTest (com.android.internal.telephony.TelephonyTest)13 Ignore (org.junit.Ignore)11 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 Message (android.os.Message)9 WorkSource (android.os.WorkSource)9 AsyncResult (android.os.AsyncResult)6 Intent (android.content.Intent)5 DataProfile (android.telephony.data.DataProfile)5 Context (android.content.Context)4 GsmSmsMessage (android.hardware.radio.V1_0.GsmSmsMessage)4 CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)3 ImsSmsMessage (android.hardware.radio.V1_0.ImsSmsMessage)3 ContentResolver (android.content.ContentResolver)2 DataProfileInfo (android.hardware.radio.V1_0.DataProfileInfo)2 NvWriteItem (android.hardware.radio.V1_0.NvWriteItem)2 SmsWriteArgs (android.hardware.radio.V1_0.SmsWriteArgs)2 CellIdentityCdma (android.telephony.CellIdentityCdma)2