Search in sources :

Example 6 with HTMLElement

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

the class Table method render.

/**
 * Renders a table for the given icon
 *
 * @param parent
 *            parent element in which the table is created
 * @param items
 *            items that will make the table rows
 * @param total
 *            the summary of all coverage data items in the table static
 *            resources that might be referenced
 * @param resources
 *            static resources that might be referenced
 * @param base
 *            base folder of the table
 * @throws IOException
 *             in case of IO problems with the element output
 */
public void render(final HTMLElement parent, final List<? extends ITableItem> items, final ICoverageNode total, final Resources resources, final ReportOutputFolder base) throws IOException {
    final List<? extends ITableItem> sortedItems = sort(items);
    final HTMLElement table = parent.table(Styles.COVERAGETABLE);
    table.attr("id", "coveragetable");
    header(table, sortedItems, total);
    footer(table, total, resources, base);
    body(table, sortedItems, resources, base);
}
Also used : HTMLElement(org.jacoco.report.internal.html.HTMLElement)

Example 7 with HTMLElement

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

the class SessionsPageTest method testExecutionDataContent.

@Test
public void testExecutionDataContent() throws Exception {
    final Collection<ExecutionData> data = new ArrayList<ExecutionData>();
    data.add(new ExecutionData(0x1000, "ClassB", new boolean[0]));
    data.add(new ExecutionData(0x1001, "ClassC", new boolean[0]));
    data.add(new ExecutionData(0x1002, "ClassA", new boolean[0]));
    index.addClass(new ReportPage(null, rootFolder, context) {

        public String getLinkLabel() {
            return "Foo";
        }

        @Override
        protected String getFileName() {
            return "Foo.html";
        }

        public String getLinkStyle() {
            return "sample";
        }

        @Override
        protected void content(HTMLElement body) throws IOException {
        }
    }, 0x1002);
    final SessionsPage page = new SessionsPage(noSessions, data, index, null, rootFolder, context);
    page.render();
    final Document doc = support.parse(output.getFile("jacoco-sessions.html"));
    assertEquals("el_class", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a/@class"));
    assertEquals("Foo.html", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a/@href"));
    assertEquals("ClassA", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a"));
    assertEquals("0000000000001002", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[2]/code"));
    assertEquals("ClassB", support.findStr(doc, "/html/body/table[1]/tbody/tr[2]/td[1]"));
    assertEquals("ClassC", support.findStr(doc, "/html/body/table[1]/tbody/tr[3]/td[1]"));
}
Also used : HTMLElement(org.jacoco.report.internal.html.HTMLElement) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Document(org.w3c.dom.Document) ExecutionData(org.jacoco.core.data.ExecutionData) Test(org.junit.Test)

Example 8 with HTMLElement

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

the class SourceHighlighter method span.

private HTMLElement span(final HTMLElement parent, final String id, final String style1, final String style2, final String title, final ICounter branches) throws IOException {
    final HTMLElement span = parent.span(style1 + " " + style2, id);
    final Integer missed = Integer.valueOf(branches.getMissedCount());
    final Integer total = Integer.valueOf(branches.getTotalCount());
    span.attr("title", String.format(locale, title, missed, total));
    return span;
}
Also used : HTMLElement(org.jacoco.report.internal.html.HTMLElement)

Example 9 with HTMLElement

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

the class Table method body.

private void body(final HTMLElement table, final List<? extends ITableItem> items, final Resources resources, final ReportOutputFolder base) throws IOException {
    final HTMLElement tbody = table.tbody();
    int idx = 0;
    for (final ITableItem item : items) {
        final HTMLElement tr = tbody.tr();
        for (final Column c : columns) {
            c.body(tr, idx, item, resources, base);
        }
        idx++;
    }
}
Also used : HTMLElement(org.jacoco.report.internal.html.HTMLElement)

Aggregations

HTMLElement (org.jacoco.report.internal.html.HTMLElement)9 ExecutionData (org.jacoco.core.data.ExecutionData)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 SessionInfo (org.jacoco.core.data.SessionInfo)1 ILanguageNames (org.jacoco.report.ILanguageNames)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1