Search in sources :

Example 1 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class Rgaa30Rule100701 method doSelect.

@Override
protected void doSelect(Collection<DomElement> domElements, SSPHandler sspHandler) {
    for (DomElement domElement : domElements) {
        if (domElement.isFocusable()) {
            Element el = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
            treatFocusableElement(el, domElement, getElements());
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element)

Example 2 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class Aw22Rule10071 method doSelect.

@Override
protected void doSelect(Collection<DomElement> domElements, SSPHandler sspHandler) {
    for (DomElement domElement : domElements) {
        if (domElement.isFocusable()) {
            Element el = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
            treatFocusableElement(el, domElement, getElements());
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element)

Example 3 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class Rgaa22Rule07111 method doSelect.

@Override
protected void doSelect(Collection<DomElement> domElements, SSPHandler sspHandler) {
    for (DomElement domElement : domElements) {
        if (domElement.isFocusable()) {
            Element el = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
            treatFocusableElement(el, domElement, getElements());
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element)

Example 4 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class ContrastChecker method checkDomElements.

/**
     * 
     * @param sspHandler
     * @param domElements
     * @param testSolutionHandler
     * 
     * @throws ContrastCheckerParseResultException
     */
private void checkDomElements(SSPHandler sspHandler, Collection<DomElement> domElements, TestSolutionHandler testSolutionHandler) throws ContrastCheckerParseResultException {
    for (DomElement domElement : domElements) {
        // to "-1"
        if (isElementPartOfTheScope(domElement)) {
            String bgColor = domElement.getBgColor();
            String fgColor = domElement.getFgColor();
            if (ContrastHelper.isColorTestable(fgColor) && ContrastHelper.isColorTestable(bgColor)) {
                elementCounter++;
                Double contrast = ContrastHelper.getConstrastRatio(fgColor, bgColor);
                if (contrast < contrastRatio) {
                    LOGGER.debug(" cssPath " + domElement.getPath() + " " + +contrast);
                    DecimalFormatSymbols decimalSymbol = new DecimalFormatSymbols(Locale.getDefault());
                    decimalSymbol.setDecimalSeparator('.');
                    TestSolution elementSolution = createRemarkOnBadContrastElement(sspHandler, domElement, new DecimalFormat("#.00", decimalSymbol).format(contrast));
                    testSolutionHandler.addTestSolution(elementSolution);
                } else {
                    LOGGER.debug(" good luminosity " + domElement.getPath() + " " + +contrast);
                }
            } else {
                elementCounter++;
                createNmiRemarkForManualCheckElement(sspHandler, domElement);
                testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
                LOGGER.debug(" nmi " + domElement.getPath());
            }
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DecimalFormatSymbols(java.text.DecimalFormatSymbols) TestSolution(org.asqatasun.entity.audit.TestSolution) DecimalFormat(java.text.DecimalFormat)

Example 5 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class ContrastChecker method createRemarkOnBadContrastElement.

/**
     * 
     * @param sspHandler
     * @param domElement
     * @param contrast
     * @return the TestSolution
     */
private TestSolution createRemarkOnBadContrastElement(SSPHandler sspHandler, DomElement domElement, String contrast) throws ContrastCheckerParseResultException {
    TestSolution testSolution;
    String msgCode;
    if (domElement.isHidden()) {
        // if the result is hidden, the result is NEED_MORE_INFO
        testSolution = TestSolution.NEED_MORE_INFO;
        msgCode = BAD_CONTRAST_HIDDEN_ELEMENT_MSG;
    } else if (alternativeContrastMechanismPresent) {
        // An alternative contrast mechanism is provided
        testSolution = TestSolution.NEED_MORE_INFO;
        msgCode = BAD_CONTRAST_BUT_ALT_MECHANISM_MSG;
    } else {
        // By default the result is failed
        testSolution = TestSolution.FAILED;
        msgCode = BAD_CONTRAST_MSG;
    }
    Element element = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
    if (element != null) {
        Collection<EvidenceElement> eeList = new LinkedList<>();
        eeList.add(getEvidenceElement(FG_COLOR_EE, domElement.getFgColor()));
        eeList.add(getEvidenceElement(BG_COLOR_EE, domElement.getBgColor()));
        eeList.add(getEvidenceElement(CONTRAST_EE, contrast));
        addSourceCodeRemark(testSolution, element, msgCode, eeList);
    } else {
        // the test returns not_tested to avoid false positive results
        throw new ContrastCheckerParseResultException();
    }
    return testSolution;
}
Also used : ContrastCheckerParseResultException(org.asqatasun.rules.elementchecker.contrast.exception.ContrastCheckerParseResultException) EvidenceElement(org.asqatasun.entity.audit.EvidenceElement) TestSolution(org.asqatasun.entity.audit.TestSolution) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element) EvidenceElement(org.asqatasun.entity.audit.EvidenceElement)

Aggregations

DomElement (org.asqatasun.rules.domelement.DomElement)9 Element (org.jsoup.nodes.Element)6 EvidenceElement (org.asqatasun.entity.audit.EvidenceElement)2 TestSolution (org.asqatasun.entity.audit.TestSolution)2 JSONException (org.json.JSONException)2 DecimalFormat (java.text.DecimalFormat)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 ContrastCheckerParseResultException (org.asqatasun.rules.elementchecker.contrast.exception.ContrastCheckerParseResultException)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1