Commit 9d40d73d0af8cb18037d44cd9e1c35c4a332140a

Authored by gibran
1 parent 1f4e6812

1) Alteração dos "N° critérios" dos métodos de acordo com o arquivo

"criteriosDescriptions.properties" do ases.

2) criação do método na classe (ContentEvaluation.java) para verificar
se um link possui 'img' e se os mesmos posuem 'alt' e se dem descrição.
src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
... ... @@ -66,9 +66,9 @@ public class BehaviorEvaluation extends Evaluation{
66 66 getOccurrences().addAll(checkRecommendation11());
67 67 getOccurrences().addAll(checkRecommendation12());
68 68 getOccurrences().addAll(checkRecommendation13());
69   - getOccurrences().addAll(checkRecommendation14());
  69 + //getOccurrences().addAll(checkRecommendation14()); comentado por Gibran
70 70 getOccurrences().addAll(checkRecommendation15());
71   - getOccurrences().addAll(checkRecommendation16());
  71 + //getOccurrences().addAll(checkRecommendation16()); comentado por Gibran
72 72  
73 73 return getOccurrences();
74 74 }
... ... @@ -107,28 +107,28 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>();
107 107 }
108 108  
109 109 if(dbclick!=null){
110   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2"));
  110 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "6"));//"2"));
111 111 }
112 112  
113 113 if(ondblclick!=null){
114   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2"));
  114 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "6"));//"2"));
115 115 }
116 116  
117 117 if (onmousedown != null && onkeydown == null) {
118   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1"));
  118 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2"));//"1"));
119 119 }
120 120  
121 121 if (onmouseup != null && onkeyup == null) {
122   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1"));
  122 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1"));//"1"));
123 123 }
124 124 /*if (onclick != null && onkeypress == null) {
125 125 occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1"));
126 126 }*/
127 127 if (onmouseover != null && onfocus == null) {
128   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1"));
  128 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2"));//"1"));
129 129 }
130 130 if (onmouseout != null && onblur == null) {
131   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1"));
  131 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2"));//"1"));
132 132 }
133 133 }
134 134  
... ... @@ -145,7 +145,7 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>();
145 145 if(element != null){
146 146 for(String attribute : attributes){
147 147 if (element.getAttributeValue(attribute) != null) {
148   - occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "3"));
  148 + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "8"));//"3"));
149 149 }
150 150 }
151 151 }
... ...
src/main/java/br/com/checker/emag/core/ContentEvaluation.java
... ... @@ -185,11 +185,11 @@ public class ContentEvaluation extends Evaluation {
185 185 getOccurrences().addAll(checkRecommendation17());
186 186 getOccurrences().addAll(checkRecommendation18());
187 187 getOccurrences().addAll(checkRecommendation19());
188   - getOccurrences().addAll(checkRecommendation20());
  188 + //getOccurrences().addAll(checkRecommendation20()); comentado por Gibran
189 189 getOccurrences().addAll(checkRecommendation21());
190 190 getOccurrences().addAll(checkRecommendation22());
191 191 getOccurrences().addAll(checkRecommendation23());
192   - getOccurrences().addAll(checkRecommendation24());
  192 + //getOccurrences().addAll(checkRecommendation24());
193 193 getOccurrences().addAll(checkRecommendation25());
194 194 getOccurrences().addAll(checkRecommendation26());
195 195 getOccurrences().addAll(checkRecommendation27());
... ... @@ -245,16 +245,16 @@ public class ContentEvaluation extends Evaluation {
245 245  
246 246 if (lang == null && (xmlLang != null || xmlns != null)) {
247 247 occurrences.add(this.buildOccurrence("3.1", false, tagHtml,
248   - html, "2"));
  248 + html, "3"));//"2"));
249 249 } else if (lang != null && lang.getValue().isEmpty()) {
250 250 occurrences.add(this.buildOccurrence("3.1", false, tagHtml,
251   - html, "2"));
  251 + html, "3"));//"2"));
252 252 } else if (xmlLang != null && xmlLang.getValue().isEmpty()) {
253 253 occurrences.add(this.buildOccurrence("3.1", false, tagHtml,
254   - html, "2"));
  254 + html, "3"));//"2"));
255 255 } else if (xmlns != null && xmlns.getValue().isEmpty()) {
256 256 occurrences.add(this.buildOccurrence("3.1", false, tagHtml,
257   - html, "2"));
  257 + html, "3"));//"2"));
258 258 }
259 259  
260 260 /*
... ... @@ -349,7 +349,9 @@ public class ContentEvaluation extends Evaluation {
349 349  
350 350 private List<Occurrence> checkRecommendation21() {
351 351 List<Occurrence> occurrences = new ArrayList<Occurrence>();
352   -
  352 +
  353 + Element LinkComImg;
  354 +
353 355 for (Element link : getDocument().getAllElements("a")) {
354 356 String href = link.getAttributeValue("href");
355 357 String title = link.getAttributeValue("title");
... ... @@ -358,18 +360,34 @@ public class ContentEvaluation extends Evaluation {
358 360 if (hasEqualsContentHref(link) && isRegistroBr(content))
359 361 occurrences.add(this.buildOccurrence("3.5", false,
360 362 link.toString(), link, "1"));
361   -
362   - if (!hasContent(link))
363   - occurrences.add(this.buildOccurrence("3.5", true,
364   - link.toString(), link, "2"));
365   - else if (hasImgWithoutAlt(link))
366   - occurrences.add(this.buildOccurrence("3.5", true,
367   - link.toString(), link, "2"));
  363 +
  364 +
  365 + LinkComImg = link.getFirstElement("img");
  366 +
  367 + if(LinkComImg == null)
  368 + {
  369 + if (!hasContent(link))
  370 + {
  371 + occurrences.add(this.buildOccurrence("3.5", true,
  372 + link.toString(), link, "3"));//"2"));
  373 + }
  374 + }
  375 + else
  376 + {
  377 + if (hasLinkComImgWithoutAlt(link))
  378 + {
  379 + occurrences.add(this.buildOccurrence("3.5", true,
  380 + link.toString(), link, "3"));//"2"));
  381 + }
  382 + }
  383 +
  384 +
  385 +
368 386  
369 387 // if(hasTitle(link) && isNotAlt(link))
370 388 if (hasTitle(link) && !hasContent(link))
371 389 occurrences.add(this.buildOccurrence("3.5", true,
372   - link.toString(), link, "3"));
  390 + link.toString(), link, "4"));//"3"));
373 391  
374 392 /*
375 393 * if(!hasTitle(link) && !hasContent(link) &&
... ... @@ -380,31 +398,31 @@ public class ContentEvaluation extends Evaluation {
380 398  
381 399 if (hasImgWithoutAlt(link))
382 400 occurrences.add(this.buildOccurrence("3.5", true,
383   - link.toString(), link, "4"));
  401 + link.toString(), link, "5"));//"4"));
384 402  
385 403 if (hasLeiaMaisDescription(link))
386 404 occurrences.add(this.buildOccurrence("3.5", true,
387   - link.toString(), link, "5"));
  405 + link.toString(), link, "6"));//"5"));
388 406  
389 407 if (hasDiferenteContentSameLink(link))
390 408 occurrences.add(this.buildOccurrence("3.5", true,
391   - link.toString(), link, "6"));
  409 + link.toString(), link, "10"));//"6"));
392 410  
393 411 if (isTitleEqualsContent(link))
394 412 occurrences.add(this.buildOccurrence("3.5", true,
395   - link.toString(), link, "8"));
  413 + link.toString(), link, "12"));//"8"));
396 414  
397 415 if (hasSameContentDiferentLink(link))
398 416 occurrences.add(this.buildOccurrence("3.5", true,
399   - link.toString(), link, "7"));
  417 + link.toString(), link, "11"));//"7"));
400 418  
401 419 if (link != null && hasLongContent(link))
402 420 occurrences.add(this.buildOccurrence("3.5", false,
403   - link.toString(), link, "9"));
  421 + link.toString(), link, "13"));//"9"));
404 422  
405 423 if (link != null && isLinkUnavailable(link, getUrl()))
406 424 occurrences.add(this.buildOccurrence("3.5", true,
407   - link.toString(), link, "10"));
  425 + link.toString(), link, "14"));//"10"));
408 426  
409 427 }
410 428 return occurrences;
... ... @@ -494,13 +512,29 @@ public class ContentEvaluation extends Evaluation {
494 512 return link.getContent().getTextExtractor().toString().length() > 500 ? true
495 513 : false;
496 514 }
497   -
  515 +
  516 +
498 517 private boolean hasContent(Element link) {
499   -
500   - int quantidadeElementosDentroLink = 0;
  518 +
501 519 boolean temConteudo;
502 520  
503   - quantidadeElementosDentroLink = link.getAllElements().size();
  521 +
  522 + temConteudo = StringUtils.isNotBlank(link.getContent().getTextExtractor().toString());
  523 +
  524 + if(!temConteudo)
  525 + {
  526 + for (Element elemento : link.getAllElements()) {
  527 + temConteudo = StringUtils.isNotBlank(elemento.getContent().getTextExtractor().toString());
  528 +
  529 + if(temConteudo)
  530 + {
  531 + break;
  532 + }
  533 + }
  534 + }
  535 + return temConteudo;
  536 +
  537 +/* quantidadeElementosDentroLink = link.getAllElements().size();
504 538 //Verifica se há elementos como img, span e outros dentro do link. o valor 1 já está atribuído a tag <a> (link avaliado)
505 539 if(quantidadeElementosDentroLink > 1)
506 540 {
... ... @@ -511,7 +545,7 @@ public class ContentEvaluation extends Evaluation {
511 545 {
512 546 temConteudo = StringUtils.isNotBlank(link.getContent().getTextExtractor().toString());
513 547 }
514   - return temConteudo;
  548 + return temConteudo;*/
515 549 }
516 550  
517 551 private boolean hasTitle(Element link) {
... ... @@ -519,6 +553,28 @@ public class ContentEvaluation extends Evaluation {
519 553 return title != null && StringUtils.isNotBlank(title);
520 554 }
521 555  
  556 +
  557 +
  558 + private boolean hasLinkComImgWithoutAlt(Element link) {
  559 +
  560 + boolean temImgSemAlt = false;
  561 +
  562 + String alt;
  563 +
  564 + for (Element elementoImagem : link.getAllElements("img")) {
  565 +
  566 + alt = elementoImagem.getAttributeValue("alt");
  567 + temImgSemAlt = (alt == null || StringUtils.isBlank(alt));
  568 + if(!temImgSemAlt)
  569 + {
  570 + break;
  571 + }
  572 + }
  573 +
  574 +
  575 + return temImgSemAlt;
  576 + }
  577 +
522 578 private boolean hasImgWithoutAlt(Element link) {
523 579 Element img = link.getFirstElement("img");
524 580 if (img == null)
... ... @@ -526,7 +582,7 @@ public class ContentEvaluation extends Evaluation {
526 582 String alt = img.getAttributeValue("alt");
527 583 return alt == null || StringUtils.isBlank(alt);
528 584 }
529   -
  585 +
530 586 private boolean hasLeiaMaisDescription(Element link) {
531 587 String title = link.getAttributeValue("title");
532 588 String content = link.getContent().getTextExtractor().toString();
... ... @@ -746,7 +802,7 @@ public class ContentEvaluation extends Evaluation {
746 802 "3.6",
747 803 false,
748 804 imgA.toString(),
749   - imgA, "5"));
  805 + imgA, "7"));//"5"));
750 806 aMap.put(srcAtt.getValue(), img);
751 807 isVerificado = true;
752 808 }
... ... @@ -762,7 +818,7 @@ public class ContentEvaluation extends Evaluation {
762 818  
763 819 if (isVerificado)
764 820 occurrences.add(buildOccurrence("3.6", false,
765   - img.toString(), img, "5"));
  821 + img.toString(), img, "7"));//"5"));
766 822 }
767 823 }
768 824  
... ... @@ -788,7 +844,7 @@ public class ContentEvaluation extends Evaluation {
788 844 if (alt != null && title != null) {
789 845 if (title.getValue().equals(alt.getValue()))
790 846 occurrences.add(buildOccurrence("3.6", true,
791   - img.toString(), img, "6"));
  847 + img.toString(), img, "8"));//"6"));
792 848 }
793 849 }
794 850  
... ... @@ -974,9 +1030,9 @@ public class ContentEvaluation extends Evaluation {
974 1030 * paragrafo.toString(), paragrafo, "1")); }
975 1031 */
976 1032  
977   - if (paragrafo.getContent().length() > 1000)
  1033 + /*if (paragrafo.getContent().length() > 1000)
978 1034 occurrences.add(this.buildOccurrence("3.11", false,
979   - paragrafo.toString(), paragrafo, "1"));
  1035 + paragrafo.toString(), paragrafo, "1"));*/ //comentado por Gibran
980 1036  
981 1037 String align = paragrafo.getAttributeValue("align");
982 1038 if ("justify".equals(align))
... ...
src/main/java/br/com/checker/emag/core/MarkEvaluation.java
... ... @@ -13,6 +13,8 @@ import net.htmlparser.jericho.Element;
13 13 import net.htmlparser.jericho.Source;
14 14  
15 15 import org.apache.commons.lang3.StringUtils;
  16 +import org.w3c.dom.Document;
  17 +
16 18  
17 19 import br.com.checker.emag.Occurrence;
18 20 import br.com.checker.emag.OccurrenceClassification;
... ... @@ -236,6 +238,8 @@ public class MarkEvaluation extends Evaluation {
236 238 return occurrences;
237 239 }
238 240  
  241 +
  242 +
239 243 private List<Occurrence> checkRecommendation2() {
240 244 List<Occurrence> occurrences = new ArrayList<Occurrence>();
241 245  
... ... @@ -306,7 +310,7 @@ public class MarkEvaluation extends Evaluation {
306 310  
307 311 if (!linhasImg.contains(this.getRow(img))) {
308 312 occurrences.add(this.buildOccurrence("1.2",
309   - false, img.toString(), img, "1"));
  313 + false, img.toString(), img, "3")); //"1"));
310 314 }
311 315  
312 316 linhasImg.add(this.getRow(img));
... ... @@ -320,7 +324,7 @@ public class MarkEvaluation extends Evaluation {
320 324 .equals("")) {
321 325 occurrences.add(this.buildOccurrence("1.2",
322 326 false, element.getStartTag().toString()
323   - + endTag, element, "1"));
  327 + + endTag, element, "3"));//"1"));
324 328 }
325 329 }
326 330 }
... ... @@ -359,7 +363,7 @@ public class MarkEvaluation extends Evaluation {
359 363 for (Element element : getDocument().getAllElements("h1")) {
360 364  
361 365 occurrences.add(this.buildOccurrence("1.3", true,
362   - element.toString(), element, "4"));
  366 + element.toString(), element, "6"));//"4"));
363 367 }
364 368 }
365 369  
... ... @@ -381,7 +385,7 @@ public class MarkEvaluation extends Evaluation {
381 385 if (count > 0 && !hasOtherH)
382 386 occurrences.add(this.buildOccurrence("1.3", false, getDocument()
383 387 .getFirstElement("h1").toString(), getDocument()
384   - .getFirstElement("h1"), "3"));
  388 + .getFirstElement("h1"), "4"));//"3"));
385 389  
386 390 // CRITERIO 2
387 391  
... ... @@ -471,11 +475,11 @@ public class MarkEvaluation extends Evaluation {
471 475 Attribute tabIndex = link.getAttributes().get("tabindex");
472 476 if (tabIndex != null) {
473 477 occurrences.add(this.buildOccurrence("1.4", false,
474   - link.toString(), link, "2"));
  478 + link.toString(), link, "3"));//"2"));
475 479  
476 480 if (rangeIncorretoTabeIndex(tabIndex))
477 481 occurrences.add(this.buildOccurrence("1.4", false,
478   - link.toString(), link, "3"));
  482 + link.toString(), link, "6"));//"3"));
479 483 }
480 484 }
481 485  
... ... @@ -484,11 +488,11 @@ public class MarkEvaluation extends Evaluation {
484 488 Attribute tabIndex = input.getAttributes().get("tabindex");
485 489 if (tabIndex != null)
486 490 occurrences.add(this.buildOccurrence("1.4", false,
487   - input.toString(), input, "2"));
  491 + input.toString(), input, "3"));//"2"));
488 492  
489 493 if (rangeIncorretoTabeIndex(tabIndex))
490 494 occurrences.add(this.buildOccurrence("1.4", false,
491   - input.toString(), input, "3"));
  495 + input.toString(), input, "6"));//"3"));
492 496 }
493 497  
494 498 for (Element select : this.getDocument().getAllElements("select")) {
... ... @@ -496,11 +500,11 @@ public class MarkEvaluation extends Evaluation {
496 500 Attribute tabIndex = select.getAttributes().get("tabindex");
497 501 if (tabIndex != null)
498 502 occurrences.add(this.buildOccurrence("1.4", false,
499   - select.toString(), select, "2"));
  503 + select.toString(), select, "3"));//"2"));
500 504  
501 505 if (rangeIncorretoTabeIndex(tabIndex))
502 506 occurrences.add(this.buildOccurrence("1.4", false,
503   - select.toString(), select, "3"));
  507 + select.toString(), select, "6"));//"3"));
504 508 }
505 509  
506 510 for (Element textarea : this.getDocument().getAllElements("textarea")) {
... ... @@ -508,11 +512,11 @@ public class MarkEvaluation extends Evaluation {
508 512 Attribute tabIndex = textarea.getAttributes().get("tabindex");
509 513 if (tabIndex != null)
510 514 occurrences.add(this.buildOccurrence("1.4", false,
511   - textarea.toString(), textarea, "2"));
  515 + textarea.toString(), textarea, "3"));//"2"));
512 516  
513 517 if (rangeIncorretoTabeIndex(tabIndex))
514 518 occurrences.add(this.buildOccurrence("1.4", false,
515   - textarea.toString(), textarea, "3"));
  519 + textarea.toString(), textarea, "6"));//"3"));
516 520 }
517 521  
518 522 /*
... ... @@ -577,7 +581,7 @@ public class MarkEvaluation extends Evaluation {
577 581 if (contLink != null && contLink.length() > 1
578 582 && contLink.substring(0, 1).equals("#")) {
579 583 occurrences.add(this.buildOccurrence("1.5", false,
580   - link.toString(), link, "4"));
  584 + link.toString(), link, "10"));//"4"));
581 585 break;
582 586 }
583 587  
... ... @@ -731,13 +735,13 @@ public class MarkEvaluation extends Evaluation {
731 735 "1.5",
732 736 true,
733 737 "Observa&ccedil;&atilde;o - Sem fonte ( n&atilde;o existe(m) accesskey(s) na página)",
734   - getDocument().getFirstElement(), "3"));
  738 + getDocument().getFirstElement(), "4"));//"3"));
735 739  
736 740 for (Element elemento : getDocument().getAllElements("accesskey",
737 741 Pattern.compile(".*"))) {
738 742 if (duplicatedAcessKey(elemento))
739 743 occurrences.add(this.buildOccurrence("1.5", false,
740   - elemento.toString(), elemento, "5"));
  744 + elemento.toString(), elemento, "11"));//"5"));
741 745 }
742 746  
743 747 this.oder(occurrences);
... ... @@ -858,6 +862,7 @@ public class MarkEvaluation extends Evaluation {
858 862 return occurrences;
859 863 }
860 864  
  865 +
861 866 public List<Occurrence> checkRecommendation8() {
862 867 List<Occurrence> occurrences = new ArrayList<Occurrence>();
863 868 Element firstElement = this.getDocument().getFirstElement();
... ... @@ -867,7 +872,7 @@ public class MarkEvaluation extends Evaluation {
867 872 Element header = getDocument().getFirstElement("header");
868 873 Element nav = getDocument().getFirstElement("nav");
869 874 Element section = getDocument().getFirstElement("section");
870   - Element footer = getDocument().getFirstElement("footer");
  875 + Element footer = getDocument().getFirstElement("footer");
871 876  
872 877 if (header == null)
873 878 occurrences
... ... @@ -876,7 +881,7 @@ public class MarkEvaluation extends Evaluation {
876 881 "1.8",
877 882 false,
878 883 "Observa&ccedil;&atilde;o - Sem fonte (N&atilde;o existe tag <HEADER>)",
879   - getDocument().getFirstElement(), "1"));
  884 + getDocument().getFirstElement(), "3"));//"1"));
880 885  
881 886 if (nav == null)
882 887 occurrences
... ... @@ -885,7 +890,7 @@ public class MarkEvaluation extends Evaluation {
885 890 "1.8",
886 891 false,
887 892 "Observa&ccedil;&atilde;o - Sem fonte (N&atilde;o existe tag <NAV>)",
888   - getDocument().getFirstElement(), "1"));
  893 + getDocument().getFirstElement(), "3"));//"1"));
889 894  
890 895 if (section == null)
891 896 occurrences
... ... @@ -894,7 +899,7 @@ public class MarkEvaluation extends Evaluation {
894 899 "1.8",
895 900 false,
896 901 "Observa&ccedil;&atilde;o - Sem fonte (N&atilde;o existe tag <SECTION>)",
897   - getDocument().getFirstElement(), "1"));
  902 + getDocument().getFirstElement(), "3"));//"1"));
898 903  
899 904 if (footer == null)
900 905 occurrences
... ... @@ -903,7 +908,7 @@ public class MarkEvaluation extends Evaluation {
903 908 "1.8",
904 909 false,
905 910 "Observa&ccedil;&atilde;o - Sem fonte (N&atilde;o existe tag <FOOTER>)",
906   - getDocument().getFirstElement(), "1"));
  911 + getDocument().getFirstElement(), "3"));//"1"));
907 912  
908 913 } else {
909 914  
... ... @@ -925,7 +930,8 @@ public class MarkEvaluation extends Evaluation {
925 930 if (hasBanner && hasNavigation && hasMain)
926 931 break;
927 932 }
928   -
  933 +/*//comentado por Gibran
  934 + *
929 935 if (!hasBanner)
930 936 occurrences
931 937 .add(this
... ... @@ -951,7 +957,7 @@ public class MarkEvaluation extends Evaluation {
951 957 "1.8",
952 958 false,
953 959 "Observa&ccedil;&atilde;o - Sem fonte (N&atilde;o existe tag com atributo ROLE e conte&uacute;do MAIN)",
954   - getDocument().getFirstElement(), "2"));
  960 + getDocument().getFirstElement(), "2"));*/ //comentado por Gibran
955 961  
956 962 }
957 963  
... ... @@ -1034,6 +1040,7 @@ public class MarkEvaluation extends Evaluation {
1034 1040  
1035 1041 }
1036 1042 } catch (Exception e) {
  1043 +
1037 1044 e.printStackTrace();
1038 1045 }
1039 1046  
... ...
src/main/java/br/com/checker/emag/core/PresentationEvaluation.java
... ... @@ -55,7 +55,7 @@ public class PresentationEvaluation extends Evaluation{
55 55  
56 56 public List<Occurrence> check() {
57 57 getOccurrences().clear();
58   - getOccurrences().addAll(checkRecommendation29());
  58 + //getOccurrences().addAll(checkRecommendation29());
59 59 getOccurrences().addAll(checkRecommendation30());
60 60 getOccurrences().addAll(checkRecommendation31());
61 61 getOccurrences().addAll(checkRecommendation32());
... ...