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.record.*;
23:
24: /**
25: * Tests that SlideShow finds the right records as its most recent ones
26: *
27: * @author Nick Burch (nick at torchbox dot com)
28: */
29: public class TestMostRecentRecords extends TestCase {
30: // HSLFSlideShow primed on the test data
31: private HSLFSlideShow hss;
32: // SlideShow primed on the test data
33: private SlideShow ss;
34:
35: public TestMostRecentRecords() throws Exception {
36: String dirname = System.getProperty("HSLF.testdata.path");
37: String filename = dirname + "/basic_test_ppt_file.ppt";
38: hss = new HSLFSlideShow(filename);
39: ss = new SlideShow(hss);
40: }
41:
42: public void testCount() throws Exception {
43: // Most recent core records
44: Record[] mrcr = ss.getMostRecentCoreRecords();
45:
46: // Master sheet + master notes + 2 slides + 2 notes + document
47: assertEquals(7, mrcr.length);
48: }
49:
50: public void testRightRecordTypes() throws Exception {
51: // Most recent core records
52: Record[] mrcr = ss.getMostRecentCoreRecords();
53:
54: // Document
55: assertEquals(1000, mrcr[0].getRecordType());
56: // Notes of master
57: assertEquals(1008, mrcr[1].getRecordType());
58: // Master
59: assertEquals(1016, mrcr[2].getRecordType());
60:
61: // Slide
62: assertEquals(1006, mrcr[3].getRecordType());
63: // Notes
64: assertEquals(1008, mrcr[4].getRecordType());
65: // Slide
66: assertEquals(1006, mrcr[5].getRecordType());
67: // Notes
68: assertEquals(1008, mrcr[6].getRecordType());
69: }
70:
71: public void testCorrectRecords() throws Exception {
72: // Most recent core records
73: Record[] mrcr = ss.getMostRecentCoreRecords();
74:
75: // All records
76: Record[] allr = hss.getRecords();
77:
78: // Ensure they are the right (latest) version of each
79:
80: // Document - late version
81: assertEquals(allr[12], mrcr[0]);
82: // Notes of master - unchanged
83: assertEquals(allr[2], mrcr[1]);
84: // Master - unchanged
85: assertEquals(allr[1], mrcr[2]);
86:
87: // Slide - added at start
88: assertEquals(allr[3], mrcr[3]);
89: // Notes - added at start
90: assertEquals(allr[4], mrcr[4]);
91: // Slide - added later and then changed
92: assertEquals(allr[13], mrcr[5]);
93: // Notes - added later but not changed
94: assertEquals(allr[9], mrcr[6]);
95: }
96: }
|