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