/** * Test when user add new icon, after that repeats click on icon and chaotic click on map to move * editing icon At the end is succ finish => icon should be at the last click position */ private void tstClickOnMapEditingAndFinish() { // simple add and finish adding of new item map.clearOverlays(); mapAddOverlayEvents.clear(); mapRemoveOverlayEvents.clear(); MapControllerT mc = new MapControllerT(map, service); mc.startAdding(); LatLng ll1 = getRandomLatLng(); mc.onMapClick(new MapClickEvent(map, null, ll1, null)); mc.finishWorking(false); // now presenter is calling web service to save and after succ. save is called onAddItem MapItem mapItem = RandomGenerator.genMapItem(false); LatLng mapItemLatLng = LatLng.newInstance(mapItem.getY(), mapItem.getX()); mc.addMapItem(mapItem); MapItemOverlay<MapItem> mi = (MapItemOverlay<MapItem>) mapAddOverlayEvents.get(1).getOverlay(); DataComparator.assertEquals(mapItemLatLng, mi.getLatLng()); // simulate click on icon mc.startEditing(mi); LatLng ll = null; for (int i = 0; i < 10; i++) // just chaotic click, icon should moves { ll = getRandomLatLng(); mc.onMapClick(new MapClickEvent(map, null, ll, null)); DataComparator.assertEquals(ll, mi.getLatLng()); DataComparator.assertEquals(mapItemLatLng, mc.mStartEditLatLng); } mc.finishWorking(false); // finished => not canceled assertEquals(mc.mState, State.Default); assertNull(mc.mCurrentMarker); assertNull(mc.mStartEditLatLng); // after finish nothing should happen assertEquals(1, mc.mCurrentVisibleMapItems.size()); assertEquals(2, mapAddOverlayEvents.size()); assertEquals(1, mapRemoveOverlayEvents.size()); // only editing icon should be at the last click position DataComparator.assertEquals(ll, mi.getLatLng()); }