summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2018-05-22 10:22:03 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-05-22 10:22:03 -0700
commitd6c2557a8389b59e45ea2e572cad62009ba30563 (patch)
tree8904e312041f7f36d49206486602ec5c7f0da7d5 /tests
parent452c389378b26a99e2d0a551ff3690db3fb6f3e1 (diff)
parent7b885be3a672a10babcfb6868d73c766c91d8d43 (diff)
Merge changes from topic "79482323-params-expid" into pi-dev
am: 7b885be3a6 Change-Id: Ic7574fa27e92c12378d3a92e178db9f47bff35dc
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java23
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java26
2 files changed, 44 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
index fc9b33ad2..56dca114a 100644
--- a/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ScoringParamsTest.java
@@ -49,7 +49,10 @@ import org.mockito.Spy;
@SmallTest
public class ScoringParamsTest {
- ScoringParams mScoringParams;
+ private static final String EXPECTED_DEFAULTS =
+ "rssi2=-83:-80:-73:-60,rssi5=-80:-77:-70:-57,pps=0:1:100,horizon=15,nud=8,expid=0";
+
+ private ScoringParams mScoringParams;
/**
* Sets up for unit test
@@ -93,8 +96,7 @@ public class ScoringParamsTest {
@Test
public void testToString() throws Exception {
mScoringParams = new ScoringParams();
- String expect =
- "rssi2=-83:-80:-73:-60,rssi5=-80:-77:-70:-57,pps=0:1:100,horizon=15,nud=8";
+ String expect = EXPECTED_DEFAULTS;
String actual = mScoringParams.toString();
assertEquals(expect, actual);
}
@@ -105,8 +107,7 @@ public class ScoringParamsTest {
@Test
public void testUpdateEverything() throws Exception {
mScoringParams = new ScoringParams();
- String params =
- "rssi2=-86:-84:-77:-10,rssi5=-88:-77:-66:-55,pps=1:10:30,horizon=3,nud=3";
+ String params = EXPECTED_DEFAULTS.replaceAll("8", "9");
assertTrue(mScoringParams.update(params));
assertEquals(params, mScoringParams.toString());
}
@@ -200,6 +201,17 @@ public class ScoringParamsTest {
}
/**
+ * Test that expid is hooked up
+ */
+ @Test
+ public void testExperimentIdentifier() throws Exception {
+ mScoringParams = new ScoringParams();
+ assertEquals(0, mScoringParams.getExperimentIdentifier());
+ assertTrue(mScoringParams.update("expid=99"));
+ assertEquals(99, mScoringParams.getExperimentIdentifier());
+ }
+
+ /**
* Check character set
*/
@Test
@@ -225,6 +237,7 @@ public class ScoringParamsTest {
assertEquals(param100.substring(0, 90),
mScoringParams.sanitize(param100 + "00000000000").substring(0, 90));
assertEquals("q?=???", mScoringParams.sanitize("q\b= ~["));
+ assertEquals("", mScoringParams.sanitize(null));
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 3e267196e..9682750d2 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -72,6 +72,7 @@ public class WifiMetricsTest {
WifiMetricsProto.WifiLog mDecodedProto;
TestLooper mTestLooper;
@Mock Clock mClock;
+ @Mock ScoringParams mScoringParams;
@Mock WifiConfigManager mWcm;
@Mock PasspointManager mPpm;
@Mock WifiNetworkSelector mWns;
@@ -86,6 +87,7 @@ public class WifiMetricsTest {
new WifiAwareMetrics(mClock), new RttMetrics(mClock));
mWifiMetrics.setWifiConfigManager(mWcm);
mWifiMetrics.setPasspointManager(mPpm);
+ mWifiMetrics.setScoringParams(mScoringParams);
mWifiMetrics.setWifiNetworkSelector(mWns);
}
@@ -1737,6 +1739,30 @@ public class WifiMetricsTest {
assertEquals(0, mDecodedProto.numOpenNetworkRecommendationUpdates);
}
+ /**
+ * Check ScoringParams
+ */
+ @Test
+ public void testExperimentId() throws Exception {
+ final int id = 42;
+ final String expectId = "x" + id;
+ when(mScoringParams.getExperimentIdentifier()).thenReturn(id);
+ dumpProtoAndDeserialize();
+ assertEquals(expectId, mDecodedProto.scoreExperimentId);
+ }
+
+ /**
+ * Check ScoringParams default case
+ */
+ @Test
+ public void testDefaultExperimentId() throws Exception {
+ final int id = 0;
+ final String expectId = "";
+ when(mScoringParams.getExperimentIdentifier()).thenReturn(id);
+ dumpProtoAndDeserialize();
+ assertEquals(expectId, mDecodedProto.scoreExperimentId);
+ }
+
/** short hand for instantiating an anonymous int array, instead of 'new int[]{a1, a2, ...}' */
private int[] a(int... element) {
return element;