summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/HSWanMetricsElementTest.java45
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/IconInfoTest.java60
2 files changed, 105 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/HSWanMetricsElementTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/HSWanMetricsElementTest.java
index c90282509..bebfc5adf 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/HSWanMetricsElementTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/HSWanMetricsElementTest.java
@@ -40,6 +40,11 @@ public class HSWanMetricsElementTest {
private static final int TEST_UPLINK_LOAD = 0x45;
private static final int TEST_LMD = 0x2132;
+ private static final HSWanMetricsElement TEST_ELEMENT = new HSWanMetricsElement(
+ TEST_LINK_STATUS, TEST_SYMMETRIC_LINK, TEST_AT_CAPACITY,
+ TEST_DOWNLINK_SPEED, TEST_UPLINK_SPEED, TEST_DOWNLINK_LOAD,
+ TEST_UPLINK_LOAD, TEST_LMD);
+
/**
* Helper function for generating a ByteBuffer with the test data.
*
@@ -61,6 +66,46 @@ public class HSWanMetricsElementTest {
return buffer;
}
+ @Test
+ public void testGetStatus() {
+ assertEquals(TEST_LINK_STATUS, TEST_ELEMENT.getStatus());
+ }
+
+ @Test
+ public void testIsSymmetric() {
+ assertEquals(TEST_SYMMETRIC_LINK, TEST_ELEMENT.isSymmetric());
+ }
+
+ @Test
+ public void testIsCapped() {
+ assertEquals(TEST_AT_CAPACITY, TEST_ELEMENT.isCapped());
+ }
+
+ @Test
+ public void testGetDownlinkSpeed() {
+ assertEquals(TEST_DOWNLINK_SPEED, TEST_ELEMENT.getDownlinkSpeed());
+ }
+
+ @Test
+ public void testGetUplinkSpeed() {
+ assertEquals(TEST_UPLINK_SPEED, TEST_ELEMENT.getUplinkSpeed());
+ }
+
+ @Test
+ public void testGetDownlinkLoad() {
+ assertEquals(TEST_DOWNLINK_LOAD, TEST_ELEMENT.getDownlinkLoad());
+ }
+
+ @Test
+ public void testGetUplinkLoad() {
+ assertEquals(TEST_UPLINK_LOAD, TEST_ELEMENT.getUplinkLoad());
+ }
+
+ @Test
+ public void testGetLMD() {
+ assertEquals(TEST_LMD, TEST_ELEMENT.getLMD());
+ }
+
/**
* Verify that ProtocolException will be thrown when parsing an empty buffer.
*
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/IconInfoTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/IconInfoTest.java
index df99fbd52..c44ad0bf0 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/IconInfoTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/anqp/IconInfoTest.java
@@ -17,6 +17,7 @@
package com.android.server.wifi.hotspot2.anqp;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import androidx.test.filters.SmallTest;
@@ -30,6 +31,40 @@ import java.nio.ByteBuffer;
*/
@SmallTest
public class IconInfoTest {
+ private static final int TEST_WIDTH = 1111;
+ private static final int TEST_HEIGHT = 2222;
+ private static final String TEST_LANGUAGE = "language";
+ private static final String TEST_ICON_TYPE = "iconType";
+ private static final String TEST_FILE_NAME = "filename";
+
+ private static final IconInfo TEST_ICON_INFO =
+ new IconInfo(TEST_WIDTH, TEST_HEIGHT, TEST_LANGUAGE, TEST_ICON_TYPE, TEST_FILE_NAME);
+
+ @Test
+ public void testGetWidth() {
+ assertEquals(TEST_WIDTH, TEST_ICON_INFO.getWidth());
+ }
+
+ @Test
+ public void testGetHeight() {
+ assertEquals(TEST_HEIGHT, TEST_ICON_INFO.getHeight());
+ }
+
+ @Test
+ public void testGetLanguage() {
+ assertEquals(TEST_LANGUAGE, TEST_ICON_INFO.getLanguage());
+ }
+
+ @Test
+ public void testGetIconType() {
+ assertEquals(TEST_ICON_TYPE, TEST_ICON_INFO.getIconType());
+ }
+
+ @Test
+ public void testGetFileName() {
+ assertEquals(TEST_FILE_NAME, TEST_ICON_INFO.getFileName());
+ }
+
/**
* Verify that BufferUnderflowException will be thrown when parsing an empty buffer.
* @throws Exception
@@ -63,4 +98,29 @@ public class IconInfoTest {
ByteBuffer buffer = ByteBuffer.wrap(IconInfoTestUtil.TEST_ICON_INFO_RAW_BYTES);
assertEquals(IconInfoTestUtil.TEST_ICON_INFO, IconInfo.parse(buffer));
}
+
+ /**
+ * Tests the hash function.
+ */
+ @Test
+ public void testHashCode() {
+ int width1 = 1;
+ int height1 = 1;
+ String language1 = "language1";
+ String iconType1 = "iconType1";
+ String fileName1 = "filename1";
+
+ int width2 = 2;
+ int height2 = 2;
+ String language2 = "language2";
+ String iconType2 = "iconType2";
+ String fileName2 = "filename2";
+
+ IconInfo info1 = new IconInfo(width1, height1, language1, iconType1, fileName1);
+ IconInfo info2 = new IconInfo(width2, height2, language2, iconType2, fileName2);
+ IconInfo info1Dup = new IconInfo(width1, height1, language1, iconType1, fileName1);
+
+ assertNotEquals(info1.hashCode(), info2.hashCode());
+ assertEquals(info1.hashCode(), info1Dup.hashCode());
+ }
}