From ca46ef0721004eec6efd557db21093d5ed0a9257 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 9 Jun 2005 15:18:17 +0000 Subject: [PATCH] Add tests for more classes git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353712 13f79535-47bb-0310-9956-ffa450edef68 --- .../hslf/extractor/TestCruddyExtractor.java | 93 +++++++++++++++++++ .../apache/poi/hslf/record/TestNotesAtom.java | 59 ++++++++++++ .../apache/poi/hslf/record/TestSlideAtom.java | 76 +++++++++++++++ .../poi/hslf/record/TestUserEditAtom.java | 65 +++++++++++++ 4 files changed, 293 insertions(+) create mode 100644 src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java create mode 100644 src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java create mode 100644 src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java create mode 100644 src/scratchpad/testcases/org/apache/poi/hslf/record/TestUserEditAtom.java diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java new file mode 100644 index 0000000000..75e6b8dae8 --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestCruddyExtractor.java @@ -0,0 +1,93 @@ + +/* ==================================================================== + Copyright 2002-2004 Apache Software Foundation + + Licensed 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.extractor; + + +import junit.framework.TestCase; +import java.util.Vector; + +/** + * Tests that the QuickButCruddyTextExtractor works correctly + * + * @author Nick Burch (nick at torchbox dot com) + */ +public class TestCruddyExtractor extends TestCase { + // Extractor primed on the test data + private QuickButCruddyTextExtractor te; + // All the text to be found in the file + String[] allTheText = new String[] { + "This is a test title", + "This is a test subtitle\nThis is on page 1", + "Click to edit Master title style", + "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level", + "*", + "*", + "*", + "*", + "*", + "Click to edit Master text styles\nSecond level\nThird level\nFourth level\nFifth level", + "*", + "*", + "These are the notes for page 1", + "This is a test title", + "This is a test subtitle\nThis is on page 1", + "This is the title on page 2", + "This is page two\nIt has several blocks of text\nNone of them have formattingT", + "These are the notes on page two, again lacking formatting", + "This is a test title", + "This is a test subtitle\nThis is on page 1", + "This is the title on page 2", + "This is page two\nIt has several blocks of text\nNone of them have formatting", + }; + + public TestCruddyExtractor() throws Exception { + String dirname = System.getProperty("HSLF.testdata.path"); + String filename = dirname + "/basic_test_ppt_file.ppt"; + te = new QuickButCruddyTextExtractor(filename); + } + + public void testReadAsVector() throws Exception { + // Extract the text from the file as a vector + Vector foundTextV = te.getTextAsVector(); + + // Ensure they match + assertEquals(allTheText.length,foundTextV.size()); + for(int i=0; i