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

Commit 9edbf7ff authored by Hall Liu's avatar Hall Liu
Browse files

Fix flakiness in BasicCallTests

One test was flaky because the call wasn't making it to the
incallservice in time. Fix this by waiting on the correct future and the
correct handler.

Change-Id: Iedf341a39f8df8e6efe5d5d90c19d4339fd64a5d
Fixes: 120828657
Test: run test 100 times
parent eb496c3a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -266,6 +266,8 @@ public class CallsManager extends Call.ListenerBase
    // Instance variables for testing -- we keep the latest copy of the outgoing call futures
    // here so that we can wait on them in tests
    private CompletableFuture<Call> mLatestPostSelectionProcessingFuture;
    private CompletableFuture<Pair<Call, List<PhoneAccountSuggestion>>>
            mLatestPreAccountSelectionFuture;

    /**
     * The current telecom call ID.  Used when creating new instances of {@link Call}.  Should
@@ -1374,6 +1376,7 @@ public class CallsManager extends Call.ListenerBase
        // the account suggestion stage and the make room for call stage.
        CompletableFuture<Pair<Call, List<PhoneAccountSuggestion>>> preSelectStage =
                makeRoomForCall.thenCombine(suggestionFuture, Pair::create);
        mLatestPreAccountSelectionFuture = preSelectStage;

        // This future takes the list of suggested accounts and the call and determines if more
        // user interaction in the form of a phone account selection screen is needed. If so, it
@@ -2464,6 +2467,11 @@ public class CallsManager extends Call.ListenerBase
        return mLatestPostSelectionProcessingFuture;
    }

    @VisibleForTesting
    public CompletableFuture getLatestPreAccountSelectionFuture() {
        return mLatestPreAccountSelectionFuture;
    }

    /**
     * Returns the first call that it finds with the given states. The states are treated as having
     * priority order so that any call with the first state will be returned before any call with
+2 −0
Original line number Diff line number Diff line
@@ -332,6 +332,8 @@ public class BasicCallTests extends TelecomSystemTest {
        int startingNumCalls = mInCallServiceFixtureX.mCallById.size();
        String callId = startOutgoingPhoneCallWithNoPhoneAccount("650-555-1212",
                mConnectionServiceFixtureA);
        mTelecomSystem.getCallsManager().getLatestPreAccountSelectionFuture().join();
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        assertEquals(Call.STATE_SELECT_PHONE_ACCOUNT,
                mInCallServiceFixtureX.getCall(callId).getState());
        assertEquals(Call.STATE_SELECT_PHONE_ACCOUNT,