Home | History | Annotate | Download | only in ims
      1 /*
      2  * Copyright (C) 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.telephony.ims;
     18 
     19 import static org.junit.Assert.assertTrue;
     20 import static org.mockito.ArgumentMatchers.eq;
     21 import static org.mockito.Mockito.mock;
     22 import static org.mockito.Mockito.verify;
     23 
     24 import android.support.test.runner.AndroidJUnit4;
     25 import android.telephony.ims.aidl.IImsCallSessionListener;
     26 import android.test.suitebuilder.annotation.SmallTest;
     27 
     28 import com.android.ims.internal.IImsMMTelFeature;
     29 
     30 import org.junit.After;
     31 import org.junit.Before;
     32 import org.junit.Test;
     33 import org.junit.runner.RunWith;
     34 import org.mockito.MockitoAnnotations;
     35 
     36 @RunWith(AndroidJUnit4.class)
     37 public class ImsCompatTests {
     38 
     39     TestMMTelFeatureCompat mCompatMmTel;
     40     IImsMMTelFeature mCompatMmTelBinder;
     41 
     42     TestImsCallSessionCompat mCompatCallSession;
     43 
     44     @Before
     45     public void setUp() {
     46         MockitoAnnotations.initMocks(this);
     47         mCompatMmTel = new TestMMTelFeatureCompat();
     48         mCompatMmTelBinder = mCompatMmTel.getBinder();
     49 
     50         mCompatCallSession = new TestImsCallSessionCompat();
     51     }
     52 
     53     @After
     54     public void tearDown() {
     55         mCompatMmTel = null;
     56         mCompatMmTelBinder = null;
     57 
     58         mCompatCallSession = null;
     59     }
     60 
     61     @SmallTest
     62     @Test
     63     public void testCreateCallSessionCompat() throws Exception {
     64         mCompatMmTelBinder.createCallSession(0, new ImsCallProfile());
     65         assertTrue(mCompatMmTel.isCreateCallSessionCalled);
     66     }
     67 
     68     @SmallTest
     69     @Test
     70     public void testListenerCompatLayer() throws Exception {
     71         IImsCallSessionListener listener = mock(IImsCallSessionListener.class);
     72         ImsReasonInfo info = new ImsReasonInfo();
     73         mCompatCallSession.setListener(listener);
     74 
     75         mCompatCallSession.mListener.callSessionTerminated(null, info);
     76 
     77         verify(listener).callSessionTerminated(eq(info));
     78     }
     79 }
     80