Changeset 12989 in josm for trunk/test


Ignore:
Timestamp:
2017-10-12T19:56:13+02:00 (23 months ago)
Author:
bastiK
Message:

closes #15410 - update tests + minor fixes

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.java

    r12949 r12989  
    33
    44import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
    6 
    7 import java.awt.Color;
    85
    96import org.junit.Rule;
    107import org.junit.Test;
    118import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.data.preferences.ColorProperty;
    139import org.openstreetmap.josm.testutils.JOSMTestRules;
    1410
     
    2824
    2925    /**
    30      * Test color name.
    31      */
    32     @Test
    33     public void testColorName() {
    34         assertEquals("Layer: {5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx",
    35                 Main.pref.getColorName("layer.{5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx"));
    36     }
    37 
    38     /**
    39      * Test color alpha.
    40      */
    41     @Test
    42     public void testColorAlpha() {
    43         assertEquals(0x12, new ColorProperty("foo", new Color(0x12345678, true)).get().getAlpha());
    44         assertTrue(Main.pref.putColor("bar", new Color(0x12345678, true)));
    45         assertEquals(0x12, new ColorProperty("bar", Color.RED).get().getAlpha());
    46     }
    47 
    48     /**
    49      * Test color name and alpha.
    50      */
    51     @Test
    52     public void testColorNameAlpha() {
    53         assertEquals(0x12, new ColorProperty("foo", new Color(0x12345678, true)).get().getAlpha());
    54         assertEquals(new Color(0x34, 0x56, 0x78, 0x12), Main.pref.getDefaultColor("foo"));
    55         assertEquals(0x12, Main.pref.getDefaultColor("foo").getAlpha());
    56     }
    57 
    58     /**
    5926     * Test {@link Preferences#toXML}.
    6027     */
  • trunk/test/unit/org/openstreetmap/josm/data/preferences/NamedColorPropertyTest.java

    r12988 r12989  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertTrue;
    56
    67import java.awt.Color;
     8import java.util.Arrays;
    79
    810import org.junit.Before;
    911import org.junit.Rule;
    1012import org.junit.Test;
     13import org.openstreetmap.josm.Main;
    1114import org.openstreetmap.josm.spi.preferences.Config;
    1215import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1821 * @author Michael Zangl
    1922 */
    20 public class ColorPropertyTest {
     23public class NamedColorPropertyTest {
    2124    /**
    2225     * This is a preference test.
     
    2528    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2629    public JOSMTestRules test = new JOSMTestRules().preferences();
    27     private ColorProperty base;
     30    private NamedColorProperty base;
    2831
    2932    /**
     
    3235    @Before
    3336    public void createTestProperty() {
    34         base = new ColorProperty("test", Color.RED);
     37        base = new NamedColorProperty("test", Color.RED);
    3538    }
    3639
     
    4144    public void testGet() {
    4245        assertEquals(Color.RED, base.get());
    43 
    44         Config.getPref().put("color.test", "#00ff00");
    45         assertEquals(new Color(0xff00ff00), base.get());
    4646    }
    4747
     
    5353        assertEquals(Color.RED, base.get());
    5454
    55         base.put(new Color(0xff00ff00));
    56         assertEquals(new Color(0xff00ff00), base.get());
    57         assertEquals("#00ff00", Config.getPref().get("color.test").toLowerCase());
     55        base.put(new Color(0xff00af00));
     56        assertEquals(new Color(0xff00af00), base.get());
     57        assertEquals("#00af00", Config.getPref().getList("clr.general.test").get(0).toLowerCase());
    5858
    5959        base.put(null);
    6060        assertEquals(Color.RED, base.get());
     61    }
     62
     63    /**
     64     * Test color alpha.
     65     */
     66    @Test
     67    public void testColorAlpha() {
     68        assertEquals(0x12, new NamedColorProperty("foo", new Color(0x12345678, true)).get().getAlpha());
     69        assertTrue(Main.pref.putList("clr.general.bar", Arrays.asList("#34567812", "general", "", "bar")));
     70        assertEquals(0x12, new NamedColorProperty("bar", Color.RED).get().getAlpha());
     71    }
     72
     73    /**
     74     * Test color name and alpha.
     75     */
     76    @Test
     77    public void testColorNameAlpha() {
     78        assertEquals(0x12, new NamedColorProperty("foo", new Color(0x12345678, true)).get().getAlpha());
    6179    }
    6280
     
    6684    @Test
    6785    public void testGetChildColor() {
    68         AbstractToStringProperty<Color> child = base.getChildColor("test2");
     86        AbstractProperty<Color> child = base.getChildColor("test2");
    6987
    7088        assertEquals(Color.RED, child.get());
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java

    r10900 r12989  
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.data.preferences.AbstractProperty;
    18 import org.openstreetmap.josm.data.preferences.ColorProperty;
     18import org.openstreetmap.josm.data.preferences.NamedColorProperty;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
    2020
     
    5252        AbstractProperty<Color> color = new LayerManagerTest.TestLayer() {
    5353            @Override
    54             protected ColorProperty getBaseColorProperty() {
    55                 return new ColorProperty("x", Color.BLACK);
     54            protected NamedColorProperty getBaseColorProperty() {
     55                return new NamedColorProperty("x", Color.BLACK);
    5656            }
    5757        }.getColorProperty();
     
    101101            @Override
    102102            public AbstractProperty<Color> getColorProperty() {
    103                 return new ColorProperty("test", Color.RED);
     103                return new NamedColorProperty("test", Color.RED);
    104104            }
    105105        };
Note: See TracChangeset for help on using the changeset viewer.