Search in sources :

Example 16 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa22Rule06131 method checkButtonSelection.

@Override
protected void checkButtonSelection(SSPHandler sspHandler, ElementHandler formButtonHandler, TestSolutionHandler testSolutionHandler) {
    if (formButtonHandler.isEmpty()) {
        return;
    }
    // checker used to create remark on form elements
    ElementChecker ec = new ElementPresenceChecker(// nmi when element is found
    TestSolution.NEED_MORE_INFO, // na when element is not found
    TestSolution.NOT_APPLICABLE, // message associated with each found form element
    CHECK_BUTTON_TITLE_PERTINENCE_MSG, null, TEXT_ELEMENT2, VALUE_ATTR);
    ec.check(sspHandler, formButtonHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 17 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa22Rule11041 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    super.check(sspHandler, testSolutionHandler);
    ElementChecker ec;
    if (!notIdentifiedTableWithoutDataTableMarkup.isEmpty()) {
        ec = new ElementPresenceChecker(// nmi when element is found
        TestSolution.NEED_MORE_INFO, // na when element is not found
        TestSolution.NOT_APPLICABLE, // message associated when element is found
        CHECK_TABLE_IS_PRESENTATION_TABLE_MSG, // no message created when child element is not found
        null);
        ec.check(sspHandler, notIdentifiedTableWithoutDataTableMarkup, testSolutionHandler);
    }
    if (!presentationTableWithoutDataTableMarkup.isEmpty()) {
        ec = new ElementPresenceChecker(// passed when element is found
        TestSolution.PASSED, // na when element is not found
        TestSolution.NOT_APPLICABLE, // message associated when element is found
        null, // no message created when child element is not found
        null);
        ec.check(sspHandler, presentationTableWithoutDataTableMarkup, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 18 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule010204 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (getSelectionWithMarkerHandler().isEmpty() && getSelectionWithoutMarkerHandler().isEmpty()) {
        testSolutionHandler.addTestSolution(NOT_APPLICABLE);
        return;
    }
    ElementChecker ec = new ElementPresenceChecker(new ImmutablePair(FAILED, DECORATIVE_SVG_WITHOUT_ROLE_IMG_ATTRIBUTE), new ImmutablePair(PASSED, ""));
    if (!decorativeSvgElementsWithoutRoleImage.isEmpty()) {
        // result is failed for sure
        ec.check(sspHandler, decorativeSvgElementsWithoutRoleImage, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(FAILED, DECORATIVE_SVG_OR_CHILDREN_WITH_ARWIA_ATTRIBUTE), new ImmutablePair(PASSED, ""));
    if (!ariaAttrOnDecorativeSvgOrChild.isEmpty()) {
        ec.check(sspHandler, ariaAttrOnDecorativeSvgOrChild, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(FAILED, DECORATIVE_SVG_WITH_NOT_EMPTY_TITLE_OR_DESC_TAGS), new ImmutablePair(PASSED, ""));
    if (!decorativeSvgElementsWithDescOrTitleChild.isEmpty()) {
        ec.check(sspHandler, decorativeSvgElementsWithDescOrTitleChild, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(FAILED, DECORATIVE_SVG_OR_CHILD_WITH_TITLE_ATTRIBUTE), new ImmutablePair(PASSED, ""));
    if (!titleAttrOnDecorativeSvgOrChild.isEmpty()) {
        // ec.check(sspHandler, titleAttrOnSvgOrChild, testSolutionHandler);
        ec.check(sspHandler, titleAttrOnDecorativeSvgOrChild, testSolutionHandler);
    }
    if (!decorativeSvgElements.isEmpty()) {
        testSolutionHandler.addTestSolution(PASSED);
    }
    // This control is inhibated to avoid throwing same error as 1.3.5
    // Thus, each vectorial image not determined with marker without role="img"
    // will raise a Failed, only once, in 1.3.5
    // ec = new ElementPresenceChecker(
    // new ImmutablePair(TestSolution.NEED_MORE_INFO, SUSPECTED_INFORMATIVE_SVG_ROLE_IMAGE_MISSING_ON_SVG),
    // new ImmutablePair(TestSolution.PASSED,""));
    // 
    // if (!svgElementsWithoutRoleImage.isEmpty()) {
    // // result is failed for sure
    // ec.check(sspHandler, svgElementsWithoutRoleImage, testSolutionHandler);
    // }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, SUSPECTED_INFORMATIVE_SVG_WITH_ARIA_ATTRIBUTE_DETECTED_ON_ELEMENT_OR_CHILD), new ImmutablePair(PASSED, ""));
    if (!ariaAttrOnSvgOrChild.isEmpty()) {
        ec.check(sspHandler, ariaAttrOnSvgOrChild, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, SUSPECTED_INFORMATIVE_SVG_WITH_DESC_OR_TITLE_CHILD_TAG), new ImmutablePair(PASSED, ""));
    if (!svgElementsWithDescOrTitleChild.isEmpty()) {
        ec.check(sspHandler, svgElementsWithDescOrTitleChild, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, SUSPECTED_INFORMATIVE_SVG_WITH_TITLE_ATTRIBUTE_ON_ELEMENT_OR_CHILD), new ImmutablePair(PASSED, ""));
    if (!titleAttrOnSvgOrChild.isEmpty()) {
        ec.check(sspHandler, titleAttrOnSvgOrChild, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, SUSPECTED_WELL_FORMATED_DECORATIVE_SVG), new ImmutablePair(PASSED, ""));
    if (!suspectedDecorativeSvgElements.isEmpty()) {
        ec.check(sspHandler, suspectedDecorativeSvgElements, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 19 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule060501 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (linksHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    if (emptyLinksHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.PASSED);
        return;
    }
    ElementChecker ec = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, EMPTY_LINK_MSG), new ImmutablePair(TestSolution.PASSED, ""), HREF_ATTR);
    ec.check(sspHandler, emptyLinksHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 20 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule010306 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (getSelectionWithMarkerHandler().isEmpty() && getSelectionWithoutMarkerHandler().isEmpty()) {
        testSolutionHandler.addTestSolution(NOT_APPLICABLE);
        return;
    }
    ElementChecker ec = new ElementPresenceChecker(new ImmutablePair(FAILED, SVG_WITHOUT_ROLE_IMAGE_MSG), new ImmutablePair(PASSED, ""));
    if (!ariaRoleMissingOnInformativeSvg.isEmpty()) {
        // result is failed for sure
        ec.check(sspHandler, ariaRoleMissingOnInformativeSvg, testSolutionHandler);
    }
    if (!ariaRoleMissingOnSvg.isEmpty()) {
        // result is failed for sure
        ec.check(sspHandler, ariaRoleMissingOnSvg, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, INFORMATIVE_SVG_WITH_NOT_PERTINENT_ALT_MSG), new ImmutablePair(NOT_APPLICABLE, ""), ROLE_ATTR, ARIA_LABEL_ATTR, TITLE_ATTR);
    if (!emptyAriaLabelOnInformativeSvg.isEmpty()) {
        ec.check(sspHandler, emptyAriaLabelOnInformativeSvg, testSolutionHandler);
    }
    if (!ariaLabelDifferentFromTitleOnInformativeSvg.isEmpty()) {
        ec.check(sspHandler, ariaLabelDifferentFromTitleOnInformativeSvg, testSolutionHandler);
    }
    if (!emptyChildDescOnInformativeSvg.isEmpty()) {
        ec.check(sspHandler, emptyChildDescOnInformativeSvg, testSolutionHandler);
    }
    if (!childDescDifferentFromTitleOnInformativeSvg.isEmpty()) {
        ec.check(sspHandler, childDescDifferentFromTitleOnInformativeSvg, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, CHECK_NATURE_OF_SVG_WITH_NOT_PERTINENT_ALT_MSG), new ImmutablePair(NOT_APPLICABLE, ""), ROLE_ATTR, ARIA_LABEL_ATTR, TITLE_ATTR);
    if (!emptyAriaLabelOnSvg.isEmpty()) {
        ec.check(sspHandler, emptyAriaLabelOnSvg, testSolutionHandler);
    }
    if (!ariaLabelDifferentFromTitleOnSvg.isEmpty()) {
        ec.check(sspHandler, ariaLabelDifferentFromTitleOnSvg, testSolutionHandler);
    }
    if (!emptyChildDescOnSvg.isEmpty()) {
        ec.check(sspHandler, emptyChildDescOnSvg, testSolutionHandler);
    }
    if (!childDescDifferentFromTitleOnSvg.isEmpty()) {
        ec.check(sspHandler, childDescDifferentFromTitleOnSvg, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, CHECK_ALT_PERTINENCE_OF_INFORMATIVE_SVG_MSG), new ImmutablePair(NOT_APPLICABLE, ""), ROLE_ATTR, ARIA_LABEL_ATTR, TITLE_ATTR);
    if (!markupOkOnInformativeSvg.isEmpty()) {
        ec.check(sspHandler, markupOkOnInformativeSvg, testSolutionHandler);
    }
    ec = new ElementPresenceChecker(new ImmutablePair(NEED_MORE_INFO, CHECK_NATURE_OF_SVG_AND_ALT_PERTINENCE_MSG), new ImmutablePair(NOT_APPLICABLE, ""), ROLE_ATTR, ARIA_LABEL_ATTR, TITLE_ATTR);
    if (!markupOkOnSvg.isEmpty()) {
        ec.check(sspHandler, markupOkOnSvg, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Aggregations

ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)39 ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)30 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)21 HashMap (java.util.HashMap)8 Map (java.util.Map)8 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)8 ElementWithAttributePresenceChecker (org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker)5 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)5 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)5 Element (org.jsoup.nodes.Element)5 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)4 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)4 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)3 TextLengthChecker (org.asqatasun.rules.elementchecker.text.TextLengthChecker)2 TestSolution (org.asqatasun.entity.audit.TestSolution)1 TextBelongsToBlackListChecker (org.asqatasun.rules.elementchecker.text.TextBelongsToBlackListChecker)1 TextNotIdenticalToAttributeChecker (org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker)1 TextOnlyContainsNonAlphanumericalCharactersChecker (org.asqatasun.rules.elementchecker.text.TextOnlyContainsNonAlphanumericalCharactersChecker)1 SimpleTextElementBuilder (org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)1