Changeset 11275 in josm for trunk/test/unit
- Timestamp:
- 2016-11-17T22:32:04+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r11267 r11275 5 5 import static org.junit.Assert.assertTrue; 6 6 7 import java.awt.geom.Area;8 7 import java.lang.reflect.Field; 9 8 import java.lang.reflect.Method; 10 import java.util.ArrayList;11 9 import java.util.Arrays; 12 10 import java.util.Collection; … … 43 41 @Rule 44 42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 45 public JOSMTestRules test = new JOSMTestRules().platform() ;43 public JOSMTestRules test = new JOSMTestRules().platform().projection().commands(); 46 44 47 45 /** … … 152 150 153 151 // Mock left/right hand traffic database 154 Field leftHandTrafficPolygons = RightAndLefthandTraffic.class155 .getDeclaredField("leftHandTrafficPolygons");156 152 Field rlCache = RightAndLefthandTraffic.class.getDeclaredField("rlCache"); 157 Utils.setObjectsAccessible( leftHandTrafficPolygons,rlCache);158 leftHandTrafficPolygons.set(null, new ArrayList<Area>());153 Utils.setObjectsAccessible(rlCache); 154 Object origRlCache = rlCache.get(null); 159 155 rlCache.set(null, new GeoPropertyIndex<>(new ConstantTrafficHand(true), 24)); 160 156 161 CreateCircleAction action = new CreateCircleAction();162 action.setEnabled(true);163 157 try { 164 Main.getLayerManager().addLayer(layer); 165 action.actionPerformed(null); 158 CreateCircleAction action = new CreateCircleAction(); 159 action.setEnabled(true); 160 try { 161 Main.getLayerManager().addLayer(layer); 162 action.actionPerformed(null); 163 } finally { 164 // Ensure we clean the place before leaving, even if test fails. 165 Main.getLayerManager().removeLayer(layer); 166 } 167 168 // Expected result: Dataset contain one closed way, clockwise 169 Collection<Way> resultingWays = dataSet.getWays(); 170 assertSame(String.format("Expect one way after perform action. %d found", resultingWays.size()), 171 resultingWays.size(), 1); 172 Way resultingWay = resultingWays.iterator().next(); 173 assertTrue("Resulting way is not closed", 174 resultingWay.isClosed()); 175 assertTrue("Found anti-clockwise way while traffic is left hand.", 176 Geometry.isClockwise(resultingWay)); 166 177 } finally { 167 // Ensure we clean the place before leaving, even if test fails.168 Main.getLayerManager().removeLayer(layer);178 // Restore left/right hand traffic database 179 rlCache.set(null, origRlCache); 169 180 } 170 171 // Expected result: Dataset contain one closed way, clockwise172 Collection<Way> resultingWays = dataSet.getWays();173 assertSame(String.format("Expect one way after perform action. %d found", resultingWays.size()),174 resultingWays.size(), 1);175 Way resultingWay = resultingWays.iterator().next();176 assertTrue("Resulting way is not closed",177 resultingWay.isClosed());178 assertTrue("Found anti-clockwise way while traffic is left hand.",179 Geometry.isClockwise(resultingWay));180 181 } 181 182 }
Note:
See TracChangeset
for help on using the changeset viewer.