Issue
So, I have problems with testing my Google Map functionality. In my activty I have callback onMapClick(LatLng latlng)
in which there is method to show/hide toolbar. Now, I would like to test it, but I have no clue how to perform click on the map. I tried to use this:
onView(withContentDescription("Mapa Google")).perform(click());
and this:
UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject map = device.findObject(new UiSelector()
.descriptionContains("Mapa Google"));
map.click();
but it seams that, it doesn't work. Do you know how can I test this kind of behavior?
Solution
The best way is UiAutomator library , https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html
private UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
private UiObject mMarker1 = uiDevice.findObject(new UiSelector().descriptionContains("The title of marker"));
try {
mMarker1.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
for taping on map you can use this
uiDevice.click(x, y);
x and y are the coordinates
Answered By - Ara Hakobyan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.