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;
19:
20: import junit.framework.TestCase;
21: import org.apache.poi.hslf.record.*;
22:
23: /**
24: * Tests that HSLFSlideShow returns the right numbers of key records when
25: * it parses the test file
26: *
27: * @author Nick Burch (nick at torchbox dot com)
28: */
29: public class TestRecordCounts extends TestCase {
30: // HSLFSlideShow primed on the test data
31: private HSLFSlideShow ss;
32:
33: public TestRecordCounts() throws Exception {
34: String dirname = System.getProperty("HSLF.testdata.path");
35: String filename = dirname + "/basic_test_ppt_file.ppt";
36: ss = new HSLFSlideShow(filename);
37: }
38:
39: public void testSheetsCount() throws Exception {
40: // Top level
41: Record[] r = ss.getRecords();
42:
43: int count = 0;
44: for (int i = 0; i < r.length; i++) {
45: if (r[i] instanceof Slide) {
46: count++;
47: }
48: }
49: // Currently still sees the Master Sheet, but might not in the future
50: assertEquals(3, count);
51: }
52:
53: public void testNotesCount() throws Exception {
54: // Top level
55: Record[] r = ss.getRecords();
56:
57: int count = 0;
58: for (int i = 0; i < r.length; i++) {
59: if (r[i] instanceof Notes && r[i].getRecordType() == 1008l) {
60: count++;
61: }
62: }
63: // Two real sheets, plus the master sheet
64: assertEquals(3, count);
65: }
66:
67: public void testSlideListWithTextCount() throws Exception {
68: // Second level
69: Record[] rt = ss.getRecords();
70: Record[] r = rt[0].getChildRecords();
71:
72: int count = 0;
73: for (int i = 0; i < r.length; i++) {
74: if (r[i] instanceof SlideListWithText
75: && r[i].getRecordType() == 4080l) {
76: count++;
77: }
78: }
79: // Two real sheets, plus the master sheet
80: assertEquals(3, count);
81: }
82: }
|