leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
820 stars 118 forks source link

Have the ability to mock the device's location using XCUILocation on iOS #2044

Open jointhejourney opened 6 months ago

jointhejourney commented 6 months ago

Use case

Hello,

I noticed the issue https://github.com/leancodepl/patrol/issues/1961 was recently closed, but I was wondering if there's any way we could implement mocking for the location of the phone by using XCUILocation as described here on Apple's doc?

Example:

import XCTest
import CoreLocation

final class SampleAppTests: XCTestCase {

  func testExample() throws {
    XCUIDevice.shared.location = XCUILocation(location: CLLocation(latitude: 37.334886, longitude: -122.008988))
    // Launch your app and run the test.
  }
}

Proposal

Ideally, we'd be able to use a method like await $.native.setLocation(LatLng(37.334886, -122.008988));

However if we're limited to before the app is launched, then perhaps we can pass coordinates to NativeAutomatorConfig()?

piotruela commented 5 months ago

Hi, nice find. It looks like a good starting point for implementing this feature if it's actually going to work.