]> source.dussan.org Git - poi.git/commitdiff
Add ExHyperlink tests against a real file
authorNick Burch <nick@apache.org>
Wed, 17 Jan 2007 17:12:26 +0000 (17:12 +0000)
committerNick Burch <nick@apache.org>
Wed, 17 Jan 2007 17:12:26 +0000 (17:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@497090 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
src/scratchpad/testcases/org/apache/poi/hslf/record/TestExHyperlink.java

index e2194ab7bc559548e85e5ff985c1850f075b02ed..5e69dcead1c4b9584e55d0be09957c81ae63591c 100644 (file)
@@ -59,7 +59,7 @@ public class RecordTypes {
     public static final Type DocRoutingSlip = new Type(1030,null);
     public static final Type OutlineViewInfo = new Type(1031,null);
     public static final Type SorterViewInfo = new Type(1032,null);
-    public static final Type ExObjList = new Type(1033,null);
+    public static final Type ExObjList = new Type(1033,DummyRecordWithChildren.class);
     public static final Type ExObjListAtom = new Type(1034,null);
     public static final Type PPDrawingGroup = new Type(1035,PPDrawingGroup.class);
     public static final Type PPDrawing = new Type(1036,PPDrawing.class);
index 64a5dd30d4d7774c50d195ff97a609225b461256..ad489a5d50a358122d0975260c1d084a175620a5 100644 (file)
@@ -24,8 +24,12 @@ package org.apache.poi.hslf.record;
 import junit.framework.TestCase;
 import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 
+import org.apache.poi.hslf.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.SlideShow;
+
 /**
  * Tests that ExHyperlink works properly.
  *
@@ -95,6 +99,46 @@ public class TestExHyperlink extends TestCase {
        }
        
        public void testRealFile() throws Exception {
-               // TODO
+               String dirname = System.getProperty("HSLF.testdata.path");
+               HSLFSlideShow hss = new HSLFSlideShow(dirname + "WithLinks.ppt");
+               SlideShow ss = new SlideShow(hss);
+               
+               // Get the document
+               Document doc = ss.getDocumentRecord();
+               // Get the ExObjList
+               RecordContainer exObjList = null;
+               for(int i=0; i<doc._children.length; i++) {
+                       if(doc._children[i].getRecordType() == RecordTypes.ExObjList.typeID) {
+                               exObjList = (RecordContainer)doc._children[i];
+                       }
+               }
+               assertNotNull(exObjList);
+               
+               // Within that, grab out the Hyperlink atoms
+               ArrayList linksA = new ArrayList();
+               for(int i=0; i<exObjList._children.length; i++) {
+                       if(exObjList._children[i] instanceof ExHyperlink) {
+                               linksA.add(exObjList._children[i]);
+                       }
+               }
+               
+               // Should be 4 of them
+               assertEquals(4, linksA.size());
+               ExHyperlink[] links = new ExHyperlink[linksA.size()];
+               linksA.toArray(links);
+               
+               // Check they have what we expect in them
+               assertEquals(1, links[0].getExHyperlinkAtom().getNumber());
+               assertEquals("http://jakarta.apache.org/poi/", links[0].getLinkURL());
+               
+               assertEquals(2, links[1].getExHyperlinkAtom().getNumber());
+               assertEquals("http://slashdot.org/", links[1].getLinkURL());
+               
+               assertEquals(3, links[2].getExHyperlinkAtom().getNumber());
+               assertEquals("http://jakarta.apache.org/poi/hssf/", links[2].getLinkURL());
+               
+               assertEquals(4, links[3].getExHyperlinkAtom().getNumber());
+               assertEquals("http://jakarta.apache.org/hslf/", links[3].getLinkURL());
+               
        }
 }