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.*;
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 import testlib.gui.SDTool;
41 
42 public class HeaderAndFooterSetting {
43 
44 	@Rule
45 	public Logger log = Logger.getLogger(this);
46 
47 	@Before
48 	public void setUp() throws Exception {
49 		app.start(true); // Bug 120476
50 
51 		// New a impress, insert some slides
52 		app.dispatch("private:factory/simpress?slot=6686");
53 		presentationWizard.ok();
54 		impress.waitForExistence(10, 2);
55 
56 		for (int i = 0; i < 5; i++) {
57 			sdInsertPageButtonOnToolbar.click();
58 		}
59 		// Pop up navigator panel
60 		if (!sdNavigatorDlg.exists()) {
61 			app.dispatch(".uno:Navigator");
62 		}
63 	}
64 
65 	@After
66 	public void tearDown() throws Exception {
67 		app.stop();
68 	}
69 
70 	/**
71 	 * Test Copy slide with Apply Footer to same file and different file
72 	 *
73 	 * @throws Exception
74 	 */
75 	@Test
76 	public void testCopySlideWithApplyFooter() throws Exception {
77 
78 		// add header and footer
79 		app.dispatch(".uno:HeaderAndFooter");
80 
81 		sdDateAndTimeFooterOnSlide.check();
82 		sdFixedDateAndTimeFooterOnSlide.check();
83 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
84 		sdFooterTextOnSlide.check();
85 		sdFooterTextOnSlideInput.setText("Footer Test");
86 		sdSlideNumAsFooterOnSlide.check();
87 		sdApplyToAllButtonOnSlideFooter.click();
88 
89 		// Click slide 3
90 		impressSlideSorter.focus();
91 		typeKeys("<up><up><up>");
92 		sleep(1);
93 		app.dispatch(".uno:HeaderAndFooter");
94 		sdSlideNumAsFooterOnSlide.uncheck();
95 		sdApplyButtonOnSlideFooter.click();
96 
97 		// paste to the same file
98 		impressSlideSorter.focus();
99 		app.dispatch(".uno:Copy");
100 		app.dispatch(".uno:Paste");
101 
102 		app.dispatch(".uno:HeaderAndFooter");
103 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
104 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
105 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
106 		sdHeaderAndFooterDlgSlideTab.cancel();
107 
108 		// paste to different file
109 		impress.focus();
110 		app.dispatch("private:factory/simpress?slot=6686");
111 		presentationWizard.ok();
112 		app.dispatch(".uno:Paste");
113 		impressSlideSorter.focus();
114 		typeKeys("<down>");
115 		sleep(1);
116 
117 		app.dispatch(".uno:HeaderAndFooter");
118 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
119 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
120 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
121 	}
122 
123 	/**
124 	 * Test Copy slide with Apply to all Footer to same file and different file
125 	 *
126 	 * @throws Exception
127 	 */
128 	@Test
129 	public void testCopySlideWithApplyToAllFooter() throws Exception {
130 
131 		// add header and footer
132 		app.dispatch(".uno:HeaderAndFooter");
133 
134 		sdDateAndTimeFooterOnSlide.check();
135 		sdFixedDateAndTimeFooterOnSlide.check();
136 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
137 		sdFooterTextOnSlide.check();
138 		sdFooterTextOnSlideInput.setText("Footer Test");
139 		sdSlideNumAsFooterOnSlide.check();
140 		sdApplyToAllButtonOnSlideFooter.click();
141 
142 		impressSlideSorter.focus();
143 		for (int j = 0; j <= 2; j++) {
144 			typeKeys("<up>");
145 		}
146 		app.dispatch(".uno:HeaderAndFooter");
147 		sdSlideNumAsFooterOnSlide.uncheck();
148 		sdApplyButtonOnSlideFooter.click();
149 
150 		// paste to the same file
151 		impressSlideSorter.focus();
152 		typeKeys("<up>");
153 		app.dispatch(".uno:Copy");
154 		typeKeys("<down>");
155 		app.dispatch(".uno:Paste");
156 
157 		app.dispatch(".uno:HeaderAndFooter");
158 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
159 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
160 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
161 		sdHeaderAndFooterDlgSlideTab.cancel();
162 
163 		// paste to different file
164 		app.dispatch("private:factory/simpress?slot=6686");
165 		presentationWizard.ok();
166 		app.dispatch(".uno:Paste");
167 		impressSlideSorter.focus();
168 		typeKeys("<down>");
169 		sleep(1); // If no sleep, error occur
170 
171 		app.dispatch(".uno:HeaderAndFooter");
172 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
173 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
174 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
175 	}
176 
177 	/**
178 	 * Test Copy slide with Notes Footer to same file and different file
179 	 *
180 	 * @throws Exception
181 	 */
182 	@Test
183 	public void testCopySlideWithNotesHeaderFooter() throws Exception {
184 
185 		// add header and footer
186 		app.dispatch(".uno:HeaderAndFooter");
187 		sdHeaderAndFooterOnNotesTabPage.select();
188 		sdHeaderTextOnNotes.check();
189 		sdHeaderTextOnNotesInput.setText("Header Test");
190 		sdDateAndTimeFooterOnSlide.check();
191 		sdFixedDateAndTimeFooterOnSlide.check();
192 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120329");
193 		sdFooterTextOnSlide.check();
194 		sdFooterTextOnSlideInput.setText("Footer Test");
195 		sdSlideNumAsFooterOnSlide.check();
196 		sdApplyToAllButtonOnSlideFooter.click();
197 
198 		// paste to the same file
199 		impressSlideSorter.focus();
200 		typeKeys("<up>");
201 		app.dispatch(".uno:Copy");
202 		typeKeys("<down>");
203 		app.dispatch(".uno:Paste");
204 
205 		app.dispatch(".uno:HeaderAndFooter");
206 		sdHeaderAndFooterOnNotesTabPage.select();
207 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
208 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
209 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
210 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
211 		sdHeaderAndFooterOnNotesTabPage.cancel();
212 
213 		// paste to different file
214 		impress.focus();
215 		app.dispatch("private:factory/simpress?slot=6686");
216 		presentationWizard.ok();
217 		app.dispatch(".uno:Paste");
218 		impressSlideSorter.focus();
219 		typeKeys("<down>");
220 		SDTool.getActiveView().activate();
221 		app.dispatch(".uno:HeaderAndFooter");
222 		sdHeaderAndFooterOnNotesTabPage.select();
223 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
224 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
225 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
226 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
227 	}
228 
229 	/**
230 	 * Test duplicate slide with Apply to all Footer to same file
231 	 *
232 	 * @throws Exception
233 	 */
234 	@Test
235 	public void testDuplicateSlideWithApplyToAllFooter() throws Exception {
236 
237 		// add header and footer
238 		app.dispatch(".uno:HeaderAndFooter");
239 
240 		sdDateAndTimeFooterOnSlide.check();
241 		sdFixedDateAndTimeFooterOnSlide.check();
242 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
243 		sdFooterTextOnSlide.check();
244 		sdFooterTextOnSlideInput.setText("Footer Test");
245 		sdSlideNumAsFooterOnSlide.check();
246 		sdApplyToAllButtonOnSlideFooter.click();
247 
248 		impressSlideSorter.focus();
249 		for (int j = 0; j <= 2; j++) {
250 			typeKeys("<up>");
251 		}
252 		app.dispatch(".uno:DuplicatePage");
253 		app.dispatch(".uno:HeaderAndFooter");
254 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
255 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
256 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
257 	}
258 
259 	/**
260 	 * Test footer not show on the first slide.
261 	 *
262 	 * @throws Exception
263 	 */
264 	@Test
265 	public void testFooterNotShowOn1stSlide() throws Exception {
266 
267 		// add header and footer
268 		app.dispatch(".uno:HeaderAndFooter");
269 		sdFooterTextOnSlide.check();
270 		sdFooterTextOnSlideInput.setText("Footer Test");
271 		sdFooterNotShowOn1stSlide.check();
272 		sdApplyToAllButtonOnSlideFooter.click();
273 
274 		// Check slide 1
275 		impressSlideSorter.focus();
276 		// typeKeys("<up><up><up><up><up>"); // Not stable on ubuntu10.04
277 		// sleep(1); // If no sleep, error occur
278 		for (int i = 0; i < 5; i++) {
279 			typeKeys("<up>");
280 			sleep(1);
281 		}
282 
283 		app.dispatch(".uno:HeaderAndFooter");
284 		assertEquals(true, sdFooterNotShowOn1stSlide.isChecked());
285 		assertEquals(false, sdFooterTextOnSlide.isChecked());
286 	}
287 
288 	/**
289 	 * Test Insert Footer to focus slide.
290 	 *
291 	 * @throws Exception
292 	 */
293 	@Test
294 	public void testInsertApplyFooterOnSlide() throws Exception {
295 
296 		// add header and footer to focus slide.
297 		app.dispatch(".uno:HeaderAndFooter");
298 
299 		sdDateAndTimeFooterOnSlide.check();
300 		sdFixedDateAndTimeFooterOnSlide.check();
301 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
302 		sdFooterTextOnSlide.check();
303 		sdFooterTextOnSlideInput.setText("Footer Test");
304 		sdSlideNumAsFooterOnSlide.check();
305 		sdApplyButtonOnSlideFooter.click();
306 
307 		app.dispatch(".uno:HeaderAndFooter");
308 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
309 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
310 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
311 		assertEquals(true, sdFooterTextOnSlide.isChecked());
312 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
313 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
314 		// close header and footer dialog.
315 		sdApplyButtonOnSlideFooter.focus();
316 		typeKeys("<tab>");
317 		typeKeys("<enter>");
318 		// end close
319 
320 		impressSlideSorter.focus();
321 		typeKeys("<up>");
322 		sleep(1); // If no sleep, error occur
323 
324 		app.dispatch(".uno:HeaderAndFooter");
325 		assertEquals("", sdFixedDateAndTimeOnSlideInput.getText());
326 		assertEquals("", sdFooterTextOnSlideInput.getText());
327 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
328 		// close header and footer dialog.
329 		sdApplyButtonOnSlideFooter.focus();
330 		typeKeys("<tab>");
331 		typeKeys("<enter>");
332 		// end close
333 
334 		sdInsertPageButtonOnToolbar.click();
335 		app.dispatch(".uno:HeaderAndFooter");
336 		assertEquals("", sdFixedDateAndTimeOnSlideInput.getText());
337 		assertEquals("", sdFooterTextOnSlideInput.getText());
338 		assertEquals(false, sdSlideNumAsFooterOnSlide.isChecked());
339 	}
340 
341 	/**
342 	 * Test Insert Footer to Notes View
343 	 *
344 	 * @throws Exception
345 	 */
346 	@Test
347 	public void testInsertApplyToAllFooterOnNotes() throws Exception {
348 
349 		// add header and footer to focus slide.
350 		app.dispatch(".uno:HeaderAndFooter");
351 		sdHeaderAndFooterOnNotesTabPage.select();
352 		sdHeaderTextOnNotes.check();
353 		sdHeaderTextOnNotesInput.setText("Header Test");
354 		sdDateAndTimeFooterOnSlide.check();
355 		sdFixedDateAndTimeFooterOnSlide.check();
356 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
357 		sdFooterTextOnSlide.check();
358 		sdFooterTextOnSlideInput.setText("Footer Test");
359 		sdSlideNumAsFooterOnSlide.check();
360 		sdApplyToAllButtonOnSlideFooter.click();
361 
362 		app.dispatch(".uno:HeaderAndFooter");
363 		sdHeaderAndFooterOnNotesTabPage.select();
364 		assertEquals(true, sdHeaderTextOnNotes.isChecked());
365 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
366 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
367 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
368 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
369 		assertEquals(true, sdFooterTextOnSlide.isChecked());
370 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
371 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
372 		// close header and footer dialog.
373 		sdApplyToAllButtonOnSlideFooter.focus();
374 		typeKeys("<tab>");
375 		typeKeys("<enter>");
376 		// end close
377 
378 		impressSlideSorter.focus();
379 		typeKeys("<up>");
380 
381 		app.dispatch(".uno:HeaderAndFooter");
382 		sdHeaderAndFooterOnNotesTabPage.select();
383 		assertEquals(true, sdHeaderTextOnNotes.isChecked());
384 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
385 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
386 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
387 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
388 		assertEquals(true, sdFooterTextOnSlide.isChecked());
389 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
390 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
391 		// close header and footer dialog.
392 		sdApplyToAllButtonOnSlideFooter.focus();
393 		typeKeys("<tab>");
394 		typeKeys("<enter>");
395 		// end close
396 
397 		sdInsertPageButtonOnToolbar.click();
398 		app.dispatch(".uno:HeaderAndFooter");
399 		sdHeaderAndFooterOnNotesTabPage.select();
400 		assertEquals(true, sdHeaderTextOnNotes.isChecked());
401 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
402 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
403 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
404 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
405 		assertEquals(true, sdFooterTextOnSlide.isChecked());
406 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
407 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
408 	}
409 
410 	/**
411 	 * Test Insert Footer to Slide, use Apply to All
412 	 *
413 	 * @throws Exception
414 	 */
415 	@Test
416 	public void testInsertApplyToAllFooterOnSlide() throws Exception {
417 
418 		// add header and footer to focus slide.
419 		app.dispatch(".uno:HeaderAndFooter");
420 
421 		sdDateAndTimeFooterOnSlide.check();
422 		sdFixedDateAndTimeFooterOnSlide.check();
423 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120323");
424 		sdFooterTextOnSlide.check();
425 		sdFooterTextOnSlideInput.setText("Footer Test");
426 		sdSlideNumAsFooterOnSlide.check();
427 		sdApplyToAllButtonOnSlideFooter.click();
428 
429 		app.dispatch(".uno:HeaderAndFooter");
430 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
431 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
432 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
433 		assertEquals(true, sdFooterTextOnSlide.isChecked());
434 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
435 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
436 		// close header and footer dialog.
437 		sdApplyButtonOnSlideFooter.focus();
438 		typeKeys("<tab>");
439 		typeKeys("<enter>");
440 		// end close
441 
442 		impressSlideSorter.focus();
443 		typeKeys("<up>");
444 
445 		app.dispatch(".uno:HeaderAndFooter");
446 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
447 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
448 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
449 		assertEquals(true, sdFooterTextOnSlide.isChecked());
450 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
451 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
452 		// close header and footer dialog.
453 		sdApplyButtonOnSlideFooter.focus();
454 		typeKeys("<tab>");
455 		typeKeys("<enter>");
456 		// end close
457 
458 		sdInsertPageButtonOnToolbar.click();
459 		app.dispatch(".uno:HeaderAndFooter");
460 		assertEquals(true, sdDateAndTimeFooterOnSlide.isChecked());
461 		assertEquals(true, sdFixedDateAndTimeFooterOnSlide.isChecked());
462 		assertEquals("Fix Date: 20120323", sdFixedDateAndTimeOnSlideInput.getText());
463 		assertEquals(true, sdFooterTextOnSlide.isChecked());
464 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
465 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
466 	}
467 
468 	/**
469 	 * Test Insert update automatically time footer to slides.
470 	 *
471 	 * @throws Exception
472 	 */
473 	@Test
474 	public void testInsertAutoUpdateTimeFooter() throws Exception {
475 
476 		// add header and footer
477 		app.dispatch(".uno:HeaderAndFooter");
478 		sdAutoUpdateTimeFooter.check();
479 		sdAutoUpdateTimeFooterType.select(7);
480 		String currentTime = sdAutoUpdateTimeFooterType.getItemText(7);
481 		sdApplyToAllButtonOnSlideFooter.click();
482 		sleep(1); // Wait some time to check the time update
483 
484 		app.dispatch(".uno:HeaderAndFooter");
485 		String updatedTime = sdAutoUpdateTimeFooterType.getItemText(7);
486 		assertNotSame("Time can not update", currentTime, updatedTime);
487 	}
488 
489 	/**
490 	 * Test Insert update automatically time footer to Notes view.
491 	 *
492 	 * @throws Exception
493 	 */
494 	@Test
495 	public void testInsertAutoUpdateTimeFooterOnNotes() throws Exception {
496 
497 		// add header and footer
498 		app.dispatch(".uno:HeaderAndFooter");
499 		sdHeaderAndFooterOnNotesTabPage.select();
500 		sdAutoUpdateTimeFooter.check();
501 		String currentTime = sdAutoUpdateTimeFooterType.getItemText(7);
502 		sdApplyToAllButtonOnSlideFooter.click();
503 		sleep(1); // Wait some time to check the time update
504 
505 		app.dispatch(".uno:HeaderAndFooter");
506 		sdHeaderAndFooterOnNotesTabPage.select();
507 		String updatedTime = sdAutoUpdateTimeFooterType.getItemText(7);
508 
509 		assertNotSame("Time can not update", currentTime, updatedTime);
510 	}
511 
512 	/**
513 	 * Test Insert Header and Footer to Notes view. Save and ReOpen
514 	 *
515 	 * @throws Exception
516 	 */
517 	@Test
518 	public void testInsertHeaderFooterOnNotes() throws Exception {
519 
520 		// add header and footer
521 		app.dispatch(".uno:HeaderAndFooter");
522 		sdHeaderAndFooterOnNotesTabPage.select();
523 		sdHeaderTextOnNotes.check();
524 		sdHeaderTextOnNotesInput.setText("Header Test");
525 		sdDateAndTimeFooterOnSlide.check();
526 		sdFixedDateAndTimeFooterOnSlide.check();
527 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120329");
528 		sdFooterTextOnSlide.check();
529 		sdFooterTextOnSlideInput.setText("Footer Test");
530 		sdSlideNumAsFooterOnSlide.check();
531 		sdApplyToAllButtonOnSlideFooter.click();
532 
533 		impressSlideSorter.focus();
534 		typeKeys("<up>");
535 
536 		app.dispatch(".uno:HeaderAndFooter");
537 		sdHeaderAndFooterOnNotesTabPage.select();
538 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
539 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
540 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
541 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
542 		sdHeaderAndFooterOnNotesTabPage.cancel();
543 
544 		// save this file
545 		app.dispatch(".uno:SaveAs");
546 		String saveTo = getPath("temp/" + "hello.odp");
547 		FileUtil.deleteFile(saveTo);
548 		submitSaveDlg(saveTo);
549 		if (activeMsgBox.exists()) {
550 			activeMsgBox.yes();
551 			sleep(2);
552 		}
553 		sleep(5);
554 		app.dispatch(".uno:CloseDoc");
555 
556 		// Reopen this file
557 		openStartcenter();
558 		app.dispatch(".uno:Open");
559 		String openFrom = getPath("temp/" + "hello.odp");
560 		submitOpenDlg(openFrom);
561 		sleep(5);
562 		// check after reopen
563 		app.dispatch(".uno:HeaderAndFooter");
564 		sdHeaderAndFooterOnNotesTabPage.select();
565 		assertEquals("Header Test", sdHeaderTextOnNotesInput.getText());
566 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
567 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
568 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
569 	}
570 
571 	/**
572 	 * Test Insert Header and Footer to Slide Save and Reopen
573 	 *
574 	 * @throws Exception
575 	 */
576 	@Test
577 	public void testInsertHeaderFooterOnSlide() throws Exception {
578 
579 		// add header and footer
580 		app.dispatch(".uno:HeaderAndFooter");
581 		sdDateAndTimeFooterOnSlide.check();
582 		sdFixedDateAndTimeFooterOnSlide.check();
583 		sdFixedDateAndTimeOnSlideInput.setText("Fix Date: 20120329");
584 		sdFooterTextOnSlide.check();
585 		sdFooterTextOnSlideInput.setText("Footer Test");
586 		sdSlideNumAsFooterOnSlide.check();
587 		sdApplyToAllButtonOnSlideFooter.click();
588 
589 		impressSlideSorter.focus();
590 		typeKeys("<up>");
591 
592 		app.dispatch(".uno:HeaderAndFooter");
593 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
594 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
595 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
596 
597 		// close header and footer dialog.
598 		sdApplyButtonOnSlideFooter.focus();
599 		typeKeys("<tab>");
600 		typeKeys("<enter>");
601 
602 		// save this file
603 		app.dispatch(".uno:SaveAs");
604 		String saveTo = getPath("temp/" + "hello.odp");
605 		FileUtil.deleteFile(saveTo);
606 		submitSaveDlg(saveTo);
607 		if (activeMsgBox.exists()) {
608 			activeMsgBox.yes();
609 			sleep(2);
610 		}
611 		sleep(5);
612 		app.dispatch(".uno:CloseDoc");
613 
614 		// Reopen this file
615 		openStartcenter();
616 		app.dispatch(".uno:Open");
617 		String openFrom = getPath("temp/" + "hello.odp");
618 		submitOpenDlg(openFrom);
619 		sleep(5);
620 		// check after reopen
621 		app.dispatch(".uno:HeaderAndFooter");
622 		assertEquals("Fix Date: 20120329", sdFixedDateAndTimeOnSlideInput.getText());
623 		assertEquals("Footer Test", sdFooterTextOnSlideInput.getText());
624 		assertEquals(true, sdSlideNumAsFooterOnSlide.isChecked());
625 	}
626 }
627