Package com.volantis.mcs.protocols.renderer

Examples of com.volantis.mcs.protocols.renderer.TestRendererContext


                                      NDimensionalIndex.ZERO_DIMENSIONS);

        final AssetResolverMock assetResolverMock =
                new AssetResolverMock("assetResolverMock", expectations);

        final TestRendererContext rendererContext = new TestRendererContext(
                assetResolverMock);
        TestDeprecatedOutputLocator outputLocator
                = new TestDeprecatedOutputLocator();
        TestMenuModuleCustomisation customisation
                = new TestMenuModuleCustomisation();

        // Create a mock OutputBufferResolver that expects to be called lots of
        // times with the same value.
        ExpectationBuilder expectations = mockFactory.createOrderedBuilder();
        final OutputBufferResolverMock resolverMock =
                new OutputBufferResolverMock("resolverMock", expectations);
        CompositeExpectedValue expectedArgument =
            MockFactory.getDefaultInstance().expectsAnyDefined();
        expectedArgument.addExpectedValue(mockFactory.expectsNull());
        expectedArgument.addExpectedValue(mockFactory.expectsSame(MENU_PANE));
        resolverMock.fuzzy.resolvePaneOutputBuffer(expectedArgument)
                .returns(rendererContext.getBuffer()).any();
        rendererContext.setOutputBufferResolver(resolverMock);

        // todo Customise the menu model to use a MockMenuBufferLocatorFactory
        // todo that will create a MockMenuBufferLocatory that expects to be
        // todo called only for menus and returns a fixed buffer.

        // Create the module.
        MenuModuleRendererFactory rendererFactory
                = new OpenwaveMenuModuleRendererFactory(
                        rendererContext, outputLocator, customisation);

        MenuModule module = new OpenwaveMenuModule(
                rendererContext, rendererFactory,
                new DefaultMenuModule(rendererContext, rendererFactory));
        MenuRendererSelector selector = module.getMenuRendererSelector();

        // Create the menu.
        MenuModelBuilder builder = new ConcreteMenuModelBuilder();
        builder.startMenu();

        // Set up style properties to use OpenWave menu renderer.
        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


        final AssetResolverMock assetResolverMock =
                new AssetResolverMock("assetResolverMock", expectations);

        // Create the related test/mock objects.
        TestRendererContext context =
                new TestRendererContext(assetResolverMock);
       
        TestDeprecatedOutputLocator outputLocator
                = new TestDeprecatedOutputLocator();
        DOMOutputBuffer buffer = context.getBuffer();
        TestDeprecatedImageOutput imageOutput
                = (TestDeprecatedImageOutput) outputLocator.getImageOutput();

        // Create the renderer to test, using the test objects created above.
        OpenwaveMenuItemRendererFactory rendererFactory =
                new OpenwaveMenuItemRendererFactory(context, outputLocator);
        final StylePropertyResolver stylePropertyResolver =
                new DefaultStylePropertyResolver(null, null);
        final DefaultMenuSeparatorRendererSelector rendererSelector =
                new DefaultMenuSeparatorRendererSelector(
                        new OpenwaveMenuSeparatorRendererFactory(),
                        context.getAssetResolver(),
                        stylePropertyResolver);
        DefaultMenuItemRendererSelector selector =
                new DefaultMenuItemRendererSelector(
                        rendererFactory, rendererSelector);

        MenuBufferFactory bufferFactory
                = new ConcreteMenuBufferFactory(SeparatorRenderer.NULL);

        DefaultMenuBufferLocator bufferLocator
                = new DefaultMenuBufferLocator(context.getOutputBufferResolver(),
                        bufferFactory);

        OpenwaveMenuRenderer menuRenderer =
                new OpenwaveMenuRenderer(selector, bufferLocator);
View Full Code Here

        super.setUp();

        // Initialise the factory
        customisation = new TestMenuModuleCustomisation();
        factory = new DefaultMenuItemRendererFactory(
                new TestRendererContext(null),
                new TestDeprecatedOutputLocator(),
                customisation);
        separator = new TestHorizontalSeparator();
    }
View Full Code Here

    /**
     * Initialise.
     */
    public TestDOMMenuModule() {
        super(new TestRendererContext(null),
              new TestDOMMenuModuleRendererFactory());
    }
View Full Code Here

     * The copyright statement.
     */
    private static String mark = "(c) Volantis Systems Ltd 2004.";

    public TestDOMMenuModuleRendererFactory() {
        super(new TestRendererContext(null),
              new TestDeprecatedOutputLocator(),
              new TestMenuModuleCustomisation());
    }
View Full Code Here

        assetResolverMock = new AssetResolverMock("assetResolverMock",
                expectations);

        RendererContext rendererContext =
                new TestRendererContext(assetResolverMock);
        DeprecatedOutputLocator outputLocator
                = new TestDeprecatedOutputLocator();
        TestMenuModuleCustomisation customisation
                = new TestMenuModuleCustomisation();
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.renderer.TestRendererContext

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.