source: josm/trunk/test/unit/org/openstreetmap/josm/data/PreferencesTest.groovy @ 10853

Last change on this file since 10853 was 10853, checked in by Don-vip, 3 years ago

see #13309 - fix most of deprecation warnings

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data
3
4import java.awt.Color
5
6import org.openstreetmap.josm.JOSMFixture
7import org.openstreetmap.josm.Main
8import org.openstreetmap.josm.data.preferences.ColorProperty
9
10class PreferencesTest extends GroovyTestCase {
11    @Override
12    void setUp() {
13        JOSMFixture.createUnitTestFixture().init();
14    }
15
16    void testColorName() {
17        assert Main.pref.getColorName("color.layer {5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx") == "color.layer {5DE308C0-916F-4B5A-B3DB-D45E17F30172}.gpx"
18    }
19
20    void testColorAlpha() {
21        assert new ColorProperty("foo", new Color(0x12345678, true)).get().alpha == 0x12
22        assert Main.pref.putColor("bar", new Color(0x12345678, true))
23        assert new ColorProperty("bar", null).get().alpha == 0x12
24    }
25
26    void testColorNameAlpha() {
27        assert new ColorProperty("foo", "bar", new Color(0x12345678, true)).get().alpha == 0x12
28        assert Main.pref.getDefaultColor("foo") == new Color(0x34, 0x56, 0x78, 0x12)
29        assert Main.pref.getDefaultColor("foo").alpha == 0x12
30    }
31
32    void testToXml() {
33        assert Main.pref.toXML(true) == String.format(
34            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" +
35            "<preferences xmlns='http://josm.openstreetmap.de/preferences-1.0' version='%d'>%n" +
36            "  <tag key='expert' value='true'/>%n" +
37            "  <tag key='jdk.Arrays.useLegacyMergeSort' value='false'/>%n" +
38            "  <tag key='language' value='en'/>%n" +
39            "  <tag key='osm-server.url' value='http://api06.dev.openstreetmap.org/api'/>%n" +
40            "  <tag key='osm-server.username' value='%s'/>%n" +
41            "</preferences>%n", Version.getInstance().getVersion(), Main.pref.get("osm-server.username"))
42    }
43}
Note: See TracBrowser for help on using the repository browser.