Package com.volantis.styling.impl.engine.matchers

Examples of com.volantis.styling.impl.engine.matchers.Matcher


        SelectorSequence sequence = styleSheetFactory.createSelectorSequence();
        sequence.addSelector(selector);

        MatcherBuilder matcherBuilder = this.createMatcherBuilder();

        Matcher matcher = matcherBuilder.getMatcher(sequence);

        assertSame("Selector on its own is preserved",
                   styleMatcher, matcher);

    }
View Full Code Here


        // =====================================================================
        //   Create Mocks
        // =====================================================================

        Matcher firstChildMatcher = new SimpleMatcherMock(
                "firstChildMatcher", expectations);

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        pseudoEntityProviderMock.expects.getStatefulPseudoClass("first-child").returns(null);

        factoryMock.fuzzy.createNthChildMatcher(new Integer(0), new Integer(1))
                .returns(firstChildMatcher);

        // Set the expectations on the specificity calculator.
        specificityCalculatorMock.expects.addPseudoClassSelector();

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        PseudoClassSelector themeSelector =
                themeModelFactory.createPseudoClassSelector("first-child");
        SelectorSequence sequence = createSelectorSequence(themeSelector);

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(sequence);

        assertSame("Constructed matcher not as expected",
                   firstChildMatcher, matcher);
    }
View Full Code Here

        PseudoClassSelector themeSelector =
                themeModelFactory.createPseudoClassSelector("hover");
        SelectorSequence sequence = createSelectorSequence(themeSelector);

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(sequence);

        assertSame("Constructed matcher not as expected",
                   universalMock, matcher);
        List entities = builder.getPseudoStyleEntities();
        assertEquals("List should contain one item", 1, entities.size());
View Full Code Here

        themeSelector = themeModelFactory.createPseudoClassSelector("visited");
        selectors.add(themeSelector);
        SelectorSequence sequence = createSelectorSequence(selectors);

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(sequence);

        assertSame("Constructed matcher not as expected",
                   universalMock, matcher);
        List entities = builder.getPseudoStyleEntities();
        assertEquals("List should contain one item", 1, entities.size());
View Full Code Here

        PseudoElementSelector themeSelector =
                themeModelFactory.createPseudoElementSelector("before");
        SelectorSequence sequence = createSelectorSequence(themeSelector);

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(sequence);

        assertSame("Constructed matcher not as expected",
                   universalMock, matcher);
        List entities = builder.getPseudoStyleEntities();
        assertEquals("List should contain one item", 1, entities.size());
View Full Code Here

        SelectorSequence sequence = createSelectorSequence(
                Arrays.asList(
                        new Object[] {mcsShortcutSelector, afterSelector}));

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(sequence);

        assertSame("Constructed matcher not as expected",
                   universalMock, matcher);
        List entities = builder.getPseudoStyleEntities();
View Full Code Here

        // =====================================================================
        //   Create Mocks
        // =====================================================================

        final Matcher alocal = new SimpleMatcherMock("alocal", expectations);
        final Matcher asequence = new MatcherMock("asequence", expectations);

        final Matcher blocal = new SimpleMatcherMock("blocal", expectations);
        final Matcher bsequence = new MatcherMock("bsequence", expectations);

        final Matcher clocal = new SimpleMatcherMock("clocal", expectations);
        final Matcher csequence = new MatcherMock("csequence", expectations);

        final Matcher b_cMatcher = new MatcherMock(
                "b_cMatcher", expectations);

        final Matcher a_bcMatcher = new MatcherMock(
                "a_bcMatcher", expectations);

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        // The different parts of the "b c" selector can be created in any
        // order but that must be before the composite matcher is created.
        final Expectations bcParts = new UnorderedExpectations() {
            public void add() {
                expectTypeSelectorWithDefaultNamespace("b", blocal, bsequence);

                expectTypeSelectorWithDefaultNamespace("c", clocal, csequence);
            }
        };

        final Expectations bcComposite = new OrderedExpectations() {
            public void add() {

                add(bcParts);

                factoryMock.expects.createCompositeMatcher(bsequence, csequence,
                        Operator.DESCENDANT, matcherBuilderContextMock)
                        .returns(b_cMatcher);
            }
        };

        // The different parts of the "a > (b c)" selector can be created in
        // any order but that must be before the composite matcher is created.
        final Expectations a_bcParts = new UnorderedExpectations() {
            public void add() {

                add(bcComposite);

                expectTypeSelectorWithDefaultNamespace("a", alocal, asequence);
            }
        };

        final Expectations a_bcComposite = new OrderedExpectations() {
            public void add() {

                add(a_bcParts);

                factoryMock.expects.createCompositeMatcher(
                        asequence, b_cMatcher, Operator.CHILD,
                        matcherBuilderContextMock)
                        .returns(a_bcMatcher);
            }
        };

        expectations.add(a_bcComposite);

        specificityCalculatorMock.expects.addElementSelector();
        specificityCalculatorMock.expects.addElementSelector();
        specificityCalculatorMock.expects.addElementSelector();

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        // CSS: b c
        CombinedSelector themeSelector;
        themeSelector = createCombinedSelector(
                createSelectorSequence("b"),
                CombinatorEnum.DESCENDANT,
                createSelectorSequence("c"));

        // CSS: a > b c
        themeSelector = createCombinedSelector(
                createSelectorSequence("a"),
                CombinatorEnum.CHILD,
                themeSelector);

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(themeSelector);

        assertSame("Constructed matcher not as expected",
                   a_bcMatcher, matcher);
    }
View Full Code Here

        // CSS: a
        SelectorSequence themeSequence = createSelectorSequence("a");

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(themeSequence);

        assertSame("Constructed matcher not as expected",
                   matcherSequenceMock, matcher);
    }
View Full Code Here

        // CSS: a
        SelectorSequence themeSequence = createSelectorSequence("cdm", "a");

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(themeSequence);

        assertSame("Constructed matcher not as expected",
                   matcherSequenceMock, matcher);
    }
View Full Code Here

        AttributeSelector themeSelector = createAttributeSelector(constraint);
        SelectorSequence sequence = createSelectorSequence(themeSelector);

        MatcherBuilder builder = createMatcherBuilder();
        Matcher matcher = builder.getMatcher(sequence);

        assertSame("Constructed matcher not as expected",
                   attributeMatcherMock, matcher);
    }
View Full Code Here

TOP

Related Classes of com.volantis.styling.impl.engine.matchers.Matcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.