user1371033
user1371033

Reputation: 353

Testing app based on geolocation?

I have a situation in which I need to test smart phone app. Objective is to disable my app based on the geolocation. So for example let say I am "live" streaming some video via my app and would like to disable streaming if user goes to certain restricted location and turn it ON when user moves to acceptable geological area.

Now the testing part is, that all the phones lets say 5 phones are in front of me and I want to test the app running on them that the app will get turned off when they will move into the restricted areas. How can this be achieved?

Edits:- Actual scenario - Live streaming of a match which should not be shown in area near the stadium on the android app. So if a user hit "play" button on app and the phone is physically in video restricted zone for that particular duration of the match, the video should not be streamed to that cell phone.

any thoughts... opinions..?

Thanks

Upvotes: 3

Views: 2708

Answers (5)

Augusto
Augusto

Reputation: 2232

Much easier with Chrome DevTools :

  • Open Chrome/ium DevTool
  • Press Command+Shift+P (Mac) or Control+Shift+P (Windows, Linux, Chrome OS) to open the Command Menu.
  • Open sensor tab
  • Choose your location (list of location is custom :)

enter image description here

Upvotes: 0

magma
magma

Reputation: 8520

When debugging your iOS application on an XCode-connected device, you can override the device's gps position by clicking on the small arrow in the lower end of the XCode interface:

enter image description here

There are a few default locations, and you can add your own with File.. New.. iOS/Resource, "GPX File":

enter image description here

Here's a GPX file:

<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode"> 

    <wpt lat="45.463965" lon="9.180247">
         <name>Milan, Italy</name>
    </wpt>

</gpx>

You can specify multiple locations (a track), but apparently you will not be able to control timing:

<?xml version="1.0" encoding="UTF-8"?>
<gpx>
    <wpt lat="52.373" lon="4.871"></wpt>
    <wpt lat="52.374" lon="4.872"></wpt>
    <wpt lat="52.375" lon="4.871"></wpt>
</gpx>

However, perhaps you're interested in automating the process by programmatically sending location sequences to the devices. Somewhere in your app, you're receiving messages from a CLLocationManager instance, that go to your delegate. When testing, don't subscribe to CLLocationManager - build a fake location manager instance instead, that sends fake locations to your delegate:

[delegate locationManager:nil didUpdateToLocation:newLocation fromLocation:oldLocation];

See:

Simulating location updates on the iPhone Simulator

Simulating location changes for `startMonitoringSignificantLocationChanges`

And:

https://github.com/futuretap/FTLocationSimulator

https://github.com/johnmckerrell/LocationManagerSimulator

Upvotes: 2

Andreas Wallner
Andreas Wallner

Reputation: 255

On android you have multiple options to supply your application with a mock location: via DDMS, telnet or via the LocationManager:

DDMS

Start DDMS from the AndroidSDK/tools/ folder. Select the device you want to spoof the location for, and go to Emulator Control. At the bottom of the tab you should find the option to manually set the location, and what location to spoof.

ADB/Telnet

List all of your devices via adb devices. From this you should get an output like this:

List of devices attached
emulator-5554 device

Then telnet to the indicated port:

telnet localhost 5554

This should open the android console. There you can use the geo fix command to set the location

geo fix $lon $lat

LocationProvider

You can supply a location for testing using the setTestProviderLocation Method of the LocationProvider

LocationManager lm = (LocationManager)this.getContext().getSystemService(Context.LOCATION_SERVICE);
String mocLocationProvider = "Test";
locationManager.addTestProvider(mocLocationProvider, false, false,
                    false, false, true, true, true, 0, 5);
locationManager.setTestProviderEnabled(mocLocationProvider, true);

Location mockLocation = new Location(mocLocationProvider);
mockLocation.setLatitude(location.getLatitude());
mockLocation.setLongitude(location.getLongitude()); 
mockLocation.setAltitude(location.getAltitude()); 
mockLocation.setTime(System.currentTimeMillis()); 
locationManager.setTestProviderLocation( mocLocationProvider, mockLocation);

This method I got from here

Additionally, do not forget to set the permission

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION">

Upvotes: 3

KosherBacon
KosherBacon

Reputation: 172

If you are on a rooted device especially there are methods of allowing for simulated locations in the developer menu. Also check out apps like this Fake GPS App (Android)

Upvotes: 0

pedros
pedros

Reputation: 1197

I dont know if I understood very well, but if you want to test if the disabling part of your app works by changing the location, the the iPhone Simulator might help.

The geolocation of the simulator can be set to a number of predetermined important locations like Hong Kong and London. Make one of those restricted and test it out.

To simulate a location you have to set it in xcode. Click the button that looks like an arrow close to the debugging control buttons.

Upvotes: 0

Related Questions