1 /******************************************************************************* 2 * Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Marc R. Hoffmann - initial API and implementation 10 * 11 *******************************************************************************/ 12 package org.jacoco.report.internal.html.page; 13 14 import java.io.IOException; 15 import java.util.Locale; 16 17 import org.jacoco.report.ILanguageNames; 18 import org.jacoco.report.JavaNames; 19 import org.jacoco.report.MemoryMultiReportOutput; 20 import org.jacoco.report.internal.ReportOutputFolder; 21 import org.jacoco.report.internal.html.HTMLSupport; 22 import org.jacoco.report.internal.html.IHTMLReportContext; 23 import org.jacoco.report.internal.html.ILinkable; 24 import org.jacoco.report.internal.html.LinkableStub; 25 import org.jacoco.report.internal.html.index.IIndexUpdate; 26 import org.jacoco.report.internal.html.resources.Resources; 27 import org.jacoco.report.internal.html.resources.Styles; 28 import org.jacoco.report.internal.html.table.LabelColumn; 29 import org.jacoco.report.internal.html.table.Table; 30 import org.junit.After; 31 32 /** 33 * Unit tests for {@link ReportPage}. 34 */ 35 public abstract class PageTestBase { 36 37 protected MemoryMultiReportOutput output; 38 39 protected ReportOutputFolder rootFolder; 40 41 protected IHTMLReportContext context; 42 43 protected HTMLSupport support; 44 45 protected void setup() throws Exception { 46 output = new MemoryMultiReportOutput(); 47 rootFolder = new ReportOutputFolder(output); 48 final Resources resources = new Resources(rootFolder); 49 final Table table = new Table(); 50 table.add("Element", null, new LabelColumn(), true); 51 context = new IHTMLReportContext() { 52 53 public ILanguageNames getLanguageNames() { 54 return new JavaNames(); 55 } 56 57 public Resources getResources() { 58 return resources; 59 } 60 61 public Table getTable() { 62 return table; 63 } 64 65 public String getFooterText() { 66 return "CustomFooter"; 67 } 68 69 public ILinkable getSessionsPage() { 70 return new LinkableStub("sessions.html", "Sessions", 71 Styles.EL_SESSION); 72 } 73 74 public String getOutputEncoding() { 75 return "UTF-8"; 76 } 77 78 public IIndexUpdate getIndexUpdate() { 79 return new IIndexUpdate() { 80 public void addClass(ILinkable link, long classid) { 81 } 82 }; 83 } 84 85 public Locale getLocale() { 86 return Locale.ENGLISH; 87 } 88 89 }; 90 support = new HTMLSupport(); 91 } 92 93 @After 94 public void teardown() throws IOException { 95 output.close(); 96 output.assertAllClosed(); 97 } 98 99 } 100