Merge changes Id532a189,I294f309e,Ie902dfa2 into rvc-dev
* changes: WifiManagerTest: Add test for isTdls & isStaApConcurrency supported WifiNetworkSuggestionTest: Add test for WAPI builder method WifiNetworkSpecifierTest: Add tests for enterprise builder methods
This commit is contained in:
committed by
Android (Google) Code Review
commit
4e10a4d6aa
@@ -1474,6 +1474,45 @@ public class WifiManagerTest extends AndroidTestCase {
|
||||
mWifiManager.isPreferredNetworkOffloadSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link WifiManager#isTdlsSupported()} does not crash.
|
||||
*/
|
||||
public void testIsTdlsSupported() throws Exception {
|
||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||
// skip the test if WiFi is not supported
|
||||
return;
|
||||
}
|
||||
mWifiManager.isTdlsSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link WifiManager#isStaApConcurrencySupported().
|
||||
*/
|
||||
public void testIsStaApConcurrencySupported() throws Exception {
|
||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||
// skip the test if WiFi is not supported
|
||||
return;
|
||||
}
|
||||
// check that softap mode is supported by the device
|
||||
if (!mWifiManager.isPortableHotspotSupported()) {
|
||||
return;
|
||||
}
|
||||
assertTrue(mWifiManager.isWifiEnabled());
|
||||
|
||||
boolean isStaApConcurrencySupported = mWifiManager.isStaApConcurrencySupported();
|
||||
// start local only hotspot.
|
||||
TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot();
|
||||
if (isStaApConcurrencySupported) {
|
||||
assertTrue(mWifiManager.isWifiEnabled());
|
||||
} else {
|
||||
// no concurrency, wifi should be disabled.
|
||||
assertFalse(mWifiManager.isWifiEnabled());
|
||||
}
|
||||
stopLocalOnlyHotspot(callback, true);
|
||||
|
||||
assertTrue(mWifiManager.isWifiEnabled());
|
||||
}
|
||||
|
||||
private static class TestTrafficStateCallback implements WifiManager.TrafficStateCallback {
|
||||
private final Object mLock;
|
||||
public boolean onStateChangedCalled = false;
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkRequest;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiEnterpriseConfig;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiManager.NetworkRequestMatchCallback;
|
||||
@@ -506,4 +507,44 @@ public class WifiNetworkSpecifierTest extends AndroidTestCase {
|
||||
.build();
|
||||
testUserRejectionWithSpecifier(specifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the builder for WPA2 enterprise networks.
|
||||
* Note: Can't do end to end tests for such networks in CTS environment.
|
||||
*/
|
||||
public void testBuilderForWpa2Enterprise() {
|
||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||
// skip the test if WiFi is not supported
|
||||
return;
|
||||
}
|
||||
WifiNetworkSpecifier specifier1 = new WifiNetworkSpecifier.Builder()
|
||||
.setSsid(WifiInfo.sanitizeSsid(mTestNetwork.SSID))
|
||||
.setWpa2EnterpriseConfig(new WifiEnterpriseConfig())
|
||||
.build();
|
||||
WifiNetworkSpecifier specifier2 = new WifiNetworkSpecifier.Builder()
|
||||
.setSsid(WifiInfo.sanitizeSsid(mTestNetwork.SSID))
|
||||
.setWpa2EnterpriseConfig(new WifiEnterpriseConfig())
|
||||
.build();
|
||||
assertThat(specifier1.satisfiedBy(specifier2)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the builder for WPA3 enterprise networks.
|
||||
* Note: Can't do end to end tests for such networks in CTS environment.
|
||||
*/
|
||||
public void testBuilderForWpa3Enterprise() {
|
||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||
// skip the test if WiFi is not supported
|
||||
return;
|
||||
}
|
||||
WifiNetworkSpecifier specifier1 = new WifiNetworkSpecifier.Builder()
|
||||
.setSsid(WifiInfo.sanitizeSsid(mTestNetwork.SSID))
|
||||
.setWpa3EnterpriseConfig(new WifiEnterpriseConfig())
|
||||
.build();
|
||||
WifiNetworkSpecifier specifier2 = new WifiNetworkSpecifier.Builder()
|
||||
.setSsid(WifiInfo.sanitizeSsid(mTestNetwork.SSID))
|
||||
.setWpa3EnterpriseConfig(new WifiEnterpriseConfig())
|
||||
.build();
|
||||
assertThat(specifier1.satisfiedBy(specifier2)).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.net.wifi.cts;
|
||||
|
||||
import static android.net.wifi.WifiEnterpriseConfig.Eap.AKA;
|
||||
import static android.net.wifi.WifiEnterpriseConfig.Eap.WAPI_CERT;
|
||||
|
||||
import android.net.MacAddress;
|
||||
import android.net.wifi.WifiEnterpriseConfig;
|
||||
@@ -198,6 +199,28 @@ public class WifiNetworkSuggestionTest extends AndroidTestCase {
|
||||
assertNull(suggestion.getPasspointConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link android.net.wifi.WifiNetworkSuggestion.Builder} class.
|
||||
*/
|
||||
public void testBuilderWithWapiEnterprise() throws Exception {
|
||||
if (!WifiFeature.isWifiSupported(getContext())) {
|
||||
// skip the test if WiFi is not supported
|
||||
return;
|
||||
}
|
||||
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
|
||||
enterpriseConfig.setEapMethod(WAPI_CERT);
|
||||
WifiNetworkSuggestion suggestion =
|
||||
createBuilderWithCommonParams()
|
||||
.setWapiEnterpriseConfig(enterpriseConfig)
|
||||
.build();
|
||||
validateCommonParams(suggestion);
|
||||
assertNull(suggestion.getPassphrase());
|
||||
assertNotNull(suggestion.getEnterpriseConfig());
|
||||
assertEquals(enterpriseConfig.getEapMethod(),
|
||||
suggestion.getEnterpriseConfig().getEapMethod());
|
||||
assertNull(suggestion.getPasspointConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for creating a {@link PasspointConfiguration} for testing.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user