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;
35*fd348426SLi Feng Wang import org.junit.Rule;
3604bad30fSLiu Zhe import org.junit.Test;
3704bad30fSLiu Zhe import org.openoffice.test.common.FileUtil;
38*fd348426SLi Feng Wang import org.openoffice.test.common.Logger;
3904bad30fSLiu Zhe 
40c37bcbf4SLi Feng Wang public class DocumentWithHeaderFooter {
41*fd348426SLi Feng Wang 	@Rule
42*fd348426SLi Feng Wang 	public Logger log = Logger.getLogger(this);
43*fd348426SLi Feng Wang 
4404bad30fSLiu Zhe 
4504bad30fSLiu Zhe 	@Before
setUp()4604bad30fSLiu Zhe 	public void setUp() throws Exception {
47c37bcbf4SLi Feng Wang 		app.start(true);
4804bad30fSLiu Zhe 	}
4904bad30fSLiu Zhe 
5004bad30fSLiu Zhe 	@After
tearDown()5104bad30fSLiu Zhe 	public void tearDown() throws Exception {
524a13b48eSLi Feng Wang 		app.stop();
5322a14f28SLiu Zhe 
5404bad30fSLiu Zhe 	}
5504bad30fSLiu Zhe 
5604bad30fSLiu Zhe 	/**
5722a14f28SLiu Zhe 	 * Test open AOO3.4 presentation with header and footer. edit and save to
5822a14f28SLiu Zhe 	 * ODP
5922a14f28SLiu Zhe 	 *
6004bad30fSLiu Zhe 	 * @throws Exception
6104bad30fSLiu Zhe 	 */
6204bad30fSLiu Zhe 	@Test
testOpenAOO34WithHeaderFooter()6322a14f28SLiu Zhe 	public void testOpenAOO34WithHeaderFooter() throws Exception {
6422a14f28SLiu Zhe 		// open sample file
6595269d92SLiu Zhe 		String file = prepareData("sd/AOO3.4HeaderFooter.odp");
66c37bcbf4SLi Feng Wang 		open(file);
67d8cae8adSLiu Zhe 		impress.waitForExistence(10, 2);
6804bad30fSLiu Zhe 
6922a14f28SLiu Zhe 		// check after reopen
703816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
71b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
72b4d2d410SLiu Zhe 		assertEquals("fixed date", sdFixedDateAndTimeOnSlideInput.getText());
73b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
74b4d2d410SLiu Zhe 		assertEquals("footer test", sdFooterTextOnSlideInput.getText());
75b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
7604bad30fSLiu Zhe 
77b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.uncheck();
78b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
7904bad30fSLiu Zhe 
8022a14f28SLiu Zhe 		// save to odp and reopen
8195269d92SLiu Zhe 		String saveTo2 = getPath("temp/" + "AOO3.4HeaderFooter.odp");
8204bad30fSLiu Zhe 		FileUtil.deleteFile(saveTo2);
83c37bcbf4SLi Feng Wang 		saveAs(saveTo2);
84c37bcbf4SLi Feng Wang 		close();
85c37bcbf4SLi Feng Wang 		open(saveTo2);
86c37bcbf4SLi Feng Wang 		impress.waitForExistence(10, 2);
87c37bcbf4SLi Feng Wang 
883816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
89b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
9004bad30fSLiu Zhe 	}
9104bad30fSLiu Zhe 
9204bad30fSLiu Zhe 	/**
9322a14f28SLiu Zhe 	 * Test open ppt file with header and footer. edit and save to PPT/ODP
9422a14f28SLiu Zhe 	 *
9504bad30fSLiu Zhe 	 * @throws Exception
9604bad30fSLiu Zhe 	 */
9704bad30fSLiu Zhe 	@Test
testOpenPPTWithHeaderFooter()9822a14f28SLiu Zhe 	public void testOpenPPTWithHeaderFooter() throws Exception {
9922a14f28SLiu Zhe 		// open sample file
10095269d92SLiu Zhe 		String file = prepareData("sd/gfdd.ppt");
101c37bcbf4SLi Feng Wang 		open(file);
102d8cae8adSLiu Zhe 		impress.waitForExistence(10, 2);
10304bad30fSLiu Zhe 
10422a14f28SLiu Zhe 		// check after reopen
1053816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
106b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
107b4d2d410SLiu Zhe 		assertEquals("testdte", sdFixedDateAndTimeOnSlideInput.getText());
108b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
109b4d2d410SLiu Zhe 		assertEquals("yesy", sdFooterTextOnSlideInput.getText());
110b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
11104bad30fSLiu Zhe 
112b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.uncheck();
113b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
11404bad30fSLiu Zhe 
11522a14f28SLiu Zhe 		// save to ppt and reopen
11695269d92SLiu Zhe 		String saveTo = getPath("temp/" + "gfdd.ppt");
11704bad30fSLiu Zhe 		FileUtil.deleteFile(saveTo);
118c37bcbf4SLi Feng Wang 		saveAs(saveTo);
119c37bcbf4SLi Feng Wang 		close();
120c37bcbf4SLi Feng Wang 		open(saveTo);
121c37bcbf4SLi Feng Wang 		impress.waitForExistence(10, 2);
122c37bcbf4SLi Feng Wang 
1233816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
124b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
12504bad30fSLiu Zhe 
12622a14f28SLiu Zhe 		// close Header and Footer dialog.
127b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
12804bad30fSLiu Zhe 		typeKeys("<tab>");
12904bad30fSLiu Zhe 		typeKeys("<enter>");
13004bad30fSLiu Zhe 
13122a14f28SLiu Zhe 		// save to odp and reopen
13295269d92SLiu Zhe 		String saveTo2 = getPath("temp/" + "gfdd.odp");
133c37bcbf4SLi Feng Wang 		FileUtil.deleteFile(saveTo);
134c37bcbf4SLi Feng Wang 		saveAs(saveTo2);
135c37bcbf4SLi Feng Wang 		close();
136c37bcbf4SLi Feng Wang 		open(saveTo2);
137c37bcbf4SLi Feng Wang 		impress.waitForExistence(10, 2);
138c37bcbf4SLi Feng Wang 
1393816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
140b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
14104bad30fSLiu Zhe 	}
14204bad30fSLiu Zhe }
143