Changeset 18254 in josm for trunk/test/unit
- Timestamp:
- 2021-10-06T13:24:19+02:00 (3 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
r17609 r18254 9 9 import javax.swing.JPanel; 10 10 11 import org.junit.jupiter.api.Test; 11 12 import org.junit.jupiter.api.extension.RegisterExtension; 12 import org.junit.jupiter.api.Test;13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 14 import org.openstreetmap.josm.data.osm.OsmUtils; … … 42 42 43 43 /** 44 * Unit test for {@link ComboMultiSelect#use_last_as_default} and {@link ComboMultiSelect#getI temToSelect}44 * Unit test for {@link ComboMultiSelect#use_last_as_default} and {@link ComboMultiSelect#getInitialValue} 45 45 */ 46 46 @Test … … 48 48 Combo combo = new Combo(); 49 49 combo.key = "addr:country"; 50 combo.use_last_as_default = 1;51 50 combo.values_from = "java.util.Locale#getISOCountries"; 52 51 OsmPrimitive way = OsmUtils.createPrimitive("way"); 52 OsmPrimitive wayTagged = OsmUtils.createPrimitive("way highway=residential"); 53 53 OsmPrimitive wayAT = OsmUtils.createPrimitive("way addr:country=AT"); 54 54 OsmPrimitive waySI = OsmUtils.createPrimitive("way addr:country=SI"); 55 KeyedItem.LAST_VALUES.clear(); 56 KeyedItem.LAST_VALUES.put("addr:country", "AT"); 55 57 58 combo.use_last_as_default = 0; 56 59 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, way)); 57 assertEquals("", combo.getSelectedValue()); 60 assertEquals("", combo.getSelectedItem().value); 61 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayTagged)); 62 assertEquals("", combo.getSelectedItem().value); 63 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT)); 64 assertEquals("AT", combo.getSelectedItem().value); 65 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, waySI)); 66 assertEquals("SI", combo.getSelectedItem().value); 67 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT, waySI)); 68 assertEquals(Combo.DIFFERENT, combo.getSelectedItem().value); 58 69 59 combo.default_ = " SI";70 combo.default_ = "AT"; 60 71 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, way)); 61 assertEquals("SI", combo.getSelectedValue()); 72 assertEquals("AT", combo.getSelectedItem().value); 73 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayTagged)); 74 assertEquals("", combo.getSelectedItem().value); 62 75 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT)); 63 assertEquals("AT", combo.getSelectedValue()); 76 assertEquals("AT", combo.getSelectedItem().value); 77 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, waySI)); 78 assertEquals("SI", combo.getSelectedItem().value); 79 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT, waySI)); 80 assertEquals(Combo.DIFFERENT, combo.getSelectedItem().value); 64 81 combo.default_ = null; 65 82 83 combo.use_last_as_default = 1; // untagged objects only 84 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, way)); 85 assertEquals("AT", combo.getSelectedItem().value); 86 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayTagged)); 87 assertEquals("", combo.getSelectedItem().value); 88 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT)); 89 assertEquals("AT", combo.getSelectedItem().value); 90 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, waySI)); 91 assertEquals("SI", combo.getSelectedItem().value); 92 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT, waySI)); 93 assertEquals(Combo.DIFFERENT, combo.getSelectedItem().value); 94 95 combo.use_last_as_default = 2; // "force" on tagged objects too 96 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, way)); 97 assertEquals("AT", combo.getSelectedItem().value); 98 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayTagged)); 99 assertEquals("AT", combo.getSelectedItem().value); 100 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT)); 101 assertEquals("AT", combo.getSelectedItem().value); 102 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, waySI)); 103 assertEquals("SI", combo.getSelectedItem().value); 104 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, wayAT, waySI)); 105 assertEquals(Combo.DIFFERENT, combo.getSelectedItem().value); 106 66 107 KeyedItem.LAST_VALUES.clear(); 67 KeyedItem.LAST_VALUES.put("addr:country", "AT");68 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(false, way));69 assertEquals("AT", combo.getSelectedValue());70 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(true, wayAT));71 assertEquals("AT", combo.getSelectedValue());72 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(true));73 assertEquals("", combo.getSelectedValue());74 combo.use_last_as_default = 2; // "force"75 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(true));76 assertEquals("AT", combo.getSelectedValue());77 KeyedItem.LAST_VALUES.clear();78 79 combo.addToPanel(new JPanel(), TaggingPresetItemGuiSupport.create(true, wayAT, waySI));80 assertEquals(Combo.DIFFERENT, combo.getSelectedValue());81 108 } 82 109 … … 91 118 assertEquals(5, combo.combobox.getItemCount()); 92 119 combo.presetListEntries.stream().filter(e -> "red".equals(e.value)).findFirst().ifPresent(combo.combobox::setSelectedItem); 93 assertEquals("red", combo.getSelected Value());120 assertEquals("red", combo.getSelectedItem().value); 94 121 assertEquals("Rot", combo.getSelectedItem().toString()); 95 122 assertEquals(new Color(0xFF0000), combo.getColor()); 96 123 combo.presetListEntries.stream().filter(e -> "green".equals(e.value)).findFirst().ifPresent(combo.combobox::setSelectedItem); 97 assertEquals("green", combo.getSelected Value());124 assertEquals("green", combo.getSelectedItem().value); 98 125 assertEquals("Grün", combo.getSelectedItem().toString()); 99 126 assertEquals(new Color(0x008000), combo.getColor()); 100 127 combo.combobox.setSelectedItem("#135"); 101 assertEquals("#135", combo.getSelected Value());128 assertEquals("#135", combo.getSelectedItem().value); 102 129 assertEquals(new Color(0x113355), combo.getColor()); 103 130 combo.combobox.setSelectedItem("#123456"); 104 assertEquals("#123456", combo.getSelected Value());131 assertEquals("#123456", combo.getSelectedItem().value); 105 132 assertEquals(new Color(0x123456), combo.getColor()); 106 133 combo.setColor(new Color(0x448822)); 107 assertEquals("#448822", combo.getSelected Value());134 assertEquals("#448822", combo.getSelectedItem().value); 108 135 } 109 136 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntryTest.java
r18221 r18254 26 26 @Test 27 27 void testTicket12416() { 28 assertTrue(new PresetListEntry("" ).getListDisplay(200).contains(" "));28 assertTrue(new PresetListEntry("", null).getListDisplay(200).contains(" ")); 29 29 } 30 30 }
Note:
See TracChangeset
for help on using the changeset viewer.