Ticket #18764: 18764.1.patch
File 18764.1.patch, 4.6 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
439 439 if (right instanceof OptimizedGeneralSelector 440 440 && ((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) { 441 441 final CrossingFinder crossingFinder = new CrossingFinder(e); 442 crossingFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox())); 442 if (e.osm.getDataSet() != null) 443 crossingFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox())); 443 444 } 444 445 return e.children != null; 445 446 } else if (ChildOrParentSelectorType.SIBLING == type) { -
test/unit/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelperTest.java
3 3 4 4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertNotNull; 6 7 8 import java.lang.reflect.Field; 9 import java.lang.reflect.InvocationTargetException; 10 import java.lang.reflect.Method; 7 11 import java.util.ArrayList; 8 12 import java.util.Arrays; 13 import java.util.Collections; 9 14 import java.util.HashMap; 10 15 import java.util.List; 11 16 import java.util.Map; … … 16 21 17 22 import org.junit.Rule; 18 23 import org.junit.Test; 24 import org.openstreetmap.josm.TestUtils; 25 import org.openstreetmap.josm.data.coor.LatLon; 26 import org.openstreetmap.josm.data.osm.DataSet; 27 import org.openstreetmap.josm.data.osm.Node; 28 import org.openstreetmap.josm.data.osm.OsmDataManager; 29 import org.openstreetmap.josm.data.osm.Way; 19 30 import org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem; 31 import org.openstreetmap.josm.gui.MainApplication; 32 import org.openstreetmap.josm.gui.dialogs.properties.TagEditHelper.AddTagsDialog; 33 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 34 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 35 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 20 36 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 37 22 38 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 65 81 assertFalse(newTagEditHelper().containsDataKey("foo")); 66 82 // TODO: complete test 67 83 } 84 85 /** 86 * Non-regression test for <a 87 * href="https://josm.openstreetmap.de/ticket/18764>#18764</a> 88 * 89 * @throws InvocationTargetException Check logs -- if caused by NPE, a 90 * regression probably occurred. 91 * @throws IllegalArgumentException Check source code 92 * @throws IllegalAccessException Check source code 93 * @throws NoSuchFieldException Check source code 94 * @throws SecurityException Probably shouldn't happen for tests 95 * @throws NoSuchMethodException Check source code 96 */ 97 @Test 98 public void testTicket18764() throws NoSuchMethodException, SecurityException, IllegalAccessException, 99 IllegalArgumentException, InvocationTargetException, NoSuchFieldException { 100 MapCSSStyleSource css = new MapCSSStyleSource( 101 "*[building] ⧉ *[highway] { text: tr(\"Building crossing highway\"); }"); 102 css.loadStyleSource(); 103 MapPaintStyles.addStyle(css); 104 DataSet ds = new DataSet(); 105 // This does require a way 106 Way way = TestUtils.newWay("", new Node(LatLon.NORTH_POLE), new Node(LatLon.SOUTH_POLE)); 107 way.getNodes().forEach(ds::addPrimitive); 108 ds.addPrimitive(way); 109 OsmDataManager.getInstance().setActiveDataSet(ds); 110 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, "Test Layer", null)); 111 TagEditHelper helper = newTagEditHelper(); 112 Field sel = TagEditHelper.class.getDeclaredField("sel"); 113 sel.set(helper, Collections.singletonList(way)); 114 AddTagsDialog addTagsDialog = helper.getAddTagsDialog(); 115 Method findIcon = TagEditHelper.AbstractTagsDialog.class.getDeclaredMethod("findIcon", String.class, 116 String.class); 117 findIcon.setAccessible(true); 118 Object val = findIcon.invoke(addTagsDialog, "highway", ""); 119 assertNotNull(val); 120 } 68 121 }