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

Commit ae216b6f authored by Hall Liu's avatar Hall Liu
Browse files

Deflake some telecom unit tests

Telecom unit tests were flaky running in crosshatch_hwasan-userdebug.
Fix these flakes by adding more waitOnHandlerActions to resolve timing
issues.

Fixes: 160343264
Test: atest TelecomUnitTests
Change-Id: I6af61bd41c86ef00ae7750539587569d432c243a
parent 490401c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            mServiceInterface.createConnectionComplete(callId,
                                    Log.getExternalSession());
                        } catch (RemoteException e) {
                            logOutgoing("createConnectionComplete remote exception=%s", e);
                        }
                    }
                }
+13 −0
Original line number Diff line number Diff line
@@ -161,6 +161,9 @@ public class BasicCallTests extends TelecomSystemTest {
                .getApplicationContext().getSystemService(Context.TELECOM_SERVICE);
        telecomManager.acceptRingingCall();

        waitForHandlerAction(mTelecomSystem.getCallsManager()
                .getConnectionServiceFocusManager().getHandler(), TEST_TIMEOUT);

        verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
                .answer(eq(ids.mConnectionId), any());
        mConnectionServiceFixtureA.sendSetActive(ids.mConnectionId);
@@ -217,6 +220,9 @@ public class BasicCallTests extends TelecomSystemTest {
                .getApplicationContext().getSystemService(Context.TELECOM_SERVICE);
        telecomManager.acceptRingingCall(VideoProfile.STATE_AUDIO_ONLY);

        waitForHandlerAction(mTelecomSystem.getCallsManager()
                .getConnectionServiceFocusManager().getHandler(), TEST_TIMEOUT);

        // The generic answer method on the ConnectionService is used to answer audio-only calls.
        verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
                .answer(eq(ids.mConnectionId), any());
@@ -246,6 +252,9 @@ public class BasicCallTests extends TelecomSystemTest {
                .getApplicationContext().getSystemService(Context.TELECOM_SERVICE);
        telecomManager.acceptRingingCall(999 /* invalid videostate */);

        waitForHandlerAction(mTelecomSystem.getCallsManager()
                .getConnectionServiceFocusManager().getHandler(), TEST_TIMEOUT);

        // Answer video API should be called
        verify(mConnectionServiceFixtureA.getTestDouble(), timeout(TEST_TIMEOUT))
                .answerVideo(eq(ids.mConnectionId), eq(VideoProfile.STATE_BIDIRECTIONAL), any());
@@ -621,6 +630,10 @@ public class BasicCallTests extends TelecomSystemTest {
        mConnectionServiceFixtureA.
                sendSetDisconnected(outgoing.mConnectionId, DisconnectCause.REMOTE);

        waitForHandlerAction(mTelecomSystem.getCallsManager().getCallAudioManager()
                .getCallAudioModeStateMachine().getHandler(), TEST_TIMEOUT);
        waitForHandlerAction(mTelecomSystem.getCallsManager().getCallAudioManager()
                .getCallAudioRouteStateMachine().getHandler(), TEST_TIMEOUT);
        verify(audioManager, timeout(TEST_TIMEOUT))
                .abandonAudioFocusForCall();
        verify(audioManager, timeout(TEST_TIMEOUT).atLeastOnce())
+1 −0
Original line number Diff line number Diff line
@@ -249,6 +249,7 @@ public class ConnectionServiceFixture implements TestFixture<IConnectionService>

        @Override
        public void createConnectionComplete(String id, Session.Info info) throws RemoteException {
            Log.i(ConnectionServiceFixture.this, "createConnectionComplete: %s", id);
            mConnectionServiceDelegateAdapter.createConnectionComplete(id, null /*Session.Info*/);
        }

+5 −0
Original line number Diff line number Diff line
@@ -925,7 +925,12 @@ public class TelecomSystemTest extends TelecomTestCase {
        // Wait for the handler to start the CallerInfo lookup
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);

        // Wait a few more times to address flakiness due to timing issues.
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);

        // Ensure callback to CS on successful creation happened.

        verify(connectionServiceFixture.getTestDouble(), timeout(TEST_TIMEOUT))
                .createConnectionComplete(anyString(), any());