コード例 #1
0
 @Before
 public void setUp() throws Exception {
   doReturn(LocationManager.GPS_PROVIDER)
       .when(locationManager)
       .getBestProvider(any(Criteria.class), anyBoolean());
   doReturn(locationManager).when(context).getSystemService(eq(Context.LOCATION_SERVICE));
   locator.prepare(context, settings);
 }
コード例 #2
0
  @Test
  public void locator_should_disable_location_updates_when_a_provider_is_disabled()
      throws NoProviderAvailable {
    locator.startLocationUpdates();

    disableProvider();

    verify(locationManager, times(3)).removeUpdates(any(PendingIntent.class));
  }
コード例 #3
0
  @Test
  public void locator_should_restart_location_updates_when_a_provider_is_disabled()
      throws NoProviderAvailable {
    locator.startLocationUpdates();

    disableProvider();

    verify(locationManager, times(2))
        .requestLocationUpdates(anyString(), anyLong(), anyFloat(), any(PendingIntent.class));
  }