My goal is to automate the movement of a user through UI Automation. In an ideal scenario, the user's location in an MKMapView
would update based on a predefined list of waypoints outlined in the automation script:
var target = UIATarget.localTarget();
var waypoints = [
{location: {latitude: 37.33170, longitude: -122.03020}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03022}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03025}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03027}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03030}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03032}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03035}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03037}, options: {course: 180}},
{location: {latitude: 37.33170, longitude: -122.03040}, options: {course: 180}}
];
for (var waypointIndex = 0; waypointIndex < waypoints.length; waypointIndex++)
{
if (waypointIndex == 0)
target.delay(5);
var waypoint = waypoints[waypointIndex];
target.setLocationWithOptions(waypoint.location, waypoint.options);
target.delay(1);
if (waypointIndex == (waypoints.length - 1))
waypointIndex = 0;
}
The location aspect works smoothly, with the user's indicator following the specified path. However, the course option doesn't seem to have any effect. I've experimented with values like 90
, 180
, -90
, 3.14
, and
1.57</code, but it doesn't make a difference.</p>
<p>I also attempted adding the <code>speed: 8
parameter to the options
, but this didn't lead to any changes.
Considering that this seems to be the only method for simulating headings, and the fact that the course
option is officially supported and documented, it's frustrating that it's not functioning as expected.
Potential workaround: If you simulate location using a GPX file on a physical device, the device's rotation functionality kicks in. This allows you to simulate a route and obtain rotation data.