summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2016-12-01 15:42:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-12-01 15:42:35 +0000
commit818b30de68475ac6a4f55c84f2f279714d915911 (patch)
tree1bb08332553e76f5f96eca45ddbb349944fefb20 /tests
parent9333b67ffda8534ee84c383dc3bbad23aee198a2 (diff)
parent375f9ff558c5298f107fd7c6a16a5aeade41cec3 (diff)
Merge "AWARE: update tests with new match filter API"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java7
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java35
2 files changed, 36 insertions, 6 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java
index 489fe6d46..61aa27441 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java
@@ -1098,7 +1098,8 @@ public class WifiAwareHalTest {
int publishCount, int publishTtl, boolean enableTerminateNotification)
throws JSONException {
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(ssi.getBytes()).setMatchFilter(tlvMatch.getArray())
+ .setServiceSpecificInfo(ssi.getBytes()).setMatchFilter(
+ new TlvBufferUtils.TlvIterable(0, 1, tlvMatch.getArray()).toList())
.setPublishType(publishType)
.setPublishCount(publishCount).setTtlSec(publishTtl)
.setTerminateNotificationEnabled(enableTerminateNotification).build();
@@ -1146,7 +1147,9 @@ public class WifiAwareHalTest {
boolean enableTerminateNotification) throws JSONException {
SubscribeConfig subscribeConfig = new SubscribeConfig.Builder()
.setServiceName(serviceName).setServiceSpecificInfo(ssi.getBytes())
- .setMatchFilter(tlvMatch.getArray()).setSubscribeType(subscribeType)
+ .setMatchFilter(
+ new TlvBufferUtils.TlvIterable(0, 1, tlvMatch.getArray()).toList())
+ .setSubscribeType(subscribeType)
.setSubscribeCount(subscribeCount).setTtlSec(subscribeTtl).setMatchStyle(matchStyle)
.setTerminateNotificationEnabled(enableTerminateNotification).build();
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java
index d54c111f0..1876cd2e3 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java
@@ -362,6 +362,16 @@ public class WifiAwareServiceImplTest {
}
/**
+ * Validate that publish() verifies the input PublishConfig and fails on a bad match filter -
+ * invalid LV.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testPublishMatchFilterBadLv() {
+ byte[] badLv = { 0, 1, 127, 2, 126, 125, 3 };
+ doBadPublishConfiguration("correctservicename", null, badLv);
+ }
+
+ /**
* Validate updatePublish() - correct pass-through args.
*/
@Test
@@ -447,6 +457,16 @@ public class WifiAwareServiceImplTest {
}
/**
+ * Validate that subscribe() verifies the input SubscribeConfig and fails on a bad match filter
+ * - invalid LV.
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void testSubscribeMatchFilterBadLv() {
+ byte[] badLv = { 0, 1, 127, 2, 126, 125, 3 };
+ doBadSubscribeConfiguration("correctservicename", null, badLv);
+ }
+
+ /**
* Validate updateSubscribe() error checking.
*/
@Test(expected = IllegalArgumentException.class)
@@ -590,8 +610,11 @@ public class WifiAwareServiceImplTest {
private void doBadPublishConfiguration(String serviceName, byte[] ssi, byte[] matchFilter)
throws IllegalArgumentException {
- PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(ssi).setMatchFilter(matchFilter).build();
+ // using the hidden constructor since may be passing invalid parameters which would be
+ // caught by the Builder. Want to test whether service side will catch invalidly
+ // constructed configs.
+ PublishConfig publishConfig = new PublishConfig(serviceName.getBytes(), ssi, matchFilter,
+ PublishConfig.PUBLISH_TYPE_UNSOLICITED, 0, 0, true);
int clientId = doConnect();
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);
@@ -603,8 +626,12 @@ public class WifiAwareServiceImplTest {
private void doBadSubscribeConfiguration(String serviceName, byte[] ssi, byte[] matchFilter)
throws IllegalArgumentException {
- SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(ssi).setMatchFilter(matchFilter).build();
+ // using the hidden constructor since may be passing invalid parameters which would be
+ // caught by the Builder. Want to test whether service side will catch invalidly
+ // constructed configs.
+ SubscribeConfig subscribeConfig = new SubscribeConfig(serviceName.getBytes(), ssi,
+ matchFilter, SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE, 0, 0,
+ SubscribeConfig.MATCH_STYLE_ALL, true);
int clientId = doConnect();
IWifiAwareDiscoverySessionCallback mockCallback = mock(
IWifiAwareDiscoverySessionCallback.class);