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

Commit f613d5e1 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Integrate new ImsCallSessionListener

am: 420041b5

Change-Id: I28c70422bcd46086a942775fe4c67cad6966078a
parents 28566fda 420041b5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

// Note: Package name is intentionally wrong for this test; the internal junk class is used to test
// that parcelables of types other than android.* are stripped out.
package com.android.telephony.ims;
package android.telephony.ims;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;

import com.android.ims.ImsCallProfile;
import com.android.ims.ImsReasonInfo;
import com.android.ims.internal.IImsMMTelFeature;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;

@RunWith(AndroidJUnit4.class)
public class ImsCompatTests {

    TestMMTelFeatureCompat mCompatMmTel;
    IImsMMTelFeature mCompatMmTelBinder;

    TestImsCallSessionCompat mCompatCallSession;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mCompatMmTel = new TestMMTelFeatureCompat();
        mCompatMmTelBinder = mCompatMmTel.getBinder();

        mCompatCallSession = new TestImsCallSessionCompat();
    }

    @After
    public void tearDown() {
        mCompatMmTel = null;
        mCompatMmTelBinder = null;

        mCompatCallSession = null;
    }

    @SmallTest
    @Test
    public void testCreateCallSessionCompat() throws Exception {
        mCompatMmTelBinder.createCallSession(0, mock(ImsCallProfile.class));
        assertTrue(mCompatMmTel.isCreateCallSessionCalled);
    }

    @SmallTest
    @Test
    public void testListenerCompatLayer() throws Exception {
        ImsCallSessionListener listener = mock(ImsCallSessionListener.class);
        ImsReasonInfo info = mock(ImsReasonInfo.class);
        mCompatCallSession.setListener(listener);

        mCompatCallSession.mListener.callSessionTerminated(null, info);

        verify(listener).callSessionTerminated(eq(info));
    }
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

import android.telephony.ims.compat.stub.ImsCallSessionImplBase;

import com.android.ims.internal.IImsCallSessionListener;

public class TestImsCallSessionCompat extends ImsCallSessionImplBase {


    IImsCallSessionListener mListener;

    @Override
    public void setListener(IImsCallSessionListener listener) {
        mListener = listener;
    }
}
+59 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

import android.telephony.ims.compat.feature.MMTelFeature;

import com.android.ims.ImsCallProfile;
import com.android.ims.internal.IImsCallSession;
import com.android.ims.internal.IImsCallSessionListener;

/**
 * MMTelFeature implementation used by mockito to test functionality.
 */

public class TestMMTelFeatureCompat extends MMTelFeature {

    public boolean isConnectedCalled = false;
    public boolean isCreateCallSessionCalled = false;

    @Override
    public boolean isConnected(int callSessionType, int callType) {
        isConnectedCalled = true;
        return true;
    }

    @Override
    public void onFeatureReady() {
    }

    @Override
    public void onFeatureRemoved() {
    }

    public void sendSetFeatureState(int state) {
        setFeatureState(state);
    }

    // Compatibility Method
    @Override
    public IImsCallSession createCallSession(int sessionId, ImsCallProfile profile,
            IImsCallSessionListener listener) {
        isCreateCallSessionCalled = true;
        return null;
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -45,9 +45,8 @@ public class TestMmTelFeature extends MmTelFeature {
    }

    @Override
    public ImsCallSession createCallSession(ImsCallProfile profile,
            ImsCallSessionListener listener) {
        return super.createCallSession(profile, listener);
    public ImsCallSession createCallSession(ImsCallProfile profile) {
        return super.createCallSession(profile);
    }

    @Override