diff options
author | Michael Plass <mplass@google.com> | 2020-03-21 20:05:20 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-03-21 20:05:20 +0000 |
commit | 5086f8da98e4d1fe44033a3ef2a3be2d76b4e333 (patch) | |
tree | 778a53e742a298814f64d24ef5f59dea8d620e9a /tests | |
parent | a2d7442bb5892c4a986a1e54d3f51abb10a9b66f (diff) | |
parent | c6f842d7676f0a20ca83d3482b5177b528b25503 (diff) |
Merge changes Ifc80ff6e,I24314151 into rvc-dev
* changes:
Prefer trusted networks to untrusted
[ThroughputScorer] Simplify last-selected bonus
Diffstat (limited to 'tests')
3 files changed, 111 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 0512307c8..918e9e834 100644 --- a/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/CandidateScorerTest.java @@ -17,6 +17,7 @@ package com.android.server.wifi; import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.lessThan; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -178,6 +179,27 @@ public class CandidateScorerTest extends WifiBaseTest { } /** + * Prefer to switch with a larger rssi difference. + */ + @Test + public void testSwitchWithLargerDifference() throws Exception { + assertThat(evaluate(mCandidate1.setScanRssi(-80) + .setCurrentNetwork(true)), + lessThan(evaluate(mCandidate2.setScanRssi(-60)))); + } + + /** + * Stay on recently selected network. + */ + @Test + public void testStayOnRecentlySelected() throws Exception { + assertThat(evaluate(mCandidate1.setScanRssi(-80) + .setCurrentNetwork(true) + .setLastSelectionWeight(0.25)), + greaterThan(evaluate(mCandidate2.setScanRssi(-60)))); + } + + /** * Above saturation, don't switch from current even with a large rssi difference. */ @Test @@ -189,7 +211,7 @@ public class CandidateScorerTest extends WifiBaseTest { } /** - * Prefer high throughput network + * Prefer high throughput network. */ @Test public void testPreferHighThroughputNetwork() throws Exception { @@ -200,4 +222,59 @@ public class CandidateScorerTest extends WifiBaseTest { .setPredictedThroughputMbps(50)))); } } + + /** + * Prefer saved over suggestion. + */ + @Test + public void testPreferSavedOverSuggestion() throws Exception { + if (mExpectedExpId != ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID) return; + assertThat(evaluate(mCandidate1.setScanRssi(-77).setEphemeral(false)), + greaterThan(evaluate(mCandidate2.setScanRssi(-40) + .setEphemeral(true) + .setPredictedThroughputMbps(1000)))); + } + + /** + * Prefer metered saved over unmetered suggestion. + */ + @Test + public void testPreferMeteredSavedOverUnmeteredSuggestion() throws Exception { + if (mExpectedExpId != ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID) return; + assertThat(evaluate(mCandidate1.setScanRssi(-77).setEphemeral(false).setMetered(false)), + greaterThan(evaluate(mCandidate2.setScanRssi(-40) + .setEphemeral(true) + .setMetered(true) + .setPredictedThroughputMbps(1000)))); + } + + /** + * Prefer trusted metered suggestion over privileged untrusted. + */ + @Test + public void testPreferTrustedOverUntrusted() throws Exception { + if (mExpectedExpId != ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID) return; + assertThat(evaluate(mCandidate1.setScanRssi(-77).setEphemeral(true).setMetered(true)), + greaterThan(evaluate(mCandidate2.setScanRssi(-40) + .setEphemeral(true) + .setPredictedThroughputMbps(1000) + .setTrusted(false) + .setCarrierOrPrivileged(true)))); + } + + /** + * Prefer carrier untrusted over other untrusted. + */ + @Test + public void testPreferCarrierUntrustedOverOtherUntrusted() throws Exception { + if (mExpectedExpId != ThroughputScorer.THROUGHPUT_SCORER_DEFAULT_EXPID) return; + assertThat(evaluate(mCandidate1.setScanRssi(-77) + .setEphemeral(true) + .setMetered(true) + .setCarrierOrPrivileged(true)), + greaterThan(evaluate(mCandidate2.setScanRssi(-40) + .setPredictedThroughputMbps(1000) + .setTrusted(false)))); + } + } diff --git a/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java b/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java index cf75ad56c..1d84c4024 100644 --- a/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java +++ b/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java @@ -30,7 +30,8 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate { private boolean mIsCurrentBssid; private boolean mIsPasspoint; private boolean mIsEphemeral; - private boolean mIsTrusted; + private boolean mIsTrusted = true; + private boolean mCarrierOrPrivileged; private boolean mIsMetered; private int mNominatorId = -1; private double mLastSelectionWeight; @@ -53,6 +54,7 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate { mIsPasspoint = candidate.isPasspoint(); mIsEphemeral = candidate.isEphemeral(); mIsTrusted = candidate.isTrusted(); + mCarrierOrPrivileged = candidate.isCarrierOrPrivileged(); mIsMetered = candidate.isMetered(); mNominatorId = candidate.getNominatorId(); mLastSelectionWeight = candidate.getLastSelectionWeight(); @@ -127,6 +129,16 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate { return mIsTrusted; } + public ConcreteCandidate setCarrierOrPrivileged(boolean carrierOrPrivileged) { + mCarrierOrPrivileged = carrierOrPrivileged; + return this; + } + + @Override + public boolean isCarrierOrPrivileged() { + return mCarrierOrPrivileged; + } + public ConcreteCandidate setMetered(boolean isMetered) { mIsMetered = isMetered; return this; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java index b97b25248..7ce59c9ee 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java @@ -348,4 +348,24 @@ public class WifiCandidatesTest extends WifiBaseTest { assertEquals(2, mWifiCandidates.size()); assertEquals(0, mWifiCandidates.getFaultCount()); } + + /** + * Verify CarrierOrPrivileged bit is remembered. + */ + @Test + public void testAddCarrierOrPrivilegedCandidate() { + WifiCandidates.Key key = mWifiCandidates + .keyFromScanDetailAndConfig(mScanDetail1, mConfig1); + WifiCandidates.Candidate candidate; + // Make sure the CarrierOrPrivileged false is remembered + assertTrue(mWifiCandidates.add(key, mConfig1, 0, -50, 2412, 0.0, false, false, 100)); + candidate = mWifiCandidates.getCandidates().get(0); + assertFalse(candidate.isCarrierOrPrivileged()); + mWifiCandidates.remove(candidate); + // Make sure the CarrierOrPrivileged true is remembered + assertTrue(mWifiCandidates.add(key, mConfig1, 0, -50, 2412, 0.0, false, true, 100)); + candidate = mWifiCandidates.getCandidates().get(0); + assertTrue(candidate.isCarrierOrPrivileged()); + mWifiCandidates.remove(candidate); + } } |