diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-04-12 20:35:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-12 20:35:15 +0000 |
commit | aa7241983001b0df6329fa2d17ed09d5933857a6 (patch) | |
tree | 82fdafae0e9ffe9dd8c12af0d74569f52714d49e /tests | |
parent | 88624ac099ce8ecc04d05e59294a5900479e49e1 (diff) | |
parent | e30a3392f1301c8529ea793840fe0a648e60da25 (diff) |
Merge "Current network bonus score adjustment" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java | 48 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java | 24 |
2 files changed, 70 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java index 918e9e834..427a5b36c 100644 --- a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java @@ -174,8 +174,52 @@ public class CandidateScorerTest extends WifiBaseTest { */ @Test public void testPreferTheCurrentNetworkEvenIfRssiDifferenceIsSignificant() throws Exception { - assertThat(evaluate(mCandidate1.setScanRssi(-74).setCurrentNetwork(true)), - greaterThan(evaluate(mCandidate2.setScanRssi(-70)))); + assertThat(evaluate(mCandidate1.setScanRssi(-65).setCurrentNetwork(true) + .setPredictedThroughputMbps(433)), + greaterThan(evaluate(mCandidate2.setScanRssi(-57) + .setPredictedThroughputMbps(433)))); + } + + /** + * Prefer the current network, even if throughput difference is significant. + */ + @Test + public void testPreferTheCurrentNetworkEvenIfTputDifferenceIsSignificant() throws Exception { + assertThat(evaluate(mCandidate1.setScanRssi(-57) + .setCurrentNetwork(true) + .setPredictedThroughputMbps(433)), + greaterThan(evaluate(mCandidate2.setScanRssi(-57) + .setPredictedThroughputMbps(560)))); + } + + /** + * Prefer to switch when current network has low throughput and no internet (unexpected) + */ + @Test + public void testSwitchifCurrentNetworkNoInternetUnexpectedAndLowThroughput() throws Exception { + if (mExpectedExpId != ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID) return; + assertThat(evaluate(mCandidate1.setScanRssi(-57) + .setCurrentNetwork(true) + .setPredictedThroughputMbps(433) + .setNoInternetAccess(true) + .setNoInternetAccessExpected(false)), + lessThan(evaluate(mCandidate2.setScanRssi(-57) + .setPredictedThroughputMbps(560)))); + } + + /** + * Prefer current network when current network has low throughput and no internet (but expected) + */ + @Test + public void testSwitchifCurrentNetworkHasNoInternetExceptedAndLowThroughput() throws Exception { + if (mExpectedExpId != ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID) return; + assertThat(evaluate(mCandidate1.setScanRssi(-57) + .setCurrentNetwork(true) + .setPredictedThroughputMbps(433) + .setNoInternetAccess(true) + .setNoInternetAccessExpected(true)), + greaterThan(evaluate(mCandidate2.setScanRssi(-57) + .setPredictedThroughputMbps(560)))); } /** diff --git a/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java b/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java index 1d84c4024..b95a1171b 100644 --- a/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java +++ b/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java @@ -33,6 +33,8 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate { private boolean mIsTrusted = true; private boolean mCarrierOrPrivileged; private boolean mIsMetered; + private boolean mHasNoInternetAccess; + private boolean mIsNoInternetAccessExpected; private int mNominatorId = -1; private double mLastSelectionWeight; private int mScanRssi = -127; @@ -56,6 +58,8 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate { mIsTrusted = candidate.isTrusted(); mCarrierOrPrivileged = candidate.isCarrierOrPrivileged(); mIsMetered = candidate.isMetered(); + mHasNoInternetAccess = candidate.hasNoInternetAccess(); + mIsNoInternetAccessExpected = candidate.isNoInternetAccessExpected(); mNominatorId = candidate.getNominatorId(); mLastSelectionWeight = candidate.getLastSelectionWeight(); mScanRssi = candidate.getScanRssi(); @@ -149,6 +153,26 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate { return mIsMetered; } + public ConcreteCandidate setNoInternetAccess(boolean hasNoInternetAccess) { + mHasNoInternetAccess = hasNoInternetAccess; + return this; + } + + @Override + public boolean hasNoInternetAccess() { + return mHasNoInternetAccess; + } + + public ConcreteCandidate setNoInternetAccessExpected(boolean isNoInternetAccessExpected) { + mIsNoInternetAccessExpected = isNoInternetAccessExpected; + return this; + } + + @Override + public boolean isNoInternetAccessExpected() { + return mIsNoInternetAccessExpected; + } + public ConcreteCandidate setNominatorId(int nominatorId) { mNominatorId = nominatorId; return this; |