1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data
|
---|
3 |
|
---|
4 | import java.awt.Color
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.JOSMFixture
|
---|
7 | import org.openstreetmap.josm.Main
|
---|
8 | import org.openstreetmap.josm.data.preferences.ColorProperty
|
---|
9 |
|
---|
10 | class 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", (String) null).get().alpha == 0x12
|
---|
24 | }
|
---|
25 |
|
---|
26 | void testColorNameAlpha() {
|
---|
27 | assert new ColorProperty("foo", 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 | }
|
---|