Changeset 13108 in josm for trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java
- Timestamp:
- 2017-11-10T22:37:58+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java
r12643 r13108 4 4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertNull; 6 7 7 8 import org.junit.Before; … … 16 17 import org.openstreetmap.josm.data.osm.Way; 17 18 import org.openstreetmap.josm.gui.MainApplication; 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer;19 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 20 … … 56 56 public void testNodesOpenWay() throws InvalidSelection { 57 57 DataSet dataSet = new DataSet(); 58 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);59 58 60 59 // Create test points, lower left is (0,0). … … 67 66 Node point3 = new Node(new EastNorth(1, 1)); 68 67 69 try { 70 MainApplication.getLayerManager().addLayer(layer); 71 72 // Create an open way. 73 createWay(dataSet, point1, point2, point3); 74 75 // Select nodes to align. 76 dataSet.addSelected(point1, point2, point3); 77 78 action.buildCommand().executeCommand(); 79 } finally { 80 // Ensure we clean the place before leaving, even if test fails. 81 MainApplication.getLayerManager().removeLayer(layer); 82 } 68 // Create an open way. 69 createWay(dataSet, point1, point2, point3); 70 71 // Select nodes to align. 72 dataSet.addSelected(point1, point2, point3); 73 74 action.buildCommand(dataSet).executeCommand(); 83 75 84 76 // Points 1 and 3 are the extremities and must not have moved. Only point 2 must have moved. … … 96 88 public void testNodesClosedWay() throws InvalidSelection { 97 89 DataSet dataSet = new DataSet(); 98 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);99 90 100 91 // Create test points, lower left is (0,0). … … 108 99 Node point4 = new Node(new EastNorth(0, 2)); 109 100 110 try { 111 MainApplication.getLayerManager().addLayer(layer); 112 113 // Create a closed way. 114 createWay(dataSet, point1, point2, point3, point4, point1); 115 // Select nodes to align (point1 must be in the second position to exhibit the bug). 116 dataSet.addSelected(point4, point1, point2); 117 118 action.buildCommand().executeCommand(); 119 } finally { 120 // Ensure we clean the place before leaving, even if test fails. 121 MainApplication.getLayerManager().removeLayer(layer); 122 } 101 // Create a closed way. 102 createWay(dataSet, point1, point2, point3, point4, point1); 103 // Select nodes to align (point1 must be in the second position to exhibit the bug). 104 dataSet.addSelected(point4, point1, point2); 105 106 action.buildCommand(dataSet).executeCommand(); 123 107 124 108 // Only point 1 must have moved. … … 137 121 public void testNodesOpenWays() throws InvalidSelection { 138 122 DataSet dataSet = new DataSet(); 139 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);140 123 141 124 // Create test points, lower left is (0,0). … … 149 132 Node point4 = new Node(new EastNorth(2, 0)); 150 133 151 try { 152 MainApplication.getLayerManager().addLayer(layer); 153 154 // Create 2 ways. 155 createWay(dataSet, point1, point2); 156 createWay(dataSet, point3, point4); 157 158 // Select nodes to align. 159 dataSet.addSelected(point1, point2, point3, point4); 160 161 // Points must align between points 1 and 4. 162 action.buildCommand().executeCommand(); 163 } finally { 164 // Ensure we clean the place before leaving, even if test fails. 165 MainApplication.getLayerManager().removeLayer(layer); 166 } 134 // Create 2 ways. 135 createWay(dataSet, point1, point2); 136 createWay(dataSet, point3, point4); 137 138 // Select nodes to align. 139 dataSet.addSelected(point1, point2, point3, point4); 140 141 // Points must align between points 1 and 4. 142 action.buildCommand(dataSet).executeCommand(); 167 143 168 144 assertCoordEq(point1, 0, 2); … … 173 149 174 150 /** 151 * Test case: only a two-nodes way selected. 152 * @throws InvalidSelection never 153 */ 154 @Test 155 public void testSimpleWay() throws InvalidSelection { 156 DataSet dataSet = new DataSet(); 157 158 // Create test points, lower left is (0,0). 159 // 160 // 1 - - 161 // - - 2 162 Node point1 = new Node(new EastNorth(0, 2)); 163 Node point2 = new Node(new EastNorth(2, 1)); 164 165 // Creates and select a single way. 166 dataSet.addSelected(createWay(dataSet, point1, point2)); 167 168 // No command must be created (nothing to do) 169 assertNull(action.buildCommand(dataSet)); 170 } 171 172 /** 175 173 * Create a way made of the provided nodes and select nodes. 176 174 * 177 175 * @param dataSet Dataset in which adding nodes. 178 176 * @param nodes List of nodes to add to dataset. 179 */ 180 private void createWay(DataSet dataSet, Node... nodes) { 177 * @return created way 178 */ 179 private Way createWay(DataSet dataSet, Node... nodes) { 181 180 Way way = new Way(); 182 181 dataSet.addPrimitive(way); … … 189 188 way.addNode(node); 190 189 } 190 return way; 191 191 } 192 192
Note:
See TracChangeset
for help on using the changeset viewer.