unfinished release guide. It would be nice to have a html version.
[poi.git] / src / scratchpad / ooxml-testcases / org / apache / poi / hslf / TestHSLFXML.java
blobfd4653a854b1bb05eeaebba89995c58ba2c7db1b
1 /* ====================================================================
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================== */
17 package org.apache.poi.hslf;
19 import java.io.File;
21 import org.apache.poi.hxf.HXFDocument;
22 import org.openxml4j.opc.Package;
23 import org.openxml4j.opc.PackagePart;
24 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideIdListEntry;
25 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
27 import junit.framework.TestCase;
29 public class TestHSLFXML extends TestCase {
30 private File sampleFile;
32 protected void setUp() throws Exception {
33 super.setUp();
35 sampleFile = new File(
36 System.getProperty("HSLF.testdata.path") +
37 File.separator + "sample.pptx"
41 public void testContainsMainContentType() throws Exception {
42 Package pack = HXFDocument.openPackage(sampleFile);
44 boolean found = false;
45 for(PackagePart part : pack.getParts()) {
46 if(part.getContentType().equals(HSLFXML.MAIN_CONTENT_TYPE)) {
47 found = true;
49 System.out.println(part);
51 assertTrue(found);
54 public void testOpen() throws Exception {
55 HXFDocument.openPackage(sampleFile);
57 HSLFXML xml;
59 // With the finalised uri, should be fine
60 xml = new HSLFXML(
61 HXFDocument.openPackage(sampleFile)
64 // Check the core
65 assertNotNull(xml.getPresentation());
67 // Check it has some slides
68 assertTrue(
69 xml.getSlideReferences().sizeOfSldIdArray() > 0
71 assertTrue(
72 xml.getSlideMasterReferences().sizeOfSldMasterIdArray() > 0
76 public void testSlideBasics() throws Exception {
77 HSLFXML xml = new HSLFXML(
78 HXFDocument.openPackage(sampleFile)
81 // Should have 1 master
82 assertEquals(1, xml.getSlideMasterReferences().sizeOfSldMasterIdArray());
83 assertEquals(1, xml.getSlideMasterReferences().getSldMasterIdArray().length);
85 // Should have three sheets
86 assertEquals(2, xml.getSlideReferences().sizeOfSldIdArray());
87 assertEquals(2, xml.getSlideReferences().getSldIdArray().length);
89 // Check they're as expected
90 CTSlideIdListEntry[] slides = xml.getSlideReferences().getSldIdArray();
91 assertEquals(256, slides[0].getId());
92 assertEquals(257, slides[1].getId());
93 assertEquals("rId2", slides[0].getId2());
94 assertEquals("rId3", slides[1].getId2());
96 // Now get those objects
97 assertNotNull(xml.getSlide(slides[0]));
98 assertNotNull(xml.getSlide(slides[1]));
100 // And check they have notes as expected
101 assertNotNull(xml.getNotes(slides[0]));
102 assertNotNull(xml.getNotes(slides[1]));
104 // And again for the master
105 CTSlideMasterIdListEntry[] masters =
106 xml.getSlideMasterReferences().getSldMasterIdArray();
107 assertEquals(2147483648l, masters[0].getId());
108 assertEquals("rId1", masters[0].getId2());
109 assertNotNull(xml.getSlideMaster(masters[0]));
112 public void testMetadataBasics() throws Exception {
113 HSLFXML xml = new HSLFXML(
114 HXFDocument.openPackage(sampleFile)
117 assertNotNull(xml.getCoreProperties());
118 assertNotNull(xml.getExtendedProperties());
120 assertEquals("Microsoft Office PowerPoint", xml.getExtendedProperties().getApplication());
121 assertEquals(0, xml.getExtendedProperties().getCharacters());
122 assertEquals(0, xml.getExtendedProperties().getLines());
124 assertEquals(null, xml.getCoreProperties().getTitleProperty().getValue());
125 assertEquals(null, xml.getCoreProperties().getSubjectProperty().getValue());