Changeset 16533 in josm for trunk/test


Ignore:
Timestamp:
2020-05-31T21:06:14+02:00 (4 years ago)
Author:
simon04
Message:

see #8352 - PropertiesDialog: add unit test for color tags

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java

    r16282 r16533  
    55import static org.junit.Assert.assertTrue;
    66
     7import java.awt.Color;
    78import java.util.Collections;
    89
     
    2627    @Rule
    2728    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules().main();
     29    public JOSMTestRules test = new JOSMTestRules().main().i18n("de");
    2930
    3031    /**
     
    3839        assertTrue(p.getComponentCount() > 0);
    3940    }
     41
     42    @Test
     43    public void testColor() {
     44        Combo combo = new Combo();
     45        combo.key = "colour";
     46        combo.values = "red;green;blue;black";
     47        combo.values_context = "color";
     48        combo.delimiter = ';';
     49        combo.addToPanel(new JPanel(), Collections.<OsmPrimitive>emptyList(), false);
     50        assertEquals(5, combo.combobox.getItemCount());
     51        combo.presetListEntries.stream().filter(e -> "red".equals(e.value)).findFirst().ifPresent(combo.combobox::setSelectedItem);
     52        assertEquals("red", combo.getSelectedValue());
     53        assertEquals("Rot", combo.getSelectedItem().toString());
     54        assertEquals(new Color(0xFF0000), combo.getColor());
     55        combo.presetListEntries.stream().filter(e -> "green".equals(e.value)).findFirst().ifPresent(combo.combobox::setSelectedItem);
     56        assertEquals("green", combo.getSelectedValue());
     57        assertEquals("Grün", combo.getSelectedItem().toString());
     58        assertEquals(new Color(0x008000), combo.getColor());
     59        combo.combobox.setSelectedItem("#135");
     60        assertEquals("#135", combo.getSelectedValue());
     61        assertEquals(new Color(0x113355), combo.getColor());
     62        combo.combobox.setSelectedItem("#123456");
     63        assertEquals("#123456", combo.getSelectedValue());
     64        assertEquals(new Color(0x123456), combo.getColor());
     65        combo.setColor(new Color(0x448822));
     66        assertEquals("#448822", combo.getSelectedValue());
     67    }
    4068}
Note: See TracChangeset for help on using the changeset viewer.