Issue
I am new to testing in android. I have a map activity, which is called after some events in the MainActivity and a map appears in the screen. I am not able to figure out how to test whether the map appears or not. I understand its not possible with espresso, but have read somewhere that its possible with UiAutomator. How to use UiAutomator for the same..?
Solution
You can set the content description of the View hosting the map to indicate its "readiness".
...
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapView = mapFragment.getView();
mapView.setContentDescription("MAP NOT READY");
// you may need to preserve existing description
mapFragment.getMapAsync(this);
@Override
public void onMapReady(GoogleMap googleMap) {
...
mapView.setContentDescription("MAP READY");
}
Then, on your test
mDevice.wait(Until.hasObject(By.desc("MAP READY")), timeout);
Answered By - Diego Torres Milano
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.