Changeset 10443 in josm for trunk/test/unit/org/openstreetmap/josm/actions
- Timestamp:
- 2016-06-20T23:57:32+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java
r10436 r10443 7 7 import static org.junit.Assert.assertTrue; 8 8 9 import org.junit. BeforeClass;9 import org.junit.Rule; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm.JOSMFixture;12 11 import org.openstreetmap.josm.Main; 13 12 import org.openstreetmap.josm.data.coor.EastNorth; … … 19 18 import org.openstreetmap.josm.gui.layer.Layer; 20 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 21 22 22 /** … … 28 28 * Setup test. 29 29 */ 30 @BeforeClass 31 public static void setUp() { 32 JOSMFixture.createUnitTestFixture().init(true); 33 } 30 @Rule 31 public JOSMTestRules rules = new JOSMTestRules().preferences().projection(); 34 32 35 33 /** … … 38 36 @Test 39 37 public void testNoDataSet() { 40 while (Main.main.hasEditLayer()) { 41 Main.getLayerManager().removeLayer(Main.getLayerManager().getEditLayer()); 42 } 43 assertNull(JosmAction.getCurrentDataSet()); 38 assertNull(Main.getLayerManager().getEditDataSet()); 44 39 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size()); 45 40 assertNull(SelectByInternalPointAction.getSmallestSurroundingObject(null)); … … 78 73 @Test 79 74 public void testGetSurroundingObjects() { 80 Layer layer = initDataSet(); 81 try { 82 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size()); 83 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(0, 0)).size()); 84 assertEquals(1, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(1.5, 1.5)).size()); 85 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(3, 3)).size()); 86 } finally { 87 // Ensure we clean the place before leaving, even if test fails. 88 Main.getLayerManager().removeLayer(layer); 89 } 75 initDataSet(); 76 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size()); 77 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(0, 0)).size()); 78 assertEquals(1, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(1.5, 1.5)).size()); 79 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(3, 3)).size()); 90 80 } 91 81 … … 95 85 @Test 96 86 public void testGetSmallestSurroundingObject() { 97 Layer layer = initDataSet(); 98 try { 99 assertNull(SelectByInternalPointAction.getSmallestSurroundingObject(null)); 100 assertNotNull(SelectByInternalPointAction.getSmallestSurroundingObject(new EastNorth(1.5, 1.5))); 101 } finally { 102 // Ensure we clean the place before leaving, even if test fails. 103 Main.getLayerManager().removeLayer(layer); 104 } 87 initDataSet(); 88 assertNull(SelectByInternalPointAction.getSmallestSurroundingObject(null)); 89 assertNotNull(SelectByInternalPointAction.getSmallestSurroundingObject(new EastNorth(1.5, 1.5))); 105 90 } 106 91 … … 110 95 @Test 111 96 public void testPerformSelection() { 112 Layer layer = initDataSet(); 113 try { 114 DataSet ds = JosmAction.getCurrentDataSet(); 97 initDataSet(); 98 DataSet ds = Main.getLayerManager().getEditDataSet(); 115 99 116 assertEquals(0, ds.getSelected().size()); 117 SelectByInternalPointAction.performSelection(null, false, false); 118 assertEquals(0, ds.getSelected().size()); 119 SelectByInternalPointAction.performSelection(new EastNorth(0, 0), false, false); 120 assertEquals(0, ds.getSelected().size()); 121 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, false); 122 assertEquals(1, ds.getSelected().size()); 123 ds.clearSelection(); 124 ds.addSelected(ds.getNodes()); 125 assertEquals(4, ds.getSelected().size()); 126 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), true, false); 127 assertEquals(5, ds.getSelected().size()); 128 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, true); 129 assertEquals(4, ds.getSelected().size()); 130 } finally { 131 // Ensure we clean the place before leaving, even if test fails. 132 Main.getLayerManager().removeLayer(layer); 133 } 100 assertEquals(0, ds.getSelected().size()); 101 SelectByInternalPointAction.performSelection(null, false, false); 102 assertEquals(0, ds.getSelected().size()); 103 SelectByInternalPointAction.performSelection(new EastNorth(0, 0), false, false); 104 assertEquals(0, ds.getSelected().size()); 105 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, false); 106 assertEquals(1, ds.getSelected().size()); 107 ds.clearSelection(); 108 ds.addSelected(ds.getNodes()); 109 assertEquals(4, ds.getSelected().size()); 110 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), true, false); 111 assertEquals(5, ds.getSelected().size()); 112 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, true); 113 assertEquals(4, ds.getSelected().size()); 134 114 } 135 115 }
Note:
See TracChangeset
for help on using the changeset viewer.