I'd like to write an instrumented test to verify the behaviour of an app that requests location updates using the FusedLocation API on API23+.
I have some requirements: - The test must run in an emulator (AVD) because I'd like the tests to run in a continuous integration service like Travis CI or circle CI. - I want to test that the Marshmallow permissions request dialog properly pops-up using UI Automator. - I want to ensure my code works by checking the Location object returned by requestLocationUpdates() using assertions.
Since testing on an emulated device is a requirement we must then use FusedLocation.setMockLocation() in order to get a location or the requestLocationUpdates() will not yield any results.
Until now I have faced these problems: - Both setMockMode() and setMockLocation() require location permission: this means that I have to request the location permission in my test code and once my code under test reaches the requestLocationUpdates() call it won't request permission again (because it already has it) thereby not letting me test the permission request dialog with UI Automator. - setMockLocation() requires manually setting "Allow mock locations" in developer options so the Continuous Integration will fail because a new emulator is created every build and will have "Allow mock locations" disabled by default.
It seems to my I've reached a dead end. Please prove me wrong!
Aucun commentaire:
Enregistrer un commentaire