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.*;
2922a14f28SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
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.Rule;
3604bad30fSLiu Zhe import org.junit.Test;
3704bad30fSLiu Zhe import org.openoffice.test.common.FileUtil;
3822a14f28SLiu Zhe import org.openoffice.test.common.Logger;
3995269d92SLiu Zhe 
40b4d2d410SLiu Zhe import testlib.gui.SDTool;
4104bad30fSLiu Zhe 
4222a14f28SLiu Zhe public class HeaderAndFooterSetting {
4304bad30fSLiu Zhe 
4404bad30fSLiu Zhe 	@Rule
4522a14f28SLiu Zhe 	public Logger log = Logger.getLogger(this);
4604bad30fSLiu Zhe 
4704bad30fSLiu Zhe 	@Before
4804bad30fSLiu Zhe 	public void setUp() throws Exception {
4922a14f28SLiu Zhe 		app.start(true); // Bug 120476
5004bad30fSLiu Zhe 
5104bad30fSLiu Zhe 		// New a impress, insert some slides
5204bad30fSLiu Zhe 		app.dispatch("private:factory/simpress?slot=6686");
53b4d2d410SLiu Zhe 		presentationWizard.ok();
54d8cae8adSLiu Zhe 		impress.waitForExistence(10, 2);
5504bad30fSLiu Zhe 
5622a14f28SLiu Zhe 		for (int i = 0; i < 5; i++) {
57b4d2d410SLiu Zhe 			sdInsertPageButtonOnToolbar.click();
5804bad30fSLiu Zhe 		}
5904bad30fSLiu Zhe 		// Pop up navigator panel
60b4d2d410SLiu Zhe 		if (!sdNavigatorDlg.exists()) {
613816404dSLiu Zhe 			app.dispatch(".uno:Navigator");
6204bad30fSLiu Zhe 		}
6304bad30fSLiu Zhe 	}
6404bad30fSLiu Zhe 
6504bad30fSLiu Zhe 	@After
6604bad30fSLiu Zhe 	public void tearDown() throws Exception {
67*4a13b48eSLi Feng Wang 		app.stop();
6804bad30fSLiu Zhe 	}
6904bad30fSLiu Zhe 
7004bad30fSLiu Zhe 	/**
7104bad30fSLiu Zhe 	 * Test Copy slide with Apply Footer to same file and different file
7222a14f28SLiu Zhe 	 *
7304bad30fSLiu Zhe 	 * @throws Exception
7404bad30fSLiu Zhe 	 */
75d8cae8adSLiu Zhe 	@Test
7622a14f28SLiu Zhe 	public void testCopySlideWithApplyFooter() throws Exception {
7704bad30fSLiu Zhe 
7822a14f28SLiu Zhe 		// add header and footer
793816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
8004bad30fSLiu Zhe 
81b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
82b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
83b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
84b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
85b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
86b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
87b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
8804bad30fSLiu Zhe 
893816404dSLiu Zhe 		// Click slide 3
90b4d2d410SLiu Zhe 		impressSlideSorter.focus();
913816404dSLiu Zhe 		typeKeys("<up><up><up>");
9204bad30fSLiu Zhe 		sleep(1);
933816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
94b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.uncheck();
95b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.click();
9604bad30fSLiu Zhe 
9722a14f28SLiu Zhe 		// paste to the same file
98b4d2d410SLiu Zhe 		impressSlideSorter.focus();
9904bad30fSLiu Zhe 		app.dispatch(".uno:Copy");
10004bad30fSLiu Zhe 		app.dispatch(".uno:Paste");
10104bad30fSLiu Zhe 
1023816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
103b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
104b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
105b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
106b4d2d410SLiu Zhe 		sdHeaderAndFooterDlgSlideTab.cancel();
10704bad30fSLiu Zhe 
10822a14f28SLiu Zhe 		// paste to different file
10904bad30fSLiu Zhe 		impress.focus();
11004bad30fSLiu Zhe 		app.dispatch("private:factory/simpress?slot=6686");
111b4d2d410SLiu Zhe 		presentationWizard.ok();
11204bad30fSLiu Zhe 		app.dispatch(".uno:Paste");
113b4d2d410SLiu Zhe 		impressSlideSorter.focus();
11404bad30fSLiu Zhe 		typeKeys("<down>");
11504bad30fSLiu Zhe 		sleep(1);
11604bad30fSLiu Zhe 
1173816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
118b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
119b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
120b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
12104bad30fSLiu Zhe 	}
12204bad30fSLiu Zhe 
12304bad30fSLiu Zhe 	/**
12404bad30fSLiu Zhe 	 * Test Copy slide with Apply to all Footer to same file and different file
12522a14f28SLiu Zhe 	 *
12604bad30fSLiu Zhe 	 * @throws Exception
12704bad30fSLiu Zhe 	 */
12804bad30fSLiu Zhe 	@Test
12922a14f28SLiu Zhe 	public void testCopySlideWithApplyToAllFooter() throws Exception {
13004bad30fSLiu Zhe 
13122a14f28SLiu Zhe 		// add header and footer
1323816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
13304bad30fSLiu Zhe 
134b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
135b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
136b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
137b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
138b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
139b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
140b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
14104bad30fSLiu Zhe 
142b4d2d410SLiu Zhe 		impressSlideSorter.focus();
14322a14f28SLiu Zhe 		for (int j = 0; j <= 2; j++) {
14404bad30fSLiu Zhe 			typeKeys("<up>");
14504bad30fSLiu Zhe 		}
1463816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
147b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.uncheck();
148b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.click();
14904bad30fSLiu Zhe 
15022a14f28SLiu Zhe 		// paste to the same file
151b4d2d410SLiu Zhe 		impressSlideSorter.focus();
15204bad30fSLiu Zhe 		typeKeys("<up>");
15304bad30fSLiu Zhe 		app.dispatch(".uno:Copy");
15404bad30fSLiu Zhe 		typeKeys("<down>");
15504bad30fSLiu Zhe 		app.dispatch(".uno:Paste");
15604bad30fSLiu Zhe 
1573816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
158b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
159b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
160b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
161b4d2d410SLiu Zhe 		sdHeaderAndFooterDlgSlideTab.cancel();
16204bad30fSLiu Zhe 
16322a14f28SLiu Zhe 		// paste to different file
1643816404dSLiu Zhe 		app.dispatch("private:factory/simpress?slot=6686");
165b4d2d410SLiu Zhe 		presentationWizard.ok();
16604bad30fSLiu Zhe 		app.dispatch(".uno:Paste");
167b4d2d410SLiu Zhe 		impressSlideSorter.focus();
16804bad30fSLiu Zhe 		typeKeys("<down>");
1693816404dSLiu Zhe 		sleep(1); // If no sleep, error occur
17004bad30fSLiu Zhe 
1713816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
172b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
173b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
174b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
17504bad30fSLiu Zhe 	}
17604bad30fSLiu Zhe 
17704bad30fSLiu Zhe 	/**
17804bad30fSLiu Zhe 	 * Test Copy slide with Notes Footer to same file and different file
17922a14f28SLiu Zhe 	 *
18004bad30fSLiu Zhe 	 * @throws Exception
18104bad30fSLiu Zhe 	 */
18204bad30fSLiu Zhe 	@Test
18322a14f28SLiu Zhe 	public void testCopySlideWithNotesHeaderFooter() throws Exception {
18404bad30fSLiu Zhe 
18522a14f28SLiu Zhe 		// add header and footer
1863816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
187b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
188b4d2d410SLiu Zhe 		sdHeaderTextOnNotes.check();
189b4d2d410SLiu Zhe 		sdHeaderTextOnNotesInput.setText("Header Test");
190b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
191b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
192b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120329");
193b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
194b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
195b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
196b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
19704bad30fSLiu Zhe 
19822a14f28SLiu Zhe 		// paste to the same file
199b4d2d410SLiu Zhe 		impressSlideSorter.focus();
20004bad30fSLiu Zhe 		typeKeys("<up>");
20104bad30fSLiu Zhe 		app.dispatch(".uno:Copy");
20204bad30fSLiu Zhe 		typeKeys("<down>");
20304bad30fSLiu Zhe 		app.dispatch(".uno:Paste");
20404bad30fSLiu Zhe 
2053816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
206b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
207b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
208b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
209b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
210b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
211b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.cancel();
21204bad30fSLiu Zhe 
21322a14f28SLiu Zhe 		// paste to different file
21404bad30fSLiu Zhe 		impress.focus();
2153816404dSLiu Zhe 		app.dispatch("private:factory/simpress?slot=6686");
216b4d2d410SLiu Zhe 		presentationWizard.ok();
21704bad30fSLiu Zhe 		app.dispatch(".uno:Paste");
218b4d2d410SLiu Zhe 		impressSlideSorter.focus();
21904bad30fSLiu Zhe 		typeKeys("<down>");
220b4d2d410SLiu Zhe 		SDTool.getActiveView().activate();
2213816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
222b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
223b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
224b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
225b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
226b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
22704bad30fSLiu Zhe 	}
22804bad30fSLiu Zhe 
22904bad30fSLiu Zhe 	/**
23022a14f28SLiu Zhe 	 * Test duplicate slide with Apply to all Footer to same file
23122a14f28SLiu Zhe 	 *
23204bad30fSLiu Zhe 	 * @throws Exception
23304bad30fSLiu Zhe 	 */
23404bad30fSLiu Zhe 	@Test
23522a14f28SLiu Zhe 	public void testDuplicateSlideWithApplyToAllFooter() throws Exception {
23604bad30fSLiu Zhe 
23722a14f28SLiu Zhe 		// add header and footer
2383816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
23904bad30fSLiu Zhe 
240b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
241b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
242b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
243b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
244b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
245b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
246b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
24704bad30fSLiu Zhe 
248b4d2d410SLiu Zhe 		impressSlideSorter.focus();
24922a14f28SLiu Zhe 		for (int j = 0; j <= 2; j++) {
25004bad30fSLiu Zhe 			typeKeys("<up>");
25104bad30fSLiu Zhe 		}
2523816404dSLiu Zhe 		app.dispatch(".uno:DuplicatePage");
2533816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
254b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
255b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
256b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
25704bad30fSLiu Zhe 	}
25804bad30fSLiu Zhe 
25904bad30fSLiu Zhe 	/**
26022a14f28SLiu Zhe 	 * Test footer not show on the first slide.
26122a14f28SLiu Zhe 	 *
26204bad30fSLiu Zhe 	 * @throws Exception
26304bad30fSLiu Zhe 	 */
264d8cae8adSLiu Zhe 	@Test
26522a14f28SLiu Zhe 	public void testFooterNotShowOn1stSlide() throws Exception {
26604bad30fSLiu Zhe 
26722a14f28SLiu Zhe 		// add header and footer
2683816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
269b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
270b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
271b4d2d410SLiu Zhe 		sdFooterNotShowOn1stSlide.check();
272b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
27304bad30fSLiu Zhe 
2743816404dSLiu Zhe 		// Check slide 1
275b4d2d410SLiu Zhe 		impressSlideSorter.focus();
27622a14f28SLiu Zhe 		// typeKeys("<up><up><up><up><up>"); // Not stable on ubuntu10.04
27722a14f28SLiu Zhe 		// sleep(1); // If no sleep, error occur
27822a14f28SLiu Zhe 		for (int i = 0; i < 5; i++) {
279d8cae8adSLiu Zhe 			typeKeys("<up>");
280d8cae8adSLiu Zhe 			sleep(1);
281d8cae8adSLiu Zhe 		}
28204bad30fSLiu Zhe 
2833816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
284b4d2d410SLiu Zhe 		assertEquals(true, sdFooterNotShowOn1stSlide.isChecked());
285b4d2d410SLiu Zhe 		assertEquals(false, sdFooterTextOnSlide.isChecked());
28604bad30fSLiu Zhe 	}
28704bad30fSLiu Zhe 
28804bad30fSLiu Zhe 	/**
28904bad30fSLiu Zhe 	 * Test Insert Footer to focus slide.
29022a14f28SLiu Zhe 	 *
29104bad30fSLiu Zhe 	 * @throws Exception
29204bad30fSLiu Zhe 	 */
29304bad30fSLiu Zhe 	@Test
29422a14f28SLiu Zhe 	public void testInsertApplyFooterOnSlide() throws Exception {
29504bad30fSLiu Zhe 
29622a14f28SLiu Zhe 		// add header and footer to focus slide.
2973816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
29804bad30fSLiu Zhe 
299b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
300b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
301b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
302b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
303b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
304b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
305b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.click();
30604bad30fSLiu Zhe 
3073816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
308b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
309b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
310b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
311b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
312b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
313b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
31422a14f28SLiu Zhe 		// close header and footer dialog.
315b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
31604bad30fSLiu Zhe 		typeKeys("<tab>");
31704bad30fSLiu Zhe 		typeKeys("<enter>");
31822a14f28SLiu Zhe 		// end close
31904bad30fSLiu Zhe 
320b4d2d410SLiu Zhe 		impressSlideSorter.focus();
32104bad30fSLiu Zhe 		typeKeys("<up>");
32222a14f28SLiu Zhe 		sleep(1); // If no sleep, error occur
32304bad30fSLiu Zhe 
3243816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
325b4d2d410SLiu Zhe 		assertEquals("", sdFixedDateAndTimeOnSlideInput.getText());
326b4d2d410SLiu Zhe 		assertEquals("", sdFooterTextOnSlideInput.getText());
327b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
32822a14f28SLiu Zhe 		// close header and footer dialog.
329b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
33004bad30fSLiu Zhe 		typeKeys("<tab>");
33104bad30fSLiu Zhe 		typeKeys("<enter>");
33222a14f28SLiu Zhe 		// end close
33304bad30fSLiu Zhe 
334b4d2d410SLiu Zhe 		sdInsertPageButtonOnToolbar.click();
3353816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
336b4d2d410SLiu Zhe 		assertEquals("", sdFixedDateAndTimeOnSlideInput.getText());
337b4d2d410SLiu Zhe 		assertEquals("", sdFooterTextOnSlideInput.getText());
338b4d2d410SLiu Zhe 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
33904bad30fSLiu Zhe 	}
34004bad30fSLiu Zhe 
34104bad30fSLiu Zhe 	/**
34204bad30fSLiu Zhe 	 * Test Insert Footer to Notes View
34322a14f28SLiu Zhe 	 *
34404bad30fSLiu Zhe 	 * @throws Exception
34504bad30fSLiu Zhe 	 */
34604bad30fSLiu Zhe 	@Test
34722a14f28SLiu Zhe 	public void testInsertApplyToAllFooterOnNotes() throws Exception {
34804bad30fSLiu Zhe 
34922a14f28SLiu Zhe 		// add header and footer to focus slide.
3503816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
351b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
352b4d2d410SLiu Zhe 		sdHeaderTextOnNotes.check();
353b4d2d410SLiu Zhe 		sdHeaderTextOnNotesInput.setText("Header Test");
354b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
355b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
356b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
357b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
358b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
359b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
360b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
361b4d2d410SLiu Zhe 
362b4d2d410SLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
363b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
364b4d2d410SLiu Zhe 		assertEquals(true, sdHeaderTextOnNotes.isChecked());
365b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
366b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
367b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
368b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
369b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
370b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
371b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
37222a14f28SLiu Zhe 		// close header and footer dialog.
373b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.focus();
37404bad30fSLiu Zhe 		typeKeys("<tab>");
37504bad30fSLiu Zhe 		typeKeys("<enter>");
37622a14f28SLiu Zhe 		// end close
37704bad30fSLiu Zhe 
378b4d2d410SLiu Zhe 		impressSlideSorter.focus();
37904bad30fSLiu Zhe 		typeKeys("<up>");
38004bad30fSLiu Zhe 
3813816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
382b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
383b4d2d410SLiu Zhe 		assertEquals(true, sdHeaderTextOnNotes.isChecked());
384b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
385b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
386b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
387b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
388b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
389b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
390b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
39122a14f28SLiu Zhe 		// close header and footer dialog.
392b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.focus();
39304bad30fSLiu Zhe 		typeKeys("<tab>");
39404bad30fSLiu Zhe 		typeKeys("<enter>");
39522a14f28SLiu Zhe 		// end close
39604bad30fSLiu Zhe 
397b4d2d410SLiu Zhe 		sdInsertPageButtonOnToolbar.click();
398b4d2d410SLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
399b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
400b4d2d410SLiu Zhe 		assertEquals(true, sdHeaderTextOnNotes.isChecked());
401b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
402b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
403b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
404b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
405b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
406b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
407b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
40804bad30fSLiu Zhe 	}
40904bad30fSLiu Zhe 
41004bad30fSLiu Zhe 	/**
41104bad30fSLiu Zhe 	 * Test Insert Footer to Slide, use Apply to All
41222a14f28SLiu Zhe 	 *
41304bad30fSLiu Zhe 	 * @throws Exception
41404bad30fSLiu Zhe 	 */
41504bad30fSLiu Zhe 	@Test
41622a14f28SLiu Zhe 	public void testInsertApplyToAllFooterOnSlide() throws Exception {
41704bad30fSLiu Zhe 
41822a14f28SLiu Zhe 		// add header and footer to focus slide.
4193816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
42004bad30fSLiu Zhe 
421b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
422b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
423b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
424b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
425b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
426b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
427b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
42804bad30fSLiu Zhe 
4293816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
430b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
431b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
432b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
433b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
434b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
435b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
43622a14f28SLiu Zhe 		// close header and footer dialog.
437b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
43804bad30fSLiu Zhe 		typeKeys("<tab>");
43904bad30fSLiu Zhe 		typeKeys("<enter>");
44022a14f28SLiu Zhe 		// end close
44104bad30fSLiu Zhe 
442b4d2d410SLiu Zhe 		impressSlideSorter.focus();
44304bad30fSLiu Zhe 		typeKeys("<up>");
44404bad30fSLiu Zhe 
4453816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
446b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
447b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
448b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
449b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
450b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
451b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
45222a14f28SLiu Zhe 		// close header and footer dialog.
453b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
45404bad30fSLiu Zhe 		typeKeys("<tab>");
45504bad30fSLiu Zhe 		typeKeys("<enter>");
45622a14f28SLiu Zhe 		// end close
45704bad30fSLiu Zhe 
458b4d2d410SLiu Zhe 		sdInsertPageButtonOnToolbar.click();
4593816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
460b4d2d410SLiu Zhe 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
461b4d2d410SLiu Zhe 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
462b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
463b4d2d410SLiu Zhe 		assertEquals(true, sdFooterTextOnSlide.isChecked());
464b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
465b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
46604bad30fSLiu Zhe 	}
46704bad30fSLiu Zhe 
46804bad30fSLiu Zhe 	/**
46904bad30fSLiu Zhe 	 * Test Insert update automatically time footer to slides.
47022a14f28SLiu Zhe 	 *
47104bad30fSLiu Zhe 	 * @throws Exception
47204bad30fSLiu Zhe 	 */
47304bad30fSLiu Zhe 	@Test
47422a14f28SLiu Zhe 	public void testInsertAutoUpdateTimeFooter() throws Exception {
47504bad30fSLiu Zhe 
47622a14f28SLiu Zhe 		// add header and footer
4773816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
478b4d2d410SLiu Zhe 		sdAutoUpdateTimeFooter.check();
479b4d2d410SLiu Zhe 		sdAutoUpdateTimeFooterType.select(7);
480b4d2d410SLiu Zhe 		String currentTime = sdAutoUpdateTimeFooterType.getItemText(7);
481b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
4823816404dSLiu Zhe 		sleep(1); // Wait some time to check the time update
48304bad30fSLiu Zhe 
4843816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
485b4d2d410SLiu Zhe 		String updatedTime = sdAutoUpdateTimeFooterType.getItemText(7);
4863816404dSLiu Zhe 		assertNotSame("Time can not update", currentTime, updatedTime);
48704bad30fSLiu Zhe 	}
48804bad30fSLiu Zhe 
48904bad30fSLiu Zhe 	/**
49004bad30fSLiu Zhe 	 * Test Insert update automatically time footer to Notes view.
49122a14f28SLiu Zhe 	 *
49204bad30fSLiu Zhe 	 * @throws Exception
49304bad30fSLiu Zhe 	 */
49404bad30fSLiu Zhe 	@Test
49522a14f28SLiu Zhe 	public void testInsertAutoUpdateTimeFooterOnNotes() throws Exception {
49604bad30fSLiu Zhe 
49722a14f28SLiu Zhe 		// add header and footer
4983816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
499b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
500b4d2d410SLiu Zhe 		sdAutoUpdateTimeFooter.check();
501b4d2d410SLiu Zhe 		String currentTime = sdAutoUpdateTimeFooterType.getItemText(7);
502b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
5033816404dSLiu Zhe 		sleep(1); // Wait some time to check the time update
50404bad30fSLiu Zhe 
5053816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
506b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
507b4d2d410SLiu Zhe 		String updatedTime = sdAutoUpdateTimeFooterType.getItemText(7);
50804bad30fSLiu Zhe 
5093816404dSLiu Zhe 		assertNotSame("Time can not update", currentTime, updatedTime);
51004bad30fSLiu Zhe 	}
51104bad30fSLiu Zhe 
51204bad30fSLiu Zhe 	/**
51322a14f28SLiu Zhe 	 * Test Insert Header and Footer to Notes view. Save and ReOpen
51422a14f28SLiu Zhe 	 *
51504bad30fSLiu Zhe 	 * @throws Exception
51604bad30fSLiu Zhe 	 */
51704bad30fSLiu Zhe 	@Test
51822a14f28SLiu Zhe 	public void testInsertHeaderFooterOnNotes() throws Exception {
51904bad30fSLiu Zhe 
52022a14f28SLiu Zhe 		// add header and footer
5213816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
522b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
523b4d2d410SLiu Zhe 		sdHeaderTextOnNotes.check();
524b4d2d410SLiu Zhe 		sdHeaderTextOnNotesInput.setText("Header Test");
525b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
526b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
527b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120329");
528b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
529b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
530b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
531b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
532b4d2d410SLiu Zhe 
533b4d2d410SLiu Zhe 		impressSlideSorter.focus();
53404bad30fSLiu Zhe 		typeKeys("<up>");
53504bad30fSLiu Zhe 
5363816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
537b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
538b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
539b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
540b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
541b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
542b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.cancel();
54304bad30fSLiu Zhe 
54422a14f28SLiu Zhe 		// save this file
5453816404dSLiu Zhe 		app.dispatch(".uno:SaveAs");
54695269d92SLiu Zhe 		String saveTo = getPath("temp/" + "hello.odp");
54704bad30fSLiu Zhe 		FileUtil.deleteFile(saveTo);
54822a14f28SLiu Zhe 		submitSaveDlg(saveTo);
549*4a13b48eSLi Feng Wang 		if (activeMsgBox.exists()) {
550*4a13b48eSLi Feng Wang 			activeMsgBox.yes();
551*4a13b48eSLi Feng Wang 			sleep(2);
552*4a13b48eSLi Feng Wang 		}
553*4a13b48eSLi Feng Wang 		sleep(5);
5543816404dSLiu Zhe 		app.dispatch(".uno:CloseDoc");
55504bad30fSLiu Zhe 
55622a14f28SLiu Zhe 		// Reopen this file
55704bad30fSLiu Zhe 		openStartcenter();
55804bad30fSLiu Zhe 		app.dispatch(".uno:Open");
55922a14f28SLiu Zhe 		String openFrom = getPath("temp/" + "hello.odp");
56004bad30fSLiu Zhe 		submitOpenDlg(openFrom);
561*4a13b48eSLi Feng Wang 		sleep(5);
56222a14f28SLiu Zhe 		// check after reopen
5633816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
564b4d2d410SLiu Zhe 		sdHeaderAndFooterOnNotesTabPage.select();
565b4d2d410SLiu Zhe 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
566b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
567b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
568b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
56904bad30fSLiu Zhe 	}
57004bad30fSLiu Zhe 
57104bad30fSLiu Zhe 	/**
57222a14f28SLiu Zhe 	 * Test Insert Header and Footer to Slide Save and Reopen
57322a14f28SLiu Zhe 	 *
57404bad30fSLiu Zhe 	 * @throws Exception
57504bad30fSLiu Zhe 	 */
57604bad30fSLiu Zhe 	@Test
57722a14f28SLiu Zhe 	public void testInsertHeaderFooterOnSlide() throws Exception {
57804bad30fSLiu Zhe 
57922a14f28SLiu Zhe 		// add header and footer
5803816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
581b4d2d410SLiu Zhe 		sdDateAndTimeFooterOnSlide.check();
582b4d2d410SLiu Zhe 		sdFixedDateAndTimeFooterOnSlide.check();
583b4d2d410SLiu Zhe 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120329");
584b4d2d410SLiu Zhe 		sdFooterTextOnSlide.check();
585b4d2d410SLiu Zhe 		sdFooterTextOnSlideInput.setText("Footer Test");
586b4d2d410SLiu Zhe 		sdSlideNumAsFooterOnSlide.check();
587b4d2d410SLiu Zhe 		sdApplyToAllButtonOnSlideFooter.click();
58804bad30fSLiu Zhe 
589b4d2d410SLiu Zhe 		impressSlideSorter.focus();
59004bad30fSLiu Zhe 		typeKeys("<up>");
59104bad30fSLiu Zhe 
5923816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
593b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
594b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
595b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
59604bad30fSLiu Zhe 
59722a14f28SLiu Zhe 		// close header and footer dialog.
598b4d2d410SLiu Zhe 		sdApplyButtonOnSlideFooter.focus();
59904bad30fSLiu Zhe 		typeKeys("<tab>");
60004bad30fSLiu Zhe 		typeKeys("<enter>");
60104bad30fSLiu Zhe 
60222a14f28SLiu Zhe 		// save this file
6033816404dSLiu Zhe 		app.dispatch(".uno:SaveAs");
60495269d92SLiu Zhe 		String saveTo = getPath("temp/" + "hello.odp");
60504bad30fSLiu Zhe 		FileUtil.deleteFile(saveTo);
60622a14f28SLiu Zhe 		submitSaveDlg(saveTo);
607*4a13b48eSLi Feng Wang 		if (activeMsgBox.exists()) {
608*4a13b48eSLi Feng Wang 			activeMsgBox.yes();
609*4a13b48eSLi Feng Wang 			sleep(2);
610*4a13b48eSLi Feng Wang 		}
611*4a13b48eSLi Feng Wang 		sleep(5);
6123816404dSLiu Zhe 		app.dispatch(".uno:CloseDoc");
61304bad30fSLiu Zhe 
61422a14f28SLiu Zhe 		// Reopen this file
61504bad30fSLiu Zhe 		openStartcenter();
61604bad30fSLiu Zhe 		app.dispatch(".uno:Open");
61722a14f28SLiu Zhe 		String openFrom = getPath("temp/" + "hello.odp");
61804bad30fSLiu Zhe 		submitOpenDlg(openFrom);
619*4a13b48eSLi Feng Wang 		sleep(5);
62022a14f28SLiu Zhe 		// check after reopen
6213816404dSLiu Zhe 		app.dispatch(".uno:HeaderAndFooter");
622b4d2d410SLiu Zhe 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
623b4d2d410SLiu Zhe 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
624b4d2d410SLiu Zhe 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
62504bad30fSLiu Zhe 	}
62604bad30fSLiu Zhe }
627