- Timestamp:
- 2024-09-19T15:38:39+02:00 (3 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r19050 r19227 13 13 import java.awt.event.KeyEvent; 14 14 import java.awt.event.MouseEvent; 15 import java.util.ArrayList; 15 16 import java.util.Collection; 16 17 import java.util.Collections; … … 18 19 import java.util.EnumSet; 19 20 import java.util.LinkedHashSet; 21 import java.util.List; 20 22 import java.util.Map; 21 23 import java.util.Optional; … … 287 289 // Since the created way is left selected, we need to unselect again here 288 290 if (pWays != null && pWays.getWays() != null) { 289 getLayerManager().getEditDataSet().clearSelection(pWays.getWays()); 291 final List<Way> ways = new ArrayList<>(pWays.getWays()); 292 ways.removeIf(w -> w.getDataSet() == null); 293 getLayerManager().getEditDataSet().clearSelection(ways); 290 294 pWays = null; 291 295 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
r18870 r19227 5 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit.jupiter.api.BeforeEach; 7 8 import org.junit.jupiter.api.Test; 8 9 import org.openstreetmap.josm.TestUtils; 9 10 import org.openstreetmap.josm.actions.mapmode.ParallelWayAction.Mode; 10 11 import org.openstreetmap.josm.actions.mapmode.ParallelWayAction.Modifier; 12 import org.openstreetmap.josm.data.UndoRedoHandler; 13 import org.openstreetmap.josm.data.coor.LatLon; 11 14 import org.openstreetmap.josm.data.osm.DataSet; 12 15 import org.openstreetmap.josm.gui.MainApplication; 13 16 import org.openstreetmap.josm.gui.MapFrame; 14 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 18 import org.openstreetmap.josm.testutils.MapModeUtils; 15 19 import org.openstreetmap.josm.testutils.annotations.Main; 16 20 import org.openstreetmap.josm.testutils.annotations.Projection; 21 import org.openstreetmap.josm.tools.Logging; 17 22 18 23 /** … … 22 27 @Projection 23 28 class ParallelWayActionTest { 29 private MapFrame map; 30 private ParallelWayAction mapMode; 31 private DataSet dataSet; 32 33 @BeforeEach 34 void setup() { 35 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "ParallelWayActionTest", null); 36 MainApplication.getLayerManager().addLayer(layer); 37 this.map = MainApplication.getMap(); 38 this.mapMode = new ParallelWayAction(this.map); 39 this.dataSet = layer.getDataSet(); 40 } 41 24 42 /** 25 43 * Unit test of {@link ParallelWayAction#enterMode} and {@link ParallelWayAction#exitMode}. … … 27 45 @Test 28 46 void testMode() { 29 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null); 30 try { 31 MainApplication.getLayerManager().addLayer(layer); 32 MapFrame map = MainApplication.getMap(); 33 ParallelWayAction mapMode = new ParallelWayAction(map); 34 MapMode oldMapMode = map.mapMode; 35 assertTrue(map.selectMapMode(mapMode)); 36 assertEquals(mapMode, map.mapMode); 37 assertTrue(map.selectMapMode(oldMapMode)); 38 } finally { 39 MainApplication.getLayerManager().removeLayer(layer); 40 } 47 final MapMode oldMapMode = this.map.mapMode; 48 assertTrue(this.map.selectMapMode(mapMode)); 49 assertEquals(this.mapMode, this.map.mapMode); 50 assertTrue(this.map.selectMapMode(oldMapMode)); 51 } 52 53 /** 54 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20908">#20908</a> 55 */ 56 @Test 57 void testNonRegression20908() { 58 Logging.clearLastErrorAndWarnings(); 59 this.map.selectMapMode(this.map.mapModeDraw); 60 MapModeUtils.clickAt(LatLon.ZERO); 61 MapModeUtils.clickAt(2, new LatLon(0.0001, 0)); 62 assertEquals(3, this.dataSet.allPrimitives().size()); 63 this.map.selectMapMode(mapMode); 64 MapModeUtils.dragFromTo(new LatLon(0.00005, 0), new LatLon(0.00005, 0.0001)); 65 assertEquals(6, this.dataSet.allPrimitives().size()); 66 UndoRedoHandler.getInstance().undo(); 67 assertEquals(3, this.dataSet.allPrimitives().size()); 68 this.map.mapMode.mousePressed(MapModeUtils.mouseClickAt(new LatLon(0.00005, 0.0001))); 69 assertTrue(Logging.getLastErrorAndWarnings().isEmpty(), String.join("\n", Logging.getLastErrorAndWarnings())); 41 70 } 42 71 -
trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
r19226 r19227 87 87 ); 88 88 } 89 89 90 /** 90 91 * Test of {@link ExceptionUtil#explainBadRequest} method. … … 94 95 @SuppressWarnings("unchecked") 95 96 void testExplainBadRequest(Supplier<String> message, Object exception) { 96 assertEquals(message.get(), ExceptionUtil.explainBadRequest(exception instanceof Supplier ? ((Supplier<OsmApiException>) exception).get() : (OsmApiException) exception)); 97 assertEquals(message.get(), ExceptionUtil.explainBadRequest( 98 exception instanceof Supplier ? ((Supplier<OsmApiException>) exception).get() : (OsmApiException) exception 99 )); 97 100 } 98 101
Note:
See TracChangeset
for help on using the changeset viewer.