Loading tests/telephonytests/src/android/telephony/ims/ImsServiceTest.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.telephony.ims; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.PackageManager; import android.os.RemoteException; import android.os.RemoteException; import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.feature.ImsFeature; Loading @@ -38,6 +39,7 @@ import org.mockito.MockitoAnnotations; import static android.Manifest.permission.MODIFY_PHONE_STATE; import static android.Manifest.permission.MODIFY_PHONE_STATE; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static com.android.internal.telephony.ims.ImsResolver.SERVICE_INTERFACE; import static com.android.internal.telephony.ims.ImsResolver.SERVICE_INTERFACE; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNotNull; Loading Loading @@ -153,6 +155,8 @@ public class ImsServiceTest { @Test @Test @SmallTest @SmallTest public void testMethodWithNoPermissions() throws RemoteException { public void testMethodWithNoPermissions() throws RemoteException { when(mMockContext.checkCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE)).thenReturn( PackageManager.PERMISSION_DENIED); doThrow(new SecurityException()).when(mMockContext).enforceCallingOrSelfPermission( doThrow(new SecurityException()).when(mMockContext).enforceCallingOrSelfPermission( eq(READ_PHONE_STATE), nullable(String.class)); eq(READ_PHONE_STATE), nullable(String.class)); mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); Loading Loading
tests/telephonytests/src/android/telephony/ims/ImsServiceTest.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.telephony.ims; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.pm.PackageManager; import android.os.RemoteException; import android.os.RemoteException; import android.support.test.runner.AndroidJUnit4; import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.feature.ImsFeature; import android.telephony.ims.feature.ImsFeature; Loading @@ -38,6 +39,7 @@ import org.mockito.MockitoAnnotations; import static android.Manifest.permission.MODIFY_PHONE_STATE; import static android.Manifest.permission.MODIFY_PHONE_STATE; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PHONE_STATE; import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE; import static com.android.internal.telephony.ims.ImsResolver.SERVICE_INTERFACE; import static com.android.internal.telephony.ims.ImsResolver.SERVICE_INTERFACE; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNotNull; Loading Loading @@ -153,6 +155,8 @@ public class ImsServiceTest { @Test @Test @SmallTest @SmallTest public void testMethodWithNoPermissions() throws RemoteException { public void testMethodWithNoPermissions() throws RemoteException { when(mMockContext.checkCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE)).thenReturn( PackageManager.PERMISSION_DENIED); doThrow(new SecurityException()).when(mMockContext).enforceCallingOrSelfPermission( doThrow(new SecurityException()).when(mMockContext).enforceCallingOrSelfPermission( eq(READ_PHONE_STATE), nullable(String.class)); eq(READ_PHONE_STATE), nullable(String.class)); mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback); Loading