test_class.declarator: locationManager
test_class.modifier: @Mock
test_class.original_string: @Mock LocationManager locationManager;
test_class.type: LocationManager
test_class.var_name: locationManager
test_class.declarator: androidLocationClient
test_class.modifier: private
test_class.original_string: private AndroidLocationClient androidLocationClient;
test_class.type: AndroidLocationClient
test_class.var_name: androidLocationClient
test_class.file: collect_app/src/test/java/org/odk/collect/android/location/client/AndroidLocationClientTest.java
test_class.identifier: AndroidLocationClientTest
test_case.body: @Test
      public void getLastLocationShouldReturnCorrectFromCorrectProviderForPriority() {
  
          // Set-up mock Locations: -------------------------------------------------------------- //
  
          Location gpsLocation = newMockLocation();
          when(locationManager.getLastKnownLocation(GPS_PROVIDER))
                  .thenReturn(gpsLocation);
  
          Location networkLocation = newMockLocation();
          when(locationManager.getLastKnownLocation(NETWORK_PROVIDER))
                  .thenReturn(networkLocation);
  
          Location passiveLocation = newMockLocation();
          when(locationManager.getLastKnownLocation(PASSIVE_PROVIDER))
                  .thenReturn(passiveLocation);
  
          // High Accuracy: -------------------------------------------------------------- //
  
          androidLocationClient.setPriority(PRIORITY_HIGH_ACCURACY);
  
          // W/ GPS
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(GPS_PROVIDER, NETWORK_PROVIDER));
          assertSame(androidLocationClient.getLastLocation(), gpsLocation);
  
          // W/out GPS:
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(NETWORK_PROVIDER));
  
          assertSame(androidLocationClient.getLastLocation(), networkLocation);
  
          // Balanced Accuracy: -------------------------------------------------------------- //
  
          androidLocationClient.setPriority(PRIORITY_BALANCED_POWER_ACCURACY);
  
          // W/ both (should be Network)
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(GPS_PROVIDER, NETWORK_PROVIDER));
          assertSame(androidLocationClient.getLastLocation(), networkLocation);
  
          // W/out Network
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(GPS_PROVIDER));
          assertSame(androidLocationClient.getLastLocation(), gpsLocation);
  
          // Low Power Accuracy: -------------------------------------------------------------- //
  
          androidLocationClient.setPriority(PRIORITY_LOW_POWER);
  
          // W/ Network
  
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(NETWORK_PROVIDER, PASSIVE_PROVIDER));
          assertSame(androidLocationClient.getLastLocation(), networkLocation);
  
          // W/out Network:
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(PASSIVE_PROVIDER));
          assertSame(androidLocationClient.getLastLocation(), passiveLocation);
  
          // No Power: -------------------------------------------------------------- //
          androidLocationClient.setPriority(PRIORITY_NO_POWER);
  
          // W/ Passive:
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of(PASSIVE_PROVIDER));
          assertSame(androidLocationClient.getLastLocation(), passiveLocation);
  
          // W/out any Providers:
          when(locationManager.getProviders(true))
                  .thenReturn(ImmutableList.of());
  
          assertNull(androidLocationClient.getLastLocation());
      }
test_case.class_method_signature: AndroidLocationClientTest.getLastLocationShouldReturnCorrectFromCorrectProviderForPriority()
test_case.full_signature: @Test public void getLastLocationShouldReturnCorrectFromCorrectProviderForPriority()
test_case.identifier: getLastLocationShouldReturnCorrectFromCorrectProviderForPriority
test_case.invocations: newMockLocation thenReturn when getLastKnownLocation newMockLocation thenReturn when getLastKnownLocation newMockLocation thenReturn when getLastKnownLocation setPriority thenReturn when getProviders of assertSame getLastLocation thenReturn when getProviders of assertSame getLastLocation setPriority thenReturn when getProviders of assertSame getLastLocation thenReturn when getProviders of assertSame getLastLocation setPriority thenReturn when getProviders of assertSame getLastLocation thenReturn when getProviders of assertSame getLastLocation setPriority thenReturn when getProviders of assertSame getLastLocation thenReturn when getProviders of assertNull getLastLocation
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getLastLocationShouldReturnCorrectFromCorrectProviderForPriority()
focal_class.declarator: locationClientListener
focal_class.modifier: @Nullable
      private
focal_class.original_string: @Nullable
      private LocationClientListener locationClientListener;
focal_class.type: LocationClientListener
focal_class.var_name: locationClientListener
focal_class.declarator: locationListener
focal_class.modifier: @Nullable
      private
focal_class.original_string: @Nullable
      private LocationListener locationListener;
focal_class.type: LocationListener
focal_class.var_name: locationListener
focal_class.declarator: isConnected
focal_class.modifier: private
focal_class.original_string: private boolean isConnected;
focal_class.type: boolean
focal_class.var_name: isConnected
focal_class.file: collect_app/src/main/java/org/odk/collect/android/location/client/AndroidLocationClient.java
focal_class.identifier: AndroidLocationClient
focal_class.interfaces: implements android.location.LocationListener
focal_class.class_method_signature: AndroidLocationClient.AndroidLocationClient(@NonNull Context context)
focal_class.full_signature:   AndroidLocationClient(@NonNull Context context)
focal_class.identifier: AndroidLocationClient
focal_class.parameters: (@NonNull Context context)
focal_class.signature:  AndroidLocationClient(@NonNull Context context)
focal_class.class_method_signature: AndroidLocationClient.AndroidLocationClient(@NonNull LocationManager locationManager)
focal_class.full_signature:   AndroidLocationClient(@NonNull LocationManager locationManager)
focal_class.identifier: AndroidLocationClient
focal_class.parameters: (@NonNull LocationManager locationManager)
focal_class.signature:  AndroidLocationClient(@NonNull LocationManager locationManager)
focal_class.class_method_signature: AndroidLocationClient.start()
focal_class.full_signature: @Override public void start()
focal_class.identifier: start
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void start()
focal_class.class_method_signature: AndroidLocationClient.stop()
focal_class.full_signature: @Override public void stop()
focal_class.identifier: stop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stop()
focal_class.class_method_signature: AndroidLocationClient.requestLocationUpdates(@NonNull LocationListener locationListener)
focal_class.full_signature: @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets public void requestLocationUpdates(@NonNull LocationListener locationListener)
focal_class.identifier: requestLocationUpdates
focal_class.modifiers: @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets public
focal_class.parameters: (@NonNull LocationListener locationListener)
focal_class.return: void
focal_class.signature: void requestLocationUpdates(@NonNull LocationListener locationListener)
focal_class.class_method_signature: AndroidLocationClient.stopLocationUpdates()
focal_class.full_signature: @Override public void stopLocationUpdates()
focal_class.identifier: stopLocationUpdates
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void stopLocationUpdates()
focal_class.class_method_signature: AndroidLocationClient.setListener(@Nullable LocationClientListener locationClientListener)
focal_class.full_signature: @Override public void setListener(@Nullable LocationClientListener locationClientListener)
focal_class.identifier: setListener
focal_class.modifiers: @Override public
focal_class.parameters: (@Nullable LocationClientListener locationClientListener)
focal_class.return: void
focal_class.signature: void setListener(@Nullable LocationClientListener locationClientListener)
focal_class.class_method_signature: AndroidLocationClient.getLastLocation()
focal_class.full_signature: @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets public Location getLastLocation()
focal_class.identifier: getLastLocation
focal_class.modifiers: @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets public
focal_class.parameters: ()
focal_class.return: Location
focal_class.signature: Location getLastLocation()
focal_class.class_method_signature: AndroidLocationClient.isMonitoringLocation()
focal_class.full_signature: @Override public boolean isMonitoringLocation()
focal_class.identifier: isMonitoringLocation
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isMonitoringLocation()
focal_class.class_method_signature: AndroidLocationClient.canSetUpdateIntervals()
focal_class.full_signature: @Override public boolean canSetUpdateIntervals()
focal_class.identifier: canSetUpdateIntervals
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean canSetUpdateIntervals()
focal_class.class_method_signature: AndroidLocationClient.setUpdateIntervals(long updateInterval, long fastestUpdateInterval)
focal_class.full_signature: @Override public void setUpdateIntervals(long updateInterval, long fastestUpdateInterval)
focal_class.identifier: setUpdateIntervals
focal_class.modifiers: @Override public
focal_class.parameters: (long updateInterval, long fastestUpdateInterval)
focal_class.return: void
focal_class.signature: void setUpdateIntervals(long updateInterval, long fastestUpdateInterval)
focal_class.class_method_signature: AndroidLocationClient.resetUpdateIntervals()
focal_class.full_signature: @Override public void resetUpdateIntervals()
focal_class.identifier: resetUpdateIntervals
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void resetUpdateIntervals()
focal_class.class_method_signature: AndroidLocationClient.onLocationChanged(Location location)
focal_class.full_signature: @Override public void onLocationChanged(Location location)
focal_class.identifier: onLocationChanged
focal_class.modifiers: @Override public
focal_class.parameters: (Location location)
focal_class.return: void
focal_class.signature: void onLocationChanged(Location location)
focal_class.class_method_signature: AndroidLocationClient.onStatusChanged(String provider, int status, Bundle extras)
focal_class.full_signature: @Override public void onStatusChanged(String provider, int status, Bundle extras)
focal_class.identifier: onStatusChanged
focal_class.modifiers: @Override public
focal_class.parameters: (String provider, int status, Bundle extras)
focal_class.return: void
focal_class.signature: void onStatusChanged(String provider, int status, Bundle extras)
focal_class.class_method_signature: AndroidLocationClient.onProviderEnabled(String provider)
focal_class.full_signature: @Override public void onProviderEnabled(String provider)
focal_class.identifier: onProviderEnabled
focal_class.modifiers: @Override public
focal_class.parameters: (String provider)
focal_class.return: void
focal_class.signature: void onProviderEnabled(String provider)
focal_class.class_method_signature: AndroidLocationClient.onProviderDisabled(String provider)
focal_class.full_signature: @Override public void onProviderDisabled(String provider)
focal_class.identifier: onProviderDisabled
focal_class.modifiers: @Override public
focal_class.parameters: (String provider)
focal_class.return: void
focal_class.signature: void onProviderDisabled(String provider)
focal_class.superclass: extends BaseLocationClient
focal_method.body: @Override
      @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets
      public Location getLastLocation() {
          String provider = getProvider();
          if (provider != null) {
              return getLocationManager().getLastKnownLocation(provider);
          }
  
          return null;
      }
focal_method.class_method_signature: AndroidLocationClient.getLastLocation()
focal_method.full_signature: @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets public Location getLastLocation()
focal_method.identifier: getLastLocation
focal_method.invocations: getProvider getLastKnownLocation getLocationManager
focal_method.modifiers: @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets public
focal_method.parameters: ()
focal_method.return: Location
focal_method.signature: Location getLastLocation()