Changeset 19657 in josm for trunk/test
- Timestamp:
- 2026-10-23T16:00:18+02:00 (5 days ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 2 edited
-
gui/tagging/presets/items/ComboTest.java (modified) (3 diffs)
-
tools/ImageResizeModeTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
r18918 r19657 7 7 import java.awt.Color; 8 8 9 import javax.swing.JLabel; 10 import javax.swing.JList; 9 11 import javax.swing.JPanel; 10 12 … … 17 19 import org.openstreetmap.josm.testutils.annotations.I18n; 18 20 import org.openstreetmap.josm.testutils.annotations.Main; 21 import org.openstreetmap.josm.tools.ImageProvider.ImageSizes; 19 22 20 23 /** … … 124 127 } 125 128 129 /** 130 * Entry icons are centered in a square and entries without an icon get a blank one, so that the texts line up. 131 */ 132 @Test 133 void testIconAlignment() { 134 final Combo combo = getInstance(); 135 combo.key = "highway"; 136 PresetListEntry trunk = new PresetListEntry("trunk", combo); 137 trunk.icon = "presets/transport/way/way_trunk.svg"; 138 combo.addListEntry(trunk); 139 combo.addListEntry(new PresetListEntry("busway", combo)); 140 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false)); 141 JList<PresetListEntry> list = new JList<>(); 142 for (PresetListEntry entry : combo.presetListEntries) { 143 JLabel label = (JLabel) combo.combobox.getRenderer().getListCellRendererComponent(list, entry, 0, false, false); 144 assertEquals(ImageSizes.SMALLICON.getAdjustedWidth(), label.getIcon().getIconWidth(), entry.value); 145 assertEquals(ImageSizes.SMALLICON.getAdjustedHeight(), label.getIcon().getIconHeight(), entry.value); 146 } 147 } 148 126 149 @Test 127 150 void testColor() { -
trunk/test/unit/org/openstreetmap/josm/tools/ImageResizeModeTest.java
r19519 r19657 7 7 8 8 import java.awt.Dimension; 9 import java.awt.image.BufferedImage; 9 10 10 11 import org.junit.jupiter.api.Test; … … 69 70 70 71 /** 72 * Test method for {@link ImageResizeMode#createBufferedImage} using {@link ImageResizeMode#PADDED} on a raster image 73 */ 74 @Test 75 void testCreateBufferedImagePaddedRaster() { 76 BufferedImage source = new BufferedImage(16, 4, BufferedImage.TYPE_INT_RGB); // opaque black 77 BufferedImage padded = ImageResizeMode.PADDED.createBufferedImage(new Dimension(32, 32), new Dimension(16, 4), null, source); 78 assertEquals(32, padded.getWidth()); 79 assertEquals(32, padded.getHeight()); 80 // aspect ratio is kept: a 32x8 bar centered vertically 81 assertEquals(0, padded.getRGB(16, 11) >>> 24); 82 assertEquals(0xff, padded.getRGB(16, 12) >>> 24); 83 assertEquals(0xff, padded.getRGB(16, 19) >>> 24); 84 assertEquals(0, padded.getRGB(16, 20) >>> 24); 85 } 86 87 /** 71 88 * Test method for {@link ImageResizeMode#cacheKey} 72 89 */
Note:
See TracChangeset
for help on using the changeset viewer.
