FileDocCategorySizeDatePackage
WifiSoftAPTest.javaAPI DocAndroid 5.1 API2728Thu Mar 12 22:22:12 GMT 2015com.android.connectivitymanagertest.unit

WifiSoftAPTest

public class WifiSoftAPTest extends android.test.AndroidTestCase
Test Wifi soft AP configuration

Fields Summary
private android.net.wifi.WifiManager
mWifiManager
private android.net.wifi.WifiConfiguration
mWifiConfig
private final String
TAG
private final int
DURATION
Constructors Summary
Methods Summary
protected voidsetUp()


    
         
        super.setUp();
        mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
        assertNotNull(mWifiManager);
        assertTrue(mWifiManager.setWifiApEnabled(null, true));
        mWifiConfig = mWifiManager.getWifiApConfiguration();
        if (mWifiConfig != null) {
            Log.v(TAG, "mWifiConfig is " + mWifiConfig.toString());
        } else {
            Log.v(TAG, "mWifiConfig is null.");
        }
    
protected voidtearDown()

        Log.v(TAG, "turn off wifi tethering");
        mWifiManager.setWifiApEnabled(null, false);
        super.tearDown();
    
public voidtestApSsidWithAlphabet()

        WifiConfiguration config = new WifiConfiguration();
        config.SSID = "abcdefghijklmnopqrstuvwxyz";
        config.allowedKeyManagement.set(KeyMgmt.NONE);
        mWifiConfig = config;
        assertTrue(mWifiManager.setWifiApEnabled(mWifiConfig, true));
        try {
            Thread.sleep(DURATION);
        } catch (InterruptedException e) {
            Log.v(TAG, "exception " + e.getStackTrace());
            assertFalse(true);
        }
        assertNotNull(mWifiManager.getWifiApConfiguration());
        assertEquals("wifi AP state is not enabled", WifiManager.WIFI_AP_STATE_ENABLED,
                     mWifiManager.getWifiApState());