Code example for Location

0
 
  @Test 
  public void shouldReturnLastKnownLocationForAProvider() throws Exception { 
    assertNull(locationManager.getLastKnownLocation(NETWORK_PROVIDER));
 
    Location networkLocation = new Location(NETWORK_PROVIDER);
    Location gpsLocation = new Location(GPS_PROVIDER);
 
    shadowLocationManager.setLastKnownLocation(NETWORK_PROVIDER, networkLocation);
    shadowLocationManager.setLastKnownLocation(GPS_PROVIDER, gpsLocation);
 
    assertSame(locationManager.getLastKnownLocation(NETWORK_PROVIDER), networkLocation);
    assertSame(locationManager.getLastKnownLocation(GPS_PROVIDER), gpsLocation);
  } 
 
  @Test 
  public void shouldStoreRequestLocationUpdateListeners() throws Exception { 
    TestLocationListener listener = new TestLocationListener();
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 2.0f, listener);
    assertSame(shadowLocationManager.getRequestLocationUpdateListeners().get(0), listener);
Contextual code suggestions in your IDE  Get Codota for Java