Source Code Cross Referenced for TestSlideOrdering.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hslf » usermodel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hslf.usermodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.hslf.usermodel;
019:
020:        import junit.framework.TestCase;
021:        import org.apache.poi.hslf.*;
022:        import org.apache.poi.hslf.model.*;
023:
024:        /**
025:         * Tests that SlideShow returns Sheets in the right order
026:         *
027:         * @author Nick Burch (nick at torchbox dot com)
028:         */
029:        public class TestSlideOrdering extends TestCase {
030:            // Simple slideshow, record order matches slide order
031:            private SlideShow ssA;
032:            // Complex slideshow, record order doesn't match slide order
033:            private SlideShow ssB;
034:
035:            public TestSlideOrdering() throws Exception {
036:                String dirname = System.getProperty("HSLF.testdata.path");
037:
038:                String filenameA = dirname + "/basic_test_ppt_file.ppt";
039:                HSLFSlideShow hssA = new HSLFSlideShow(filenameA);
040:                ssA = new SlideShow(hssA);
041:
042:                String filenameB = dirname + "/incorrect_slide_order.ppt";
043:                HSLFSlideShow hssB = new HSLFSlideShow(filenameB);
044:                ssB = new SlideShow(hssB);
045:            }
046:
047:            /**
048:             * Test the simple case - record order matches slide order
049:             */
050:            public void testSimpleCase() throws Exception {
051:                assertEquals(2, ssA.getSlides().length);
052:
053:                Slide s1 = ssA.getSlides()[0];
054:                Slide s2 = ssA.getSlides()[1];
055:
056:                String[] firstTRs = new String[] { "This is a test title",
057:                        "This is the title on page 2" };
058:
059:                assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
060:                assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
061:            }
062:
063:            /**
064:             * Test the complex case - record order differs from slide order
065:             */
066:            public void testComplexCase() throws Exception {
067:                assertEquals(3, ssB.getSlides().length);
068:
069:                Slide s1 = ssB.getSlides()[0];
070:                Slide s2 = ssB.getSlides()[1];
071:                Slide s3 = ssB.getSlides()[2];
072:
073:                String[] firstTRs = new String[] { "Slide 1", "Slide 2",
074:                        "Slide 3" };
075:
076:                assertEquals(firstTRs[0], s1.getTextRuns()[0].getText());
077:                assertEquals(firstTRs[1], s2.getTextRuns()[0].getText());
078:                assertEquals(firstTRs[2], s3.getTextRuns()[0].getText());
079:            }
080:
081:            /**
082:             * Assert that the order of slides is correct.
083:             *
084:             * @param filename  file name of the slide show to assert
085:             * @param titles    array of reference slide titles
086:             */
087:            protected void assertSlideOrdering(String filename, String[] titles)
088:                    throws Exception {
089:                SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));
090:                Slide[] slide = ppt.getSlides();
091:
092:                assertEquals(titles.length, slide.length);
093:                for (int i = 0; i < slide.length; i++) {
094:                    String title = slide[i].getTitle();
095:                    assertEquals("Wrong slide title in " + filename, titles[i],
096:                            title);
097:                }
098:            }
099:
100:            public void testTitles() throws Exception {
101:                String dirname = System.getProperty("HSLF.testdata.path");
102:
103:                assertSlideOrdering(dirname + "/basic_test_ppt_file.ppt",
104:                        new String[] { "This is a test title",
105:                                "This is the title on page 2" });
106:
107:                assertSlideOrdering(dirname + "/incorrect_slide_order.ppt",
108:                        new String[] { "Slide 1", "Slide 2", "Slide 3" });
109:
110:                assertSlideOrdering(dirname + "/next_test_ppt_file.ppt",
111:                        new String[] { "This is a test title",
112:                                "This is the title on page 2" });
113:
114:                assertSlideOrdering(dirname + "/Single_Coloured_Page.ppt",
115:                        new String[] { "This is a title, it" + (char) 0x2019
116:                                + "s in black" });
117:
118:                assertSlideOrdering(
119:                        dirname
120:                                + "/Single_Coloured_Page_With_Fonts_and_Alignments.ppt",
121:                        new String[] { "This is a title, it" + (char) 0x2019
122:                                + "s in black" });
123:
124:                assertSlideOrdering(
125:                        dirname + "/ParagraphStylesShorterThanCharStyles.ppt",
126:                        new String[] {
127:                                "ROMANCE: AN ANALYSIS",
128:                                "AGENDA",
129:                                "You are an important supplier of various items that I need",
130:                                (char) 0x0B
131:                                        + "Although The Psycho set back my relationship process, recovery is luckily enough under way",
132:                                "Since the time that we seriously go out together, you rank highly among existing relationships",
133:                                "Although our personal interests are mostly compatible, the greatest gap exists in Sex and Shopping",
134:                                "Your physical characteristics are strong when compared with your competition",
135:                                "The combination of your high physical appearance and personality rank you highly, although your sister is also a top prospect",
136:                                "When people found out that we were going out, their responses have been mixed",
137:                                "The benchmark of relationship lifecycles, suggests that we are on schedule",
138:                                "In summary we can say that we are on the right track, but we must remain aware of possible roadblocks ",
139:                                "THE ANSWER",
140:                                "Unfortunately a huge disconnect exists between my needs and your existing service",
141:                                "SUMMARY", });
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.