Search in sources :

Example 11 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker 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 12 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker 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)

Example 13 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule080901 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (linkWithoutTarget.isEmpty() && fieldsetNotWithinForm.isEmpty()) {
        sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.NEED_MORE_INFO, RuleCheckHelper.specifyMessageToRule(NO_PATTERN_DETECTED_MSG, this.getTest().getCode()));
        testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
        return;
    }
    ElementChecker linkWithoutTargetChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, LINK_WITHOUT_TARGET_MSG), new ImmutablePair(TestSolution.PASSED, ""));
    linkWithoutTargetChecker.check(sspHandler, linkWithoutTarget, testSolutionHandler);
    ElementChecker fieldsetNotWithinFormChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.NEED_MORE_INFO, FIELDSET_NOT_WITHIN_FORM_MSG), new ImmutablePair(TestSolution.PASSED, ""));
    fieldsetNotWithinFormChecker.check(sspHandler, fieldsetNotWithinForm, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 14 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class SeoRule08011 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    ElementChecker ec = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, FLASH_CONTENT_DETECTED_MSG, null);
    ec.check(sspHandler, decidableElements, testSolutionHandler);
    ec = new ElementPresenceChecker(TestSolution.NEED_MORE_INFO, TestSolution.PASSED, SUSPECTED_FLASH_CONTENT_DETECTED_MSG, null);
    ec.check(sspHandler, notDecidableElements, testSolutionHandler);
    if (testSolutionHandler.getTestSolution().equals(TestSolution.PASSED)) {
        testSolutionHandler.addTestSolution(checkSourceCode(sspHandler));
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 15 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Aw22Rule11013 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (explicitLabelElements.isEmpty() && innerControlLabelElements.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    // if all the label are explicitely defined, the test is passed
    if (innerControlLabelElements.isEmpty()) {
        // add the explicit label element to main handler for counter
        // purpose
        innerControlLabelElements.addAll(explicitLabelElements.get());
        testSolutionHandler.addTestSolution(TestSolution.PASSED);
        return;
    }
    ElementHandler<Element> labelOnError = new ElementHandlerImpl();
    for (Element el : innerControlLabelElements.get()) {
        if (!isForAttributeOfLabelEqualsToIdAttributeOfFormField(el, el.attr(FOR_ATTR))) {
            labelOnError.add(el);
        }
    }
    // use this checker to create sourceCodeRemark when needed
    ElementChecker checker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
    checker.check(sspHandler, labelOnError, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Aggregations

ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)29 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)24 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)15 LinkTextElementBuilder (org.asqatasun.rules.textbuilder.LinkTextElementBuilder)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)4 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)4 Element (org.jsoup.nodes.Element)4 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)3 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)3 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)2 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)2 ElementWithAttributePresenceChecker (org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker)1