Changeset 14542 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2018-12-09T23:58:32+01:00 (6 years ago)
Author:
Don-vip
Message:

see #17040 - fix unit tests

Location:
trunk/test/unit/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java

    r14138 r14542  
    1717import org.openstreetmap.josm.data.osm.Node;
    1818import org.openstreetmap.josm.data.osm.Way;
    19 import org.openstreetmap.josm.gui.MainApplication;
    20 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2119import org.openstreetmap.josm.testutils.JOSMTestRules;
    2220import org.openstreetmap.josm.tools.GeoProperty;
     
    3836    @Rule
    3937    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().projection().main();
     38    public JOSMTestRules test = new JOSMTestRules().projection();
    4139
    4240    /**
     
    4947    public void testTicket7421case0() throws ReflectiveOperationException {
    5048        DataSet dataSet = new DataSet();
    51         OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
    5249
    5350        Node n1 = new Node(new EastNorth(0, 0));
     
    6461        dataSet.addSelected(w);
    6562
    66         CreateCircleAction action = new CreateCircleAction();
    67         action.setEnabled(true);
    68         try {
    69             MainApplication.getLayerManager().addLayer(layer);
    70             action.actionPerformed(null);
    71         } finally {
    72             // Ensure we clean the place before leaving, even if test fails.
    73             MainApplication.getLayerManager().removeLayer(layer);
    74         }
     63        CreateCircleAction.runOn(dataSet);
    7564
    7665        // Expected result: Dataset contain one closed way, clockwise
     
    115104    public void testTicket7421case1() throws ReflectiveOperationException {
    116105        DataSet dataSet = new DataSet();
    117         OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
    118106
    119107        Node n1 = new Node(new EastNorth(0, 0));
     
    135123
    136124        try {
    137             CreateCircleAction action = new CreateCircleAction();
    138             action.setEnabled(true);
    139             try {
    140                 MainApplication.getLayerManager().addLayer(layer);
    141                 action.actionPerformed(null);
    142             } finally {
    143                 // Ensure we clean the place before leaving, even if test fails.
    144                 MainApplication.getLayerManager().removeLayer(layer);
    145             }
     125            CreateCircleAction.runOn(dataSet);
    146126
    147127            // Expected result: Dataset contain one closed way, clockwise
  • trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java

    r12828 r14542  
    77import java.util.Arrays;
    88
    9 import org.junit.Before;
    109import org.junit.Rule;
    1110import org.junit.Test;
     
    1413import org.openstreetmap.josm.data.osm.Node;
    1514import org.openstreetmap.josm.data.osm.Way;
    16 import org.openstreetmap.josm.gui.MainApplication;
    17 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1815import org.openstreetmap.josm.testutils.JOSMTestRules;
    1916
     
    2522public final class SplitWayActionTest {
    2623
    27     /** Class under test. */
    28     private static SplitWayAction action;
    29 
    3024    /**
    3125     * Setup test.
     
    3327    @Rule
    3428    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().main().projection();
    36 
    37     /**
    38      * Setup test.
    39      */
    40     @Before
    41     public void setUp() {
    42         if (action == null) {
    43             action = MainApplication.getMenu().splitWay;
    44             action.setEnabled(true);
    45         }
    46     }
     29    public JOSMTestRules test = new JOSMTestRules().projection();
    4730
    4831    /**
     
    5336    public void testTicket11184() {
    5437        DataSet dataSet = new DataSet();
    55         OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
    5638
    5739        Node n1 = new Node(new EastNorth(0, 0));
     
    8163        dataSet.addSelected(w2);
    8264
    83         try {
    84             MainApplication.getLayerManager().addLayer(layer);
    85             action.actionPerformed(null);
    86         } finally {
    87             // Ensure we clean the place before leaving, even if test fails.
    88             MainApplication.getLayerManager().removeLayer(layer);
    89         }
     65        SplitWayAction.runOn(dataSet);
    9066
    9167        // Ensures 3 ways.
Note: See TracChangeset for help on using the changeset viewer.