How to: Test Applications that Use Location Data
March 22, 2012
The Windows Phone SDK 7.1 includes a location sensor simulator. This topic describes how to test applications that use location data. You can find a location service sample at Code Samples for Windows Phone.
You can view the location sensor simulator from Windows Phone Emulator. The location sensor simulator toolbar contains controls to find a location, add points to the mapped location, and record and play back your location data.
To view the location sensor simulator
-
In Visual Studio, run the application you want to test in the emulator.
-
Move the mouse pointer to the right of the emulator to display the emulator toolbar.
The following image shows the toolbar with the chevron button highlighted.
-
At the bottom of the emulator toolbar, click the chevron button to open the Additional Tools window.
-
Click the Location tab to view the location sensor simulator.
The following image shows the location sensor simulator toolbar.
1
Search
2
Zoom
3
Toggle live interactions with map on or off
4
Toggle push pin mode on or off
5
Clear all points
6
Save map points
7
Interval in seconds
8
Play all points
You can test the location sensor with live or recorded input.
To test an application with live input
-
In Visual Studio, run the application you want to test in the emulator.
-
Open the Additional Tools window and click the Location tab.
-
Make sure the live input mode is on by toggling the Live button.
If the Live button is grayed out, live input mode is off.
-
In the Search box, type the location you want to display in the map.
-
Click the Search button or press Enter.
The following image shows the location sensor simulator with a location specified and the Live button on.
-
Use the zoom controls to zoom in or out from the mapped location.
-
Reposition the map by dragging the map with the mouse.
-
Toggle the push pin button on.
-
Click the map to add points to the map.
Each time you add a point to the map, the PositionChanged event will be raised in your application.
-
Stop your application when you have completed testing.
To test an application with recorded location data
-
In Visual Studio, open the project you want to test and start Windows Phone Emulator. The portion of your application that uses the Location service must not be running.
-
Open the Additional Tools window.
-
Make sure the live input mode is off by toggling the Live button.
If the Live button is grayed out, live input mode is off.
-
Use the Search box to find a location you want to display in the map.
-
Toggle the push pin button on.
-
Click the map to add points to the map.
Each time you add a point, an entry is added to the list at the lower left of the simulator. The following image shows the location sensor simulator with a location specified, live mode turned off, and several points added to the map.
-
To delete a point added in error, locate the point in the list at the lower left of the simulator and then click the Delete point button to the right of the point.
You can delete all of the points by clicking the Clear all points button.
-
To enter the time interval that should elapse between points on the map, specify the number of seconds in the Fire every box.
This number indicates the time interval (in seconds) between each occurrence of the PositionChanged event in your application.
-
Optionally, you can save your data to a file by clicking the Save map points button. If you save the data, you can use it in subsequent test passes.
When the Save As dialog box appears, specify a file name and click Save. The file is saved as an XML file in the \Documents\WindowsPhoneEmulator\Location folder.
-
Run your application in the emulator or start the portion of your application that uses the location service
-
On the right side of the toolbar, click the Play all points button to start playback of the recorded location data.
You can play back the location data as many times as necessary to test your application.
-
Stop your application when you have completed testing.
To test an application with previously saved data
-
In Visual Studio, open the project you want to test and start Windows Phone Emulator. The portion of your application that uses the Location service must not be running.
-
Open the Additional Tools window and click the Location tab.
-
In the Recorded Data pane, click Load.
An Open file dialog box appears.
-
Select the location file you want to use and click Open.
-
Run your application in the emulator or start the portion of your application that uses the location service.
-
On the right side of the toolbar, click the Play all points button to start playback of the recorded location data.
You can play back the location data as many times as necessary to test your application.
The following image shows saved data displayed in the simulator.
-
Stop your application when you have completed testing.