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.Rule;
36 import org.junit.Test;
37 import org.openoffice.test.common.FileUtil;
38 import org.openoffice.test.common.Logger;
39 
40 public class DocumentWithHeaderFooter {
41 	@Rule
42 	public Logger log = Logger.getLogger(this);
43 
44 
45 	@Before
setUp()46 	public void setUp() throws Exception {
47 		app.start(true);
48 	}
49 
50 	@After
tearDown()51 	public void tearDown() throws Exception {
52 		app.stop();
53 
54 	}
55 
56 	/**
57 	 * Test open AOO3.4 presentation with header and footer. edit and save to
58 	 * ODP
59 	 *
60 	 * @throws Exception
61 	 */
62 	@Test
testOpenAOO34WithHeaderFooter()63 	public void testOpenAOO34WithHeaderFooter() throws Exception {
64 		// open sample file
65 		String file = prepareData("sd/AOO3.4HeaderFooter.odp");
66 		open(file);
67 		impress.waitForExistence(10, 2);
68 
69 		// check after reopen
70 		app.dispatch(".uno:HeaderAndFooter");
71 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
72 		assertEquals("fixed date", sdFixedDateAndTimeOnSlideInput.getText());
73 		assertEquals(true, sdFooterTextOnSlide.isChecked());
74 		assertEquals("footer test", sdFooterTextOnSlideInput.getText());
75 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
76 
77 		sdSlideNumAsFooterOnSlide.uncheck();
78 		sdApplyToAllButtonOnSlideFooter.click();
79 
80 		// save to odp and reopen
81 		String saveTo2 = getPath("temp/" + "AOO3.4HeaderFooter.odp");
82 		FileUtil.deleteFile(saveTo2);
83 		saveAs(saveTo2);
84 		close();
85 		open(saveTo2);
86 		impress.waitForExistence(10, 2);
87 
88 		app.dispatch(".uno:HeaderAndFooter");
89 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
90 	}
91 
92 	/**
93 	 * Test open ppt file with header and footer. edit and save to PPT/ODP
94 	 *
95 	 * @throws Exception
96 	 */
97 	@Test
testOpenPPTWithHeaderFooter()98 	public void testOpenPPTWithHeaderFooter() throws Exception {
99 		// open sample file
100 		String file = prepareData("sd/gfdd.ppt");
101 		open(file);
102 		impress.waitForExistence(10, 2);
103 
104 		// check after reopen
105 		app.dispatch(".uno:HeaderAndFooter");
106 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
107 		assertEquals("testdte", sdFixedDateAndTimeOnSlideInput.getText());
108 		assertEquals(true, sdFooterTextOnSlide.isChecked());
109 		assertEquals("yesy", sdFooterTextOnSlideInput.getText());
110 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
111 
112 		sdSlideNumAsFooterOnSlide.uncheck();
113 		sdApplyToAllButtonOnSlideFooter.click();
114 
115 		// save to ppt and reopen
116 		String saveTo = getPath("temp/" + "gfdd.ppt");
117 		FileUtil.deleteFile(saveTo);
118 		saveAs(saveTo);
119 		close();
120 		open(saveTo);
121 		impress.waitForExistence(10, 2);
122 
123 		app.dispatch(".uno:HeaderAndFooter");
124 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
125 
126 		// close Header and Footer dialog.
127 		sdApplyButtonOnSlideFooter.focus();
128 		typeKeys("<tab>");
129 		typeKeys("<enter>");
130 
131 		// save to odp and reopen
132 		String saveTo2 = getPath("temp/" + "gfdd.odp");
133 		FileUtil.deleteFile(saveTo);
134 		saveAs(saveTo2);
135 		close();
136 		open(saveTo2);
137 		impress.waitForExistence(10, 2);
138 
139 		app.dispatch(".uno:HeaderAndFooter");
140 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
141 	}
142 }
143