use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestEPUB method testUnpackFile.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#unpack(java.io.File)}.
* <ul>
* <li>Unpacked EPUB shall have the same contents as the packed one.</li>
* </ul>
*
* @throws Exception
*/
@Test
public final void testUnpackFile() throws Exception {
EPUB epub = new EPUB();
Publication oebps = new OPSPublication();
oebps.addItem(new File("testdata/plain-page.xhtml"));
epub.add(oebps);
epub.pack(epubFile, epubFolder);
EPUB epub2 = new EPUB();
epub2.unpack(epubFile);
assertEquals(1, epub2.getOPSPublications().size());
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestOPSPublication method testSetCover.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.Publication#setCover(java.io.File, java.lang.String)} .
* <ul>
* <li>Cover page SVG shall exist in the unpacked folder</li>
* <li>Cover page HTML shall exist in the unpacked folder</li>
* </ul>
*
* @throws Exception
*/
@Test
public final void testSetCover() throws Exception {
oebps.setCover(new File("testdata/drawing.svg"), "Title");
oebps.addItem(new File("testdata/plain-page.xhtml"));
epub.add(oebps);
epub.pack(epubFile);
EPUB epub2 = new EPUB();
epub2.unpack(epubFile, epubFolder);
Publication oebps = epub2.getOPSPublications().get(0);
File root = oebps.getRootFolder();
File svg = new File(root.getAbsolutePath() + File.separator + "drawing.svg");
Assert.assertTrue(svg.exists());
File html = new File(root.getAbsolutePath() + File.separator + "cover-page.xhtml");
Assert.assertTrue(html.exists());
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestOPSPublication method testReadTableOfContents.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.OPSPublication#readTableOfContents(java.io.File)} .
*
* @throws Exception
*/
@Test
public final void testReadTableOfContents() throws Exception {
epub.add(oebps);
oebps.addItem(new File("testdata/plain-page.xhtml"));
epub.pack(epubFile);
EPUB epub_in = new EPUB();
epub_in.unpack(epubFile, epubFolder);
Publication oebps_in = epub_in.getOPSPublications().get(0);
assertTrue(oebps_in.getTableOfContents() != null);
assertTrue(oebps_in.getTableOfContents() instanceof Ncx);
Ncx ncx = (Ncx) oebps_in.getTableOfContents();
NavPoint h1_1 = ncx.getNavMap().getNavPoints().get(0);
NavPoint h1_2 = ncx.getNavMap().getNavPoints().get(1);
assertEquals("First item", getText(h1_1));
assertEquals("Second item", getText(h1_2));
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestPublication method test_Bug360701.
/**
* Test method for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=360701">bug 360701</a>: [epub] Automatic
* inclusion of referenced resources don't work for WikiText generated HTML.
*
* @throws Exception
*/
@Test
public final void test_Bug360701() throws Exception {
oebps.setIncludeReferencedResources(true);
// This page is similar to what WikiText would generate
oebps.addItem(new File("testdata/plain-page_link.html"));
epub.add(oebps);
// Included resources will only be added when we pack
epub.pack(epubFile);
EPUB epub2 = new EPUB();
epub2.unpack(epubFile, epubFolder);
Publication oebps = epub2.getOPSPublications().get(0);
File root = oebps.getRootFolder();
File svg = new File(root.getAbsolutePath() + File.separator + "drawing.svg");
Assert.assertTrue(svg.exists());
File svg2 = new File(root.getAbsolutePath() + File.separator + "images" + File.separator + "subfolder-drawing.svg");
Assert.assertTrue(svg2.exists());
File html = new File(root.getAbsolutePath() + File.separator + "plain-page_no-header.html");
Assert.assertTrue(html.exists());
}
use of org.eclipse.mylyn.docs.epub.core.Publication in project mylyn.docs by eclipse.
the class TestEPUB method testGetOPSPublications.
/**
* Test method for {@link org.eclipse.mylyn.docs.epub.core.EPUB#getOPSPublications()}.
* <p>
* One OPS-publication and one SVG drawing are added. Only the OPS-publication shall be returned.
* </p>
*
* @throws Exception
*/
@Test
public final void testGetOPSPublications() throws Exception {
EPUB epub = new EPUB();
Publication oebps = new OPSPublication();
epub.add(oebps);
File drawing = new File("testdata/drawing.svg");
epub.add(drawing, "image/svg+xml");
assertEquals(1, epub.getOPSPublications().size());
}
Aggregations