use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Aw22Rule11011 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
// If the page has no input form element, the test is not applicable
if (inputFormHandler.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
// If all the input form have a label, the test is passed
if (inputFormWithoutLabelHandler.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.PASSED);
return;
}
ElementChecker titleAttrPresenceChecker = new AttributePresenceChecker(TITLE_ATTR, TestSolution.PASSED, TestSolution.FAILED, null, INVALID_FORM_FIELD_MSG);
titleAttrPresenceChecker.check(sspHandler, inputFormWithoutLabelHandler, testSolutionHandler);
}
use of org.asqatasun.rules.elementchecker.ElementChecker 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);
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Aw22Rule11012 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
// If the page has no input form element, the test is not applicable
if (labels.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
/* The attribute Presence Checker */
ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, TestSolution.PASSED, TestSolution.FAILED, null, ID_MISSING_MSG);
attributePresenceChecker.check(sspHandler, labels, testSolutionHandler);
/* The attribute Emptiness Checker. Keep default value i.e failed
when attribute is empty
*/
ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
attributeEmptinessChecker.check(sspHandler, labels, testSolutionHandler);
/* The id unicityChecker */
ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
idUnicityChecker.check(sspHandler, labels, testSolutionHandler);
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Aw22Rule10012 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
// Attributes checks
for (Map.Entry<String, ElementHandler> attrElementHandlerMapEntry : attrElementHandlerMap.entrySet()) {
ElementChecker attrEc = new ElementWithAttributePresenceChecker(new ImmutablePair(TestSolution.FAILED, PRESENTATION_ATTR_DETECTED_MSG), new ImmutablePair(TestSolution.PASSED, ""), attrElementHandlerMapEntry.getKey());
attrEc.check(sspHandler, attrElementHandlerMapEntry.getValue(), testSolutionHandler);
}
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Rgaa22Rule07091 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(TestSolution.FAILED, TestSolution.PASSED, LINK_WITHOUT_TARGET_MSG, null);
linkWithoutTargetChecker.check(sspHandler, linkWithoutTarget, testSolutionHandler);
ElementChecker fieldsetNotWithinFormChecker = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, FIELDSET_NOT_WITHIN_FORM_MSG, null);
fieldsetNotWithinFormChecker.check(sspHandler, fieldsetNotWithinForm, testSolutionHandler);
}
Aggregations