public void testGPS() { LocationManager lm = (LocationManager) mActivity .getSystemService(Context.LOCATION_SERVICE); lm.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true); lm.setTestProviderStatus(LocationManager.GPS_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis()); Location location = new Location(LocationManager.GPS_PROVIDER); location.setLatitude(1.0); location.setLongitude(2.0); location.setTime(System.currentTimeMillis()); lm.setTestProviderLocation(LocationManager.GPS_PROVIDER, location); try { Thread.sleep(2000); } catch(InterruptedException e) { } }
public void test1_TestCaseFoo() { Location location = new Location("network"); location.setLatitude(-15.83554363); location.setLongitude(-48.01770782); location.setTime(new Date().getTime()); location.setAccuracy(100.0f); location.setElapsedRealtimeNanos(System.nanoTime()); LocationManager locationManager = (LocationManager) getInstrumentation().getTargetContext().getSystemService(Context.LOCATION_SERVICE); locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, true, true, true, Criteria.POWER_LOW, Criteria.ACCURACY_FINE); locationManager.setTestProviderStatus(LocationManager.GPS_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis()); locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true); locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, location); locationManager.addTestProvider(LocationManager.NETWORK_PROVIDER, false, false, false, false, true, true, true, Criteria.POWER_LOW, Criteria.ACCURACY_FINE); locationManager.setTestProviderStatus(LocationManager.NETWORK_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis()); locationManager.setTestProviderEnabled(LocationManager.NETWORK_PROVIDER, true); locationManager.setTestProviderLocation(LocationManager.NETWORK_PROVIDER, location); mActivity = getActivity(); ....
geoLocationManager.addTestProvider(mocLocationProvider, false, false, false, false, true, true, true, 1, 5); geoLocationManager.setTestProviderEnabled(mocLocationProvider, true); geoLocationManager.setTestProviderStatus(mocLocationProvider, 2, null, System.currentTimeMillis());
true, true, 0, 5); mLocationManager.setTestProviderEnabled(mockLocationProvider, true); mLocationManager.setTestProviderStatus(mockLocationProvider, LocationProvider.AVAILABLE, null, System.currentTimeMillis()); if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED) {
locationManager.setTestProviderEnabled(GPS_MOCK_PROVIDER, true); locationManager.setTestProviderStatus(GPS_MOCK_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis());