Code example for LocationManager

Methods: getBestProvider

0
  public void shouldReturnBestEnabledProvider() throws Exception { 
    shadowLocationManager.setProviderEnabled("BEST_ENABLED_PROVIDER", true);
 
    assertTrue(shadowLocationManager.setBestProvider("BEST_ENABLED_PROVIDER", true));
    assertFalse(shadowLocationManager.setBestProvider("BEST_ENABLED_PROVIDER", false));
    assertThat("BEST_ENABLED_PROVIDER").isEqualTo(locationManager.getBestProvider(null, true));
    assertNull(locationManager.getBestProvider(null, false));
  } 
 
  @Test 
  public void shouldNotifyAllListenersIfProviderStateChanges() { 
    TestLocationListener listener = new TestLocationListener();
    locationManager.requestLocationUpdates("TEST_PROVIDER", 0, 0, listener);
    shadowLocationManager.setProviderEnabled("TEST_PROVIDER", true);
    assertTrue(listener.providerEnabled);
    shadowLocationManager.setProviderEnabled("TEST_PROVIDER", false);
    assertFalse(listener.providerEnabled);
  } 
 
  @Test 
  public void shouldRegisterLocationUpdatesWhenProviderGiven() throws Exception {