summaryrefslogtreecommitdiffstats
path: root/tests/wifitests/src/com
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-09-12 11:33:15 -0700
committerOscar Shu <xshu@google.com>2019-10-15 00:29:04 +0000
commit4892c0b7b6b65584ce7574bf18053ecbba79e024 (patch)
treeda415a462aedd1a3b03a195c4c2b386637a0761c /tests/wifitests/src/com
parent7957387b5d459386191cf45ca90e45446ed13f93 (diff)
downloadandroid_frameworks_opt_net_wifi-4892c0b7b6b65584ce7574bf18053ecbba79e024.tar.gz
android_frameworks_opt_net_wifi-4892c0b7b6b65584ce7574bf18053ecbba79e024.tar.bz2
android_frameworks_opt_net_wifi-4892c0b7b6b65584ce7574bf18053ecbba79e024.zip
[MAC rand] Avoid null Object of mac address
Bug: 140309663 Test: unit tests Merged-In: I914a2678e62f1e2ef6dc1b358a76a306b9cc0cc4 Change-Id: Ibf281c5e25c21c17652d718c346c8b560aedcc72 (cherry picked from commit I914a2678e62f1e2ef6dc1b358a76a306b9cc0cc4)
Diffstat (limited to 'tests/wifitests/src/com')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index 7896a8f0b..f0e9d2c10 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -2748,6 +2748,21 @@ public class ClientModeImplTest {
}
/**
+ * Verify that we don't crash when WifiNative returns null as the current MAC address.
+ * @throws Exception
+ */
+ @Test
+ public void testMacRandomizationWifiNativeReturningNull() throws Exception {
+ when(mWifiNative.getMacAddress(anyString())).thenReturn(null);
+ initializeAndAddNetworkAndVerifySuccess();
+ assertEquals(ClientModeImpl.CONNECT_MODE, mCmi.getOperationalModeForTest());
+ assertEquals(WifiManager.WIFI_STATE_ENABLED, mCmi.syncGetWifiState());
+
+ connect();
+ verify(mWifiNative).setMacAddress(WIFI_IFACE_NAME, TEST_LOCAL_MAC_ADDRESS);
+ }
+
+ /**
* Verifies that CMD_START_CONNECT make WifiDiagnostics report
* CONNECTION_EVENT_STARTED
* @throws Exception