Examples of DOMOutputBuffer


Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     */
    public void testOpenSpatialFormatIteratorCellspacing() throws Exception {
        privateSetUp();
        context.setDevice(INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice(DEVICE_NAME, new HashMap(), null)));
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        SpatialFormatIterator sfi = new SpatialFormatIterator(canvasLayout);

        SpatialFormatIteratorAttributes sfiAttrs =
                new SpatialFormatIteratorAttributes();
        sfiAttrs.setStyles(StylesBuilder.getDeprecatedStyles());

        sfiAttrs.setFormat(sfi);

        protocol.openSpatialFormatIterator(buffer, sfiAttrs);

        Element table = buffer.closeElement("table");
        checkTableAttributes(table);
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     * stylesheets, there should be no <div> tag output.
     */
    public void testOpenPaneTableAndDiv() throws Exception {
        privateSetUp();

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        Pane pane = new Pane(canvasLayout);
        pane.setName(PANE_NAME);

        PaneAttributes paneAttributes = new PaneAttributes();
        paneAttributes.setStyles(StylesBuilder.getDeprecatedStyles());
        paneAttributes.setPane(pane);

        protocol.openPaneTable(buffer, paneAttributes);
        Element elem = buffer.getCurrentElement();

        System.out.println("Open Pane Table: " + DOMUtilities.toString(elem));
        if (protocol.supportsStyleSheets()) {
            assertTrue("There should be a div element",
                    "div".equals(elem.getName()));
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     * and correctly assigns the padding style to the table cell, not the table.
     */
    public void testOpenPaneTableWithPadding() throws Exception {
        privateSetUp();

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        Pane pane = new Pane(canvasLayout);
        pane.setName(PANE_NAME);
        PaneAttributes paneAttributes = new PaneAttributes();
        Styles paneStyles = StylesBuilder.getSparseStyles("padding: 10px");
        paneAttributes.setStyles(paneStyles);
        paneAttributes.setPane(pane);

        protocol.openPaneTable(buffer, paneAttributes);
        Element tableElement = (Element) buffer.getRoot().getHead();
        assertTrue("Root element should be a table", "table".equals(tableElement.getName()));
        String cellPadding = tableElement.getAttributeValue("cellpadding");
        assertNotNull("Table should have cell padding attribute set", cellPadding);
        assertEquals("Cell padding should be 10 pixels", "10", cellPadding);

View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     * todo XDIME-CP: Fix when done layout transformation.
     */
    public void notestOpenPane() throws RepositoryException {
        privateSetUp();

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        Element el = null;

        Pane pane = null;
        PaneAttributes attributes = null;

        //=============================================================
        // Styles defined = No
        //=============================================================
        pane = new Pane(null);
        pane.setName(PANE_NAME);
        attributes = new PaneAttributes();
        attributes.setStyles(StylesBuilder.getDeprecatedStyles());
        attributes.setPane(pane);

        protocol.openPane(buffer, attributes);

        // We expect absolutely no markup to be rendered for a pane that has
        // no attributes and no styling
        assertSame("The buffer current element should be the root element " +
                   "but was" + buffer.getCurrentElement(),
                   buffer.getRoot(),
                   buffer.getCurrentElement());

        //=============================================================
        // Styles defined = Yes
        // @todo XDIME-CP pass in Styles and check they're correctly propagated through
        //=============================================================
        pane = new Pane(null);
        pane.setName(PANE_NAME);

        attributes = new PaneAttributes();
        attributes.setStyles(StylesBuilder.getDeprecatedStyles());
//        attributes.setStyleClass("fred");
//        attributes.setBackgroundColour("#ff0000");
//        attributes.setBorderWidth("1");
//        attributes.setCellPadding("2");
//        attributes.setCellSpacing("3");
        attributes.setPane(pane);

        protocol.openPane(buffer, attributes);

        el = buffer.closeElement("div");
//        assertEquals("Invalid class attribute on div",
//                     "VE-pane-fred", el.getAttributeValue("class"));

        el = buffer.closeElement("td");
//        assertNull("Invalid class attribute on td",
//                   el.getAttributeValue("class"));
        assertNull("bgcolor on td", el.getAttributeValue("bgcolor"));
        assertNull("border on td", el.getAttributeValue("border"));
        assertNull("cellspacing on td", el.getAttributeValue("cellspacing"));
        assertNull("cellpadding on td", el.getAttributeValue("cellpadding"));
        el = buffer.closeElement("tr");
        assertNull("Class attribute on tr", el.getAttributeValue("class"));
        assertNull("bgcolor on tr", el.getAttributeValue("bgcolor"));
        assertNull("border on tr", el.getAttributeValue("border"));
        assertNull("cellspacing on tr", el.getAttributeValue("cellspacing"));
        assertNull("cellpadding on tr", el.getAttributeValue("cellpadding"));
        el = buffer.closeElement("table");
        assertNull("Class attribute on table", el.getAttributeValue("class"));
        assertNull("bgcolor on table", el.getAttributeValue("bgcolor"));
        assertEquals("Invalid border attribute", "1",
                     el.getAttributeValue("border"));
        assertEquals("Invalid cellspacing attribute", "3",
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

        context = new TestMarinerPageContext();
        protocol.setMarinerPageContext(context);
        TestDeviceLayoutContext deviceContext = new TestDeviceLayoutContext();
        context.pushDeviceLayoutContext(deviceContext);

        DOMOutputBuffer dom = new DOMOutputBuffer();
        dom.initialise();
        PaneAttributes attributes = new PaneAttributes();
        Pane pane = new Pane(null);
        attributes.setPane(pane);

        Element body;
        body = dom.openStyledElement("body", attributes);

        dom.appendEncoded("Example");

        protocol.closePane(dom, attributes);

        assertSame("The DOM's current element isn't the body element",
                   dom.getCurrentElement(),
                   body);
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

    /**
     * Tests if media types are applied correctly.
     */
    public void testOpenStyleHandheldMedia() throws IOException {

        final DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        final ProtocolConfigurationImpl protocolConfiguration =
            (ProtocolConfigurationImpl) protocol.getProtocolConfiguration();
        protocolConfiguration.setCSSMedia("handheld");
        final StyleAttributes styleAttributes = new StyleAttributes();
        protocol.openStyle(buffer, styleAttributes);
        final Element head = (Element) buffer.getRoot().getHead();
        assertEquals("handheld", head.getAttributeValue("media"));
        assertEquals("text/css", head.getAttributeValue("type"));
        buffer.appendEncoded(".c {color:red}");
        protocol.closeStyle(buffer, styleAttributes);
        final Comment comment = (Comment) head.getHead();
        assertEquals(".c {color:red}",
            new String(comment.getContents(), 0, comment.getLength()));
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

    /**
     * Tests if media type can be omitted.
     */
    public void testOpenStyleNoMedia() {

        final DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        final ProtocolConfigurationImpl protocolConfiguration =
            (ProtocolConfigurationImpl) protocol.getProtocolConfiguration();
        protocolConfiguration.setCSSMedia(null);
        final StyleAttributes styleAttributes = new StyleAttributes();
        protocol.openStyle(buffer, styleAttributes);
        final Element head = (Element) buffer.getRoot().getHead();
        assertNull(head.getAttributeValue("media"));
        assertEquals("text/css", head.getAttributeValue("type"));
        buffer.appendEncoded(".c {color:red}");
        protocol.closeStyle(buffer, styleAttributes);
        final Comment comment = (Comment) head.getHead();
        assertEquals(".c {color:red}",
            new String(comment.getContents(), 0, comment.getLength()));
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

            builder.setHref(new LiteralLinkAssetReference(href));

            builder.startLabel();
   
            builder.startText();
            DOMOutputBuffer dom = new TestDOMOutputBuffer();
            dom.writeText(text);
            builder.setText(dom);
            builder.endText();
           
            builder.endLabel();
   
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

                    }
                };
        OpenWaveNumericShortcutFragmentLinkRenderer renderer =
                new OpenWaveNumericShortcutFragmentLinkRenderer(context);
       
        DOMOutputBuffer buffer = new TestDOMOutputBuffer();
        String href = "href";
        String text = "text";
        FraglinkAttributes attrs = new FraglinkAttributes();
        attrs.setHref(href);
        final DOMOutputBuffer outputBuffer = new DOMOutputBuffer();
        outputBuffer.writeText(text);
        attrs.setLinkText(outputBuffer);
        final StylingFactory factory = StylingFactory.getDefaultInstance();
        attrs.setStyles(factory.createStyles(factory.createPropertyValues(
                StylePropertyDetails.getDefinitions())));
        renderer.doFragmentLink(buffer, attrs);
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

        builder.setElementDetails("menu", null,
                StylesBuilder.getCompleteStyles(
                        "mcs-menu-link-style: numeric-shortcut"));

        // Target it at a specific pane.
        DOMOutputBuffer buffer;

        builder.setPane(MENU_PANE);

        // Create the first menu item explicitly targeted at a different pane.
        builder.startMenuItem();

        // Set the style.
        builder.setElementDetails("menuitem", null,
                StylesBuilder.getInitialValueStyles());

        // Set the href.
        builder.setHref(new LiteralLinkAssetReference("href1.xml"));

        // Set the pane.
        builder.setPane(ITEM1_PANE);

        // Create a plain text label.
        builder.startLabel();
        builder.startText();

        // Set the text.
        buffer = new TestDOMOutputBuffer();
        buffer.writeText("item 1");
        builder.setText(buffer);

        builder.endText();
        builder.endLabel();

        builder.endMenuItem();

        // Create the second menu item explicitly targeted at a different pane.
        builder.startMenuItem();

        // Set the style.
        builder.setElementDetails("menuitem", null,
                StylesBuilder.getInitialValueStyles());

        // Set the href.
        builder.setHref(new LiteralLinkAssetReference("href2.xml"));

        // Set the pane.
        builder.setPane(ITEM2_PANE);

        // Create a plain text label.
        builder.startLabel();
        builder.startText();

        // Set the text.
        buffer = new TestDOMOutputBuffer();
        buffer.writeText("item 2");
        builder.setText(buffer);

        builder.endText();
        builder.endLabel();

        builder.endMenuItem();

        builder.endMenu();

        Menu menu = builder.getCompletedMenuModel();

        // Select the renderer to use for this menu.
        MenuRenderer renderer = selector.selectMenuRenderer(menu);

        // Make sure that it is of the appropriate type.
        assertTrue("Incorrect renderer returned: " + renderer,
                   renderer instanceof OpenwaveMenuRenderer);

        // Render the menu.
        renderer.render(menu);

        // Check the markup output.
        String expected
                = "<BLOCK style='mcs-menu-link-style: numeric-shortcut; white-space: nowrap'>"
                + "<select>"
                + "<option onpick=\"href1.xml\">item 1</option>"
                + "<option onpick=\"href2.xml\">item 2</option>"
                + "</select>"
                + "</BLOCK>";

        DOMOutputBuffer outputBuffer = rendererContext.getBuffer();

        String actual = styledDOMTester.render(outputBuffer.getRoot());
        expected = styledDOMTester.normalize(expected);

        assertEquals("Output not correct", expected, actual);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.