xref: /AOO41X/test/testgui/source/pvt/gui/Benchmark.java (revision f46d12a6c5d8c7fb6ec880c7d5f1c7f7fdcc2d61)
157caf934SLiu Zhe /**************************************************************
257caf934SLiu Zhe  *
357caf934SLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
457caf934SLiu Zhe  * or more contributor license agreements.  See the NOTICE file
557caf934SLiu Zhe  * distributed with this work for additional information
657caf934SLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
757caf934SLiu Zhe  * to you under the Apache License, Version 2.0 (the
857caf934SLiu Zhe  * "License"); you may not use this file except in compliance
957caf934SLiu Zhe  * with the License.  You may obtain a copy of the License at
1057caf934SLiu Zhe  *
1157caf934SLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
1257caf934SLiu Zhe  *
1357caf934SLiu Zhe  * Unless required by applicable law or agreed to in writing,
1457caf934SLiu Zhe  * software distributed under the License is distributed on an
1557caf934SLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1657caf934SLiu Zhe  * KIND, either express or implied.  See the License for the
1757caf934SLiu Zhe  * specific language governing permissions and limitations
1857caf934SLiu Zhe  * under the License.
1957caf934SLiu Zhe  *
2057caf934SLiu Zhe  *************************************************************/
2157caf934SLiu Zhe 
2257caf934SLiu Zhe /**
2357caf934SLiu Zhe  *
2457caf934SLiu Zhe  */
2557caf934SLiu Zhe 
2657caf934SLiu Zhe package pvt.gui;
2757caf934SLiu Zhe 
28*f46d12a6SLiu Zhe import static org.junit.Assert.*;
2957caf934SLiu Zhe import static org.openoffice.test.common.Testspace.*;
3057caf934SLiu Zhe import static org.openoffice.test.vcl.Tester.*;
31*f46d12a6SLiu Zhe import static testlib.gui.AppTool.*;
3257caf934SLiu Zhe import static testlib.gui.UIMap.*;
3357caf934SLiu Zhe 
34*f46d12a6SLiu Zhe import java.awt.Rectangle;
3557caf934SLiu Zhe import java.io.File;
3657caf934SLiu Zhe import java.io.FileOutputStream;
3757caf934SLiu Zhe import java.io.PrintStream;
3857caf934SLiu Zhe import java.util.HashMap;
3957caf934SLiu Zhe 
4057caf934SLiu Zhe import org.junit.AfterClass;
4157caf934SLiu Zhe import org.junit.BeforeClass;
42*f46d12a6SLiu Zhe import org.junit.Ignore;
4357caf934SLiu Zhe import org.junit.Rule;
4457caf934SLiu Zhe import org.junit.Test;
4557caf934SLiu Zhe import org.junit.rules.TestName;
4657caf934SLiu Zhe import org.openoffice.test.OpenOffice;
4757caf934SLiu Zhe import org.openoffice.test.common.Condition;
48*f46d12a6SLiu Zhe import org.openoffice.test.common.GraphicsUtil;
4957caf934SLiu Zhe import org.openoffice.test.common.Logger;
5057caf934SLiu Zhe import org.openoffice.test.common.SystemUtil;
5157caf934SLiu Zhe import org.openoffice.test.common.Testspace;
5257caf934SLiu Zhe 
5357caf934SLiu Zhe 
5457caf934SLiu Zhe public class Benchmark {
5557caf934SLiu Zhe 	@Rule
5657caf934SLiu Zhe 	public Logger log = Logger.getLogger(this);
5757caf934SLiu Zhe 
5857caf934SLiu Zhe 	@Rule
5957caf934SLiu Zhe 	public TestName testname = new TestName();
6057caf934SLiu Zhe 
6157caf934SLiu Zhe 	private static PrintStream result;
6257caf934SLiu Zhe 
6357caf934SLiu Zhe 	private static final double INTERVAL = 0.01;
6457caf934SLiu Zhe 
6557caf934SLiu Zhe 	public Benchmark() {
6657caf934SLiu Zhe 
6757caf934SLiu Zhe 	}
6857caf934SLiu Zhe 
6957caf934SLiu Zhe 	@BeforeClass
7057caf934SLiu Zhe 	public static void beforeClass() throws Exception {
71*f46d12a6SLiu Zhe 		File resultFile = Testspace.getFile("output/pvt_gui_benchmark.csv");
7257caf934SLiu Zhe 		resultFile.getParentFile().mkdirs();
7357caf934SLiu Zhe 		result = new PrintStream(new FileOutputStream(resultFile));
7457caf934SLiu Zhe 		OpenOffice.killAll();
7557caf934SLiu Zhe 
76*f46d12a6SLiu Zhe 		result.println("Scenario,No,Consumed Time,Memory(VSZ),Memory(RSS),Handles(Windows Only)");
7757caf934SLiu Zhe 	}
7857caf934SLiu Zhe 
7957caf934SLiu Zhe 	@AfterClass
8057caf934SLiu Zhe 	public static void afterClass() throws Exception {
8157caf934SLiu Zhe 		result.close();
8257caf934SLiu Zhe 		app.close();
8357caf934SLiu Zhe 	}
8457caf934SLiu Zhe 
8557caf934SLiu Zhe 	private HashMap<String, Object> getPerfData() {
8657caf934SLiu Zhe 		HashMap<String, Object> proccessInfo = SystemUtil.findProcess(".*(soffice\\.bin|soffice\\.exe .*-env).*");
8757caf934SLiu Zhe 		String pid = (String) proccessInfo.get("pid");
8857caf934SLiu Zhe 		return SystemUtil.getProcessPerfData(pid);
8957caf934SLiu Zhe 	}
9057caf934SLiu Zhe 
9157caf934SLiu Zhe 	private void addRecord(int i, long start, long end) {
9257caf934SLiu Zhe 		HashMap<String, Object>  perf = getPerfData();
93*f46d12a6SLiu Zhe 		result.println(testname.getMethodName() + "," + i + "," + (end - start) + "," + perf.get("vsz") + "," + perf.get("rss") + "," + perf.get("handles"));
9457caf934SLiu Zhe 	}
9557caf934SLiu Zhe 
9657caf934SLiu Zhe 	@Test
9757caf934SLiu Zhe 	public void coolStartup() throws Exception {
9857caf934SLiu Zhe 		aoo.kill();
9957caf934SLiu Zhe 		aoo.cleanUserInstallation();
10057caf934SLiu Zhe 		aoo.start();
10157caf934SLiu Zhe 		long start = System.currentTimeMillis();
10257caf934SLiu Zhe 		startcenter.waitForExistence(120, INTERVAL);
10357caf934SLiu Zhe 		long end = System.currentTimeMillis();
10457caf934SLiu Zhe 		sleep(2);
10557caf934SLiu Zhe 		addRecord(0, start, end);
10657caf934SLiu Zhe 		app.close();
10757caf934SLiu Zhe 	}
10857caf934SLiu Zhe 
10957caf934SLiu Zhe 	@Test
11057caf934SLiu Zhe 	public void warmStartup() throws Exception {
11157caf934SLiu Zhe 		for (int i = 0; i < 8; i++) {
11257caf934SLiu Zhe 			aoo.kill();//make sure app is closed
11357caf934SLiu Zhe 			aoo.start();
11457caf934SLiu Zhe 			long start = System.currentTimeMillis();
11557caf934SLiu Zhe 			startcenter.waitForExistence(120, INTERVAL);
11657caf934SLiu Zhe 			long end = System.currentTimeMillis();
11757caf934SLiu Zhe 			sleep(2);
11857caf934SLiu Zhe 			addRecord(i, start, end);
11957caf934SLiu Zhe 			app.close();
12057caf934SLiu Zhe 		}
12157caf934SLiu Zhe 	}
12257caf934SLiu Zhe 
12357caf934SLiu Zhe 	@Test
12457caf934SLiu Zhe 	public void newTextDocument() {
12557caf934SLiu Zhe 		for (int i = 0; i < 8; i++) {
12657caf934SLiu Zhe 			aoo.kill();//make sure app is closed
12757caf934SLiu Zhe 			aoo.start();
12857caf934SLiu Zhe 			startCenterWriterButton.waitForExistence(120, 1);
12957caf934SLiu Zhe 			sleep(2);
13057caf934SLiu Zhe 			startCenterWriterButton.click(0.5, 0.5);
13157caf934SLiu Zhe 			long start = System.currentTimeMillis();
13257caf934SLiu Zhe 			writer.waitForExistence(60, INTERVAL);
13357caf934SLiu Zhe 			long end = System.currentTimeMillis();
13457caf934SLiu Zhe 			sleep(2);
13557caf934SLiu Zhe 			addRecord(i, start, end);
13657caf934SLiu Zhe 			app.close();
13757caf934SLiu Zhe 		}
13857caf934SLiu Zhe 	}
13957caf934SLiu Zhe 
14057caf934SLiu Zhe 	@Test
14157caf934SLiu Zhe 	public void newSpreadsheet() {
14257caf934SLiu Zhe 		for (int i = 0; i < 8; i++) {
14357caf934SLiu Zhe 			aoo.kill();//make sure app is closed
14457caf934SLiu Zhe 			aoo.start();
14557caf934SLiu Zhe 			startCenterCalcButton.waitForExistence(120, 1);
14657caf934SLiu Zhe 			sleep(2);
14757caf934SLiu Zhe 			startCenterCalcButton.click(0.5, 0.5);
14857caf934SLiu Zhe 			long start = System.currentTimeMillis();
14957caf934SLiu Zhe 			calc.waitForExistence(60, INTERVAL);
15057caf934SLiu Zhe 			long end = System.currentTimeMillis();
15157caf934SLiu Zhe 			sleep(2);
15257caf934SLiu Zhe 			addRecord(i, start, end);
15357caf934SLiu Zhe 			app.close();
15457caf934SLiu Zhe 		}
15557caf934SLiu Zhe 	}
15657caf934SLiu Zhe 
15757caf934SLiu Zhe 	@Test
15857caf934SLiu Zhe 	public void newPresentation() {
15957caf934SLiu Zhe 		for (int i = 0; i < 8; i++) {
16057caf934SLiu Zhe 			aoo.kill();//make sure app is closed
16157caf934SLiu Zhe 			aoo.start();
16257caf934SLiu Zhe 			startCenterImpressButton.waitForExistence(120, 1);
16357caf934SLiu Zhe 			sleep(2);
16457caf934SLiu Zhe 			startCenterImpressButton.click(0.5, 0.5);
16557caf934SLiu Zhe 			sleep(1);
16657caf934SLiu Zhe 			presentationWizard.click(0.9, 0.95);
16757caf934SLiu Zhe 			long start = System.currentTimeMillis();
16857caf934SLiu Zhe 			impress.waitForExistence(60, INTERVAL);
16957caf934SLiu Zhe 			long end = System.currentTimeMillis();
17057caf934SLiu Zhe 			sleep(2);
17157caf934SLiu Zhe 			addRecord(i, start, end);
17257caf934SLiu Zhe 			app.close();
17357caf934SLiu Zhe 		}
17457caf934SLiu Zhe 	}
17557caf934SLiu Zhe 
17657caf934SLiu Zhe 	@Test
177*f46d12a6SLiu Zhe 	public void loadFinishPlainODT() {
178*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_200p.odt", "Page 1 / 23[0-9]{1}");
17957caf934SLiu Zhe 	}
18057caf934SLiu Zhe 
18157caf934SLiu Zhe 	@Test
182*f46d12a6SLiu Zhe 	public void loadFinishPlainDOC() {
183*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_200p.doc", "Page 1 / 23[0-9]{1}");
18457caf934SLiu Zhe 	}
18557caf934SLiu Zhe 
18657caf934SLiu Zhe 	@Test
187*f46d12a6SLiu Zhe 	public void loadFinishPlainDOCX() {
188*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_200p.docx", "Page 1 / 19[0-9]{1}");
18957caf934SLiu Zhe 	}
19057caf934SLiu Zhe 
19157caf934SLiu Zhe 	@Test
19257caf934SLiu Zhe 	public void loadFinishPlainODS() {
193*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_11s.ods", "Sheet 1 / 11");
19457caf934SLiu Zhe 	}
19557caf934SLiu Zhe 
19657caf934SLiu Zhe 	@Test
197*f46d12a6SLiu Zhe 	public void loadFinishPlainXLS() {
198*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_11s.xls", "Sheet 1 / 11");
19957caf934SLiu Zhe 	}
20057caf934SLiu Zhe 
20157caf934SLiu Zhe 	@Test
202*f46d12a6SLiu Zhe 	public void loadFinishPlainXLSX() {
203*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_11s.xlsx", "Sheet 1 / 11");
20457caf934SLiu Zhe 	}
20557caf934SLiu Zhe 
20657caf934SLiu Zhe 	@Test
20757caf934SLiu Zhe 	public void loadFinishPlainODP() {
208*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_200p.odp", "Slide 1 / 200");
20957caf934SLiu Zhe 	}
21057caf934SLiu Zhe 
21157caf934SLiu Zhe 	@Test
21257caf934SLiu Zhe 	public void loadFinishPlainPPT() {
213*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_200p.ppt", "Slide 1 / 200");
21457caf934SLiu Zhe 	}
21557caf934SLiu Zhe 
21657caf934SLiu Zhe 	@Test
217*f46d12a6SLiu Zhe 	public void loadFinishPlainPPTX() {
218*f46d12a6SLiu Zhe 		loadFinish("pvt/plain_200p.pptx", "Slide 1 / 200");
219*f46d12a6SLiu Zhe 	}
220*f46d12a6SLiu Zhe 
221*f46d12a6SLiu Zhe 	@Test
222*f46d12a6SLiu Zhe 	@Ignore
223*f46d12a6SLiu Zhe 	public void loadFinishComplexDOC() {
224*f46d12a6SLiu Zhe 		loadFinish("pvt/sw_complex_100p.doc", "Page 1 / ");
225*f46d12a6SLiu Zhe 	}
226*f46d12a6SLiu Zhe 
227*f46d12a6SLiu Zhe 	@Test
228*f46d12a6SLiu Zhe 	@Ignore
229*f46d12a6SLiu Zhe 	public void loadFinishComplexODT() {
230*f46d12a6SLiu Zhe 		loadFinish("pvt/sw_complex_100p_odf1.2.odt", "Page 1 / ");
231*f46d12a6SLiu Zhe 	}
232*f46d12a6SLiu Zhe 
233*f46d12a6SLiu Zhe 	@Test
234*f46d12a6SLiu Zhe 	public void loadFinishComplexXLS() {
235*f46d12a6SLiu Zhe 		loadFinish("pvt/sc_complex_13sh_4kcell.xls", "Sheet 2 / 13");
236*f46d12a6SLiu Zhe 	}
237*f46d12a6SLiu Zhe 
238*f46d12a6SLiu Zhe 	@Test
239*f46d12a6SLiu Zhe 	public void loadFinishComplexODS() {
240*f46d12a6SLiu Zhe 		loadFinish("pvt/sc_complex_13sh_4kcell_new_odf1.2.ods", "Sheet 6 / 13");
241*f46d12a6SLiu Zhe 	}
242*f46d12a6SLiu Zhe 
243*f46d12a6SLiu Zhe 
244*f46d12a6SLiu Zhe 	@Test
24557caf934SLiu Zhe 	public void loadFinishComplexODP() {
246*f46d12a6SLiu Zhe 		loadFinish("pvt/sd_complex_51p_odf1.2.odp", "Slide 1 / 51");
24757caf934SLiu Zhe 	}
24857caf934SLiu Zhe 
24957caf934SLiu Zhe 	@Test
25057caf934SLiu Zhe 	public void loadFinishComplexPPT() {
251*f46d12a6SLiu Zhe 		loadFinish("pvt/sd_complex_51p.ppt", "Slide 1 / 51");
25257caf934SLiu Zhe 	}
25357caf934SLiu Zhe 
25457caf934SLiu Zhe 	public void loadFinish(String file, final String indicator) {
255*f46d12a6SLiu Zhe 		final int openIndicatorIndex = file.matches(".*\\.(odp|ppt|pptx)$") ? 4 : 0;
25657caf934SLiu Zhe 		String path = prepareData(file);
25757caf934SLiu Zhe 		aoo.kill();
258*f46d12a6SLiu Zhe 		app.start();
259*f46d12a6SLiu Zhe 		startcenter.waitForExistence(10, 1);
260*f46d12a6SLiu Zhe 		sleep(2); // Give some seconds to AOO relax. We want data more stable.
26157caf934SLiu Zhe 		for (int i = 0; i < 8; i++) {
26257caf934SLiu Zhe 			app.dispatch(".uno:Open");
26357caf934SLiu Zhe 			filePickerPath.setText(path);
264*f46d12a6SLiu Zhe 			sleep(2);
265*f46d12a6SLiu Zhe 			filePickerOpen.click(0.5, 0.5);
26657caf934SLiu Zhe 			long start = System.currentTimeMillis();
26757caf934SLiu Zhe 			new Condition() {
26857caf934SLiu Zhe 				@Override
26957caf934SLiu Zhe 				public boolean value() {
270*f46d12a6SLiu Zhe 					try {
271*f46d12a6SLiu Zhe 						String text = statusBar.getItemText(openIndicatorIndex);
272*f46d12a6SLiu Zhe 						return text.matches(indicator);
273*f46d12a6SLiu Zhe 					} catch (Exception e) {
27457caf934SLiu Zhe 						return false;
275*f46d12a6SLiu Zhe 					}
27657caf934SLiu Zhe 				}
27757caf934SLiu Zhe 
27857caf934SLiu Zhe 			}.waitForTrue("", 120, INTERVAL);
27957caf934SLiu Zhe 			long end = System.currentTimeMillis();
28057caf934SLiu Zhe 			sleep(2);
28157caf934SLiu Zhe 			addRecord(i, start, end);
282*f46d12a6SLiu Zhe 			discard();
28357caf934SLiu Zhe 		}
28457caf934SLiu Zhe 
28557caf934SLiu Zhe 		app.close();
28657caf934SLiu Zhe 	}
28757caf934SLiu Zhe 
288*f46d12a6SLiu Zhe 	@Test
289*f46d12a6SLiu Zhe 	public void savePlainDOC() {
290*f46d12a6SLiu Zhe 		save("pvt/sw_plain_120p.doc", "Page 1 / ");
291*f46d12a6SLiu Zhe 	}
29257caf934SLiu Zhe 
293*f46d12a6SLiu Zhe 	@Test
294*f46d12a6SLiu Zhe 	public void savePlainODT() {
295*f46d12a6SLiu Zhe 		save("pvt/plain_200p.odt", "Page 1 / 23[0-9]{1}");
296*f46d12a6SLiu Zhe 	}
297*f46d12a6SLiu Zhe 
298*f46d12a6SLiu Zhe 	@Test
299*f46d12a6SLiu Zhe 	public void saveComplexDOC() {
300*f46d12a6SLiu Zhe 		save("pvt/plain_200p.doc", "Page 1 / 23[0-9]{1}");
301*f46d12a6SLiu Zhe 	}
302*f46d12a6SLiu Zhe 
303*f46d12a6SLiu Zhe 	@Test
304*f46d12a6SLiu Zhe 	public void saveComplexODT() {
305*f46d12a6SLiu Zhe 		save("pvt/sw_complex_100p_odf1.2.odt", "Page 1 / ");
306*f46d12a6SLiu Zhe 	}
307*f46d12a6SLiu Zhe 
308*f46d12a6SLiu Zhe 	@Test
309*f46d12a6SLiu Zhe 	public void savePlainXLS() {
310*f46d12a6SLiu Zhe 		save("pvt/plain_11s.xls", "Sheet 1 / 11");
311*f46d12a6SLiu Zhe 	}
312*f46d12a6SLiu Zhe 
313*f46d12a6SLiu Zhe 	@Test
314*f46d12a6SLiu Zhe 	public void savePlainODS() {
315*f46d12a6SLiu Zhe 		save("pvt/plain_11s.ods", "Sheet 1 / 11");
316*f46d12a6SLiu Zhe 	}
317*f46d12a6SLiu Zhe 
318*f46d12a6SLiu Zhe 	@Test
319*f46d12a6SLiu Zhe 	public void saveComplexXLS() {
320*f46d12a6SLiu Zhe 		save("pvt/sc_complex_13sh_4kcell.xls", "Sheet 2 / 13");
321*f46d12a6SLiu Zhe 	}
322*f46d12a6SLiu Zhe 
323*f46d12a6SLiu Zhe 	@Test
324*f46d12a6SLiu Zhe 	public void saveComplexODS() {
325*f46d12a6SLiu Zhe 		save("pvt/sc_complex_13sh_4kcell_new_odf1.2.ods", "Sheet 6 / 13");
326*f46d12a6SLiu Zhe 	}
327*f46d12a6SLiu Zhe 
328*f46d12a6SLiu Zhe 	@Test
329*f46d12a6SLiu Zhe 	public void savePlainODP() {
330*f46d12a6SLiu Zhe 		save("pvt/plain_200p.odp", "Slide 1 / 200");
331*f46d12a6SLiu Zhe 	}
332*f46d12a6SLiu Zhe 
333*f46d12a6SLiu Zhe 	@Test
334*f46d12a6SLiu Zhe 	public void savePlainPPT() {
335*f46d12a6SLiu Zhe 		save("pvt/plain_200p.ppt", "Slide 1 / 200");
336*f46d12a6SLiu Zhe 	}
337*f46d12a6SLiu Zhe 
338*f46d12a6SLiu Zhe 	@Test
339*f46d12a6SLiu Zhe 	public void saveComplexODP() {
340*f46d12a6SLiu Zhe 		save("pvt/sd_complex_51p_odf1.2.odp", "Slide 1 / 51");
341*f46d12a6SLiu Zhe 	}
342*f46d12a6SLiu Zhe 
343*f46d12a6SLiu Zhe 	@Test
344*f46d12a6SLiu Zhe 	public void saveComplexPPT() {
345*f46d12a6SLiu Zhe 		save("pvt/sd_complex_51p.ppt", "Slide 1 / 51");
346*f46d12a6SLiu Zhe 	}
347*f46d12a6SLiu Zhe 
348*f46d12a6SLiu Zhe 	public void save(String file, final String openIndicator) {
349*f46d12a6SLiu Zhe 		boolean alienFormat = file.matches(".*\\.(doc|xls|ppt|docx|xlsx|pptx)$");
350*f46d12a6SLiu Zhe 		final int openIndicatorIndex = file.matches(".*\\.(odp|ppt|pptx)$") ? 4 : 0;
351*f46d12a6SLiu Zhe 		final int saveIndicatorIndex = file.matches(".*\\.(odt|doc|docx)$") ? 5 : file.matches(".*\\.(ods|xls|xlsx)$") ? 4 : 2;
352*f46d12a6SLiu Zhe 		aoo.kill();
353*f46d12a6SLiu Zhe 		app.start();
354*f46d12a6SLiu Zhe 		String picture = prepareData("image/red_64x64.bmp");
355*f46d12a6SLiu Zhe 		for (int i = 0; i < 8; i++) {
356*f46d12a6SLiu Zhe 			String dir = "temp/file" + i;
357*f46d12a6SLiu Zhe 			getFile(dir).mkdirs();
358*f46d12a6SLiu Zhe 			open(prepareData(file, dir));
359*f46d12a6SLiu Zhe 			new Condition() {
360*f46d12a6SLiu Zhe 				@Override
361*f46d12a6SLiu Zhe 				public boolean value() {
362*f46d12a6SLiu Zhe 					try {
363*f46d12a6SLiu Zhe 						String text = statusBar.getItemText(openIndicatorIndex);
364*f46d12a6SLiu Zhe 						return text.matches(openIndicator);
365*f46d12a6SLiu Zhe 					} catch (Exception e) {
366*f46d12a6SLiu Zhe 						return false;
367*f46d12a6SLiu Zhe 					}
368*f46d12a6SLiu Zhe 				}
369*f46d12a6SLiu Zhe 
370*f46d12a6SLiu Zhe 			}.waitForTrue("", 120, 1);
371*f46d12a6SLiu Zhe 			sleep(2);
372*f46d12a6SLiu Zhe 			insertPicture(picture);
373*f46d12a6SLiu Zhe 			sleep(3);
374*f46d12a6SLiu Zhe 			assertEquals("File is modified", "*", statusBar.getItemText(saveIndicatorIndex));
375*f46d12a6SLiu Zhe 			app.dispatch(".uno:Save");
376*f46d12a6SLiu Zhe 			if (alienFormat) {
377*f46d12a6SLiu Zhe 				alienFormatDlg.waitForExistence(3, 1);
378*f46d12a6SLiu Zhe 				sleep(1);
379*f46d12a6SLiu Zhe 				typeKeys("<enter>");
380*f46d12a6SLiu Zhe 			}
381*f46d12a6SLiu Zhe 
382*f46d12a6SLiu Zhe 			long start = System.currentTimeMillis();
383*f46d12a6SLiu Zhe 			new Condition() {
384*f46d12a6SLiu Zhe 				@Override
385*f46d12a6SLiu Zhe 				public boolean value() {
386*f46d12a6SLiu Zhe 					try {
387*f46d12a6SLiu Zhe 						String text = statusBar.getItemText(saveIndicatorIndex);
388*f46d12a6SLiu Zhe 						return " ".equals(text);
389*f46d12a6SLiu Zhe 					} catch (Exception e) {
390*f46d12a6SLiu Zhe 						return false;
391*f46d12a6SLiu Zhe 					}
392*f46d12a6SLiu Zhe 				}
393*f46d12a6SLiu Zhe 
394*f46d12a6SLiu Zhe 			}.waitForTrue("", 120, INTERVAL);
395*f46d12a6SLiu Zhe 			long end = System.currentTimeMillis();
396*f46d12a6SLiu Zhe 			sleep(2);
397*f46d12a6SLiu Zhe 			addRecord(i, start, end);
398*f46d12a6SLiu Zhe 			close();
399*f46d12a6SLiu Zhe 		}
400*f46d12a6SLiu Zhe 
401*f46d12a6SLiu Zhe 		app.close();
402*f46d12a6SLiu Zhe 	}
403*f46d12a6SLiu Zhe 
404*f46d12a6SLiu Zhe 	@Test
405*f46d12a6SLiu Zhe 	public void slideShow() {
406*f46d12a6SLiu Zhe 		aoo.kill();
407*f46d12a6SLiu Zhe 		app.start();
408*f46d12a6SLiu Zhe 		String path = prepareData("pvt/sd_slideshow.odp");
409*f46d12a6SLiu Zhe 		final Rectangle rect = GraphicsUtil.getScreenRectangle();
410*f46d12a6SLiu Zhe 		// when slide show is running, top-center area will be filled with green
411*f46d12a6SLiu Zhe 		rect.setRect(rect.getCenterX(), 2, 2, 2);
412*f46d12a6SLiu Zhe 		for (int i = 0; i < 8; i++) {
413*f46d12a6SLiu Zhe 			open(path);
414*f46d12a6SLiu Zhe 			impress.waitForExistence(60, 1);
415*f46d12a6SLiu Zhe 			sleep(2);
416*f46d12a6SLiu Zhe 			assertFalse("Slideshow control exists", slideShow.exists());
417*f46d12a6SLiu Zhe 			assertFalse("Slideshow is not started", GraphicsUtil.isFilledWith(0xFF00FF00, rect));
418*f46d12a6SLiu Zhe 			typeKeys("<F5>");
419*f46d12a6SLiu Zhe 			long start = System.currentTimeMillis();
420*f46d12a6SLiu Zhe 			new Condition() {
421*f46d12a6SLiu Zhe 				@Override
422*f46d12a6SLiu Zhe 				public boolean value() {
423*f46d12a6SLiu Zhe 					return GraphicsUtil.isFilledWith(0xFF00FF00, rect);
424*f46d12a6SLiu Zhe 				}
425*f46d12a6SLiu Zhe 
426*f46d12a6SLiu Zhe 			}.waitForTrue("", 120, INTERVAL);
427*f46d12a6SLiu Zhe 			long end = System.currentTimeMillis();
428*f46d12a6SLiu Zhe 			sleep(2);
429*f46d12a6SLiu Zhe 			addRecord(i, start, end);
430*f46d12a6SLiu Zhe 			slideShow.typeKeys("<esc>");
431*f46d12a6SLiu Zhe 			sleep(2);
432*f46d12a6SLiu Zhe 			close();
433*f46d12a6SLiu Zhe 		}
434*f46d12a6SLiu Zhe 		app.close();
435*f46d12a6SLiu Zhe 	}
43657caf934SLiu Zhe }
437