Changeset 33412 in osm for applications/editors/josm/plugins/pt_assistant
- Timestamp:
- 2017-06-22T23:08:53+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/.classpath
r32680 r33412 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry including="GPL-v2.0.txt|GPL-v3.0.txt|LICENSE|README|data/|images/|resources/" kind="src" path=""/> 4 5 <classpathentry kind="src" path="test/unit"/> 5 6 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutTest.java
r33410 r33412 8 8 import java.io.FileNotFoundException; 9 9 import java.util.Collection; 10 import java.util.Collections; 10 11 import java.util.List; 11 12 import java.util.Map; 12 13 13 import org.junit.After;14 14 import org.junit.Before; 15 import org.junit.Rule; 15 16 import org.junit.Test; 16 import org.openstreetmap.josm.JOSMFixture;17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.actions.SplitWayAction; 19 import org.openstreetmap.josm.actions.SplitWayAction.SplitWayResult; 19 20 import org.openstreetmap.josm.data.osm.DataSet; 20 21 import org.openstreetmap.josm.data.osm.Node; … … 27 28 import org.openstreetmap.josm.io.OsmReader; 28 29 import org.openstreetmap.josm.plugins.pt_assistant.AbstractTest; 30 import org.openstreetmap.josm.testutils.JOSMTestRules; 29 31 30 32 public class SplitRoundaboutTest extends AbstractTest { 31 33 32 DataSet ds; 33 OsmDataLayer layer; 34 SplitRoundaboutAction action; 35 SplitWayAction swa; 36 Way r1, r2, r3; 34 /** 35 * Setup test. 36 */ 37 @Rule 38 public JOSMTestRules rules = new JOSMTestRules().preferences().platform(); 39 40 private DataSet ds; 41 private OsmDataLayer layer; 42 private SplitRoundaboutAction action; 43 private Way r1, r2, r3; 37 44 38 45 @Before 39 46 public void init() throws FileNotFoundException, IllegalDataException { 40 41 new JOSMFixture("../../JOSM/test/config/unit-josm.home").init(true);42 43 47 ds = OsmReader.parseDataSet(new FileInputStream(AbstractTest.PATH_TO_ROUNDABOUT), null); 44 48 layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null); … … 47 51 Main.pref.put("pt_assistant.roundabout-splitter.alignalways", true); 48 52 action = new SplitRoundaboutAction(); 49 swa = Main.main.menu.splitWay;50 swa.setEnabled(true);51 53 r1 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(293302077L, OsmPrimitiveType.WAY)); 52 54 r2 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(205833435L, OsmPrimitiveType.WAY)); … … 54 56 } 55 57 58 private Collection<Way> splitWay(Way w) { 59 Map<Relation, Integer> savedPositions = action.getSavedPositions(w); 60 List<Node> splitNodes = action.getSplitNodes(w); 61 assertEquals(4, splitNodes.size()); 62 SplitWayResult result = SplitWayAction.split(layer, w, splitNodes, Collections.emptyList()); 63 result.getCommand().executeCommand(); 64 Collection<Way> splitWays = result.getNewWays(); 65 action.updateRelations(savedPositions, splitNodes, splitWays); 66 return splitWays; 67 } 68 56 69 @Test 57 70 public void test1() { 58 59 Map<Relation, Integer> savedPositions = action.getSavedPositions(r1); 60 List<Node> splitNodes = action.getSplitNodes(r1); 61 assertEquals(4, splitNodes.size()); 62 ds.setSelected(splitNodes); 63 swa.actionPerformed(null); 64 65 Collection<Way> splitWays = ds.getSelectedWays(); 66 action.updateRelations(savedPositions, splitNodes, splitWays); 67 68 splitWays.forEach(w -> { 71 splitWay(r1).forEach(w -> { 69 72 if (w.firstNode().getUniqueId() == 267843779L && w.lastNode().getUniqueId() == 2968718407L) 70 73 assertEquals(w.getReferrers().size(), 5); … … 80 83 } 81 84 82 @Test 83 public void test2() { 84 Map<Relation, Integer> savedPositions = action.getSavedPositions(r2); 85 List<Node> splitNodes = action.getSplitNodes(r2); 86 assertEquals(4, splitNodes.size()); 87 ds.setSelected(splitNodes); 88 swa.actionPerformed(null); 89 90 Collection<Way> splitWays = ds.getSelectedWays(); 91 action.updateRelations(savedPositions, splitNodes, splitWays); 92 93 splitWays.forEach(w -> { 85 @Test 86 public void test2() { 87 splitWay(r2).forEach(w -> { 94 88 if(w.firstNode().getUniqueId() == 2158181809L && w.lastNode().getUniqueId() == 2158181798L) 95 89 assertEquals(w.getReferrers().size(), 8); … … 103 97 fail(); 104 98 }); 105 99 } 106 100 107 @Test 108 public void test3() { 109 Map<Relation, Integer> savedPositions = action.getSavedPositions(r3); 110 List<Node> splitNodes = action.getSplitNodes(r3); 111 assertEquals(4, splitNodes.size()); 112 ds.setSelected(splitNodes); 113 swa.actionPerformed(null); 114 115 Collection<Way> splitWays = ds.getSelectedWays(); 116 action.updateRelations(savedPositions, splitNodes, splitWays); 117 118 splitWays.forEach(w -> { 101 @Test 102 public void test3() { 103 splitWay(r3).forEach(w -> { 119 104 if(w.firstNode().getUniqueId() == 280697532L && w.lastNode().getUniqueId() == 280697452L) 120 105 assertEquals(w.getReferrers().size(), 0); … … 128 113 fail(); 129 114 }); 130 }131 132 @After133 public void end() {134 Main.getLayerManager().removeLayer(layer);135 115 } 136 116 }
Note:
See TracChangeset
for help on using the changeset viewer.