summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2016-08-19 23:22:00 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-08-19 23:22:00 +0000
commit6975c33e8abbeedcb1b5f64a94f008b3c35b9d88 (patch)
tree5a57c27bac9b275c8bbea061c94b32b33d18f060 /tests
parentf0c2934a3c1fae411e41f8a700a38bacaa706454 (diff)
parent65e89d2063f6ee50d00a2579b809deb0a98b5d8b (diff)
[NAN] Simplify publish/subscribe configuration - merge match filters
am: 65e89d2063 Change-Id: I18018e236686cfd87fb8d9ebda420cfcd0cd1c07
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java88
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java38
2 files changed, 53 insertions, 73 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
index e50d207f5..17e144af7 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
@@ -124,16 +124,12 @@ public class WifiNanHalTest {
final int publishTtl = 66;
final boolean enableTerminateNotification = true;
- TlvBufferUtils.TlvConstructor tlvTx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvTx.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
+ TlvBufferUtils.TlvConstructor tlvMatch = new TlvBufferUtils.TlvConstructor(0, 1);
+ tlvMatch.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
.putZeroLengthElement(0);
- TlvBufferUtils.TlvConstructor tlvRx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvRx.allocate(150).putByte(0, (byte) 66).putInt(0, 127).putString(0, "some other string")
- .putZeroLengthElement(0).putByteArray(0, serviceName.getBytes());
-
testPublish(transactionId, publishId, PublishConfig.PUBLISH_TYPE_UNSOLICITED, serviceName,
- ssi, tlvTx, tlvRx, publishCount, publishTtl, enableTerminateNotification);
+ ssi, tlvMatch, publishCount, publishTtl, enableTerminateNotification);
}
@Test
@@ -146,16 +142,12 @@ public class WifiNanHalTest {
final int publishTtl = 33;
final boolean enableTerminateNotification = false;
- TlvBufferUtils.TlvConstructor tlvTx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvTx.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
+ TlvBufferUtils.TlvConstructor tlvMatch = new TlvBufferUtils.TlvConstructor(0, 1);
+ tlvMatch.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
.putZeroLengthElement(0);
- TlvBufferUtils.TlvConstructor tlvRx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvRx.allocate(150).putByte(0, (byte) 66).putInt(0, 127).putString(0, "some other string")
- .putZeroLengthElement(0).putByteArray(0, serviceName.getBytes());
-
testPublish(transactionId, publishId, PublishConfig.PUBLISH_TYPE_SOLICITED, serviceName,
- ssi, tlvTx, tlvRx, publishCount, publishTtl, enableTerminateNotification);
+ ssi, tlvMatch, publishCount, publishTtl, enableTerminateNotification);
}
@Test
@@ -183,16 +175,12 @@ public class WifiNanHalTest {
final int matchStyle = SubscribeConfig.MATCH_STYLE_ALL;
final boolean enableTerminateNotification = true;
- TlvBufferUtils.TlvConstructor tlvTx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvTx.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
+ TlvBufferUtils.TlvConstructor tlvMatch = new TlvBufferUtils.TlvConstructor(0, 1);
+ tlvMatch.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
.putZeroLengthElement(0);
- TlvBufferUtils.TlvConstructor tlvRx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvRx.allocate(150).putByte(0, (byte) 66).putInt(0, 127).putString(0, "some other string")
- .putZeroLengthElement(0).putByteArray(0, serviceName.getBytes());
-
testSubscribe(transactionId, subscribeId, SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE,
- serviceName, ssi, tlvTx, tlvRx, subscribeCount, subscribeTtl, matchStyle,
+ serviceName, ssi, tlvMatch, subscribeCount, subscribeTtl, matchStyle,
enableTerminateNotification);
}
@@ -207,16 +195,12 @@ public class WifiNanHalTest {
final int matchStyle = SubscribeConfig.MATCH_STYLE_FIRST_ONLY;
final boolean enableTerminateNotification = false;
- TlvBufferUtils.TlvConstructor tlvTx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvTx.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
+ TlvBufferUtils.TlvConstructor tlvMatch = new TlvBufferUtils.TlvConstructor(0, 1);
+ tlvMatch.allocate(150).putByte(0, (byte) 10).putInt(0, 100).putString(0, "some string")
.putZeroLengthElement(0);
- TlvBufferUtils.TlvConstructor tlvRx = new TlvBufferUtils.TlvConstructor(0, 1);
- tlvRx.allocate(150).putByte(0, (byte) 66).putInt(0, 127).putString(0, "some other string")
- .putZeroLengthElement(0).putByteArray(0, serviceName.getBytes());
-
testSubscribe(transactionId, subscribeId, SubscribeConfig.SUBSCRIBE_TYPE_ACTIVE,
- serviceName, ssi, tlvTx, tlvRx, subscribeCount, subscribeTtl, matchStyle,
+ serviceName, ssi, tlvMatch, subscribeCount, subscribeTtl, matchStyle,
enableTerminateNotification);
}
@@ -1092,12 +1076,12 @@ public class WifiNanHalTest {
}
private void testPublish(short transactionId, int publishId, int publishType,
- String serviceName, String ssi, TlvBufferUtils.TlvConstructor tlvTx,
- TlvBufferUtils.TlvConstructor tlvRx, int publishCount, int publishTtl,
- boolean enableTerminateNotification) throws JSONException {
+ String serviceName, String ssi, TlvBufferUtils.TlvConstructor tlvMatch,
+ int publishCount, int publishTtl, boolean enableTerminateNotification)
+ throws JSONException {
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(ssi).setTxFilter(tlvTx.getArray())
- .setRxFilter(tlvRx.getArray()).setPublishType(publishType)
+ .setServiceSpecificInfo(ssi).setMatchFilter(tlvMatch.getArray())
+ .setPublishType(publishType)
.setPublishCount(publishCount).setTtlSec(publishTtl)
.setEnableTerminateNotification(enableTerminateNotification).build();
@@ -1124,10 +1108,13 @@ public class WifiNanHalTest {
equalTo(ssi.getBytes()));
collector.checkThat("publish_match_indicator", argsData.getInt("publish_match_indicator"),
equalTo(0));
- collector.checkThat("rx_match_filter", argsData.getByteArray("rx_match_filter"),
- equalTo(tlvRx.getArray()));
- collector.checkThat("tx_match_filter", argsData.getByteArray("tx_match_filter"),
- equalTo(tlvTx.getArray()));
+ if (publishType == PublishConfig.PUBLISH_TYPE_SOLICITED) {
+ collector.checkThat("rx_match_filter", argsData.getByteArray("rx_match_filter"),
+ equalTo(tlvMatch.getArray()));
+ } else {
+ collector.checkThat("tx_match_filter", argsData.getByteArray("tx_match_filter"),
+ equalTo(tlvMatch.getArray()));
+ }
collector.checkThat("rssi_threshold_flag", argsData.getInt("rssi_threshold_flag"),
equalTo(0));
collector.checkThat("connmap", argsData.getInt("connmap"), equalTo(0));
@@ -1136,14 +1123,14 @@ public class WifiNanHalTest {
}
private void testSubscribe(short transactionId, int subscribeId, int subscribeType,
- String serviceName, String ssi, TlvBufferUtils.TlvConstructor tlvTx,
- TlvBufferUtils.TlvConstructor tlvRx, int subscribeCount, int subscribeTtl,
- int matchStyle, boolean enableTerminateNotification) throws JSONException {
- SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(
- serviceName).setServiceSpecificInfo(ssi).setTxFilter(tlvTx.getArray()).setRxFilter(
- tlvRx.getArray()).setSubscribeType(subscribeType).setSubscribeCount(
- subscribeCount).setTtlSec(subscribeTtl).setMatchStyle(
- matchStyle).setEnableTerminateNotification(enableTerminateNotification).build();
+ String serviceName, String ssi, TlvBufferUtils.TlvConstructor tlvMatch,
+ int subscribeCount, int subscribeTtl, int matchStyle,
+ boolean enableTerminateNotification) throws JSONException {
+ SubscribeConfig subscribeConfig = new SubscribeConfig.Builder()
+ .setServiceName(serviceName).setServiceSpecificInfo(ssi)
+ .setMatchFilter(tlvMatch.getArray()).setSubscribeType(subscribeType)
+ .setSubscribeCount(subscribeCount).setTtlSec(subscribeTtl).setMatchStyle(matchStyle)
+ .setEnableTerminateNotification(enableTerminateNotification).build();
mDut.subscribe(transactionId, subscribeId, subscribeConfig);
@@ -1176,10 +1163,13 @@ public class WifiNanHalTest {
argsData.getInt("service_specific_info_len"), equalTo(serviceName.length()));
collector.checkThat("service_specific_info", argsData.getByteArray("service_specific_info"),
equalTo(ssi.getBytes()));
- collector.checkThat("rx_match_filter", argsData.getByteArray("rx_match_filter"),
- equalTo(tlvRx.getArray()));
- collector.checkThat("tx_match_filter", argsData.getByteArray("tx_match_filter"),
- equalTo(tlvTx.getArray()));
+ if (subscribeType == SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE) {
+ collector.checkThat("rx_match_filter", argsData.getByteArray("rx_match_filter"),
+ equalTo(tlvMatch.getArray()));
+ } else {
+ collector.checkThat("tx_match_filter", argsData.getByteArray("tx_match_filter"),
+ equalTo(tlvMatch.getArray()));
+ }
collector.checkThat("rssi_threshold_flag", argsData.getInt("rssi_threshold_flag"),
equalTo(0));
collector.checkThat("connmap", argsData.getInt("connmap"), equalTo(0));
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
index 3883b56c3..4291b32b9 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
@@ -669,10 +669,8 @@ public class WifiNanManagerTest {
public void testSubscribeConfigBuilder() {
final String serviceName = "some_service_or_other";
final String serviceSpecificInfo = "long arbitrary string with some info";
- final byte[] txFilter = {
+ final byte[] matchFilter = {
0, 1, 16, 1, 22 };
- final byte[] rxFilter = {
- 1, 127, 0, 1, -5, 1, 22 };
final int subscribeType = SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE;
final int subscribeCount = 10;
final int subscribeTtl = 15;
@@ -680,8 +678,8 @@ public class WifiNanManagerTest {
final boolean enableTerminateNotification = false;
SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(serviceSpecificInfo).setTxFilter(txFilter)
- .setRxFilter(rxFilter).setSubscribeType(subscribeType)
+ .setServiceSpecificInfo(serviceSpecificInfo).setMatchFilter(matchFilter)
+ .setSubscribeType(subscribeType)
.setSubscribeCount(subscribeCount).setTtlSec(subscribeTtl).setMatchStyle(matchStyle)
.setEnableTerminateNotification(enableTerminateNotification).build();
@@ -689,8 +687,7 @@ public class WifiNanManagerTest {
equalTo(subscribeConfig.mServiceName));
collector.checkThat("mServiceSpecificInfo",
serviceSpecificInfo.getBytes(), equalTo(subscribeConfig.mServiceSpecificInfo));
- collector.checkThat("mTxFilter", txFilter, equalTo(subscribeConfig.mTxFilter));
- collector.checkThat("mRxFilter", rxFilter, equalTo(subscribeConfig.mRxFilter));
+ collector.checkThat("mMatchFilter", matchFilter, equalTo(subscribeConfig.mMatchFilter));
collector.checkThat("mSubscribeType", subscribeType,
equalTo(subscribeConfig.mSubscribeType));
collector.checkThat("mSubscribeCount", subscribeCount,
@@ -705,10 +702,8 @@ public class WifiNanManagerTest {
public void testSubscribeConfigParcel() {
final String serviceName = "some_service_or_other";
final String serviceSpecificInfo = "long arbitrary string with some info";
- final byte[] txFilter = {
+ final byte[] matchFilter = {
0, 1, 16, 1, 22 };
- final byte[] rxFilter = {
- 1, 127, 0, 1, -5, 1, 22 };
final int subscribeType = SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE;
final int subscribeCount = 10;
final int subscribeTtl = 15;
@@ -716,8 +711,8 @@ public class WifiNanManagerTest {
final boolean enableTerminateNotification = true;
SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(serviceSpecificInfo).setTxFilter(txFilter)
- .setTxFilter(rxFilter).setSubscribeType(subscribeType)
+ .setServiceSpecificInfo(serviceSpecificInfo).setMatchFilter(matchFilter)
+ .setSubscribeType(subscribeType)
.setSubscribeCount(subscribeCount).setTtlSec(subscribeTtl).setMatchStyle(matchStyle)
.setEnableTerminateNotification(enableTerminateNotification).build();
@@ -778,18 +773,16 @@ public class WifiNanManagerTest {
public void testPublishConfigBuilder() {
final String serviceName = "some_service_or_other";
final String serviceSpecificInfo = "long arbitrary string with some info";
- final byte[] txFilter = {
+ final byte[] matchFilter = {
0, 1, 16, 1, 22 };
- final byte[] rxFilter = {
- 1, 127, 0, 1, -5, 1, 22 };
final int publishType = PublishConfig.PUBLISH_TYPE_SOLICITED;
final int publishCount = 10;
final int publishTtl = 15;
final boolean enableTerminateNotification = false;
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(serviceSpecificInfo).setTxFilter(txFilter)
- .setRxFilter(rxFilter).setPublishType(publishType)
+ .setServiceSpecificInfo(serviceSpecificInfo).setMatchFilter(matchFilter)
+ .setPublishType(publishType)
.setPublishCount(publishCount).setTtlSec(publishTtl)
.setEnableTerminateNotification(enableTerminateNotification).build();
@@ -797,8 +790,7 @@ public class WifiNanManagerTest {
equalTo(publishConfig.mServiceName));
collector.checkThat("mServiceSpecificInfo",
serviceSpecificInfo.getBytes(), equalTo(publishConfig.mServiceSpecificInfo));
- collector.checkThat("mTxFilter", txFilter, equalTo(publishConfig.mTxFilter));
- collector.checkThat("mRxFilter", rxFilter, equalTo(publishConfig.mRxFilter));
+ collector.checkThat("mMatchFilter", matchFilter, equalTo(publishConfig.mMatchFilter));
collector.checkThat("mPublishType", publishType, equalTo(publishConfig.mPublishType));
collector.checkThat("mPublishCount", publishCount, equalTo(publishConfig.mPublishCount));
collector.checkThat("mTtlSec", publishTtl, equalTo(publishConfig.mTtlSec));
@@ -810,18 +802,16 @@ public class WifiNanManagerTest {
public void testPublishConfigParcel() {
final String serviceName = "some_service_or_other";
final String serviceSpecificInfo = "long arbitrary string with some info";
- final byte[] txFilter = {
+ final byte[] matchFilter = {
0, 1, 16, 1, 22 };
- final byte[] rxFilter = {
- 1, 127, 0, 1, -5, 1, 22 };
final int publishType = PublishConfig.PUBLISH_TYPE_SOLICITED;
final int publishCount = 10;
final int publishTtl = 15;
final boolean enableTerminateNotification = false;
PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(serviceName)
- .setServiceSpecificInfo(serviceSpecificInfo).setTxFilter(txFilter)
- .setTxFilter(rxFilter).setPublishType(publishType)
+ .setServiceSpecificInfo(serviceSpecificInfo).setMatchFilter(matchFilter)
+ .setPublishType(publishType)
.setPublishCount(publishCount).setTtlSec(publishTtl)
.setEnableTerminateNotification(enableTerminateNotification).build();