use of org.eclipse.mylyn.docs.epub.ncx.Ncx in project mylyn.docs by eclipse.
the class TestOPSPublication method testGenerateEmptyTableOfContents.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#generateTableOfContents()} .
* <ul>
* <li>Table of contents shall exist but be empty if not otherwise specified.</li>
* </ul>
*
* @throws Exception
*/
public final void testGenerateEmptyTableOfContents() throws Exception {
epub.add(oebps);
oebps.addItem(new File("testdata/plain-page.xhtml"));
oebps.setGenerateToc(false);
epub.pack(epubFile);
assertTrue(oebps.getTableOfContents() != null);
assertTrue(oebps.getTableOfContents() instanceof Ncx);
}
use of org.eclipse.mylyn.docs.epub.ncx.Ncx in project mylyn.docs by eclipse.
the class TestTOCGenerator method testMissingIdentifier.
@Test
public void testMissingIdentifier() throws ParserConfigurationException, SAXException, IOException {
String html = "<body><h1 id='h1-1'>test</h1><h2>test</h2><h1 id='h1-2'>test</h1></body>";
Ncx ncx = createNcx();
TOCGenerator.parse(new InputSource(new StringReader(html)), "test.html", ncx, 0);
EList<NavPoint> points = ncx.getNavMap().getNavPoints();
assertEquals(2, points.size());
// "h2" will be added as a sub-node to the first "h1" regardless of the
// missing identifier.
assertEquals(1, points.get(0).getNavPoints().size());
}
use of org.eclipse.mylyn.docs.epub.ncx.Ncx in project mylyn.docs by eclipse.
the class TestTOCGenerator method testMissingParent.
@Test
public void testMissingParent() throws ParserConfigurationException, SAXException, IOException {
String html = "<body><h1 id='h1-1'>test</h1><h3 id='h3-1'>test</h3><h1 id='h1-2'>test</h1></body>";
Ncx ncx = createNcx();
TOCGenerator.parse(new InputSource(new StringReader(html)), "test.html", ncx, 0);
EList<NavPoint> points = ncx.getNavMap().getNavPoints();
// should be two items at level 1 and one at level 2
assertEquals(2, points.size());
assertEquals(1, points.get(0).getNavPoints().size());
}
use of org.eclipse.mylyn.docs.epub.ncx.Ncx in project mylyn.docs by eclipse.
the class TestTOCGenerator method createNcx.
private Ncx createNcx() {
Ncx ncx = NCXFactory.eINSTANCE.createNcx();
NavMap navMap = NCXFactory.eINSTANCE.createNavMap();
ncx.setNavMap(navMap);
return ncx;
}
use of org.eclipse.mylyn.docs.epub.ncx.Ncx in project mylyn.docs by eclipse.
the class TestTOCGenerator method testCrazyStructure.
@Test
public void testCrazyStructure() throws ParserConfigurationException, SAXException, IOException {
String html = "<body><h3 id='h3-1'>test</h3><h2 id='h2-1'>test</h2><h1 id='h1-1'>test</h1></body>";
Ncx ncx = createNcx();
TOCGenerator.parse(new InputSource(new StringReader(html)), "test.html", ncx, 0);
EList<NavPoint> points = ncx.getNavMap().getNavPoints();
// "h3" will be created as a "h1" and "h2" added to it
assertEquals(2, points.size());
}
Aggregations