01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: http://www.apache.org/licenses/LICENSE-2.0
10:
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:
18: package org.apache.poi.hslf.usermodel;
19:
20: import junit.framework.TestCase;
21: import org.apache.poi.hslf.*;
22: import org.apache.poi.hslf.model.*;
23:
24: /**
25: * Tests that SlideShow returns the right number of Sheets and MetaSheets
26: *
27: * @author Nick Burch (nick at torchbox dot com)
28: */
29: public class TestCounts extends TestCase {
30: // SlideShow primed on the test data
31: private SlideShow ss;
32:
33: public TestCounts() throws Exception {
34: String dirname = System.getProperty("HSLF.testdata.path");
35: String filename = dirname + "/basic_test_ppt_file.ppt";
36: HSLFSlideShow hss = new HSLFSlideShow(filename);
37: ss = new SlideShow(hss);
38: }
39:
40: public void testSheetsCount() throws Exception {
41: Slide[] slides = ss.getSlides();
42: // Two sheets - master sheet is seperate
43: assertEquals(2, slides.length);
44:
45: // They are slides 1+2
46: assertEquals(1, slides[0].getSlideNumber());
47: assertEquals(2, slides[1].getSlideNumber());
48:
49: // The ref IDs are 4 and 6
50: assertEquals(4, slides[0]._getSheetRefId());
51: assertEquals(6, slides[1]._getSheetRefId());
52:
53: // These are slides 1+2 -> 256+257
54: assertEquals(256, slides[0]._getSheetNumber());
55: assertEquals(257, slides[1]._getSheetNumber());
56: }
57:
58: public void testNotesCount() throws Exception {
59: Notes[] notes = ss.getNotes();
60: // Two sheets -> two notes
61: // Note: there are also notes on the slide master
62: //assertEquals(3, notes.length); // When we do slide masters
63: assertEquals(2, notes.length);
64:
65: // First is for master
66: //assertEquals(-2147483648, notes[0]._getSheetNumber()); // When we do slide masters
67:
68: // Next two are for the two slides
69: assertEquals(256, notes[0]._getSheetNumber());
70: assertEquals(257, notes[1]._getSheetNumber());
71:
72: // They happen to go between the two slides in Ref terms
73: assertEquals(5, notes[0]._getSheetRefId());
74: assertEquals(7, notes[1]._getSheetRefId());
75: }
76: }
|