Changeset 15141 in josm for trunk/test


Ignore:
Timestamp:
2019-05-30T10:01:42+02:00 (5 years ago)
Author:
GerdP
Message:

see #17767 and #17768: add non regression unit tests
Test testTicket17768() fails with current code and is ignored for now.

Location:
trunk/test
Files:
4 added
1 edited

Legend:

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

    r15034 r15141  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertTrue;
    57
    68import java.nio.file.Files;
     
    1012import java.util.TreeMap;
    1113
     14import org.junit.Ignore;
    1215import org.junit.Rule;
    1316import org.junit.Test;
     
    1518import org.openstreetmap.josm.command.SequenceCommand;
    1619import org.openstreetmap.josm.data.osm.DataSet;
     20import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1721import org.openstreetmap.josm.data.osm.Relation;
    1822import org.openstreetmap.josm.data.osm.RelationMember;
     
    2125import org.openstreetmap.josm.data.osm.search.SearchParseError;
    2226import org.openstreetmap.josm.data.osm.search.SearchSetting;
     27import org.openstreetmap.josm.gui.MainApplication;
     28import org.openstreetmap.josm.gui.layer.Layer;
     29import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2330import org.openstreetmap.josm.io.OsmReader;
    2431import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    3845    @Rule
    3946    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().projection();
     47    public JOSMTestRules test = new JOSMTestRules().projection().main().preferences();
    4148
    4249    private static Map<String, String> getRefToRoleMap(Relation relation) {
     
    107114        assertEquals("{1=outer, 1.1=inner, 1.1.1=outer, 1.1.2=outer, 1.2=inner}", getRefToRoleMap(mp2).toString());
    108115    }
     116
     117    /**
     118     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17767">Bug #17767</a>.
     119     * @throws Exception if an error occurs
     120     */
     121    @Test
     122    public void testTicket17767() throws Exception {
     123        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(17767, "upd-mp.osm"), null);
     124        Layer layer = new OsmDataLayer(ds, null, null);
     125        MainApplication.getLayerManager().addLayer(layer);
     126        try {
     127            CreateMultipolygonAction updateAction = new CreateMultipolygonAction(true);
     128            CreateMultipolygonAction createAction = new CreateMultipolygonAction(false);
     129            assertFalse(updateAction.isEnabled());
     130            assertFalse(createAction.isEnabled());
     131            ds.setSelected(ds.getPrimitiveById(189944949L, OsmPrimitiveType.WAY));
     132            assertFalse(updateAction.isEnabled());
     133            assertTrue(createAction.isEnabled());
     134        } finally {
     135            MainApplication.getLayerManager().removeLayer(layer);
     136        }
     137    }
     138
     139    /**
     140     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17768">Bug #17768</a>.
     141     * @throws Exception if an error occurs
     142     */
     143    @Test
     144    @Ignore
     145    public void testTicket17768() throws Exception {
     146        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(17768, "dupmem.osm"), null);
     147        Layer layer = new OsmDataLayer(ds, null, null);
     148        MainApplication.getLayerManager().addLayer(layer);
     149        try {
     150            Relation old = (Relation) ds.getPrimitiveById(580092, OsmPrimitiveType.RELATION);
     151            assertEquals(3, old.getMembersCount());
     152            Relation mp = createMultipolygon(ds.getWays(), "type:way", old, true);
     153            assertEquals(mp.getPrimitiveId(), old.getPrimitiveId());
     154            assertEquals(2, mp.getMembersCount());
     155        } finally {
     156            MainApplication.getLayerManager().removeLayer(layer);
     157        }
     158
     159    }
    109160}
Note: See TracChangeset for help on using the changeset viewer.