blob: d96201b89f2ceed3ac9a268660a51de1b4bb1db4 [file] [log] [blame]
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.usermodel;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.apache.poi.POIDataSamples;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Tests that SlideShow finds the right records as its most recent ones
*/
public final class TestMostRecentRecords {
// HSLFSlideShow primed on the test data
private HSLFSlideShowImpl hss;
// SlideShow primed on the test data
private HSLFSlideShow ss;
@BeforeEach
void setup() throws Exception {
POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
hss = new HSLFSlideShowImpl(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
ss = new HSLFSlideShow(hss);
}
@Test
void testCount() {
// Most recent core records
org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
// Master sheet + master notes + 2 slides + 2 notes + document
assertEquals(7, mrcr.length);
}
@Test
void testRightRecordTypes() {
// Most recent core records
org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
// Document
assertEquals(1000, mrcr[0].getRecordType());
// Notes of master
assertEquals(1008, mrcr[1].getRecordType());
// Master
assertEquals(1016, mrcr[2].getRecordType());
// Slide
assertEquals(1006, mrcr[3].getRecordType());
// Notes
assertEquals(1008, mrcr[4].getRecordType());
// Slide
assertEquals(1006, mrcr[5].getRecordType());
// Notes
assertEquals(1008, mrcr[6].getRecordType());
}
@Test
void testCorrectRecords() {
// Most recent core records
org.apache.poi.hslf.record.Record[] mrcr = ss.getMostRecentCoreRecords();
// All records
org.apache.poi.hslf.record.Record[] allr = hss.getRecords();
// Ensure they are the right (latest) version of each
// Document - late version
assertEquals(allr[12], mrcr[0]);
// Notes of master - unchanged
assertEquals(allr[2], mrcr[1]);
// Master - unchanged
assertEquals(allr[1], mrcr[2]);
// Slide - added at start
assertEquals(allr[3], mrcr[3]);
// Notes - added at start
assertEquals(allr[4], mrcr[4]);
// Slide - added later and then changed
assertEquals(allr[13], mrcr[5]);
// Notes - added later but not changed
assertEquals(allr[9], mrcr[6]);
}
}