@Test
public void shouldRemovePendingIntentsWhenRequestingLocationUpdatesUsingCriteria() throws Exception {
Intent someIntent = new Intent("some_action");
PendingIntent someLocationListenerPendingIntent =
PendingIntent.getBroadcast(context, 0, someIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent someOtherIntent = new Intent("some_other_action");
PendingIntent someOtherLocationListenerPendingIntent =
PendingIntent.getBroadcast(context, 0, someOtherIntent, PendingIntent.FLAG_UPDATE_CURRENT);
shadowLocationManager.setProviderEnabled(GPS_PROVIDER, true);
shadowLocationManager.setBestProvider(LocationManager.GPS_PROVIDER, true);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
locationManager.requestLocationUpdates(0, 0, criteria, someLocationListenerPendingIntent);
locationManager.requestLocationUpdates(0, 0, criteria, someOtherLocationListenerPendingIntent);
locationManager.removeUpdates(someLocationListenerPendingIntent);
Map<PendingIntent, Criteria> expectedCriteria = new HashMap<>();
expectedCriteria.put(someOtherLocationListenerPendingIntent, criteria);
assertThat(shadowLocationManager.getRequestLocationUdpateCriteriaPendingIntents()).isEqualTo(expectedCriteria);
}