Changeset 11986 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-04-23T19:14:12+02:00 (3 years ago)
Author:
Don-vip
Message:

add unit test for Main.postConstructorProcessCmdLine

File:
1 edited

Legend:

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

    r11925 r11986  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
    56import static org.junit.Assert.assertNotNull;
    67import static org.junit.Assert.assertNull;
     
    89
    910import java.util.Collection;
     11import java.util.List;
    1012
    1113import javax.swing.UIManager;
     
    1416import org.junit.Test;
    1517import org.openstreetmap.josm.Main.DownloadParamType;
     18import org.openstreetmap.josm.data.osm.DataSet;
     19import org.openstreetmap.josm.gui.ProgramArguments;
     20import org.openstreetmap.josm.gui.layer.GpxLayer;
    1621import org.openstreetmap.josm.testutils.JOSMTestRules;
    1722
     
    2833    @Rule
    2934    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().platform();
     35    public JOSMTestRules test = new JOSMTestRules().platform().devAPI();
    3136
    3237    /**
     
    8186        assertNotNull(Main.toolbar);
    8287    }
     88
     89    /**
     90     * Unit test of {@link Main#postConstructorProcessCmdLine} - empty case.
     91     */
     92    @Test
     93    public void testPostConstructorProcessCmdLineEmpty() {
     94        // Check the method accepts no arguments
     95        Main.postConstructorProcessCmdLine(new ProgramArguments(new String[0]));
     96    }
     97
     98    /**
     99     * Unit test of {@link Main#postConstructorProcessCmdLine} - nominal cases.
     100     * This test assumes the DEV API contains nodes around 0,0 and GPX tracks around London
     101     */
     102    @Test
     103    public void testPostConstructorProcessCmdLineNominal() {
     104        assertNull(Main.getLayerManager().getEditDataSet());
     105        Main.postConstructorProcessCmdLine(new ProgramArguments(new String[]{
     106                "--download=0.01,0.01,0.05,0.05",
     107                "--downloadgps=51.35,-0.4,51.60,0.2",
     108                "--selection=type: node"}));
     109        DataSet ds = Main.getLayerManager().getEditDataSet();
     110        assertNotNull(ds);
     111        assertFalse(ds.getSelected().isEmpty());
     112        Main.getLayerManager().removeLayer(Main.getLayerManager().getEditLayer());
     113        List<GpxLayer> gpxLayers = Main.getLayerManager().getLayersOfType(GpxLayer.class);
     114        assertEquals(1, gpxLayers.size());
     115        Main.getLayerManager().removeLayer(gpxLayers.iterator().next());
     116    }
     117
     118    /**
     119     * Unit test of {@link DownloadParamType} enum.
     120     */
     121    @Test
     122    public void testEnumDownloadParamType() {
     123        TestUtils.superficialEnumCodeCoverage(DownloadParamType.class);
     124    }
    83125}
Note: See TracChangeset for help on using the changeset viewer.