Ignore:
Timestamp:
2021-04-12T22:43:33+02:00 (4 years ago)
Author:
simon04
Message:

see #20744 - Evaluate MapCSS pseudo classes without array creation

Location:
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactoryTest.java

    r17275 r17762  
    1313import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1414import net.trajano.commons.testing.UtilityClassTestUtil;
     15
     16import java.lang.reflect.Method;
    1517
    1618/**
     
    4345        UtilityClassTestUtil.assertUtilityClassWellDefined(PseudoClasses.class);
    4446    }
     47
     48    /**
     49     * Tests that all functions have been registered to {@link ConditionFactory.PseudoClassCondition#CONDITION_MAP}
     50     */
     51    @Test
     52    void testAllPseudoClassesRegistered() {
     53        for (Method method : PseudoClasses.class.getDeclaredMethods()) {
     54            String name = method.getName().replaceFirst("^_new$", "new");
     55            Context context = name.equals("sameTags") ? Context.LINK : Context.PRIMITIVE;
     56            ConditionFactory.PseudoClassCondition.createPseudoClassCondition(name, false, context);
     57            ConditionFactory.PseudoClassCondition.createPseudoClassCondition(name, true, context);
     58        }
     59    }
    4560}
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

    r17760 r17762  
    8989    @Test
    9090    void testPseudoClassCondition() throws Exception {
     91        Condition c0 = ((Selector.GeneralSelector) getParser("way:area-style").selector()).conds.get(0);
    9192        Condition c1 = ((Selector.GeneralSelector) getParser("way!:area-style").selector()).conds.get(0);
    9293        Condition c2 = ((Selector.GeneralSelector) getParser("way!:areaStyle").selector()).conds.get(0);
    9394        Condition c3 = ((Selector.GeneralSelector) getParser("way!:area_style").selector()).conds.get(0);
     95        assertEquals(":areaStyle", c0.toString());
    9496        assertEquals("!:areaStyle", c1.toString());
    9597        assertEquals("!:areaStyle", c2.toString());
    9698        assertEquals("!:areaStyle", c3.toString());
     99        Selector tagged = getParser("way:tagged").selector();
     100        Selector notTagged = getParser("way!:tagged").selector();
     101        assertFalse(tagged.matches((new Environment(OsmUtils.createPrimitive("way")))));
     102        assertTrue(tagged.matches((new Environment(OsmUtils.createPrimitive("way building=yes")))));
     103        assertTrue(notTagged.matches((new Environment(OsmUtils.createPrimitive("way")))));
     104        assertFalse(notTagged.matches((new Environment(OsmUtils.createPrimitive("way building=yes")))));
    97105    }
    98106
Note: See TracChangeset for help on using the changeset viewer.