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

Commit 9de9b626 authored by Ling Ma's avatar Ling Ma
Browse files

Update outdated test

Fix failed test that was introduced due to an earlier change/merge timing.
And improve the log.

Fix: 297416175
Fix: 297415680
Test: https://android-build.googleplex.com/builds/abtd/run/L21300000962760990 and https://android-build.googleplex.com/builds/abtd/run/L71800000962759145
Change-Id: I69525b6f71fbc048151dbd4b94f207629eb971a0
parent a9ea71f1
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -535,13 +535,13 @@ public class AutoDataSwitchController extends Handler {
        if (preferredPhoneId == defaultDataPhoneId) {
            // on default data sub
            int candidatePhoneId = getSwitchCandidatePhoneId(defaultDataPhoneId, debugMessage);
            log(debugMessage.toString());
            if (candidatePhoneId != INVALID_PHONE_INDEX) {
                mSelectedTargetPhoneId = candidatePhoneId;
                startStabilityCheck(candidatePhoneId, mRequirePingTestBeforeSwitch);
            } else {
                cancelAnyPendingSwitch();
            }
            log(debugMessage.toString());
        } else {
            // on backup data sub
            Phone backupDataPhone = PhoneFactory.getPhone(preferredPhoneId);
@@ -663,10 +663,9 @@ public class AutoDataSwitchController extends Handler {
                        debugMessage.append(", but its data is not allowed");
                    }
                }
            } else {
                debugMessage.append(", no candidate found in Home service");
            }
        }
        debugMessage.append(", found no qualified candidate.");
        return INVALID_PHONE_INDEX;
    }

+7 −5
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {

        // Change data config
        doReturn(true).when(mDataConfigManager).isPingTestBeforeAutoDataSwitchRequired();
        doReturn(1L).when(mDataConfigManager)
        doReturn(10000L).when(mDataConfigManager)
                .getAutoDataSwitchAvailabilityStabilityTimeThreshold();
        doReturn(MAX_RETRY).when(mDataConfigManager).getAutoDataSwitchValidationMaxRetry();
        doReturn(SCORE_TOLERANCE).when(mDataConfigManager).getAutoDataSwitchScoreTolerance();
@@ -353,10 +353,12 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {
        // Switch success, but the previous stability check is still pending
        doReturn(PHONE_2).when(mPhoneSwitcher).getPreferredDataPhoneId();

        // The attempt to switch back should override the previous stability check
        serviceStateChanged(PHONE_1, NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING);
        // process messages without touching the delayed message, allow it to be overridden.
        processAllMessages();
        // Display info and signal strength on secondary phone became worse than the default.
        // Expect to switch back, and it should override the previous stability check
        serviceStateChanged(PHONE_1, NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
        signalStrengthChanged(PHONE_1, SignalStrength.SIGNAL_STRENGTH_GREAT);
        displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo);
        signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_POOR);
        // process all messages include the delayed message
        processAllFutureMessages();