summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMukesh Agrawal <quiche@google.com>2018-03-29 22:25:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-03-29 22:25:13 +0000
commit453bfc87609e12da3e831caca0e206eadaf8f186 (patch)
tree98b2b472c09dfcde3ec668fd85aae79840b7808c /tests
parentc4002658545b95d0f7f1686e925072518416a78e (diff)
parentde108ed648e6aeed94c61ac9bb893181e83dcb4b (diff)
Merge "Use "02:00:00:00:00:00" as default invalid mac" into pi-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java29
2 files changed, 33 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 7ba8ef96e..4cccc88c9 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -33,6 +33,7 @@ import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
import android.net.wifi.WifiEnterpriseConfig;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
import android.os.Process;
@@ -1454,7 +1455,7 @@ public class WifiConfigManagerTest {
}
/**
- * Verifies that randomized MAC address is masked out to "0:0:0:0:0:0" when we return
+ * Verifies that randomized MAC address is masked out when we return
* external configs except when explicitly asked for MAC address.
*/
@Test
@@ -3797,9 +3798,10 @@ public class WifiConfigManagerTest {
private void assertRandomizedMacAddressMaskedInWifiConfiguration(
WifiConfiguration configuration) {
+ MacAddress defaultMac = MacAddress.fromString(WifiInfo.DEFAULT_MAC_ADDRESS);
MacAddress randomizedMacAddress = configuration.getRandomizedMacAddress();
if (randomizedMacAddress != null) {
- assertEquals(MacAddress.ALL_ZEROS_ADDRESS, randomizedMacAddress);
+ assertEquals(defaultMac, randomizedMacAddress);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index cf6ff8e53..67c3b12f6 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -2435,4 +2435,33 @@ public class WifiStateMachineTest {
verify(mWifiNative, never()).setMacAddress(eq(WIFI_IFACE_NAME), any(MacAddress.class));
assertEquals(mWsm.getWifiInfo().getMacAddress(), oldMac);
}
+
+ /**
+ * Verifies that we don't set MAC address when config returns an invalid MAC address.
+ */
+ @Test
+ public void testDoNotSetMacWhenInvalid() throws Exception {
+ initializeAndAddNetworkAndVerifySuccess();
+ assertEquals(WifiStateMachine.CONNECT_MODE, mWsm.getOperationalModeForTest());
+ assertEquals(WifiManager.WIFI_STATE_ENABLED, mWsm.syncGetWifiState());
+
+ when(mFrameworkFacade.getIntegerSetting(mContext,
+ Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0)).thenReturn(1);
+ mContentObserver.onChange(false);
+ when(mWifiNative.getMacAddress(WIFI_IFACE_NAME))
+ .thenReturn(TEST_GLOBAL_MAC_ADDRESS.toString());
+
+ WifiConfiguration config = mock(WifiConfiguration.class);
+ when(config.getOrCreateRandomizedMacAddress())
+ .thenReturn(MacAddress.fromString(WifiInfo.DEFAULT_MAC_ADDRESS));
+ when(config.getNetworkSelectionStatus())
+ .thenReturn(new WifiConfiguration.NetworkSelectionStatus());
+ when(mWifiConfigManager.getConfiguredNetworkWithoutMasking(0)).thenReturn(config);
+
+ mWsm.sendMessage(WifiStateMachine.CMD_START_CONNECT, 0, 0, sBSSID);
+ mLooper.dispatchAll();
+
+ verify(config).getOrCreateRandomizedMacAddress();
+ verify(mWifiNative, never()).setMacAddress(eq(WIFI_IFACE_NAME), any(MacAddress.class));
+ }
}