Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.DoSelectInputTestHelper


    public void testRenderSelectionSimple() throws Exception {
        privateSetUp();
        XFSelectAttributes attributes = new XFSelectAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());
       
        DoSelectInputTestHelper helper = new DoSelectInputTestHelper();
        helper.addOption(attributes,"Caption","Prompt","Value",false);
               
        attributes.setName("testName");
        WMLDefaultSelectionRenderer renderer =
            (WMLDefaultSelectionRenderer)protocol.getSelectionRenderer(attributes);
        renderer.renderSelection(attributes, buffer);
View Full Code Here


        XFSelectAttributes attributes = new XFSelectAttributes();
        attributes.setStyles(StylesBuilder.getCompleteStyles(
                "mcs-selection-list-style: " + listType));

        DoSelectInputTestHelper helper = new DoSelectInputTestHelper();
        helper.addOption(attributes,"Caption","Prompt","Value",false);

        attributes.setName("testName");
        attributes.setMultiple(multipleSelect);
        attributes.setTitle("title");
View Full Code Here

     */
    public void doTestDefaultSelectInput(boolean selectedOptions[],
                                         boolean multiSelect)
            throws Exception {

        DoSelectInputTestHelper helper = new DoSelectInputTestHelper();

        final String rowCount = "3";
        final String tabIndex ="1";

        XFSelectAttributes atts = helper.buildSelectAttributes();
        atts.setStyles(StylesBuilder.getStyles("mcs-rows: " + rowCount));
        atts.setMultiple(multiSelect);

        if(!multiSelect) {
            for(int i=0; i<selectedOptions.length; i++) {
                if(selectedOptions[i]) {
                    atts.setInitial("Value" + (i+1));
                    break;
                }
            }
        }
        atts.setTabindex(tabIndex);
        // add some options

        for(int i=0; i<selectedOptions.length; i++) {
            helper.addOption(atts,
                              "Caption" + (i+1),
                              "Prompt" + (i+1),
                              "Value" + (i+1),
                              selectedOptions[i]);
        }


        //protocol.addStyleMapping(atts, style);
        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();


        TestMarinerPageContext testPageContext =
                (TestMarinerPageContext)protocol.getMarinerPageContext();
        testPageContext.setFormFragmentResetState(true);

        testable.setCurrentBuffer(atts.getEntryContainerInstance(), buffer);

        StringBuffer sb = new StringBuffer();

        sb.append("<select ");
        sb.append("id=\"").append(atts.getId()).append("\" ");
        if(multiSelect) {
            sb.append("multiple=\"multiple\" ");
        }
        sb.append("name=\"").append(atts.getName()).append("\" ");
        if(multiSelect) {
            sb.append("size=\"").append(rowCount).append("\" ");
        }
        sb.append("tabindex=\"").append(tabIndex).append("\" ");
        sb.append("title=\"")
                .append(atts.getPrompt().getText(TextEncoding.PLAIN))
                .append("\">");

        for(int i=0; i<selectedOptions.length; i++) {
            sb.append("<option id=\"OptionId\" ");
            if(selectedOptions[i]) {
                sb.append("selected=\"selected\" ");
            }
            sb.append("title=\"Prompt").append(i+1)
              .append("\" value=\"Value").append(i+1)
              .append("\">Caption").append(i+1).append("</option>");
        }

        sb.append("</select>");


        helper.runTest(protocol, buffer, atts, sb.toString());

    }
View Full Code Here

                                    final boolean rightAlignCaption,
                                    int optGroupCount)
            throws Exception {


        DoSelectInputTestHelper helper = new DoSelectInputTestHelper();

        XFSelectAttributes atts = helper.buildSelectAttributes();
        Styles styles = atts.getStyles();
        MutablePropertyValues propertyValues = styles.getPropertyValues();

        if (!multiSelect) {
            for (int i = 0; i < selectedOtions.length; i++) {
                if (selectedOtions[i]) {
                    atts.setInitial("Value" + (i + 1));
                    break;
                }
            }
        }

        atts.setMultiple(multiSelect);
        // add some options
        helper.addOption(atts, "Caption1", "Prompt1", "Value1",
                selectedOtions[0]);
        helper.addOption(atts, "Caption2", "Prompt2", "Value2",
                selectedOtions[1]);


        SelectOptionGroup group = null;
        String caption, prompt;
        int count = 0;
        do {
            caption = "Group" + (count + 1);
            prompt = "Prompt" + (count + 1);
            if (0 == count) {
                group = helper.addOptionGroup(atts, caption, prompt);
            } else {
                group = helper.addOptionGroup(group, caption, prompt);
            }
        } while (++count < optGroupCount);


        helper.addOption(group, "Caption3", "Prompt3", "Value3",
                selectedOtions[2]);

        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

        propertyValues.setComputedValue(
                StylePropertyDetails.MCS_SELECTION_LIST_STYLE,
                MCSSelectionListStyleKeywords.CONTROLS);
        propertyValues.setComputedValue(
                StylePropertyDetails.MCS_SELECTION_LIST_OPTION_LAYOUT,
                rightAlignCaption ? MCSSelectionListOptionLayoutKeywords.CONTROL_FIRST
                : MCSSelectionListOptionLayoutKeywords.CAPTION_FIRST);
        propertyValues.setComputedValue(
                StylePropertyDetails.MCS_MENU_ORIENTATION,
                vertical ? MCSMenuOrientationKeywords.VERTICAL
                : MCSMenuOrientationKeywords.HORIZONTAL);

        TestMarinerPageContext testPageContext =
                (TestMarinerPageContext) protocol.getMarinerPageContext();
        testPageContext.setFormFragmentResetState(true);

        testable.setCurrentBuffer(atts.getEntryContainerInstance(), buffer);

        String type = (multiSelect) ? "checkbox" : "radio";
        String seperator = (vertical) ? "<br/>" : "\u00a0";
        StringBuffer sb = new StringBuffer();

        sb.append("<div>");

        for (int i = 0; i < 3; i++) {
            if (i > 0) {
                sb.append(seperator);
            }
            if (!rightAlignCaption) {
                sb.append("Caption").append(i + 1);
            }
            sb.append("<input ");
            if (selectedOtions[i]) {
                sb.append("checked=\"checked\" ");
            }
            sb.append("name=\"").append(atts.getName()).append("\" ");
            sb.append("type=\"").append(type).append("\" ");
            sb.append("value=\"").append("Value").append(i + 1).append("\"/>");
            if (rightAlignCaption) {
                sb.append("Caption").append(i + 1);
            }
        }
        sb.append("</div>");


        helper.runTest(protocol, buffer, atts, sb.toString());
    }
View Full Code Here

    // Javadoc inherited
    public void testOptGroupsNestingWithDefaultSelect() throws Exception {
        privateSetUp();

        DoSelectInputTestHelper helper = new DoSelectInputTestHelper();


        XFSelectAttributes atts = helper.buildSelectAttributes();

        // build the following nested option optgroup structure
        // <group 1>
        //   <group 2>
        //      <group 3>
        //         <option 1>
        //      </group>
        //   <group>
        // </group>
        // <group 4>
        //   <option 2>
        // </group>
        SelectOptionGroup group = helper.addOptionGroup(atts, "Group1",
                "Prompt1");
        group = helper.addOptionGroup(group, "Group2", "Prompt2");
        group = helper.addOptionGroup(group, "Group3", "Prompt3");
        helper.addOption(group, "Caption1", "Prompt1", "Value1", false);

        group = helper.addOptionGroup(atts, "Group4", "Prompt4");
        helper.addOption(group, "Caption2", "Prompt2", "Value2", false);


        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();
        testable.setCurrentBuffer(atts.getEntryContainerInstance(), buffer);

        StringBuffer sb = new StringBuffer();

        sb.append("<select ");
        sb.append("name=\"").append(atts.getName()).append("\">");
        sb.append("<option value=\"Value1\">Caption1</option>");

        sb.append("<option value=\"Value2\">Caption2</option>");

        sb.append("</select>");
        helper.runTest(protocol, buffer, atts, sb.toString());
    }
View Full Code Here

    // Javadoc inherited
    public void doTestDefaultSelectInput(boolean selectedOptions[],
                                         boolean multiSelect)
            throws Exception {

        DoSelectInputTestHelper helper = new DoSelectInputTestHelper();

        final String rowCount = "3";
        final String tabIndex = "1";

        XFSelectAttributes atts = helper.buildSelectAttributes();
        atts.setStyles(StylesBuilder.getStyles("mcs-rows: " + rowCount));
        atts.setMultiple(multiSelect);

        if (!multiSelect) {
            for (int i = 0; i < selectedOptions.length; i++) {
                if (selectedOptions[i]) {
                    atts.setInitial("Value" + (i + 1));
                    break;
                }
            }
        }
        atts.setTabindex(tabIndex);
        // add some options

        for (int i = 0; i < selectedOptions.length; i++) {
            helper.addOption(atts,
                    "Caption" + (i + 1),
                    "Prompt" + (i + 1),
                    "Value" + (i + 1),
                    selectedOptions[i]);
        }


        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

        TestMarinerPageContext testPageContext =
                (TestMarinerPageContext) protocol.getMarinerPageContext();
        testPageContext.setFormFragmentResetState(true);

        testable.setCurrentBuffer(atts.getEntryContainerInstance(), buffer);

        StringBuffer sb = new StringBuffer();

        sb.append("<select ");
        if (multiSelect) {
            sb.append("multiple=\"multiple\" ");
        }
        sb.append("name=\"").append(atts.getName()).append("\" ");
        if (multiSelect) {
            sb.append("size=\"").append(rowCount).append("\" ");
        }
        sb.append("tabindex=\"").append(tabIndex).append("\">");

        for (int i = 0; i < selectedOptions.length; i++) {
            sb.append("<option ");
            if (selectedOptions[i]) {
                sb.append("selected=\"selected\" ");
            }
            sb.append("value=\"Value").append(i + 1)
                    .append("\">Caption").append(i + 1).append("</option>");
        }

        sb.append("</select>");


        helper.runTest(protocol, buffer, atts, sb.toString());

    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.DoSelectInputTestHelper

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.