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

Commit 005710d2 authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "Fix broken and flaky unit tests" into nyc-mr1-dev

parents cb3a48d0 609992b6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -452,6 +452,11 @@ public class CallAudioManager extends CallsManagerListenerBase {
        return mCallAudioRouteStateMachine;
    }

    @VisibleForTesting
    public CallAudioModeStateMachine getCallAudioModeStateMachine() {
        return mCallAudioModeStateMachine;
    }

    void dump(IndentingPrintWriter pw) {
        pw.println("All calls:");
        pw.increaseIndent();
+15 −11
Original line number Diff line number Diff line
@@ -1080,6 +1080,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
    private final StatusBarNotifier mStatusBarNotifier;
    private final CallAudioManager.AudioServiceFactory mAudioServiceFactory;
    private final boolean mDoesDeviceSupportEarpieceRoute;
    private final TelecomSystem.SyncRoot mLock;
    private boolean mHasUserExplicitlyLeftBluetooth = false;

    private HashMap<String, Integer> mStateNameToRouteCode;
@@ -1117,6 +1118,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
        mStatusBarNotifier = statusBarNotifier;
        mAudioServiceFactory = audioServiceFactory;
        mDoesDeviceSupportEarpieceRoute = doesDeviceSupportEarpieceRoute;
        mLock = callsManager.getLock();

        mStateNameToRouteCode = new HashMap<>(8);
        mStateNameToRouteCode.put(mQuiescentEarpieceRoute.getName(), ROUTE_EARPIECE);
@@ -1298,6 +1300,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
    }

    private void setSystemAudioState(CallAudioState newCallAudioState, boolean force) {
        synchronized (mLock) {
            Log.i(this, "setSystemAudioState: changing from %s to %s", mLastKnownCallAudioState,
                    newCallAudioState);
            if (force || !newCallAudioState.equals(mLastKnownCallAudioState)) {
@@ -1312,6 +1315,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                mLastKnownCallAudioState = newCallAudioState;
            }
        }
    }

    private void updateAudioForForegroundCall(CallAudioState newCallAudioState) {
        Call call = mCallsManager.getForegroundCall();
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ public class AnalyticsTests extends TelecomSystemTest {
        sessions.stream()
                .filter(s -> Log.Sessions.CSW_ADD_CONFERENCE_CALL.equals(
                        Analytics.sSessionIdToLogSession.get(s.getKey())))
                .forEach(s -> assertTrue(s.getTime() > minTime));
                .forEach(s -> assertTrue(s.getTime() >= minTime));
    }

    @MediumTest
+5 −0
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ public class BasicCallTests extends TelecomSystemTest {
                .createConnection(any(PhoneAccountHandle.class), anyString(),
                        any(ConnectionRequest.class), eq(true), eq(false));

        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        assertEquals(1, mCallerInfoAsyncQueryFactoryFixture.mRequests.size());
        for (CallerInfoAsyncQueryFactoryFixture.Request request :
                mCallerInfoAsyncQueryFactoryFixture.mRequests) {
@@ -314,10 +315,12 @@ public class BasicCallTests extends TelecomSystemTest {
        mTelecomSystem.getTelecomServiceImpl().getBinder()
                .addNewIncomingCall(mPhoneAccountA0.getAccountHandle(), extras);

        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        verify(mConnectionServiceFixtureA.getTestDouble())
                .createConnection(any(PhoneAccountHandle.class), anyString(),
                        any(ConnectionRequest.class), eq(true), eq(false));

        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        // Never reply to the caller info lookup.
        assertEquals(1, mCallerInfoAsyncQueryFactoryFixture.mRequests.size());

@@ -357,10 +360,12 @@ public class BasicCallTests extends TelecomSystemTest {
        mTelecomSystem.getTelecomServiceImpl().getBinder()
                .addNewIncomingCall(mPhoneAccountA0.getAccountHandle(), extras);

        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        verify(mConnectionServiceFixtureA.getTestDouble())
                .createConnection(any(PhoneAccountHandle.class), anyString(),
                        any(ConnectionRequest.class), eq(true), eq(false));

        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        assertEquals(1, mCallerInfoAsyncQueryFactoryFixture.mRequests.size());
        for (CallerInfoAsyncQueryFactoryFixture.Request request :
                mCallerInfoAsyncQueryFactoryFixture.mRequests) {
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.server.telecom.CallsManager;
import com.android.server.telecom.ConnectionServiceWrapper;
import com.android.server.telecom.CallAudioManager;
import com.android.server.telecom.StatusBarNotifier;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.WiredHeadsetManager;

import org.mockito.ArgumentCaptor;
@@ -117,6 +118,7 @@ public class CallAudioRouteStateMachineTest
    private CallAudioManager.AudioServiceFactory mAudioServiceFactory;
    private static final int TEST_TIMEOUT = 500;
    private AudioManager mockAudioManager;
    private final TelecomSystem.SyncRoot mLock = new TelecomSystem.SyncRoot() { };

    @Override
    public void setUp() throws Exception {
@@ -133,6 +135,7 @@ public class CallAudioRouteStateMachineTest
        };

        when(mockCallsManager.getForegroundCall()).thenReturn(fakeCall);
        when(mockCallsManager.getLock()).thenReturn(mLock);
        when(fakeCall.getConnectionService()).thenReturn(mockConnectionServiceWrapper);
        when(fakeCall.isAlive()).thenReturn(true);
        doNothing().when(mockConnectionServiceWrapper).onCallAudioStateChanged(any(Call.class),
@@ -856,6 +859,7 @@ public class CallAudioRouteStateMachineTest
        reset(mockAudioManager, mockBluetoothManager, mockCallsManager,
                mockConnectionServiceWrapper);
        when(mockCallsManager.getForegroundCall()).thenReturn(fakeCall);
        when(mockCallsManager.getLock()).thenReturn(mLock);
        doNothing().when(mockConnectionServiceWrapper).onCallAudioStateChanged(any(Call.class),
                any(CallAudioState.class));
    }
Loading