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

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

fix #13037 - Small fixes for unit tests (patch by michael2402) - gsoc-core

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