blob: 2bdb831faf4e7f9136a9ee707d79b408365533b1 (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ua.tests.help.toc;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.help.internal.toc.Toc;
import org.eclipse.help.internal.toc.TocBuilder;
import org.eclipse.help.internal.toc.TocFile;
import org.eclipse.help.ui.internal.HelpUIPlugin;
import org.eclipse.ua.tests.help.util.TocModelSerializer;
import org.eclipse.ua.tests.help.util.TocModelSerializerTest;
import org.eclipse.ua.tests.plugin.UserAssistanceTestPlugin;
import org.eclipse.ua.tests.util.FileUtil;
import org.osgi.framework.Bundle;
public class ParserTest extends TestCase {
/*
* Returns an instance of this Test.
*/
public static Test suite() {
return new TestSuite(ParserTest.class);
}
/*
* Ensure that org.eclipse.help.ui is started. It contributes extra content
* filtering that is used by this test. See UIContentFilterProcessor.
*/
protected void setUp() throws Exception {
HelpUIPlugin.getDefault();
}
public void testParser() {
Collection tocFiles = TocModelSerializerTest.getTocFiles();
TocBuilder builder = new TocBuilder();
builder.build(tocFiles);
Collection builtTocs = builder.getBuiltTocs();
Iterator iter = builtTocs.iterator();
while (iter.hasNext()) {
Toc toc = (Toc)iter.next();
TocFile file = toc.getTocFile();
Bundle bundle = UserAssistanceTestPlugin.getDefault().getBundle();
String relativePath = file.getHref();
/*
* Only test what's in the toc test data folder.
*/
if (relativePath.startsWith("data/help/toc/")) {
try {
String expected = FileUtil.getResultFileContents(bundle, relativePath);
String actual = TocModelSerializer.serialize(toc);
Assert.assertEquals("Serialized toc model for " + relativePath + " did not match the expected result", expected, actual);
}
catch(IOException e) {
Assert.fail("An error occured while loading expected result file for TOC at: " + relativePath + ": " + e);
}
}
}
}
}
|