com.xtremelabs.robolectric.shadows
Class ShadowGeocoder

java.lang.Object
  extended by com.xtremelabs.robolectric.shadows.ShadowGeocoder

@Implements(value=android.location.Geocoder.class)
public class ShadowGeocoder
extends java.lang.Object

A shadow for Geocoder that supports simulated responses and failures


Constructor Summary
ShadowGeocoder()
           
 
Method Summary
 java.util.List<android.location.Address> getFromLocation(double latitude, double longitude, int maxResults)
           
 java.util.List<android.location.Address> getFromLocationName(java.lang.String locationName, int maxResults)
           
 double getLastLatitude()
           
 double getLastLongitude()
           
 void setShouldSimulateGeocodeException(boolean shouldSimulateException)
          Sets a flag to indicate whether or not getFromLocationName(String, int) should throw an exception to simulate a failure.
 void setSimulatedLatLong(double lat, double lng)
          Sets up a simulated response for getFromLocationName(String, int)}
 void setSimulatedResponse(java.lang.String address, java.lang.String city, java.lang.String state, java.lang.String zip, java.lang.String countryCode)
          Sets up a simulated response for getFromLocation(double, double, int)
 boolean wasGetFromLocationCalled()
          Non-Android accessor that indicates whether getFromLocation(double, double, int) was called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShadowGeocoder

public ShadowGeocoder()
Method Detail

getFromLocation

@Implementation
public java.util.List<android.location.Address> getFromLocation(double latitude,
                                                                               double longitude,
                                                                               int maxResults)
                                                         throws java.io.IOException
Throws:
java.io.IOException

getFromLocationName

@Implementation
public java.util.List<android.location.Address> getFromLocationName(java.lang.String locationName,
                                                                                   int maxResults)
                                                             throws java.io.IOException
Throws:
java.io.IOException

setSimulatedResponse

public void setSimulatedResponse(java.lang.String address,
                                 java.lang.String city,
                                 java.lang.String state,
                                 java.lang.String zip,
                                 java.lang.String countryCode)
Sets up a simulated response for getFromLocation(double, double, int)

Parameters:
address - the address for the response
city - the city for the response
state - the state for the response
zip - the zip code for the response
countryCode - the country code for the response

setSimulatedLatLong

public void setSimulatedLatLong(double lat,
                                double lng)
Sets up a simulated response for getFromLocationName(String, int)}

Parameters:
lat - latitude for simulated response
lng - longitude for simulated response

setShouldSimulateGeocodeException

public void setShouldSimulateGeocodeException(boolean shouldSimulateException)
Sets a flag to indicate whether or not getFromLocationName(String, int) should throw an exception to simulate a failure.

Parameters:
shouldSimulateException - whether or not an exception should be thrown from getFromLocationName(String, int)

wasGetFromLocationCalled

public boolean wasGetFromLocationCalled()
Non-Android accessor that indicates whether getFromLocation(double, double, int) was called.

Returns:
whether getFromLocation(double, double, int) was called.

getLastLongitude

public double getLastLongitude()

getLastLatitude

public double getLastLatitude()