diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-01-13 06:14:22 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-01-13 06:14:22 +0000 |
commit | f91694ff0b589d5b9fbe55b5da1b80642990321a (patch) | |
tree | 21f23a1c46f98a77e19f34d332c92a39ee5b9ef8 /tests | |
parent | 50f36ec6fe906445db996bf3918e5cb3f170bc79 (diff) | |
parent | b86089a48fae8878b5a27533a116c97b0be6d0e7 (diff) |
Merge "util: fix parsing logic for ExtendedCapabilities IE"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/InformationElementUtilTest.java | 57 |
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 */ |