104bad30fSLiu Zhe /**************************************************************
204bad30fSLiu Zhe  *
304bad30fSLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
404bad30fSLiu Zhe  * or more contributor license agreements.  See the NOTICE file
504bad30fSLiu Zhe  * distributed with this work for additional information
604bad30fSLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
704bad30fSLiu Zhe  * to you under the Apache License, Version 2.0 (the
804bad30fSLiu Zhe  * "License"); you may not use this file except in compliance
904bad30fSLiu Zhe  * with the License.  You may obtain a copy of the License at
1004bad30fSLiu Zhe  *
1104bad30fSLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1204bad30fSLiu Zhe  *
1304bad30fSLiu Zhe  * Unless required by applicable law or agreed to in writing,
1404bad30fSLiu Zhe  * software distributed under the License is distributed on an
1504bad30fSLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1604bad30fSLiu Zhe  * KIND, either express or implied.  See the License for the
1704bad30fSLiu Zhe  * specific language governing permissions and limitations
1804bad30fSLiu Zhe  * under the License.
1904bad30fSLiu Zhe  *
2004bad30fSLiu Zhe  *************************************************************/
2104bad30fSLiu Zhe 
2204bad30fSLiu Zhe /**
2304bad30fSLiu Zhe  *
2404bad30fSLiu Zhe  */
2580a6f5c5SLiu Zhe package fvt.gui.sd.headerandfooter;
2622a14f28SLiu Zhe 
2722a14f28SLiu Zhe import static org.junit.Assert.*;
2895269d92SLiu Zhe import static org.openoffice.test.common.Testspace.*;
294a13b48eSLi Feng Wang import static org.openoffice.test.vcl.Tester.sleep;
30b4d2d410SLiu Zhe import static testlib.gui.AppTool.*;
3195269d92SLiu Zhe import static testlib.gui.UIMap.*;
3222a14f28SLiu Zhe 
3304bad30fSLiu Zhe import org.junit.After;
3404bad30fSLiu Zhe import org.junit.Before;
3504bad30fSLiu Zhe import org.junit.Test;
3604bad30fSLiu Zhe import org.openoffice.test.common.FileUtil;
3704bad30fSLiu Zhe 
38*c37bcbf4SLi Feng Wang public class DocumentWithHeaderFooter {
3904bad30fSLiu Zhe 
4004bad30fSLiu Zhe 	@Before
4104bad30fSLiu Zhe 	public void setUp() throws Exception {
42*c37bcbf4SLi Feng Wang 		app.start(true);
4304bad30fSLiu Zhe 	}
4404bad30fSLiu Zhe 
4504bad30fSLiu Zhe 	@After
4604bad30fSLiu Zhe 	public void tearDown() throws Exception {
474a13b48eSLi Feng Wang 		app.stop();
4822a14f28SLiu Zhe 
4904bad30fSLiu Zhe 	}
5004bad30fSLiu Zhe 
5104bad30fSLiu Zhe 	/**
5222a14f28SLiu Zhe 	 * Test open AOO3.4 presentation with header and footer. edit and save to
5322a14f28SLiu Zhe 	 * ODP
5422a14f28SLiu Zhe 	 *
5504bad30fSLiu Zhe 	 * @throws Exception
5604bad30fSLiu Zhe 	 */
5704bad30fSLiu Zhe 	@Test
5822a14f28SLiu Zhe 	public void testOpenAOO34WithHeaderFooter() throws Exception {
5922a14f28SLiu Zhe 		// open sample file
6095269d92SLiu Zhe 		String file = prepareData("sd/AOO3.4HeaderFooter.odp");
61*c37bcbf4SLi Feng Wang 		open(file);
62d8cae8adSLiu Zhe 		impress.waitForExistence(10, 2);
6304bad30fSLiu Zhe 
6422a14f28SLiu Zhe 		// check after reopen
653816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
66b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
67b4d2d410SLiu Zhe 		assertEquals("fixed date", sdFixedDateAndTimeOnSlideInput.getText());
68b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
69b4d2d410SLiu Zhe 		assertEquals("footer test", sdFooterTextOnSlideInput.getText());
70b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
7104bad30fSLiu Zhe 
72b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.uncheck();
73b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
7404bad30fSLiu Zhe 
7522a14f28SLiu Zhe 		// save to odp and reopen
7695269d92SLiu Zhe 		String saveTo2 = getPath("temp/" + "AOO3.4HeaderFooter.odp");
7704bad30fSLiu Zhe 		FileUtil.deleteFile(saveTo2);
78*c37bcbf4SLi Feng Wang 		saveAs(saveTo2);
79*c37bcbf4SLi Feng Wang 		close();
80*c37bcbf4SLi Feng Wang 		open(saveTo2);
81*c37bcbf4SLi Feng Wang 		impress.waitForExistence(10, 2);
82*c37bcbf4SLi Feng Wang 
833816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
84b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
8504bad30fSLiu Zhe 	}
8604bad30fSLiu Zhe 
8704bad30fSLiu Zhe 	/**
8822a14f28SLiu Zhe 	 * Test open ppt file with header and footer. edit and save to PPT/ODP
8922a14f28SLiu Zhe 	 *
9004bad30fSLiu Zhe 	 * @throws Exception
9104bad30fSLiu Zhe 	 */
9204bad30fSLiu Zhe 	@Test
9322a14f28SLiu Zhe 	public void testOpenPPTWithHeaderFooter() throws Exception {
9422a14f28SLiu Zhe 		// open sample file
9595269d92SLiu Zhe 		String file = prepareData("sd/gfdd.ppt");
96*c37bcbf4SLi Feng Wang 		open(file);
97d8cae8adSLiu Zhe 		impress.waitForExistence(10, 2);
9804bad30fSLiu Zhe 
9922a14f28SLiu Zhe 		// check after reopen
1003816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
101b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
102b4d2d410SLiu Zhe 		assertEquals("testdte", sdFixedDateAndTimeOnSlideInput.getText());
103b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
104b4d2d410SLiu Zhe 		assertEquals("yesy", sdFooterTextOnSlideInput.getText());
105b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
10604bad30fSLiu Zhe 
107b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.uncheck();
108b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
10904bad30fSLiu Zhe 
11022a14f28SLiu Zhe 		// save to ppt and reopen
11195269d92SLiu Zhe 		String saveTo = getPath("temp/" + "gfdd.ppt");
11204bad30fSLiu Zhe 		FileUtil.deleteFile(saveTo);
113*c37bcbf4SLi Feng Wang 		saveAs(saveTo);
114*c37bcbf4SLi Feng Wang 		close();
115*c37bcbf4SLi Feng Wang 		open(saveTo);
116*c37bcbf4SLi Feng Wang 		impress.waitForExistence(10, 2);
117*c37bcbf4SLi Feng Wang 
1183816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
119b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
12004bad30fSLiu Zhe 
12122a14f28SLiu Zhe 		// close Header and Footer dialog.
122b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
12304bad30fSLiu Zhe 		typeKeys("<tab>");
12404bad30fSLiu Zhe 		typeKeys("<enter>");
12504bad30fSLiu Zhe 
12622a14f28SLiu Zhe 		// save to odp and reopen
12795269d92SLiu Zhe 		String saveTo2 = getPath("temp/" + "gfdd.odp");
128*c37bcbf4SLi Feng Wang 		FileUtil.deleteFile(saveTo);
129*c37bcbf4SLi Feng Wang 		saveAs(saveTo2);
130*c37bcbf4SLi Feng Wang 		close();
131*c37bcbf4SLi Feng Wang 		open(saveTo2);
132*c37bcbf4SLi Feng Wang 		impress.waitForExistence(10, 2);
133*c37bcbf4SLi Feng Wang 
1343816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
135b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
13604bad30fSLiu Zhe 	}
13704bad30fSLiu Zhe }
138