Ignore:
Timestamp:
2017-08-03T19:57:36+02:00 (7 years ago)
Author:
Don-vip
Message:

speedup unit tests

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

Legend:

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

    r12557 r12562  
    3030    /**
    3131     * We need prefs for this. We need platform for actions and the OSM API for checking blacklist.
    32      * The timeout is set to default httpclient read timeout + connect timeout + a small delay to ignore
    33      * common but harmless network issues.
    3432     */
    3533    @Rule
    3634    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules test = new JOSMTestRules().preferences().platform().fakeAPI().timeout(45500);
     35    public JOSMTestRules test = new JOSMTestRules().preferences().platform().fakeAPI();
    3836
    3937    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java

    r12110 r12562  
    66
    77import org.junit.Before;
     8import org.junit.Rule;
    89import org.junit.Test;
    9 import org.openstreetmap.josm.JOSMFixture;
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.actions.AlignInLineAction.InvalidSelection;
     
    1717import org.openstreetmap.josm.data.osm.Way;
    1818import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     19import org.openstreetmap.josm.testutils.JOSMTestRules;
     20
     21import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1922
    2023/**
     
    2326public final class AlignInLineActionTest {
    2427
     28    /**
     29     * Setup test.
     30     */
     31    @Rule
     32    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     33    public JOSMTestRules test = new JOSMTestRules().mainMenu().projection();
     34
    2535    /** Class under test. */
    2636    private static AlignInLineAction action;
     
    3141    @Before
    3242    public void setUp() {
    33         JOSMFixture.createUnitTestFixture().init(true);
    34 
    3543        // Enable "Align in line" feature.
    3644        action = Main.main.menu.alignInLine;
     
    4351     * https://josm.openstreetmap.de/ticket/9605#comment:3. Note that in this test, after alignment, way is overlapping
    4452     * itself.
    45      */
    46     @Test
    47     public void testNodesOpenWay() {
     53     * @throws InvalidSelection never
     54     */
     55    @Test
     56    public void testNodesOpenWay() throws InvalidSelection {
    4857        DataSet dataSet = new DataSet();
    4958        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     
    6776            dataSet.addSelected(point1, point2, point3);
    6877
    69             action.actionPerformed(null);
     78            action.buildCommand().executeCommand();
    7079        } finally {
    7180            // Ensure we clean the place before leaving, even if test fails.
     
    8291     * Test case: only nodes selected, part of a closed way: align these nodes on the line passing through the most
    8392     * distant nodes.
    84      */
    85     @Test
    86     public void testNodesClosedWay() {
     93     * @throws InvalidSelection never
     94     */
     95    @Test
     96    public void testNodesClosedWay() throws InvalidSelection {
    8797        DataSet dataSet = new DataSet();
    8898        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     
    106116            dataSet.addSelected(point4, point1, point2);
    107117
    108             action.actionPerformed(null);
     118            action.buildCommand().executeCommand();
    109119        } finally {
    110120            // Ensure we clean the place before leaving, even if test fails.
     
    122132     * Test case: only nodes selected, part of multiple ways: align these nodes on the line passing through the most
    123133     * distant nodes.
    124      */
    125     @Test
    126     public void testNodesOpenWays() {
     134     * @throws InvalidSelection never
     135     */
     136    @Test
     137    public void testNodesOpenWays() throws InvalidSelection {
    127138        DataSet dataSet = new DataSet();
    128139        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     
    149160
    150161            // Points must align between points 1 and 4.
    151             action.actionPerformed(null);
     162            action.buildCommand().executeCommand();
    152163        } finally {
    153164            // Ensure we clean the place before leaving, even if test fails.
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java

    r12111 r12562  
    3838    @Rule
    3939    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().platform().projection().commands();
     40    public JOSMTestRules test = new JOSMTestRules().platform().projection().main();
    4141
    4242    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java

    r11278 r12562  
    1717    @Rule
    1818    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    19     public JOSMTestRules test = new JOSMTestRules().platform().commands();
     19    public JOSMTestRules test = new JOSMTestRules().platform().main();
    2020
    2121    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r12357 r12562  
    4747    @Rule
    4848    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    49     public JOSMTestRules test = new JOSMTestRules().commands();
     49    public JOSMTestRules test = new JOSMTestRules().platform().mainMenu().projection();
    5050
    5151    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java

    r11885 r12562  
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.data.osm.DataSet;
     12import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    1213import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;
    1314import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    2627    @Rule
    2728    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules().platform().commands();
     29    public JOSMTestRules test = new JOSMTestRules().platform().mainMenu();
    2930
    3031    private MergeLayerAction action;
     
    3536    @Before
    3637    public void setUp() {
     38        try {
     39            LayerListDialog.getInstance();
     40        } catch (IllegalStateException e) {
     41            LayerListDialog.createInstance(Main.getLayerManager());
     42            Main.trace(e);
     43        }
    3744        if (action == null) {
    3845            action = new MergeLayerAction();
  • trunk/test/unit/org/openstreetmap/josm/actions/MergeNodesActionTest.java

    r11110 r12562  
    2828    @Rule
    2929    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().platform().commands();
     30    public JOSMTestRules test = new JOSMTestRules().platform().projection();
    3131
    3232    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java

    r10966 r12562  
    3232    @Rule
    3333    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().platform().commands();
     34    public JOSMTestRules test = new JOSMTestRules().platform().main();
    3535
    3636    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java

    r11121 r12562  
    1010import java.util.stream.Stream;
    1111
    12 import org.junit.BeforeClass;
     12import org.junit.Before;
     13import org.junit.Rule;
    1314import org.junit.Test;
    14 import org.openstreetmap.josm.JOSMFixture;
    1515import org.openstreetmap.josm.Main;
    1616import org.openstreetmap.josm.command.DeleteCommand;
     
    2121import org.openstreetmap.josm.data.osm.Way;
    2222import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     23import org.openstreetmap.josm.testutils.JOSMTestRules;
    2324import org.openstreetmap.josm.tools.Utils;
     25
     26import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2427
    2528/**
     
    3437     * Setup test.
    3538     */
    36     @BeforeClass
    37     public static void setUp() {
    38         JOSMFixture.createUnitTestFixture().init(true);
    39         action = Main.main.menu.simplifyWay;
    40         action.setEnabled(true);
     39    @Rule
     40    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     41    public JOSMTestRules test = new JOSMTestRules().mainMenu();
     42
     43    /**
     44     * Setup test.
     45     */
     46    @Before
     47    public void setUp() {
     48        if (action == null) {
     49            action = Main.main.menu.simplifyWay;
     50            action.setEnabled(true);
     51        }
    4152    }
    4253
  • trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java

    r10599 r12562  
    1111import java.util.Iterator;
    1212
    13 import org.junit.BeforeClass;
     13import org.junit.Before;
     14import org.junit.Rule;
    1415import org.junit.Test;
    15 import org.openstreetmap.josm.JOSMFixture;
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.actions.SplitWayAction.Strategy;
     
    2525import org.openstreetmap.josm.data.osm.Way;
    2626import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     27import org.openstreetmap.josm.testutils.JOSMTestRules;
     28
     29import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2730
    2831/**
     
    3740     * Setup test.
    3841     */
    39     @BeforeClass
    40     public static void setUp() {
    41         JOSMFixture.createUnitTestFixture().init(true);
    42         action = Main.main.menu.splitWay;
    43         action.setEnabled(true);
     42    @Rule
     43    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     44    public JOSMTestRules test = new JOSMTestRules().mainMenu().projection();
     45
     46    /**
     47     * Setup test.
     48     */
     49    @Before
     50    public void setUp() {
     51        if (action == null) {
     52            action = Main.main.menu.splitWay;
     53            action.setEnabled(true);
     54        }
    4455    }
    4556
  • trunk/test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java

    r10436 r12562  
    55import static org.junit.Assert.assertTrue;
    66
    7 import org.junit.BeforeClass;
     7import org.junit.Before;
     8import org.junit.Rule;
    89import org.junit.Test;
    9 import org.openstreetmap.josm.JOSMFixture;
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.data.coor.LatLon;
     
    1414import org.openstreetmap.josm.data.osm.Way;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     16import org.openstreetmap.josm.testutils.JOSMTestRules;
     17
     18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1619
    1720/**
     
    2629     * Setup test.
    2730     */
    28     @BeforeClass
    29     public static void setUp() {
    30         JOSMFixture.createUnitTestFixture().init(true);
    31         action = Main.main.menu.unglueNodes;
    32         action.setEnabled(true);
     31    @Rule
     32    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     33    public JOSMTestRules test = new JOSMTestRules().mainMenu();
     34
     35    /**
     36     * Setup test.
     37     */
     38    @Before
     39    public void setUp() {
     40        if (action == null) {
     41            action = Main.main.menu.unglueNodes;
     42            action.setEnabled(true);
     43        }
    3344    }
    3445
Note: See TracChangeset for help on using the changeset viewer.