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

Commit 3c3afb81 authored by Jack Yu's avatar Jack Yu Committed by Android Partner Code Review
Browse files

Merge "Revert "Test infrastructure improvement and code clean up."" into mm-wireless-dev

parents 9af2d687 21e1b42d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ import java.util.Map;
 * <p>For information about how to behave as the default SMS app on Android 4.4 (API level 19)
 * and higher, see {@link android.provider.Telephony}.
 */
public class SmsManager {
public final class SmsManager {
    private static final String TAG = "SmsManager";
    /**
     * A psuedo-subId that represents the default subId at any given time. The actual subId it
+10 −8
Original line number Diff line number Diff line
@@ -15,21 +15,17 @@
 */
package com.android.internal.telephony;

import android.icu.impl.Assert;
import android.os.Handler;
import android.os.HandlerThread;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
import android.test.suitebuilder.annotation.SmallTest;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;

import java.lang.reflect.Field;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -42,8 +38,12 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

public class CallManagerTest extends TelephonyTest {
import android.telephony.ServiceState;
import android.telephony.PhoneNumberUtils;
import java.lang.reflect.Field;

public class CallManagerTest extends TelephonyTest {
    private CallManager mCallManager = CallManager.getInstance();
    @Mock
    GsmCdmaCall mFgCall;
    @Mock
@@ -66,7 +66,9 @@ public class CallManagerTest extends TelephonyTest {
    @Before
    public void setUp() throws Exception {
        super.setUp(this.getClass().getSimpleName());
        restoreInstance(CallManager.class, "INSTANCE", null);
        Field field = CallManager.class.getDeclaredField("INSTANCE");
        field.setAccessible(true);
        field.set(null, mCallManager);
        /* Mock Phone and Call, initially all calls are idle */
        doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getState();
        doReturn(mServiceState).when(mPhone).getServiceState();
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 * Copyright (C) 2015 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.
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 * Copyright (C) 2015 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.
+28 −9
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 * Copyright (C) 2015 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.
@@ -21,27 +21,43 @@ import android.os.Looper;
import android.telephony.PhoneNumberUtils;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.util.Log;
import android.telephony.DisconnectCause;

import com.android.internal.telephony.test.SimulatedCommands;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.lang.reflect.Field;

public class GsmCdmaConnectionTest extends TelephonyTest {

public class GsmCdmaConnectionTest {
    private static final String TAG = "GsmCdmaConnectionTest";
    private ContextFixture mContextFixture;
    private GsmCdmaConnection connection;
    private SimulatedCommands mCi;

    @Mock
    GsmCdmaPhone mPhone;
    @Mock
    GsmCdmaCallTracker mCT;
    @Mock
    DriverCall mDC;

    @Before
    public void setUp() throws Exception {
        super.setUp(getClass().getSimpleName());
        replaceInstance(Handler.class, "mLooper", mCT, Looper.getMainLooper());

        MockitoAnnotations.initMocks(this);
        mContextFixture = new ContextFixture();
        mCi = new SimulatedCommands();

        Field field = Handler.class.getDeclaredField("mLooper");
        field.setAccessible(true);
        field.set(mCT, Looper.getMainLooper());
        mCT.mCi = mCi;
        doReturn(mContextFixture.getTestDouble()).when(mPhone).getContext();
        doReturn(mPhone).when(mCT).getPhone();
        doReturn(PhoneConstants.PHONE_TYPE_GSM).when(mPhone).getPhoneType();
        mCT.mForegroundCall = new GsmCdmaCall(mCT);
        mCT.mBackgroundCall = new GsmCdmaCall(mCT);
@@ -51,7 +67,6 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
    @After
    public void tearDown() throws Exception {
        connection = null;
        super.tearDown();
    }

    @Test @SmallTest
@@ -183,4 +198,8 @@ public class GsmCdmaConnectionTest extends TelephonyTest {
        assertEquals(connection.getDisconnectCause(), DisconnectCause.LOCAL);
        assertTrue(connection.getDisconnectTime() <= System.currentTimeMillis());
    }

    private static void logd(String s) {
        Log.d(TAG, s);
    }
}
Loading