Changeset 15921 in josm


Ignore:
Timestamp:
2020-02-24T21:04:37+01:00 (3 months ago)
Author:
simon04
Message:

see #18764, see #14088 - Add non-regression test (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelperTest.java

    r12859 r15921  
    44import static org.junit.Assert.assertEquals;
    55import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertNotNull;
    67
     8import java.lang.reflect.Field;
     9import java.lang.reflect.InvocationTargetException;
     10import java.lang.reflect.Method;
    711import java.util.ArrayList;
    812import java.util.Arrays;
     13import java.util.Collections;
    914import java.util.HashMap;
    1015import java.util.List;
     
    1722import org.junit.Rule;
    1823import org.junit.Test;
     24import org.openstreetmap.josm.TestUtils;
     25import org.openstreetmap.josm.data.coor.LatLon;
     26import org.openstreetmap.josm.data.osm.DataSet;
     27import org.openstreetmap.josm.data.osm.Node;
     28import org.openstreetmap.josm.data.osm.OsmDataManager;
     29import org.openstreetmap.josm.data.osm.Way;
    1930import org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem;
     31import org.openstreetmap.josm.gui.MainApplication;
     32import org.openstreetmap.josm.gui.dialogs.properties.TagEditHelper.AddTagsDialog;
     33import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     34import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     35import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2036import org.openstreetmap.josm.testutils.JOSMTestRules;
    2137
     
    6682        // TODO: complete test
    6783    }
     84
     85    /**
     86     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18764>#18764</a>
     87     *
     88     * @throws InvocationTargetException Check logs -- if caused by NPE, a
     89     *                                   regression probably occurred.
     90     * @throws IllegalArgumentException  Check source code
     91     * @throws IllegalAccessException    Check source code
     92     * @throws NoSuchFieldException      Check source code
     93     * @throws SecurityException         Probably shouldn't happen for tests
     94     * @throws NoSuchMethodException     Check source code
     95     */
     96    @Test
     97    public void testTicket18764() throws NoSuchMethodException, SecurityException, IllegalAccessException,
     98            IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
     99        MapCSSStyleSource css = new MapCSSStyleSource(
     100                "*[building] ⧉ *[highway] { text: tr(\"Building crossing highway\"); }");
     101        css.loadStyleSource();
     102        MapPaintStyles.addStyle(css);
     103        DataSet ds = new DataSet();
     104        // This does require a way
     105        Way way = TestUtils.newWay("", new Node(LatLon.NORTH_POLE), new Node(LatLon.SOUTH_POLE));
     106        way.getNodes().forEach(ds::addPrimitive);
     107        ds.addPrimitive(way);
     108        OsmDataManager.getInstance().setActiveDataSet(ds);
     109        MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, "Test Layer", null));
     110        TagEditHelper helper = newTagEditHelper();
     111        Field sel = TagEditHelper.class.getDeclaredField("sel");
     112        sel.set(helper, Collections.singletonList(way));
     113        AddTagsDialog addTagsDialog = helper.getAddTagsDialog();
     114        Method findIcon = TagEditHelper.AbstractTagsDialog.class.getDeclaredMethod("findIcon", String.class,
     115                String.class);
     116        findIcon.setAccessible(true);
     117        Object val = findIcon.invoke(addTagsDialog, "highway", "");
     118        assertNotNull(val);
     119    }
    68120}
Note: See TracChangeset for help on using the changeset viewer.