Code example for Criteria

Methods: setAccuracy, setPowerRequirement

0
    } 
  } 
 
  @Test 
  public void shouldReturnBestCustomProviderUsingCriteria() throws Exception { 
    Criteria criteria = new Criteria();
    Criteria customProviderCriteria = new Criteria();
 
    // Manually set best provider should be returned 
    ArrayList<Criteria> criteriaList = new ArrayList<Criteria>();
    customProviderCriteria.setAccuracy(Criteria.ACCURACY_COARSE);
    criteriaList.add(customProviderCriteria);
    shadowLocationManager.setProviderEnabled("BEST_ENABLED_PROVIDER_WITH_CRITERIA", true, criteriaList);
    assertTrue(shadowLocationManager.setBestProvider("BEST_ENABLED_PROVIDER_WITH_CRITERIA", true));
    criteria.setAccuracy(Criteria.ACCURACY_COARSE);
    criteria.setPowerRequirement(Criteria.NO_REQUIREMENT);
    assertThat("BEST_ENABLED_PROVIDER_WITH_CRITERIA").isEqualTo(locationManager.getBestProvider(criteria, true));
    assertTrue(shadowLocationManager.setBestProvider("BEST_ENABLED_PROVIDER_WITH_CRITERIA", true));
    assertThat("BEST_ENABLED_PROVIDER_WITH_CRITERIA").isEqualTo(locationManager.getBestProvider(criteria, false));
    assertThat("BEST_ENABLED_PROVIDER_WITH_CRITERIA").isEqualTo(locationManager.getBestProvider(criteria, true));
  }