Code example for LocationManager

Methods: getProviders

0
  public void shouldReturnEnabledProviders() throws Exception { 
    shadowLocationManager.setProviderEnabled(NETWORK_PROVIDER, false);
    shadowLocationManager.setProviderEnabled(GPS_PROVIDER, false);
    shadowLocationManager.setProviderEnabled(LocationManager.PASSIVE_PROVIDER, false);
 
    assertTrue(locationManager.getProviders(true).isEmpty());
    assertThat(locationManager.getProviders(false).size()).isEqualTo(3);
 
    shadowLocationManager.setProviderEnabled(NETWORK_PROVIDER, true);
 
    List<String> providers = locationManager.getProviders(true);
    assertTrue(providers.contains(NETWORK_PROVIDER));
    assertThat(providers.size()).isEqualTo(1);
 
    shadowLocationManager.setProviderEnabled(GPS_PROVIDER, true);
    providers = locationManager.getProviders(true);
    assertTrue(providers.contains(NETWORK_PROVIDER));
    assertTrue(providers.contains(GPS_PROVIDER));
    assertThat(providers.size()).isEqualTo(2);
 
    shadowLocationManager.setProviderEnabled(LocationManager.PASSIVE_PROVIDER, true);
    providers = locationManager.getProviders(true);
    assertTrue(providers.contains(NETWORK_PROVIDER));
    assertTrue(providers.contains(GPS_PROVIDER));
    assertTrue(providers.contains(LocationManager.PASSIVE_PROVIDER));
    assertThat(providers.size()).isEqualTo(3);
  } 
Stop searching for code, let great code find you!  Add Codota to your java IDE