Search in sources :

Example 36 with ElementChecker

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

the class Rgaa30Rule050801 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
        new ImmutablePair(TestSolution.NEED_MORE_INFO, CHECK_TABLE_IS_PRESENTATION_TABLE_MSG), // na when element is not found
        new ImmutablePair(TestSolution.NOT_APPLICABLE, ""));
        ec.check(sspHandler, notIdentifiedTableWithoutDataTableMarkup, testSolutionHandler);
    }
    if (!presentationTableWithoutDataTableMarkup.isEmpty()) {
        ec = new ElementPresenceChecker(// passed when element is foundexit
        new ImmutablePair(TestSolution.PASSED, ""), // na when element is not found
        new ImmutablePair(TestSolution.NOT_APPLICABLE, ""));
        ec.check(sspHandler, presentationTableWithoutDataTableMarkup, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 37 with ElementChecker

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

the class Rgaa40Rule050101 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // TEST-1   Elements identified with the markers
    // with role="table" and aria-describedby attributes
    // - PASSED: SET-2 is not empty
    // - NA:     SET-2 is empty
    ElementChecker tableRoleWithAriaDescribedbyWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(PASSED, ""), new ImmutablePair<>(NOT_APPLICABLE, ""));
    tableRoleWithAriaDescribedbyWithMarkerChecker.check(sspHandler, tableRoleWithAriaDescribedbyWithMarkerHandler, testSolutionHandler);
    // TEST-2   Elements not identified by the markers
    // with role="table" and aria-describedby attributes
    // - NMI: SET-3 is not empty  ---> msg "CheckTableRoleWithAriaDescribedbyIsComplex"
    // - NA:  SET-3 is empty
    ElementChecker tableRoleWithAriaDescribedbyWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_TABLE_ROLE_WITH_ARIA_DESCRIBEDBY_IS_COMPLEX_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), ARIA_DESCRIBEDBY_ATTR);
    tableRoleWithAriaDescribedbyWithoutMarkerChecker.check(sspHandler, tableRoleWithAriaDescribedbyWithoutMarkerHandler, testSolutionHandler);
    // TEST-3   Elements identified with the markers
    // with role="table" attribute, but without aria-describedby attribute
    // - FAILED: SET-5 is not empty  ---> msg "AriaDescribedbyMissingOnComplexTableRole"
    // - NA:     SET-5 is empty
    ElementChecker tableRoleWithoutAriaDescribedbyWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(FAILED, ARIA_DESCRIBEDBY_MISSING_ON_COMPLEX_TABLE_ROLE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""));
    tableRoleWithoutAriaDescribedbyWithMarkerChecker.check(sspHandler, tableRoleWithoutAriaDescribedbyWithMarkerHandler, testSolutionHandler);
    // TEST-4   Elements not identified by the markers
    // with role="table" attribute, but without aria-describedby attribute
    // - NMI: SET-6 is not empty  ---> msg "CheckTableRoleWithoutAriaDescribedbyIsNotComplex"
    // - NA:  SET-6 is empty
    ElementChecker tableRoleWithoutAriaDescribedbyWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_TABLE_ROLE_WITHOUT_ARIA_DESCRIBEDBY_IS_NOT_COMPLEX_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""));
    tableRoleWithoutAriaDescribedbyWithoutMarkerChecker.check(sspHandler, tableRoleWithoutAriaDescribedbyWithoutMarkerHandler, testSolutionHandler);
    if (isHtml5Page) {
        // HTML 5 page
        // TEST-5   For HTML5 page, table elements identified with the markers
        // with a caption child element
        // - PASSED: SET-8 is not empty
        // - NA:     SET-8 is empty
        ElementChecker tableForHtml5PageWithCaptionWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(PASSED, ""), new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml5PageWithCaptionWithMarkerChecker.check(sspHandler, tableForHtml5PageWithCaptionWithMarkerHandler, // @@@TODO Add checker: only one <caption>
        testSolutionHandler);
        // TEST-6   For HTML5 page, table elements not identified by the markers
        // with a caption child element
        // - NMI: SET-9 is not empty  ---> msg "CheckTableWithCaptionChildElementIsComplex"
        // - NA:  SET-9 is empty
        ElementChecker tableForHtml5PageWithCaptionWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_TABLE_WITH_CAPTION_IS_COMPLEX_MSG), // @@@TODO add evidence
        new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml5PageWithCaptionWithoutMarkerChecker.check(sspHandler, tableForHtml5PageWithCaptionWithoutMarkerHandler, testSolutionHandler);
        // TEST-7   For HTML5 page, table elements identified with the markers
        // without a caption child element
        // - FAILED: SET-11 is not empty  ---> msg "CaptionMissingOnComplexTable"
        // - NA:     SET-11 is empty
        ElementChecker tableForHtml5PageWithoutCaptionWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(FAILED, CAPTION_MISSING_ON_COMPLEX_TABLE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml5PageWithoutCaptionWithMarkerChecker.check(sspHandler, tableForHtml5PageWithoutCaptionWithMarkerHandler, testSolutionHandler);
        // TEST-8   For HTML5 page, table elements not identified by the markers
        // without a caption child element
        // - NMI: SET-12 is not empty  ---> msg "CheckTableWithoutCaptionChildElementIsNotComplex"
        // - NA:  SET-12 is empty
        ElementChecker tableForHtml5PageWithoutCaptionWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_TABLE_WITHOUT_CAPTION_IS_NOT_COMPLEX_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml5PageWithoutCaptionWithoutMarkerChecker.check(sspHandler, tableForHtml5PageWithoutCaptionWithoutMarkerHandler, testSolutionHandler);
    } else {
        // HTML4 page (a non-HTML5 page: HTML4, XHTML1, ...)
        // TEST-9   For HTML4 page, table elements identified with the markers
        // with a summary attribute
        // - PASSED: SET-14 is not empty
        // - NA:     SET-14 is empty
        ElementChecker tableForHtml4PageWithSummaryWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(PASSED, ""), // @@@TODO add evidence
        new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml4PageWithSummaryWithMarkerChecker.check(sspHandler, tableForHtml4PageWithSummaryWithMarkerHandler, testSolutionHandler);
        // TEST-10   For HTML4 page, table elements not identified by the markers
        // with a summary attribute
        // - NMI: SET-15 is not empty  ---> msg "CheckTableWithSummaryIsComplex"
        // - NA:  SET-15 is empty
        ElementChecker tableForHtml4PageWithSummaryWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_TABLE_WITH_SUMMARY_IS_COMPLEX_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), SUMMARY_ATTR);
        tableForHtml4PageWithSummaryWithoutMarkerChecker.check(sspHandler, tableForHtml4PageWithSummaryWithoutMarkerHandler, testSolutionHandler);
        // TEST-11   For HTML4 page, table elements identified with the markers
        // without a summary attribute
        // - FAILED: SET-17 is not empty  ---> msg "SummaryMissingOnComplexTable"
        // - NA:     SET-17 is empty
        ElementChecker tableForHtml4PageWithoutSummaryWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(FAILED, SUMMARY_MISSING_ON_COMPLEX_TABLE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml4PageWithoutSummaryWithMarkerChecker.check(sspHandler, tableForHtml4PageWithoutSummaryWithMarkerHandler, testSolutionHandler);
        // TEST-12   For HTML4 page, table elements not identified by the markers
        // without a summary attribute
        // - NMI: SET-18 is not empty  ---> msg "CheckTableWithoutSummaryIsNotComplex"
        // - NA:  SET-18 is empty
        ElementChecker tableForHtml4PageWithoutSummaryWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_TABLE_WITHOUT_SUMMARY_IS_NOT_COMPLEX_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""));
        tableForHtml4PageWithoutSummaryWithoutMarkerChecker.check(sspHandler, tableForHtml4PageWithoutSummaryWithoutMarkerHandler, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 38 with ElementChecker

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

the class Rgaa40Rule010201 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    ElementChecker passedOnPresenceChecker = new ElementPresenceChecker(new ImmutablePair<>(PASSED, ""), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    passedOnPresenceChecker.check(sspHandler, imgAriaHiddenWithMarkerHandler, testSolutionHandler);
    ElementChecker imgWithNotEmptyAlternativeWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(FAILED, DECORATIVE_ELEMENT_WITH_NOT_EMPTY_TEXTUAL_ALTERNATIVE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    imgWithNotEmptyAlternativeWithMarkerChecker.check(sspHandler, imgWithNotEmptyAlternativeWithMarkerHandler, testSolutionHandler);
    passedOnPresenceChecker.check(sspHandler, imgWithEmptyAlternativeWithMarkerHandler, testSolutionHandler);
    ElementChecker imgWithNotEmptyAlternativeWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_NATURE_OF_IMAGE_WITH_TEXTUAL_ALTERNATIVE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    imgWithNotEmptyAlternativeWithoutMarkerChecker.check(sspHandler, imgWithNotEmptyAlternativeWithoutMarkerHandler, testSolutionHandler);
    ElementChecker imgAriaHiddenWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_NATURE_OF_IMAGE_HIDDEN_WITH_ARIA_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    imgAriaHiddenWithoutMarkerChecker.check(sspHandler, imgAriaHiddenWithoutMarkerHandler, testSolutionHandler);
    ElementChecker imgWithEmptyAlternativeWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_NATURE_OF_IMAGE_WITHOUT_TEXTUAL_ALTERNATIVE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    imgWithEmptyAlternativeWithoutMarkerChecker.check(sspHandler, imgWithEmptyAlternativeWithoutMarkerHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 39 with ElementChecker

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

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