summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java40
2 files changed, 32 insertions, 20 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java b/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java
index 3f3bbe6e7..871218f1f 100644
--- a/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java
+++ b/tests/wifitests/src/com/android/server/wifi/ConcreteCandidate.java
@@ -30,6 +30,7 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate {
private boolean mIsPasspoint;
private boolean mIsEphemeral;
private boolean mIsTrusted;
+ private boolean mIsMetered;
private int mEvaluatorId = -1;
private int mEvaluatorScore = Integer.MIN_VALUE;
private double mLastSelectionWeight;
@@ -51,6 +52,7 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate {
mIsPasspoint = candidate.isPasspoint();
mIsEphemeral = candidate.isEphemeral();
mIsTrusted = candidate.isTrusted();
+ mIsMetered = candidate.isMetered();
mEvaluatorId = candidate.getEvaluatorId();
mEvaluatorScore = candidate.getEvaluatorScore();
mLastSelectionWeight = candidate.getLastSelectionWeight();
@@ -134,6 +136,16 @@ public final class ConcreteCandidate implements WifiCandidates.Candidate {
return mIsTrusted;
}
+ public ConcreteCandidate setMetered(boolean isMetered) {
+ mIsMetered = isMetered;
+ return this;
+ }
+
+ @Override
+ public boolean isMetered() {
+ return mIsMetered;
+ }
+
public ConcreteCandidate setEvaluatorId(int evaluatorId) {
mEvaluatorId = evaluatorId;
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 f460e6d6a..5c07edc27 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCandidatesTest.java
@@ -79,10 +79,10 @@ public class WifiCandidatesTest extends WifiBaseTest {
*/
@Test
public void testDontDieFromNulls() throws Exception {
- mWifiCandidates.add(null, mConfig1, 1, 42);
- mWifiCandidates.add(mScanDetail1, null, 2, 16);
+ mWifiCandidates.add(null, mConfig1, 1, 42, 0.0, false);
+ mWifiCandidates.add(mScanDetail1, null, 2, 16, 0.0, false);
doReturn(null).when(mScanDetail2).getScanResult();
- mWifiCandidates.add(mScanDetail2, mConfig2, 3, 314, 1.0);
+ mWifiCandidates.add(mScanDetail2, mConfig2, 3, 314, 1.0, true);
assertFalse(mWifiCandidates.remove(null));
assertEquals(0, mWifiCandidates.size());
@@ -93,7 +93,7 @@ public class WifiCandidatesTest extends WifiBaseTest {
*/
@Test
public void testAddJustOne() throws Exception {
- assertTrue(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0));
+ assertTrue(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false));
assertEquals(1, mWifiCandidates.size());
assertEquals(0, mWifiCandidates.getFaultCount());
@@ -108,7 +108,7 @@ public class WifiCandidatesTest extends WifiBaseTest {
public void testQuotingBotch() throws Exception {
// Unfortunately ScanResult.SSID is not quoted; make sure we catch that
mScanResult1.SSID = mConfig1.SSID;
- mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0);
+ mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, true);
// Should not have added this one
assertEquals(0, mWifiCandidates.size());
@@ -136,7 +136,7 @@ public class WifiCandidatesTest extends WifiBaseTest {
assertFalse(matchInfo1 == matchInfo1Prime); // Checking assumption
MacAddress mac1 = MacAddress.createRandomUnicastAddress();
MacAddress mac2 = MacAddress.createRandomUnicastAddress();
- assertNotEquals(mac1, mac2); // really tiny probablility of failing here
+ assertNotEquals(mac1, mac2); // really tiny probability of failing here
WifiCandidates.Key key1 = new WifiCandidates.Key(matchInfo1, mac1, 1);
@@ -167,7 +167,7 @@ public class WifiCandidatesTest extends WifiBaseTest {
assertTrue(mWifiCandidates == mWifiCandidates.setPicky(true));
try {
mScanResult1.SSID = mConfig1.SSID; // As in testQuotingBotch()
- mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0);
+ mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false);
fail("Exception not raised in picky mode");
} catch (IllegalArgumentException e) {
assertEquals(1, mWifiCandidates.getFaultCount());
@@ -181,23 +181,23 @@ public class WifiCandidatesTest extends WifiBaseTest {
@Test
public void testNoOverwriteCases() throws Exception {
// Setup is to add the first candidate
- mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0);
+ mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false);
assertEquals(1, mWifiCandidates.size());
// Same evaluator, same score. Should not add.
- assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0));
+ assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false));
assertEquals(0, mWifiCandidates.getFaultCount()); // But not considered a fault
// Same evaluator, lower score. Should not add.
- assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 13, 0.0));
+ assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 13, 0.0, false));
assertEquals(0, mWifiCandidates.getFaultCount()); // Also not a fault
// Later evaluator. Should not add (regardless of score).
- assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 5, 13));
- assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 5, 15));
+ assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 5, 13, 0.0, false));
+ assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 5, 15, 0.0, false));
assertEquals(0, mWifiCandidates.getFaultCount()); // Still no faults
// Evaluator out of order. Should not add (regardless of score).
- assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 1, 12));
+ assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 1, 12, 0.0, false));
assertNotNull(mWifiCandidates.getLastFault()); // This one is considered a caller error
- assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 1, 15));
+ assertFalse(mWifiCandidates.add(mScanDetail1, mConfig1, 1, 15, 0.0, false));
assertEquals(2, mWifiCandidates.getFaultCount());
// After all that, only one candidate should be there.
assertEquals(1, mWifiCandidates.size());
@@ -210,12 +210,12 @@ public class WifiCandidatesTest extends WifiBaseTest {
public void testBssidValidation() throws Exception {
// Null BSSID.
mScanResult1.BSSID = null;
- mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14);
+ mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false);
assertTrue("Expecting NPE, got " + mWifiCandidates.getLastFault(),
mWifiCandidates.getLastFault() instanceof NullPointerException);
// Malformed BSSID
mScanResult1.BSSID = "NotaBssid!";
- mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14);
+ mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false);
assertTrue("Expecting IAE, got " + mWifiCandidates.getLastFault(),
mWifiCandidates.getLastFault() instanceof IllegalArgumentException);
assertEquals(0, mWifiCandidates.size());
@@ -232,8 +232,8 @@ public class WifiCandidatesTest extends WifiBaseTest {
mScanResult2.SSID = mScanResult1.SSID;
mScanResult2.BSSID = mScanResult1.BSSID.replace('1', '2');
// Add both
- mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14);
- mWifiCandidates.add(mScanDetail2, mConfig2, 2, 14);
+ mWifiCandidates.add(mScanDetail1, mConfig1, 2, 14, 0.0, false);
+ mWifiCandidates.add(mScanDetail2, mConfig2, 2, 14, 0.0, false);
// We expect them both to be there
assertEquals(2, mWifiCandidates.size());
// But just one group
@@ -268,8 +268,8 @@ public class WifiCandidatesTest extends WifiBaseTest {
mScanResult2.SSID = mScanResult1.SSID;
mScanResult2.BSSID = mScanResult1.BSSID;
// Try adding them both, the higher-scoring one second
- assertTrue(mWifiCandidates.add(mScanDetail2, mConfig2, 2, 14));
- assertTrue(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 15));
+ assertTrue(mWifiCandidates.add(mScanDetail2, mConfig2, 2, 14, 0.0, false));
+ assertTrue(mWifiCandidates.add(mScanDetail1, mConfig1, 2, 15, 0.0, false));
// Only one should survive
assertEquals(1, mWifiCandidates.size());
// And no faults