Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c33bd7aa authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Fixes ImsService Unit Tests

Correctly mocks out the Context to test
ImsService permission checks correctly.

Test: ImsServiceTest unit tests
Change-Id: If770968441e4157f8696b9b51956d0a36977c976
parent 5b18fad2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.telephony.ims;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.support.test.runner.AndroidJUnit4;
import android.telephony.ims.feature.ImsFeature;
@@ -38,6 +39,7 @@ import org.mockito.MockitoAnnotations;

import static android.Manifest.permission.MODIFY_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 junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@@ -153,6 +155,8 @@ public class ImsServiceTest {
    @Test
    @SmallTest
    public void testMethodWithNoPermissions() throws RemoteException {
        when(mMockContext.checkCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE)).thenReturn(
                PackageManager.PERMISSION_DENIED);
        doThrow(new SecurityException()).when(mMockContext).enforceCallingOrSelfPermission(
                eq(READ_PHONE_STATE), anyString());
        mTestImsServiceBinder.createImsFeature(TEST_SLOT_0, ImsFeature.MMTEL, mTestCallback);