1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 /**
23  *
24  */
25 package fvt.gui.sd.headerandfooter;
26 
27 import static org.junit.Assert.*;
28 import static org.openoffice.test.common.Testspace.*;
29 import static org.openoffice.test.vcl.Tester.sleep;
30 import static testlib.gui.AppTool.*;
31 import static testlib.gui.UIMap.*;
32 
33 import org.junit.After;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.openoffice.test.common.FileUtil;
37 
38 public class DocumentWithHeaderFooter {
39 
40 	@Before
41 	public void setUp() throws Exception {
42 		app.start(true);
43 	}
44 
45 	@After
46 	public void tearDown() throws Exception {
47 		app.stop();
48 
49 	}
50 
51 	/**
52 	 * Test open AOO3.4 presentation with header and footer. edit and save to
53 	 * ODP
54 	 *
55 	 * @throws Exception
56 	 */
57 	@Test
58 	public void testOpenAOO34WithHeaderFooter() throws Exception {
59 		// open sample file
60 		String file = prepareData("sd/AOO3.4HeaderFooter.odp");
61 		open(file);
62 		impress.waitForExistence(10, 2);
63 
64 		// check after reopen
65 		app.dispatch(".uno:HeaderAndFooter");
66 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
67 		assertEquals("fixed date", sdFixedDateAndTimeOnSlideInput.getText());
68 		assertEquals(true, sdFooterTextOnSlide.isChecked());
69 		assertEquals("footer test", sdFooterTextOnSlideInput.getText());
70 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
71 
72 		sdSlideNumAsFooterOnSlide.uncheck();
73 		sdApplyToAllButtonOnSlideFooter.click();
74 
75 		// save to odp and reopen
76 		String saveTo2 = getPath("temp/" + "AOO3.4HeaderFooter.odp");
77 		FileUtil.deleteFile(saveTo2);
78 		saveAs(saveTo2);
79 		close();
80 		open(saveTo2);
81 		impress.waitForExistence(10, 2);
82 
83 		app.dispatch(".uno:HeaderAndFooter");
84 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
85 	}
86 
87 	/**
88 	 * Test open ppt file with header and footer. edit and save to PPT/ODP
89 	 *
90 	 * @throws Exception
91 	 */
92 	@Test
93 	public void testOpenPPTWithHeaderFooter() throws Exception {
94 		// open sample file
95 		String file = prepareData("sd/gfdd.ppt");
96 		open(file);
97 		impress.waitForExistence(10, 2);
98 
99 		// check after reopen
100 		app.dispatch(".uno:HeaderAndFooter");
101 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
102 		assertEquals("testdte", sdFixedDateAndTimeOnSlideInput.getText());
103 		assertEquals(true, sdFooterTextOnSlide.isChecked());
104 		assertEquals("yesy", sdFooterTextOnSlideInput.getText());
105 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
106 
107 		sdSlideNumAsFooterOnSlide.uncheck();
108 		sdApplyToAllButtonOnSlideFooter.click();
109 
110 		// save to ppt and reopen
111 		String saveTo = getPath("temp/" + "gfdd.ppt");
112 		FileUtil.deleteFile(saveTo);
113 		saveAs(saveTo);
114 		close();
115 		open(saveTo);
116 		impress.waitForExistence(10, 2);
117 
118 		app.dispatch(".uno:HeaderAndFooter");
119 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
120 
121 		// close Header and Footer dialog.
122 		sdApplyButtonOnSlideFooter.focus();
123 		typeKeys("<tab>");
124 		typeKeys("<enter>");
125 
126 		// save to odp and reopen
127 		String saveTo2 = getPath("temp/" + "gfdd.odp");
128 		FileUtil.deleteFile(saveTo);
129 		saveAs(saveTo2);
130 		close();
131 		open(saveTo2);
132 		impress.waitForExistence(10, 2);
133 
134 		app.dispatch(".uno:HeaderAndFooter");
135 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
136 	}
137 }
138