summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@google.com>2017-01-10 10:22:26 -0800
committerPeter Qiu <zqiu@google.com>2017-01-12 11:32:16 -0800
commitb86089a48fae8878b5a27533a116c97b0be6d0e7 (patch)
tree2cd244c1da053db1d67a6c552168ac69d67d584e /tests
parent6a8e5ccb593fa239d53d1be4ac6913cfeba47ab6 (diff)
util: fix parsing logic for ExtendedCapabilities IE
The IEEE 802.11 standard specified that Extended Capabilities IE contained a bit field of variable length. So use BitSet to represent the data instead of an integer. Bug: 34179560 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I1df2c92c475f1dbc4e7b17c243b4560d822ff129
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
index 4c037ff6c..d3e8c7039 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java
@@ -18,6 +18,8 @@ package com.android.server.wifi.util;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import android.net.wifi.ScanResult.InformationElement;
import android.test.suitebuilder.annotation.SmallTest;
@@ -410,6 +412,61 @@ public class InformationElementUtilTest {
}
/**
+ * Verify the expectations when building an ExtendedCapabilites IE from data with no bits set.
+ * Both ExtendedCapabilities#isStrictUtf8() and ExtendedCapabilites#is80211McRTTResponder()
+ * should return false.
+ */
+ @Test
+ public void buildExtendedCapabilities_emptyBitSet() {
+ InformationElement ie = new InformationElement();
+ ie.id = InformationElement.EID_EXTENDED_CAPS;
+ ie.bytes = new byte[8];
+
+ InformationElementUtil.ExtendedCapabilities extendedCap =
+ new InformationElementUtil.ExtendedCapabilities();
+ extendedCap.from(ie);
+ assertFalse(extendedCap.isStrictUtf8());
+ assertFalse(extendedCap.is80211McRTTResponder());
+ }
+
+ /**
+ * Verify the expectations when building an ExtendedCapabilites IE from data with UTF-8 SSID
+ * bit set (bit 48). ExtendedCapabilities#isStrictUtf8() should return true.
+ */
+ @Test
+ public void buildExtendedCapabilites_strictUtf8() {
+ InformationElement ie = new InformationElement();
+ ie.id = InformationElement.EID_EXTENDED_CAPS;
+ ie.bytes = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00 };
+
+ InformationElementUtil.ExtendedCapabilities extendedCap =
+ new InformationElementUtil.ExtendedCapabilities();
+ extendedCap.from(ie);
+ assertTrue(extendedCap.isStrictUtf8());
+ assertFalse(extendedCap.is80211McRTTResponder());
+ }
+
+ /**
+ * Verify the expectations when building an ExtendedCapabilites IE from data with RTT Response
+ * Enable bit set (bit 70). ExtendedCapabilities#is80211McRTTResponder() should return true.
+ */
+ @Test
+ public void buildExtendedCapabilites_80211McRTTResponder() {
+ InformationElement ie = new InformationElement();
+ ie.id = InformationElement.EID_EXTENDED_CAPS;
+ ie.bytes = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x40 };
+
+ InformationElementUtil.ExtendedCapabilities extendedCap =
+ new InformationElementUtil.ExtendedCapabilities();
+ extendedCap.from(ie);
+ assertFalse(extendedCap.isStrictUtf8());
+ assertTrue(extendedCap.is80211McRTTResponder());
+ }
+
+ /**
* Test a that a correctly formed TIM Information Element is decoded into a valid TIM element,
* and the values are captured
*/