@Test public void testSingleLocationRequest() { when(mockAdapterTwo.isAvailable(context)).thenReturn(true); provider.requestSingleLocation(options, locationCallback); verify(mockAdapterTwo).requestSingleLocation(eq(context), eq(options), eq(locationCallback)); verify(mockAdapterOne, times(0)).requestSingleLocation(eq(context), eq(options), eq(locationCallback)); }
@Nullable @WorkerThread Cancelable requestSingleLocation(@NonNull LocationRequestOptions options, ResultCallback<Location> resultCallback) { connect(); if (availableAdapter == null) { Logger.debug("UALocationProvider - Ignoring request, connected adapter unavailable."); } Logger.verbose("UALocationProvider - Requesting single location update: %s", options); try { return availableAdapter.requestSingleLocation(context, options, resultCallback); } catch (Exception e) { Logger.error(e, "Unable to request location."); } return null; }
UALocationProvider { @Nullable @WorkerThread Cancelable requestSingleLocation(@NonNull LocationRequestOptions options, ResultCallback<Location> resultCallback) { connect(); if (availableAdapter == null) { Logger.debug("UALocationProvider - Ignoring request, connected adapter unavailable."); } Logger.verbose("UALocationProvider - Requesting single location update: %s", options); try { return availableAdapter.requestSingleLocation(context, options, resultCallback); } catch (Exception e) { Logger.error(e, "Unable to request location."); } return null; } }
UALocationProvider { @Nullable @WorkerThread Cancelable requestSingleLocation(@NonNull LocationRequestOptions options, ResultCallback<Location> resultCallback) { connect(); if (availableAdapter == null) { Logger.debug("UALocationProvider - Ignoring request, connected adapter unavailable."); } Logger.verbose("UALocationProvider - Requesting single location update: %s", options); try { return availableAdapter.requestSingleLocation(context, options, resultCallback); } catch (Exception e) { Logger.error(e, "Unable to request location."); } return null; } UALocationProvider(@NonNull Context context, @NonNull Intent locationUpdateIntent); @VisibleForTesting  UALocationProvider(@NonNull Context context, @NonNull Intent locationUpdateIntent, LocationAdapter... adapters); }
UALocationProvider { @Nullable @WorkerThread Cancelable requestSingleLocation(@NonNull LocationRequestOptions options, ResultCallback<Location> resultCallback) { connect(); if (availableAdapter == null) { Logger.debug("UALocationProvider - Ignoring request, connected adapter unavailable."); } Logger.verbose("UALocationProvider - Requesting single location update: %s", options); try { return availableAdapter.requestSingleLocation(context, options, resultCallback); } catch (Exception e) { Logger.error(e, "Unable to request location."); } return null; } UALocationProvider(@NonNull Context context, @NonNull Intent locationUpdateIntent); @VisibleForTesting  UALocationProvider(@NonNull Context context, @NonNull Intent locationUpdateIntent, LocationAdapter... adapters);  }
UALocationProvider { @Nullable @WorkerThread Cancelable requestSingleLocation(@NonNull LocationRequestOptions options, ResultCallback<Location> resultCallback) { connect(); if (availableAdapter == null) { Logger.debug("UALocationProvider - Ignoring request, connected adapter unavailable."); } Logger.verbose("UALocationProvider - Requesting single location update: %s", options); try { return availableAdapter.requestSingleLocation(context, options, resultCallback); } catch (Exception e) { Logger.error(e, "Unable to request location."); } return null; } UALocationProvider(@NonNull Context context, @NonNull Intent locationUpdateIntent); @VisibleForTesting  UALocationProvider(@NonNull Context context, @NonNull Intent locationUpdateIntent, LocationAdapter... adapters);   }