use of android.net.wifi.WifiInfo in project robolectric by robolectric.
the class ShadowWifiInfoTest method shouldReturnFrequency.
@Test
@Config(minSdk = LOLLIPOP)
public void shouldReturnFrequency() {
WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getFrequency()).isEqualTo(-1);
shadowOf(wifiInfo).setFrequency(10);
wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getFrequency()).isEqualTo(10);
}
use of android.net.wifi.WifiInfo in project robolectric by robolectric.
the class ShadowWifiInfoTest method shouldReturnBSSID.
@Test
public void shouldReturnBSSID() {
WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getBSSID()).isEqualTo(null);
shadowOf(wifiInfo).setBSSID("BSSID");
wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getBSSID()).isEqualTo("BSSID");
}
use of android.net.wifi.WifiInfo in project robolectric by robolectric.
the class ShadowWifiInfoTest method shouldReturnMacAddress.
@Test
public void shouldReturnMacAddress() {
WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getMacAddress()).isEqualTo(// WifiInfo.DEFAULT_MAC_ADDRESS
"02:00:00:00:00:00");
shadowOf(wifiInfo).setMacAddress("mac address");
wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getMacAddress()).isEqualTo("mac address");
}
use of android.net.wifi.WifiInfo in project robolectric by robolectric.
the class ShadowWifiInfoTest method shouldReturnSSID.
@Test
public void shouldReturnSSID() {
WifiManager wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
// WifiSsid.NONE
assertThat(wifiInfo.getSSID()).isEqualTo("<unknown ssid>");
shadowOf(wifiInfo).setSSID("SSID");
wifiManager = (WifiManager) application.getSystemService(WIFI_SERVICE);
wifiInfo = wifiManager.getConnectionInfo();
assertThat(wifiInfo.getSSID()).isEqualTo("SSID");
}
use of android.net.wifi.WifiInfo in project platform_frameworks_base by android.
the class WifiAssociationTest method testWifiAssociation.
/**
* Test that the wifi can associate with a given access point.
*/
@LargeTest
public void testWifiAssociation() {
WifiAssociationTestRunner runner = (WifiAssociationTestRunner) getInstrumentation();
Bundle arguments = runner.getArguments();
String ssid = arguments.getString("ssid");
assertNotNull("ssid is empty", ssid);
String securityTypeStr = arguments.getString("security-type");
assertNotNull("security-type is empty", securityTypeStr);
SecurityType securityType = SecurityType.valueOf(securityTypeStr);
String password = arguments.getString("password");
assertTrue("enable Wifi failed", enableWifi());
WifiInfo wi = mWifiManager.getConnectionInfo();
logv("%s", wi);
assertNotNull("no active wifi info", wi);
WifiConfiguration config = getConfig(ssid, securityType, password);
logv("Network config: %s", config.toString());
connectToWifi(config);
}
Aggregations