Search in sources :

Example 6 with HTMLSupport

use of org.jacoco.report.internal.html.HTMLSupport in project jacoco by jacoco.

the class ReportPageTest method testPageContent.

@Test
public void testPageContent() throws Exception {
    page.render();
    final HTMLSupport support = new HTMLSupport();
    final Document doc = support.parse(output.getFile("Test.html"));
    // language
    assertEquals("en", support.findStr(doc, "/html/@lang"));
    // style sheet
    assertEquals("jacoco-resources/report.css", support.findStr(doc, "/html/head/link[@rel='stylesheet']/@href"));
    // bread crumb
    assertEquals("Report", support.findStr(doc, "/html/body/div[@class='breadcrumb']/a[1]/text()"));
    assertEquals("Report.html", support.findStr(doc, "/html/body/div[@class='breadcrumb']/a[1]/@href"));
    assertEquals("el_report", support.findStr(doc, "/html/body/div[@class='breadcrumb']/a[1]/@class"));
    assertEquals("Test", support.findStr(doc, "/html/body/div[@class='breadcrumb']/span[2]/text()"));
    assertEquals("el_group", support.findStr(doc, "/html/body/div[@class='breadcrumb']/span[2]/@class"));
    // Header
    assertEquals("Test", support.findStr(doc, "/html/body/h1/text()"));
    // Content
    assertEquals("Hello Test", support.findStr(doc, "/html/body/div[@class='testcontent']/text()"));
    // Footer
    assertEquals("CustomFooter", support.findStr(doc, "/html/body/div[@class='footer']/text()"));
}
Also used : HTMLSupport(org.jacoco.report.internal.html.HTMLSupport) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 7 with HTMLSupport

use of org.jacoco.report.internal.html.HTMLSupport in project jacoco by jacoco.

the class SourceHighlighterTest method setup.

@Before
public void setup() throws Exception {
    htmlSupport = new HTMLSupport();
    source = new SourceNodeImpl(ElementType.SOURCEFILE, "Foo.java");
    buffer = new StringWriter();
    html = new HTMLDocument(buffer, "UTF-8");
    html.head().title();
    parent = html.body();
    sourceHighlighter = new SourceHighlighter(Locale.US);
}
Also used : SourceNodeImpl(org.jacoco.core.internal.analysis.SourceNodeImpl) HTMLSupport(org.jacoco.report.internal.html.HTMLSupport) StringWriter(java.io.StringWriter) HTMLDocument(org.jacoco.report.internal.html.HTMLDocument) Before(org.junit.Before)

Example 8 with HTMLSupport

use of org.jacoco.report.internal.html.HTMLSupport in project jacoco by jacoco.

the class TableTest method testSortIds.

@Test
public void testSortIds() throws Exception {
    final List<ITableItem> items = Arrays.asList(createItem("C", 3), createItem("E", 4), createItem("A", 1), createItem("D", 2));
    table.add("Forward", null, new StubRenderer(CounterComparator.TOTALITEMS.on(CounterEntity.CLASS)), false);
    table.add("Reverse", null, new StubRenderer(CounterComparator.TOTALITEMS.reverse().on(CounterEntity.CLASS)), false);
    table.render(body, items, createTotal("Sum", 6), resources, root);
    doc.close();
    final HTMLSupport support = new HTMLSupport();
    final Document doc = support.parse(output.getFile("Test.html"));
    // The elements in Column 1 are sorted in forward order:
    assertEquals("sortable", support.findStr(doc, "/html/body/table/thead/tr/td[1]/@class"));
    assertEquals("a", support.findStr(doc, "/html/body/table/thead/tr/td[1]/@id"));
    assertEquals("a2", support.findStr(doc, "/html/body/table/tbody/tr[1]/td[1]/@id"));
    assertEquals("a3", support.findStr(doc, "/html/body/table/tbody/tr[2]/td[1]/@id"));
    assertEquals("a0", support.findStr(doc, "/html/body/table/tbody/tr[3]/td[1]/@id"));
    assertEquals("a1", support.findStr(doc, "/html/body/table/tbody/tr[4]/td[1]/@id"));
    // The elements in Column 2 are sorted in reverse order:
    assertEquals("sortable", support.findStr(doc, "/html/body/table/thead/tr/td[2]/@class"));
    assertEquals("b", support.findStr(doc, "/html/body/table/thead/tr/td[2]/@id"));
    assertEquals("b1", support.findStr(doc, "/html/body/table/tbody/tr[1]/td[2]/@id"));
    assertEquals("b0", support.findStr(doc, "/html/body/table/tbody/tr[2]/td[2]/@id"));
    assertEquals("b3", support.findStr(doc, "/html/body/table/tbody/tr[3]/td[2]/@id"));
    assertEquals("b2", support.findStr(doc, "/html/body/table/tbody/tr[4]/td[2]/@id"));
}
Also used : HTMLSupport(org.jacoco.report.internal.html.HTMLSupport) HTMLDocument(org.jacoco.report.internal.html.HTMLDocument) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 9 with HTMLSupport

use of org.jacoco.report.internal.html.HTMLSupport in project jacoco by jacoco.

the class TableTest method testDefaultSorting.

@Test
public void testDefaultSorting() throws Exception {
    final List<ITableItem> items = Arrays.asList(createItem("C", 3), createItem("E", 5), createItem("A", 1), createItem("D", 4), createItem("B", 2));
    table.add("Forward", null, new StubRenderer(CounterComparator.TOTALITEMS.on(CounterEntity.CLASS)), true);
    table.render(body, items, createTotal("Sum", 1), resources, root);
    doc.close();
    final HTMLSupport support = new HTMLSupport();
    final Document doc = support.parse(output.getFile("Test.html"));
    assertEquals("down sortable", support.findStr(doc, "/html/body/table/thead/tr/td[1]/@class"));
    assertEquals("A", support.findStr(doc, "/html/body/table/tbody/tr[1]/td[1]"));
    assertEquals("B", support.findStr(doc, "/html/body/table/tbody/tr[2]/td[1]"));
    assertEquals("C", support.findStr(doc, "/html/body/table/tbody/tr[3]/td[1]"));
    assertEquals("D", support.findStr(doc, "/html/body/table/tbody/tr[4]/td[1]"));
    assertEquals("E", support.findStr(doc, "/html/body/table/tbody/tr[5]/td[1]"));
}
Also used : HTMLSupport(org.jacoco.report.internal.html.HTMLSupport) HTMLDocument(org.jacoco.report.internal.html.HTMLDocument) Document(org.w3c.dom.Document) Test(org.junit.Test)

Aggregations

HTMLSupport (org.jacoco.report.internal.html.HTMLSupport)9 HTMLDocument (org.jacoco.report.internal.html.HTMLDocument)7 MemoryMultiReportOutput (org.jacoco.report.MemoryMultiReportOutput)5 ReportOutputFolder (org.jacoco.report.internal.ReportOutputFolder)5 Resources (org.jacoco.report.internal.html.resources.Resources)5 Before (org.junit.Before)5 Test (org.junit.Test)3 Document (org.w3c.dom.Document)3 StringWriter (java.io.StringWriter)1 Locale (java.util.Locale)1 SourceNodeImpl (org.jacoco.core.internal.analysis.SourceNodeImpl)1 ILanguageNames (org.jacoco.report.ILanguageNames)1 JavaNames (org.jacoco.report.JavaNames)1 IHTMLReportContext (org.jacoco.report.internal.html.IHTMLReportContext)1 ILinkable (org.jacoco.report.internal.html.ILinkable)1 LinkableStub (org.jacoco.report.internal.html.LinkableStub)1 IIndexUpdate (org.jacoco.report.internal.html.index.IIndexUpdate)1 LabelColumn (org.jacoco.report.internal.html.table.LabelColumn)1 Table (org.jacoco.report.internal.html.table.Table)1