Changeset 16691 in josm for trunk/test/unit/org
- Timestamp:
- 2020-06-21T09:54:54+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
r16533 r16691 4 4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertTrue; 6 import static org.openstreetmap.josm.tools.I18n.tr; 6 7 7 8 import java.awt.Color; 9 import java.util.Arrays; 8 10 import java.util.Collections; 9 11 … … 13 15 import org.junit.Test; 14 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.osm.OsmUtils; 15 18 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 19 … … 38 41 assertTrue(new Combo().addToPanel(p, Collections.<OsmPrimitive>emptyList(), false)); 39 42 assertTrue(p.getComponentCount() > 0); 43 } 44 45 /** 46 * Unit test for {@link ComboMultiSelect#use_last_as_default} and {@link ComboMultiSelect#getItemToSelect} 47 */ 48 @Test 49 public void testUseLastAsDefault() { 50 Combo combo = new Combo(); 51 combo.key = "addr:country"; 52 combo.use_last_as_default = 1; 53 combo.values_from = "java.util.Locale#getISOCountries"; 54 OsmPrimitive way = OsmUtils.createPrimitive("way"); 55 OsmPrimitive wayAT = OsmUtils.createPrimitive("way addr:country=AT"); 56 OsmPrimitive waySI = OsmUtils.createPrimitive("way addr:country=SI"); 57 58 combo.addToPanel(new JPanel(), Collections.singleton(way), false); 59 assertEquals("", combo.getSelectedValue()); 60 61 combo.default_ = "SI"; 62 combo.addToPanel(new JPanel(), Collections.singleton(way), false); 63 assertEquals("SI", combo.getSelectedValue()); 64 combo.addToPanel(new JPanel(), Collections.singleton(wayAT), false); 65 assertEquals("AT", combo.getSelectedValue()); 66 combo.default_ = null; 67 68 KeyedItem.LAST_VALUES.clear(); 69 KeyedItem.LAST_VALUES.put("addr:country", "AT"); 70 combo.addToPanel(new JPanel(), Collections.singleton(way), false); 71 assertEquals("AT", combo.getSelectedValue()); 72 combo.addToPanel(new JPanel(), Collections.singleton(wayAT), true); 73 assertEquals("AT", combo.getSelectedValue()); 74 combo.addToPanel(new JPanel(), Collections.singleton(way), true); 75 assertEquals("", combo.getSelectedValue()); 76 combo.use_last_as_default = 2; // "force" 77 combo.addToPanel(new JPanel(), Collections.singleton(way), true); 78 assertEquals("AT", combo.getSelectedValue()); 79 KeyedItem.LAST_VALUES.clear(); 80 81 combo.addToPanel(new JPanel(), Arrays.asList(wayAT, waySI), true); 82 assertEquals(tr("<different>"), combo.getSelectedValue()); 40 83 } 41 84
Note:
See TracChangeset
for help on using the changeset viewer.