Changeset 18935 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2024-01-15T17:20:18+01:00 (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java
r18870 r18935 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.junit.jupiter.api.Assertions.assertAll; 5 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 6 import static org.junit.jupiter.api.Assertions.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertFalse; 5 8 import static org.junit.jupiter.api.Assertions.assertNotNull; 9 import static org.openstreetmap.josm.tools.I18n.tr; 6 10 7 11 import java.io.IOException; … … 25 29 import org.openstreetmap.josm.data.osm.Node; 26 30 import org.openstreetmap.josm.data.osm.Way; 31 import org.openstreetmap.josm.gui.ExtendedDialog; 27 32 import org.openstreetmap.josm.gui.MainApplication; 33 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 import org.openstreetmap.josm.gui.util.GuiHelper; 28 35 import org.openstreetmap.josm.io.IllegalDataException; 29 36 import org.openstreetmap.josm.io.OsmReader; 30 37 import org.openstreetmap.josm.testutils.annotations.Main; 31 38 import org.openstreetmap.josm.testutils.annotations.Projection; 39 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 40 import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker; 32 41 import org.openstreetmap.josm.tools.Utils; 33 42 … … 100 109 assertEquals(Collections.singleton(n1), deleteCommands.iterator().next().getParticipatingPrimitives()); 101 110 } 111 112 /** 113 * Non-regression test for #23399 114 */ 115 @Test 116 void testNonRegression23399() { 117 TestUtils.assumeWorkingJMockit(); 118 new ExtendedDialogMocker(Collections.singletonMap("Simplify way", "Simplify")) { 119 @Override 120 protected String getString(ExtendedDialog instance) { 121 return instance.getTitle(); 122 } 123 }; 124 new HelpAwareOptionPaneMocker(Collections.singletonMap( 125 tr("The selection contains {0} ways. Are you sure you want to simplify them all?", 1000), "Yes")); 126 final ArrayList<Way> ways = new ArrayList<>(1000); 127 final DataSet ds = new DataSet(); 128 for (int i = 0; i < 1000; i++) { 129 final Way way = TestUtils.newWay("", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.001)), 130 new Node(new LatLon(0, 0.002))); 131 ways.add(way); 132 ds.addPrimitiveRecursive(way); 133 } 134 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, "SimplifyWayActionTest#testNonRegression23399", null)); 135 GuiHelper.runInEDTAndWait(() -> ds.setSelected(ds.allPrimitives())); 136 assertEquals(ds.allPrimitives().size(), ds.getAllSelected().size()); 137 assertDoesNotThrow(() -> GuiHelper.runInEDTAndWaitWithException(() -> action.actionPerformed(null))); 138 assertAll(ways.stream().map(way -> () -> assertEquals(2, way.getNodesCount()))); 139 assertAll(ds.getAllSelected().stream().map(p -> () -> assertFalse(p.isDeleted()))); 140 assertEquals(3000, ds.getAllSelected().size()); 141 } 102 142 }
Note:
See TracChangeset
for help on using the changeset viewer.