aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.report.test/src/org/jacoco/report/internal/html/page/PageTestBase.java
blob: 56705a8dc8fae2fef9594fadf445612f832da1d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*******************************************************************************
 * Copyright (c) 2009, 2012 Mountainminds GmbH & Co. KG and Contributors
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Marc R. Hoffmann - initial API and implementation
 *    
 *******************************************************************************/
package org.jacoco.report.internal.html.page;

import java.io.IOException;
import java.util.Locale;

import org.jacoco.report.ILanguageNames;
import org.jacoco.report.JavaNames;
import org.jacoco.report.MemoryMultiReportOutput;
import org.jacoco.report.internal.ReportOutputFolder;
import org.jacoco.report.internal.html.HTMLSupport;
import org.jacoco.report.internal.html.IHTMLReportContext;
import org.jacoco.report.internal.html.ILinkable;
import org.jacoco.report.internal.html.LinkableStub;
import org.jacoco.report.internal.html.index.IIndexUpdate;
import org.jacoco.report.internal.html.resources.Resources;
import org.jacoco.report.internal.html.resources.Styles;
import org.jacoco.report.internal.html.table.LabelColumn;
import org.jacoco.report.internal.html.table.Table;
import org.junit.After;

/**
 * Unit tests for {@link ReportPage}.
 */
public abstract class PageTestBase {

	protected MemoryMultiReportOutput output;

	protected ReportOutputFolder rootFolder;

	protected IHTMLReportContext context;

	protected HTMLSupport support;

	protected void setup() throws Exception {
		output = new MemoryMultiReportOutput();
		rootFolder = new ReportOutputFolder(output);
		final Resources resources = new Resources(rootFolder);
		final Table table = new Table();
		table.add("Element", null, new LabelColumn(), true);
		context = new IHTMLReportContext() {

			public ILanguageNames getLanguageNames() {
				return new JavaNames();
			}

			public Resources getResources() {
				return resources;
			}

			public Table getTable() {
				return table;
			}

			public String getFooterText() {
				return "CustomFooter";
			}

			public ILinkable getSessionsPage() {
				return new LinkableStub("sessions.html", "Sessions",
						Styles.EL_SESSION);
			}

			public String getOutputEncoding() {
				return "UTF-8";
			}

			public IIndexUpdate getIndexUpdate() {
				return new IIndexUpdate() {
					public void addClass(ILinkable link, long classid) {
					}
				};
			}

			public Locale getLocale() {
				return Locale.ENGLISH;
			}

		};
		support = new HTMLSupport();
	}

	@After
	public void teardown() throws IOException {
		output.close();
		output.assertAllClosed();
	}

}