Changeset 17119 in josm


Ignore:
Timestamp:
2020-10-08T20:26:04+02:00 (4 years ago)
Author:
simon04
Message:

see #19819 - NamedColorProperty: update Javadoc, add unit test

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/preferences/NamedColorProperty.java

    r17118 r17119  
    55import java.util.Arrays;
    66import java.util.List;
     7
     8import javax.swing.UIManager;
    79
    810import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    3032    /**
    3133     * Construct a new {@code NamedColorProperty}.
     34     *
     35     * The priority for getting the color is: 1. a set property, 2. {@link UIManager#getColor}, 3. the given {@code defaultValue}
    3236     * @param category a category, can be any identifier, but the following values are recognized by
    3337     * the GUI preferences: {@link #COLOR_CATEGORY_GENERAL} and {@link #COLOR_CATEGORY_MAPPAINT}
  • trunk/test/unit/org/openstreetmap/josm/data/preferences/NamedColorPropertyTest.java

    r14149 r17119  
    77import java.awt.Color;
    88import java.util.Arrays;
     9import java.util.Collections;
     10
     11import javax.swing.UIManager;
    912
    1013import org.junit.Before;
     
    4346    @Test
    4447    public void testGet() {
     48        assertEquals(Color.RED, base.get());
     49
     50        UIManager.put("JOSM.clr.general.test", Color.GRAY);
     51        base = new NamedColorProperty("test", Color.RED);
     52        assertEquals(Color.GRAY, base.get());
     53
     54        Config.getPref().putList("clr.general.test", Collections.singletonList("#123456"));
     55        assertEquals(new Color(0x123456), base.get());
     56
     57        Config.getPref().putList("clr.general.test", null);
     58        UIManager.put("JOSM.clr.general.test", null);
     59        base = new NamedColorProperty("test", Color.RED);
    4560        assertEquals(Color.RED, base.get());
    4661    }
Note: See TracChangeset for help on using the changeset viewer.