1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.mapcss;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
7 | import org.junit.jupiter.api.Test;
|
---|
8 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
9 |
|
---|
10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Unit tests of {@code ParsingLinkSelector}.
|
---|
14 | */
|
---|
15 | class ParsingLinkSelectorTest {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Setup rule
|
---|
19 | */
|
---|
20 | @RegisterExtension
|
---|
21 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
22 | public JOSMTestRules test = new JOSMTestRules().projection();
|
---|
23 |
|
---|
24 | @Test
|
---|
25 | public void parseEmptyChildSelector() {
|
---|
26 | String css = "relation > way {}";
|
---|
27 | MapCSSStyleSource source = new MapCSSStyleSource(css);
|
---|
28 | source.loadStyleSource();
|
---|
29 | assertEquals(1, source.rules.size());
|
---|
30 | }
|
---|
31 |
|
---|
32 | @Test
|
---|
33 | public void parseEmptyParentSelector() {
|
---|
34 | String css = "way < relation {}";
|
---|
35 | MapCSSStyleSource source = new MapCSSStyleSource(css);
|
---|
36 | source.loadStyleSource();
|
---|
37 | assertEquals(1, source.rules.size());
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Test
|
---|
41 | public void parseChildSelectorWithKeyValueCondition() {
|
---|
42 | String css = "relation >[role=\"my_role\"] way {}";
|
---|
43 | MapCSSStyleSource source = new MapCSSStyleSource(css);
|
---|
44 | source.loadStyleSource();
|
---|
45 | assertEquals(1, source.rules.size());
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Test
|
---|
49 | public void parseChildSelectorWithKeyCondition() {
|
---|
50 | String css = "relation >[\"my_role\"] way{}";
|
---|
51 | MapCSSStyleSource source = new MapCSSStyleSource(css);
|
---|
52 | source.loadStyleSource();
|
---|
53 | assertEquals(1, source.rules.size());
|
---|
54 | }
|
---|
55 | }
|
---|