Search in sources :

Example 31 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class MouseEventWithoutKeyboardEquivalentCheckTest method detected.

@Test
public void detected() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/MouseEventWithoutKeyboardEquivalentCheck.html"), new MouseEventWithoutKeyboardEquivalentCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Add a 'onKeyPress' attribute to this <a> tag.").next().atLine(2).withMessage("Add a 'onFocus' attribute to this <A> tag.").next().atLine(3).withMessage("Add a 'onBlur' attribute to this <a> tag.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 32 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class NonConsecutiveHeadingCheckTest method only_h2_tags.

@Test
public void only_h2_tags() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/NonConsecutiveHeadingCheck/OnlyH2Tags.html"), new NonConsecutiveHeadingCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Do not skip level H1.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 33 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class NonConsecutiveHeadingCheckTest method h5_with_h4.

@Test
public void h5_with_h4() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/NonConsecutiveHeadingCheck/H5WithH4.html"), new NonConsecutiveHeadingCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues()).next().atLine(1).withMessage("Do not skip level H3.");
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 34 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class NonConsecutiveHeadingCheckTest method h2_with_h1.

@Test
public void h2_with_h1() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/NonConsecutiveHeadingCheck/H2WithH1.html"), new NonConsecutiveHeadingCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues());
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Example 35 with WebSourceCode

use of org.sonar.plugins.web.visitor.WebSourceCode in project sonar-web by SonarSource.

the class NonConsecutiveHeadingCheckTest method no_heading_tags.

@Test
public void no_heading_tags() throws Exception {
    WebSourceCode sourceCode = TestHelper.scan(new File("src/test/resources/checks/NonConsecutiveHeadingCheck/NoHeadingTags.html"), new NonConsecutiveHeadingCheck());
    checkMessagesVerifier.verify(sourceCode.getIssues());
}
Also used : WebSourceCode(org.sonar.plugins.web.visitor.WebSourceCode) File(java.io.File) Test(org.junit.Test)

Aggregations

WebSourceCode (org.sonar.plugins.web.visitor.WebSourceCode)93 File (java.io.File)91 Test (org.junit.Test)89 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)10 InputFile (org.sonar.api.batch.fs.InputFile)8 FileReader (java.io.FileReader)6 PageLexer (org.sonar.plugins.web.lex.PageLexer)3 Node (org.sonar.plugins.web.node.Node)3 HtmlAstScanner (org.sonar.plugins.web.visitor.HtmlAstScanner)3 FileNotFoundException (java.io.FileNotFoundException)1 ExpectedException (org.junit.rules.ExpectedException)1 FilePredicates (org.sonar.api.batch.fs.FilePredicates)1 FileSystem (org.sonar.api.batch.fs.FileSystem)1 ComplexityVisitor (org.sonar.plugins.web.analyzers.ComplexityVisitor)1 PageCountLines (org.sonar.plugins.web.analyzers.PageCountLines)1