use of android.net.wifi.WifiManager 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.WifiManager 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.WifiManager 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.WifiManager 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.WifiManager in project fqrouter by fqrouter.
the class AcquireWifiLockService method onCreate.
@Override
public void onCreate() {
super.onCreate();
try {
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
if (null == wifiLock) {
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "fqrouter wifi hotspot");
}
wifiLock.acquire();
LogUtils.i("acquired wifi lock");
} catch (Exception e) {
LogUtils.e("failed to acquire wifi lock", e);
}
}
Aggregations