aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-07-17 12:16:58 +0000
committerJaven O'Neal <onealj@apache.org>2016-07-17 12:16:58 +0000
commit941daf4cacccc287a643df68df3d03feb0ec8064 (patch)
treea1d5e78a72ca20b7d7e20fc84076ce6196831912
parent5d0b2fa59fa16fe869ad2b02a801e9fed016e481 (diff)
downloadpoi-941daf4cacccc287a643df68df3d03feb0ec8064.tar.gz
poi-941daf4cacccc287a643df68df3d03feb0ec8064.zip
bug 58190: add unit tests for XMLSlideShow#addPicture and XMLSlideShow#findPicture
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753065 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java
index b1224cbc04..06e55aeca1 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java
@@ -19,13 +19,18 @@ package org.apache.poi.xslf.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import org.apache.poi.POIDataSamples;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.junit.Before;
import org.junit.Test;
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMasterIdListEntry;
@@ -168,4 +173,45 @@ public class TestXMLSlideShow {
xmlComments.close();
xml.close();
}
+
+ @Test
+ public void addPicture_File() throws IOException {
+ XMLSlideShow xml = new XMLSlideShow();
+ File f = slTests.getFile("clock.jpg");
+
+ assertEquals(0, xml.getPictureData().size());
+ XSLFPictureData picture = xml.addPicture(f, PictureType.JPEG);
+ assertEquals(1, xml.getPictureData().size());
+ assertSame(picture, xml.getPictureData().get(0));
+
+ xml.close();
+ }
+
+ @Test
+ public void addPicture_Stream() throws IOException {
+ XMLSlideShow xml = new XMLSlideShow();
+ InputStream stream = slTests.openResourceAsStream("clock.jpg");
+
+ assertEquals(0, xml.getPictureData().size());
+ XSLFPictureData picture = xml.addPicture(stream, PictureType.JPEG);
+ assertEquals(1, xml.getPictureData().size());
+ assertSame(picture, xml.getPictureData().get(0));
+
+ xml.close();
+ }
+
+ /** also tests {@link XMLSlideShow#addPicture(byte[], PictureType)} */
+ @Test
+ public void findPicture() throws IOException {
+ XMLSlideShow xml = new XMLSlideShow();
+ byte[] data = slTests.readFile("clock.jpg");
+
+ assertNull(xml.findPictureData(data));
+ XSLFPictureData picture = xml.addPicture(data, PictureType.JPEG);
+ XSLFPictureData found = xml.findPictureData(data);
+ assertNotNull(found);
+ assertEquals(picture, found);
+
+ xml.close();
+ }
}