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

Commit 51bf0be2 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Fixed two flaky tests.

am: 325ea5a0

* commit '325ea5a0':
  Fixed two flaky tests.
parents 27f47164 325ea5a0
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -16,25 +16,40 @@

package com.android.internal.telephony;

import android.os.IBinder;
import android.os.ServiceManager;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;

public class Sms7BitEncodingTranslatorTest extends TelephonyTest {

    @Mock
    HashMap<String, IBinder> mServiceCache;
    @Mock
    IBinder mBinder;

    @Before
    public void setUp() throws Exception {
        logd("+Setup!");
        super.setUp(getClass().getSimpleName());

        doReturn(mBinder).when(mServiceCache).get(anyString());
        replaceInstance(ServiceManager.class, "sCache", null, mServiceCache);
        logd("-Setup!");
    }

@@ -80,6 +95,7 @@ public class Sms7BitEncodingTranslatorTest extends TelephonyTest {
    public void testCdmaTranslate() {

        TelephonyManager telephonyManager = TelephonyManager.from(mContext);

        doReturn(PhoneConstants.PHONE_TYPE_CDMA).when(telephonyManager).getCurrentPhoneType();

        String s = null;
+2 −1
Original line number Diff line number Diff line
@@ -255,6 +255,8 @@ public abstract class TelephonyTest {
                "mCdmaSubscriptionSourceChangedRegistrants", mCdmaSSM, mRegistrantList);
        replaceInstance(SimulatedCommandsVerifier.class, "sInstance", null,
                mSimulatedCommandsVerifier);
        replaceInstance(Singleton.class, "mInstance", mIActivityManagerSingleton,
                mIActivityManager);

        mSimulatedCommands = new SimulatedCommands();
        mContextFixture = new ContextFixture();
@@ -325,7 +327,6 @@ public abstract class TelephonyTest {
        doReturn(true).when(mImsManagerInstances).containsKey(anyInt());
        doReturn(mPhone).when(mInboundSmsHandler).getPhone();
        doReturn(mTelephonyEventLog).when(mTelephonyEventLogInstances).get(anyInt());
        doReturn(mIActivityManager).when(mIActivityManagerSingleton).get();
        doReturn(mImsCallProfile).when(mImsCall).getCallProfile();

        setReady(false);