Search in sources :

Example 1 with HtmlImageInput

use of com.gargoylesoftware.htmlunit.html.HtmlImageInput in project faces by jakartaee.

the class URLClient method cbuttonRenderEncodeNonPassthroughTest.

/*
   * @class.setup_props: webServerHost; webServerPort; ts_home;
   */
/**
 * @testName: cbuttonRenderEncodeNonPassthroughTest
 *
 * @assertion_ids: PENDING
 *
 * @test_Strategy: Render several command buttons within a form using
 *                 combinations of the various non-passthrough attributes to
 *                 ensure the command button and the non-passthrough
 *                 attributes are properly rendered.
 *
 * @since 1.2
 */
public void cbuttonRenderEncodeNonPassthroughTest() throws Fault {
    StringBuilder messages = new StringBuilder(64);
    Formatter formatter = new Formatter(messages);
    List<HtmlPage> pages = new ArrayList<HtmlPage>();
    pages.add(getPage(CONTEXT_ROOT + "/faces/encodetest_facelet.xhtml"));
    for (HtmlPage page : pages) {
        HtmlSubmitInput button1 = (HtmlSubmitInput) getInputIncludingId(page, "command1");
        // begin validate command1
        if (button1 == null) {
            formatter.format("Unable to find rendered" + " command button containing ID 'command1' %n");
        } else {
            if (!"Click Me".equals(button1.getValueAttribute())) {
                formatter.format("Expected value attribute for command1 to" + " be 'Click Me', found '%s' %n", button1.getValueAttribute());
            }
            if (!"submit".equals(button1.getTypeAttribute())) {
                formatter.format("Expected type attribute for command1 to " + "be 'submit', found '%s' %n", button1.getTypeAttribute());
            }
        }
        HtmlSubmitInput button2 = (HtmlSubmitInput) getInputIncludingId(page, "command2");
        if (button2 == null) {
            formatter.format("Unable to find rendered" + " command button containing ID 'command2' %n");
        } else {
            if (!"Click Me".equals(button2.getValueAttribute())) {
                formatter.format("Expected value attribute for command2 to" + " be 'Click Me', found '%s' %n", button2.getValueAttribute());
            }
            if (!"submit".equals(button2.getTypeAttribute())) {
                formatter.format("Expected type attribute for command2 to " + "be 'submit', found '%s' %n", button2.getTypeAttribute());
            }
        }
        HtmlResetInput button3 = (HtmlResetInput) getInputIncludingId(page, "command3");
        if (button3 == null) {
            formatter.format("Unable to find rendered" + " command button containing ID 'command3' %n");
        } else {
            if (!"Click Me".equals(button3.getValueAttribute())) {
                formatter.format("Expected value attribute for command3 to" + " be 'Click Me', found '%s' %n", button3.getValueAttribute());
            }
            if (!"reset".equals(button3.getTypeAttribute())) {
                formatter.format("Expected type attribute for command3 to " + "be 'reset', found '%s' %n", button3.getTypeAttribute());
            }
        }
        HtmlSubmitInput button4 = (HtmlSubmitInput) getInputIncludingId(page, "command4");
        if (button4 == null) {
            formatter.format("Unable to find rendered" + " command button containing ID 'command4' %n");
        } else {
            if (!"Click Me".equals(button4.getValueAttribute())) {
                formatter.format("Expected value attribute for command4 to" + " be 'Click Me', found '%s' %n", button4.getValueAttribute());
            }
            if (!"submit".equals(button4.getTypeAttribute())) {
                formatter.format("Expected type attribute for command4 with an" + " invalid type attribute value specified to " + "be 'submit', found '%s' %n", button4.getTypeAttribute());
            }
        }
        HtmlSubmitInput button5 = (HtmlSubmitInput) getInputIncludingId(page, "command5");
        if (button5 == null) {
            formatter.format("Unable to find rendered" + " command button containing ID 'command5' %n");
        } else {
            if (!"Click Me".equals(button5.getValueAttribute())) {
                formatter.format("Expected value attribute for command5 to" + " be 'Click Me', found '%s' %n", button5.getValueAttribute());
            }
            if (!"submit".equals(button5.getTypeAttribute())) {
                formatter.format("Expected type attribute for command5 to " + "be 'submit', found '%s' %n", button5.getTypeAttribute());
            }
            if (!"Color: red;".equals(button5.getAttribute("class"))) {
                formatter.format("Expected class attribute for command5 to" + " be 'Color: red;', found '%s %n", button5.getAttribute("class"));
            }
        }
        HtmlImageInput button6 = (HtmlImageInput) getInputIncludingId(page, "command6");
        if (button6 == null) {
            formatter.format("Unable to find rendered" + " command button (as image) containing ID " + "'command6' %n");
        } else {
            if ("Click Me".equals(button6.getValueAttribute())) {
                formatter.format("Didn't expect the value attribute for " + "command6 to be rendered, found '%s' %n", button6.getValueAttribute());
            }
            if (!"image".equals(button6.getTypeAttribute())) {
                formatter.format("Expected type attribute for command6 " + "to be 'image', found '%s' %n", button6.getTypeAttribute());
            }
            String expectedImgSrc = "pnglogo.png";
            if (!button6.getSrcAttribute().contains(expectedImgSrc)) {
                formatter.format("Unexpected result for '%s' Attribute!%n" + "Expected: '%s'%n, " + "Received: '%s'%n", "src", expectedImgSrc, button6.getSrcAttribute());
            }
        }
        HtmlSubmitInput button7 = (HtmlSubmitInput) getInputIncludingId(page, "command7");
        if (!validateExistence("command7", "input", button7, formatter)) {
            handleTestStatus(messages);
            return;
        } else {
            if (!"disabled".equals(button7.getDisabledAttribute())) {
                formatter.format("(button7) Expected the disabled attribute " + "to be rendered as '%s', instead found '%s' %n", "disabled", button7.getDisabledAttribute());
            }
        }
        HtmlSubmitInput button8 = (HtmlSubmitInput) getInputIncludingId(page, "command8");
        if (!validateExistence("command8", "input", button8, formatter)) {
            handleTestStatus(messages);
            return;
        } else {
            if (!HtmlElement.ATTRIBUTE_NOT_DEFINED.equals(button8.getDisabledAttribute())) {
                formatter.format("(command8) Expected the disabled attribute " + "to not be rendered when the disabled " + "attribute was specified as false in the JSP" + " %n.");
            }
        }
        HtmlSubmitInput button9 = (HtmlSubmitInput) getInputIncludingId(page, "command9");
        if (!validateExistence("command9", "input", button9, formatter)) {
            handleTestStatus(messages);
            return;
        } else {
            if (!"readonly".equals(button9.getReadOnlyAttribute())) {
                formatter.format("(button9) Expected the readonly attribute " + "to be rendered as '%s', instead found '%s' %n", "readonly", button9.getReadOnlyAttribute());
            }
        }
        HtmlSubmitInput button10 = (HtmlSubmitInput) getInputIncludingId(page, "command10");
        if (!validateExistence("command10", "input", button10, formatter)) {
            handleTestStatus(messages);
            return;
        } else {
            if (!HtmlElement.ATTRIBUTE_NOT_DEFINED.equals(button10.getDisabledAttribute())) {
                formatter.format("(button10) Expected the disabled attribute " + "to not be rendered when the disabled " + "attribute was specified as false in the JSP" + " %n.");
            }
        }
        // ------------------------------------------------------------ case
        // 11
        HtmlSubmitInput button11 = (HtmlSubmitInput) getInputIncludingId(page, "command11");
        if (!validateExistence("command11", "input", button11, formatter)) {
            handleTestStatus(messages);
            return;
        }
        // Test for Styleclass attribute.
        String clazzAttrOne = button11.getAttribute("class");
        if (!"blue".equals(clazzAttrOne)) {
            formatter.format("Unexpected rendered value for the " + "\"styleClass\" attribute on the '%s' tag with the " + "id of '%s'. %nExpected: '%s' %nFound: '%s' %n", "h:commandButton", "onoff", "blue", clazzAttrOne);
        }
        // Test for Value attribute.
        String valueAttrOne = button11.getValueAttribute();
        if (!"onoff".equals(valueAttrOne)) {
            formatter.format("Unexpected rendered value for the " + "\"title\" attribute on the '%s' tag with the " + "id of '%s'. %nExpected: '%s' %nFound: '%s' %n", "h:commandButton", "onoff", "onoff", valueAttrOne);
        }
        // Test for Title attribute.
        String titleAttrOne = button11.getAttribute("title");
        if (!"onoff".equals(titleAttrOne)) {
            formatter.format("Unexpected rendered value for the " + "\"title\" attribute on the '%s' tag with the " + "id of '%s'. %nExpected: '%s' %nFound: '%s' %n", "h:commandButton", "onoff", "onoff", titleAttrOne);
        }
        // display test result
        handleTestStatus(messages);
    }
}
Also used : HtmlImageInput(com.gargoylesoftware.htmlunit.html.HtmlImageInput) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlSubmitInput(com.gargoylesoftware.htmlunit.html.HtmlSubmitInput) Formatter(java.util.Formatter) ArrayList(java.util.ArrayList) HtmlResetInput(com.gargoylesoftware.htmlunit.html.HtmlResetInput)

Aggregations

HtmlImageInput (com.gargoylesoftware.htmlunit.html.HtmlImageInput)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 HtmlResetInput (com.gargoylesoftware.htmlunit.html.HtmlResetInput)1 HtmlSubmitInput (com.gargoylesoftware.htmlunit.html.HtmlSubmitInput)1 ArrayList (java.util.ArrayList)1 Formatter (java.util.Formatter)1