Ticket #18798: 18798.1.patch
| File 18798.1.patch, 4.6 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
70 70 import org.openstreetmap.josm.command.Command; 71 71 import org.openstreetmap.josm.command.SequenceCommand; 72 72 import org.openstreetmap.josm.data.UndoRedoHandler; 73 import org.openstreetmap.josm.data.coor.LatLon; 73 74 import org.openstreetmap.josm.data.osm.DataSet; 75 import org.openstreetmap.josm.data.osm.INode; 74 76 import org.openstreetmap.josm.data.osm.OsmDataManager; 75 77 import org.openstreetmap.josm.data.osm.OsmPrimitive; 76 78 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 692 694 final Iterator<OsmPrimitive> osmPrimitiveIterator = sel.iterator(); 693 695 final OsmPrimitive virtual = (osmPrimitiveIterator.hasNext() ? osmPrimitiveIterator.next().getType() : OsmPrimitiveType.NODE) 694 696 .newInstance(0, false); 697 if (virtual instanceof INode) 698 ((INode) virtual).setCoor(LatLon.ZERO); 695 699 virtual.put(key, value); 696 700 final ImageIcon padded = ImageProvider.getPadded(virtual, ImageProvider.ImageSizes.LARGEICON.getImageDimension(), 697 701 EnumSet.of(ImageProvider.GetPaddedOptions.NO_DEFAULT, ImageProvider.GetPaddedOptions.NO_DEPRECATED)); -
test/unit/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelperTest.java
36 36 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 37 37 import org.openstreetmap.josm.testutils.JOSMTestRules; 38 38 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 39 import org.openstreetmap.josm.tools.RightAndLefthandTraffic; 39 40 40 41 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 41 42 … … 49 50 */ 50 51 @Rule 51 52 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 52 public JOSMTestRules test = new JOSMTestRules() ;53 public JOSMTestRules test = new JOSMTestRules().territories().projection(); 53 54 54 55 private static TagEditHelper newTagEditHelper() { 55 56 DefaultTableModel propertyData = new DefaultTableModel(); … … 123 124 Object val = findIcon.invoke(addTagsDialog, "highway", ""); 124 125 assertNotNull(val); 125 126 } 127 128 /** 129 * Non-regression test for <a 130 * href="https://josm.openstreetmap.de/ticket/18798>#18798</a> 131 * 132 * @throws InvocationTargetException Check logs -- if caused by NPE, a 133 * regression probably occurred. 134 * @throws IllegalArgumentException Check source code 135 * @throws IllegalAccessException Check source code 136 * @throws NoSuchFieldException Check source code 137 * @throws SecurityException Probably shouldn't happen for tests 138 * @throws NoSuchMethodException Check source code 139 */ 140 @Test 141 public void testTicket18798() throws NoSuchMethodException, SecurityException, IllegalAccessException, 142 IllegalArgumentException, InvocationTargetException, NoSuchFieldException { 143 TestUtils.assumeWorkingJMockit(); 144 if (GraphicsEnvironment.isHeadless()) { 145 new WindowMocker(); 146 } 147 RightAndLefthandTraffic.initialize(); 148 MapCSSStyleSource css = new MapCSSStyleSource( 149 "node:righthandtraffic[junction=roundabout] { text: tr(\"Roundabout node\"); }"); 150 css.loadStyleSource(); 151 MapPaintStyles.addStyle(css); 152 Node node = new Node(LatLon.NORTH_POLE); 153 DataSet ds = new DataSet(node); 154 OsmDataManager.getInstance().setActiveDataSet(ds); 155 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, "Test Layer", null)); 156 TagEditHelper helper = newTagEditHelper(); 157 Field sel = TagEditHelper.class.getDeclaredField("sel"); 158 sel.set(helper, Collections.singletonList(node)); 159 AddTagsDialog addTagsDialog = helper.getAddTagsDialog(); 160 Method findIcon = TagEditHelper.AbstractTagsDialog.class.getDeclaredMethod("findIcon", String.class, 161 String.class); 162 findIcon.setAccessible(true); 163 Object val = findIcon.invoke(addTagsDialog, "junction", "roundabout"); 164 assertNotNull(val); 165 } 126 166 }
