Search in sources :

Example 1 with CapabilityCallback

use of android.telephony.ims.ImsMmTelManager.CapabilityCallback in project robolectric by robolectric.

the class ShadowImsMmTelManagerTest method registerMmTelCapabilityCallback_imsNotSupported_imsExceptionThrown.

@Test
public void registerMmTelCapabilityCallback_imsNotSupported_imsExceptionThrown() {
    shadowImsMmTelManager.setImsAvailableOnDevice(false);
    try {
        shadowImsMmTelManager.registerMmTelCapabilityCallback(Runnable::run, new CapabilityCallback());
        assertWithMessage("Expected ImsException was not thrown").fail();
    } catch (ImsException e) {
        assertThat(e.getCode()).isEqualTo(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION);
        assertThat(e).hasMessageThat().contains("IMS not available on device.");
    }
}
Also used : CapabilityCallback(android.telephony.ims.ImsMmTelManager.CapabilityCallback) ImsException(android.telephony.ims.ImsException) Test(org.junit.Test)

Example 2 with CapabilityCallback

use of android.telephony.ims.ImsMmTelManager.CapabilityCallback in project robolectric by robolectric.

the class ShadowImsMmTelManagerTest method registerMmTelCapabilityCallback_imsNotRegistered_availabilityChange_onCapabilitiesStatusChangedNotInvoked.

@Test
public void registerMmTelCapabilityCallback_imsNotRegistered_availabilityChange_onCapabilitiesStatusChangedNotInvoked() throws ImsException {
    MmTelCapabilities[] mmTelCapabilities = new MmTelCapabilities[1];
    CapabilityCallback capabilityCallback = new CapabilityCallback() {

        @Override
        public void onCapabilitiesStatusChanged(MmTelCapabilities capabilities) {
            super.onCapabilitiesStatusChanged(capabilities);
            mmTelCapabilities[0] = capabilities;
        }
    };
    shadowImsMmTelManager.registerMmTelCapabilityCallback(Runnable::run, capabilityCallback);
    shadowImsMmTelManager.setMmTelCapabilitiesAvailable(new MmTelCapabilities());
    assertThat(mmTelCapabilities[0]).isNull();
}
Also used : CapabilityCallback(android.telephony.ims.ImsMmTelManager.CapabilityCallback) MmTelCapabilities(android.telephony.ims.feature.MmTelFeature.MmTelCapabilities) Test(org.junit.Test)

Example 3 with CapabilityCallback

use of android.telephony.ims.ImsMmTelManager.CapabilityCallback in project robolectric by robolectric.

the class ShadowImsMmTelManagerTest method registerMmTelCapabilityCallback_imsRegistered_availabilityChange_onCapabilitiesStatusChangedInvoked.

@Test
public void registerMmTelCapabilityCallback_imsRegistered_availabilityChange_onCapabilitiesStatusChangedInvoked() throws ImsException {
    MmTelCapabilities[] mmTelCapabilities = new MmTelCapabilities[1];
    CapabilityCallback capabilityCallback = new CapabilityCallback() {

        @Override
        public void onCapabilitiesStatusChanged(MmTelCapabilities capabilities) {
            super.onCapabilitiesStatusChanged(capabilities);
            mmTelCapabilities[0] = capabilities;
        }
    };
    shadowImsMmTelManager.setImsRegistered(ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
    shadowImsMmTelManager.registerMmTelCapabilityCallback(Runnable::run, capabilityCallback);
    MmTelCapabilities mmTelCapabilitiesWithCallbackRegistered = new MmTelCapabilities();
    mmTelCapabilitiesWithCallbackRegistered.addCapabilities(MmTelCapabilities.CAPABILITY_TYPE_VIDEO);
    mmTelCapabilitiesWithCallbackRegistered.addCapabilities(MmTelCapabilities.CAPABILITY_TYPE_VOICE);
    shadowImsMmTelManager.setMmTelCapabilitiesAvailable(mmTelCapabilitiesWithCallbackRegistered);
    assertThat(mmTelCapabilities[0]).isNotNull();
    assertThat(mmTelCapabilities[0]).isEqualTo(mmTelCapabilitiesWithCallbackRegistered);
    shadowImsMmTelManager.unregisterMmTelCapabilityCallback(capabilityCallback);
    shadowImsMmTelManager.setMmTelCapabilitiesAvailable(new MmTelCapabilities());
    assertThat(mmTelCapabilities[0]).isEqualTo(mmTelCapabilitiesWithCallbackRegistered);
}
Also used : CapabilityCallback(android.telephony.ims.ImsMmTelManager.CapabilityCallback) MmTelCapabilities(android.telephony.ims.feature.MmTelFeature.MmTelCapabilities) Test(org.junit.Test)

Aggregations

CapabilityCallback (android.telephony.ims.ImsMmTelManager.CapabilityCallback)3 Test (org.junit.Test)3 MmTelCapabilities (android.telephony.ims.feature.MmTelFeature.MmTelCapabilities)2 ImsException (android.telephony.ims.ImsException)1