Source Code Cross Referenced for TestReOrderingSlides.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 java.io.ByteArrayInputStream;
021:        import java.io.ByteArrayOutputStream;
022:
023:        import junit.framework.TestCase;
024:        import org.apache.poi.hslf.*;
025:        import org.apache.poi.hslf.model.*;
026:
027:        /**
028:         * Tests that SlideShow can re-order slides properly
029:         *
030:         * @author Nick Burch (nick at torchbox dot com)
031:         */
032:        public class TestReOrderingSlides extends TestCase {
033:            // A SlideShow with one slide
034:            private HSLFSlideShow hss_one;
035:            private SlideShow ss_one;
036:
037:            // A SlideShow with two slides
038:            private HSLFSlideShow hss_two;
039:            private SlideShow ss_two;
040:
041:            // A SlideShow with three slides
042:            private HSLFSlideShow hss_three;
043:            private SlideShow ss_three;
044:
045:            /**
046:             * Create/open the slideshows
047:             */
048:            public void setUp() throws Exception {
049:                String dirname = System.getProperty("HSLF.testdata.path");
050:
051:                String filename = dirname + "/Single_Coloured_Page.ppt";
052:                hss_one = new HSLFSlideShow(filename);
053:                ss_one = new SlideShow(hss_one);
054:
055:                filename = dirname + "/basic_test_ppt_file.ppt";
056:                hss_two = new HSLFSlideShow(filename);
057:                ss_two = new SlideShow(hss_two);
058:
059:                filename = dirname + "/incorrect_slide_order.ppt";
060:                hss_three = new HSLFSlideShow(filename);
061:                ss_three = new SlideShow(hss_three);
062:            }
063:
064:            /**
065:             * Test that we can "re-order" a slideshow with only 1 slide on it
066:             */
067:            public void testReOrder1() throws Exception {
068:                // Has one slide
069:                assertEquals(1, ss_one.getSlides().length);
070:                Slide s1 = ss_one.getSlides()[0];
071:
072:                // Check slide 1 is as expected
073:                assertEquals(256, s1._getSheetNumber());
074:                assertEquals(3, s1._getSheetRefId());
075:                assertEquals(1, s1.getSlideNumber());
076:
077:                // Now move it to one
078:                ss_one.reorderSlide(1, 1);
079:
080:                // Write out, and read back in
081:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
082:                hss_one.write(baos);
083:                ByteArrayInputStream bais = new ByteArrayInputStream(baos
084:                        .toByteArray());
085:
086:                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
087:                SlideShow ss_read = new SlideShow(hss_read);
088:
089:                // Check it still has 1 slide
090:                assertEquals(1, ss_read.getSlides().length);
091:
092:                // And check it's as expected
093:                s1 = ss_read.getSlides()[0];
094:                assertEquals(256, s1._getSheetNumber());
095:                assertEquals(3, s1._getSheetRefId());
096:                assertEquals(1, s1.getSlideNumber());
097:            }
098:
099:            /**
100:             * Test doing a dummy re-order on a slideshow with
101:             *  two slides in it
102:             */
103:            public void testReOrder2() throws Exception {
104:                // Has two slides
105:                assertEquals(2, ss_two.getSlides().length);
106:                Slide s1 = ss_two.getSlides()[0];
107:                Slide s2 = ss_two.getSlides()[1];
108:
109:                // Check slide 1 is as expected
110:                assertEquals(256, s1._getSheetNumber());
111:                assertEquals(4, s1._getSheetRefId()); // master has notes
112:                assertEquals(1, s1.getSlideNumber());
113:                // Check slide 2 is as expected
114:                assertEquals(257, s2._getSheetNumber());
115:                assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
116:                assertEquals(2, s2.getSlideNumber());
117:
118:                // Don't swap them around
119:                ss_two.reorderSlide(2, 2);
120:
121:                // Write out, and read back in
122:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
123:                hss_two.write(baos);
124:                ByteArrayInputStream bais = new ByteArrayInputStream(baos
125:                        .toByteArray());
126:
127:                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
128:                SlideShow ss_read = new SlideShow(hss_read);
129:
130:                // Check it still has 2 slides
131:                assertEquals(2, ss_read.getSlides().length);
132:
133:                // And check it's as expected
134:                s1 = ss_read.getSlides()[0];
135:                s2 = ss_read.getSlides()[1];
136:                assertEquals(256, s1._getSheetNumber());
137:                assertEquals(4, s1._getSheetRefId());
138:                assertEquals(1, s1.getSlideNumber());
139:                assertEquals(257, s2._getSheetNumber());
140:                assertEquals(6, s2._getSheetRefId());
141:                assertEquals(2, s2.getSlideNumber());
142:            }
143:
144:            /**
145:             * Test re-ordering slides in a slideshow with 2 slides on it
146:             */
147:            public void testReOrder2swap() throws Exception {
148:                // Has two slides
149:                assertEquals(2, ss_two.getSlides().length);
150:                Slide s1 = ss_two.getSlides()[0];
151:                Slide s2 = ss_two.getSlides()[1];
152:
153:                // Check slide 1 is as expected
154:                assertEquals(256, s1._getSheetNumber());
155:                assertEquals(4, s1._getSheetRefId()); // master has notes
156:                assertEquals(1, s1.getSlideNumber());
157:                // Check slide 2 is as expected
158:                assertEquals(257, s2._getSheetNumber());
159:                assertEquals(6, s2._getSheetRefId()); // master and 1 have notes
160:                assertEquals(2, s2.getSlideNumber());
161:
162:                // Swap them around
163:                ss_two.reorderSlide(2, 1);
164:
165:                // Write out, and read back in
166:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
167:                hss_two.write(baos);
168:                ByteArrayInputStream bais = new ByteArrayInputStream(baos
169:                        .toByteArray());
170:
171:                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
172:                SlideShow ss_read = new SlideShow(hss_read);
173:
174:                // Check it still has 2 slides
175:                assertEquals(2, ss_read.getSlides().length);
176:
177:                // And check it's as expected
178:                s1 = ss_read.getSlides()[0];
179:                s2 = ss_read.getSlides()[1];
180:                assertEquals(257, s1._getSheetNumber());
181:                assertEquals(6, s1._getSheetRefId());
182:                assertEquals(1, s1.getSlideNumber());
183:                assertEquals(256, s2._getSheetNumber());
184:                assertEquals(4, s2._getSheetRefId());
185:                assertEquals(2, s2.getSlideNumber());
186:            }
187:
188:            /**
189:             * Test doing a dummy re-order on a slideshow with
190:             *  three slides in it
191:             */
192:            public void testReOrder3() throws Exception {
193:                // Has three slides
194:                assertEquals(3, ss_three.getSlides().length);
195:                Slide s1 = ss_three.getSlides()[0];
196:                Slide s2 = ss_three.getSlides()[1];
197:                Slide s3 = ss_three.getSlides()[2];
198:
199:                // Check slide 1 is as expected
200:                assertEquals(256, s1._getSheetNumber());
201:                assertEquals(3, s1._getSheetRefId()); // no notes on master
202:                assertEquals(1, s1.getSlideNumber());
203:                // Check slide 2 is as expected (was re-ordered from 3)
204:                assertEquals(258, s2._getSheetNumber());
205:                assertEquals(5, s2._getSheetRefId()); // no notes on slide
206:                assertEquals(2, s2.getSlideNumber());
207:                // Check slide 3 is as expected (was re-ordered from 2)
208:                assertEquals(257, s3._getSheetNumber());
209:                assertEquals(4, s3._getSheetRefId()); // no notes on slide
210:                assertEquals(3, s3.getSlideNumber());
211:
212:                // Don't swap them around
213:                ss_three.reorderSlide(2, 2);
214:
215:                // Write out, and read back in
216:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
217:                hss_three.write(baos);
218:                ByteArrayInputStream bais = new ByteArrayInputStream(baos
219:                        .toByteArray());
220:
221:                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
222:                SlideShow ss_read = new SlideShow(hss_read);
223:
224:                // Check it still has 3 slides
225:                assertEquals(3, ss_read.getSlides().length);
226:
227:                // And check it's as expected
228:                s1 = ss_read.getSlides()[0];
229:                s2 = ss_read.getSlides()[1];
230:                s3 = ss_read.getSlides()[2];
231:
232:                assertEquals(256, s1._getSheetNumber());
233:                assertEquals(3, s1._getSheetRefId());
234:                assertEquals(1, s1.getSlideNumber());
235:                assertEquals(258, s2._getSheetNumber());
236:                assertEquals(5, s2._getSheetRefId());
237:                assertEquals(2, s2.getSlideNumber());
238:                assertEquals(257, s3._getSheetNumber());
239:                assertEquals(4, s3._getSheetRefId());
240:                assertEquals(3, s3.getSlideNumber());
241:            }
242:
243:            /**
244:             * Test re-ordering slides in a slideshow with 3 slides on it
245:             */
246:            public void testReOrder3swap() throws Exception {
247:                // Has three slides
248:                assertEquals(3, ss_three.getSlides().length);
249:                Slide s1 = ss_three.getSlides()[0];
250:                Slide s2 = ss_three.getSlides()[1];
251:                Slide s3 = ss_three.getSlides()[2];
252:
253:                // Check slide 1 is as expected
254:                assertEquals(256, s1._getSheetNumber());
255:                assertEquals(3, s1._getSheetRefId()); // no notes on master
256:                assertEquals(1, s1.getSlideNumber());
257:                // Check slide 2 is as expected (was re-ordered from 3)
258:                assertEquals(258, s2._getSheetNumber());
259:                assertEquals(5, s2._getSheetRefId()); // no notes on slide
260:                assertEquals(2, s2.getSlideNumber());
261:                // Check slide 3 is as expected (was re-ordered from 2)
262:                assertEquals(257, s3._getSheetNumber());
263:                assertEquals(4, s3._getSheetRefId()); // no notes on slide
264:                assertEquals(3, s3.getSlideNumber());
265:
266:                // Put 3 in place of 1
267:                // (1 -> 2, 2 -> 3)
268:                ss_three.reorderSlide(3, 1);
269:
270:                // Write out, and read back in
271:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
272:                hss_three.write(baos);
273:                ByteArrayInputStream bais = new ByteArrayInputStream(baos
274:                        .toByteArray());
275:
276:                HSLFSlideShow hss_read = new HSLFSlideShow(bais);
277:                SlideShow ss_read = new SlideShow(hss_read);
278:
279:                // Check it still has 3 slides
280:                assertEquals(3, ss_read.getSlides().length);
281:
282:                // And check it's as expected
283:                s1 = ss_read.getSlides()[0];
284:                s2 = ss_read.getSlides()[1];
285:                s3 = ss_read.getSlides()[2];
286:
287:                assertEquals(257, s1._getSheetNumber());
288:                assertEquals(4, s1._getSheetRefId());
289:                assertEquals(1, s1.getSlideNumber());
290:                assertEquals(256, s2._getSheetNumber());
291:                assertEquals(3, s2._getSheetRefId());
292:                assertEquals(2, s2.getSlideNumber());
293:                assertEquals(258, s3._getSheetNumber());
294:                assertEquals(5, s3._getSheetRefId());
295:                assertEquals(3, s3.getSlideNumber());
296:            }
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.