@Test public void onLocationChanged_shouldSendPendingIntent() { LostClientManager clientManager = mock(LostClientManager.class); IFusedLocationProviderService service = mock(IFusedLocationProviderService.class); LocationAvailability locationAvailability = mock(LocationAvailability.class); try { when(service.getLocationAvailability()).thenReturn(locationAvailability); } catch (RemoteException e) { e.printStackTrace(); } Context context = mock(Context.class); Location location = mock(Location.class); callbackManager.onLocationChanged(context, location, clientManager, service); verify(clientManager).sendPendingIntent(eq(context), eq(location), eq(locationAvailability), any(LocationResult.class)); }
void onLocationChanged(Context context, Location location, ClientManager clientManager, IFusedLocationProviderService service) { clientManager.reportLocationChanged(location); LocationAvailability availability = null; try { availability = service.getLocationAvailability(); } catch (RemoteException e) { Log.e(TAG, "Error occurred trying to get LocationAvailability", e); } ArrayList<Location> locations = new ArrayList<>(); locations.add(location); final LocationResult result = LocationResult.create(locations); clientManager.sendPendingIntent(context, location, availability, result); clientManager.reportLocationResult(location, result); }
FusedLocationServiceCallbackManager { void onLocationChanged(Context context, Location location, ClientManager clientManager, IFusedLocationProviderService service) { clientManager.reportLocationChanged(location); LocationAvailability availability = null; try { availability = service.getLocationAvailability(); } catch (RemoteException e) { Log.e(TAG, "Error occurred trying to get LocationAvailability", e); } ArrayList<Location> locations = new ArrayList<>(); locations.add(location); final LocationResult result = LocationResult.create(locations); clientManager.sendPendingIntent(context, location, availability, result); clientManager.reportLocationResult(location, result); } }
FusedLocationServiceCallbackManager { void onLocationChanged(Context context, Location location, ClientManager clientManager, IFusedLocationProviderService service) { clientManager.reportLocationChanged(location); LocationAvailability availability = null; try { availability = service.getLocationAvailability(); } catch (RemoteException e) { Log.e(TAG, "Error occurred trying to get LocationAvailability", e); } ArrayList<Location> locations = new ArrayList<>(); locations.add(location); final LocationResult result = LocationResult.create(locations); clientManager.sendPendingIntent(context, location, availability, result); clientManager.reportLocationResult(location, result); }  }
FusedLocationServiceCallbackManager { void onLocationChanged(Context context, Location location, ClientManager clientManager, IFusedLocationProviderService service) { clientManager.reportLocationChanged(location); LocationAvailability availability = null; try { availability = service.getLocationAvailability(); } catch (RemoteException e) { Log.e(TAG, "Error occurred trying to get LocationAvailability", e); } ArrayList<Location> locations = new ArrayList<>(); locations.add(location); final LocationResult result = LocationResult.create(locations); clientManager.sendPendingIntent(context, location, availability, result); clientManager.reportLocationResult(location, result); }   }
FusedLocationServiceCallbackManager { void onLocationChanged(Context context, Location location, ClientManager clientManager, IFusedLocationProviderService service) { clientManager.reportLocationChanged(location); LocationAvailability availability = null; try { availability = service.getLocationAvailability(); } catch (RemoteException e) { Log.e(TAG, "Error occurred trying to get LocationAvailability", e); } ArrayList<Location> locations = new ArrayList<>(); locations.add(location); final LocationResult result = LocationResult.create(locations); clientManager.sendPendingIntent(context, location, availability, result); clientManager.reportLocationResult(location, result); }    }