1739258c9SLi Feng Wang /**************************************************************
2739258c9SLi Feng Wang  *
3739258c9SLi Feng Wang  * Licensed to the Apache Software Foundation (ASF) under one
4739258c9SLi Feng Wang  * or more contributor license agreements.  See the NOTICE file
5739258c9SLi Feng Wang  * distributed with this work for additional information
6739258c9SLi Feng Wang  * regarding copyright ownership.  The ASF licenses this file
7739258c9SLi Feng Wang  * to you under the Apache License, Version 2.0 (the
8739258c9SLi Feng Wang  * "License"); you may not use this file except in compliance
9739258c9SLi Feng Wang  * with the License.  You may obtain a copy of the License at
10739258c9SLi Feng Wang  *
11739258c9SLi Feng Wang  *   http://www.apache.org/licenses/LICENSE-2.0
12739258c9SLi Feng Wang  *
13739258c9SLi Feng Wang  * Unless required by applicable law or agreed to in writing,
14739258c9SLi Feng Wang  * software distributed under the License is distributed on an
15739258c9SLi Feng Wang  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16739258c9SLi Feng Wang  * KIND, either express or implied.  See the License for the
17739258c9SLi Feng Wang  * specific language governing permissions and limitations
18739258c9SLi Feng Wang  * under the License.
19739258c9SLi Feng Wang  *
20739258c9SLi Feng Wang  *************************************************************/
21739258c9SLi Feng Wang 
22739258c9SLi Feng Wang /**
23739258c9SLi Feng Wang  *
24739258c9SLi Feng Wang  */
25739258c9SLi Feng Wang package svt.gui.sw;
26739258c9SLi Feng Wang 
27739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.getFile;
28739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.getPath;
29739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.prepareData;
30739258c9SLi Feng Wang import static org.openoffice.test.vcl.Tester.*;
31739258c9SLi Feng Wang import static testlib.gui.AppTool.*;
32739258c9SLi Feng Wang import static testlib.gui.UIMap.*;
33739258c9SLi Feng Wang 
34739258c9SLi Feng Wang import java.io.FileOutputStream;
35739258c9SLi Feng Wang import java.io.PrintStream;
36739258c9SLi Feng Wang import java.util.HashMap;
37*122356beSHerbert Dürr import java.util.logging.Level;
38739258c9SLi Feng Wang 
39739258c9SLi Feng Wang import org.junit.After;
40739258c9SLi Feng Wang import org.junit.AfterClass;
41739258c9SLi Feng Wang import org.junit.Before;
42739258c9SLi Feng Wang import org.junit.BeforeClass;
43739258c9SLi Feng Wang import org.junit.Ignore;
44739258c9SLi Feng Wang import org.junit.Rule;
45739258c9SLi Feng Wang import org.junit.Test;
46739258c9SLi Feng Wang import org.junit.rules.TestName;
47739258c9SLi Feng Wang import org.openoffice.test.common.DataSheet;
48739258c9SLi Feng Wang import org.openoffice.test.common.FileUtil;
49739258c9SLi Feng Wang import org.openoffice.test.common.Logger;
50739258c9SLi Feng Wang import org.openoffice.test.common.SystemUtil;
51739258c9SLi Feng Wang import org.openoffice.test.common.Testspace;
52739258c9SLi Feng Wang 
53739258c9SLi Feng Wang public class BasicFuncOnWriter {
54739258c9SLi Feng Wang 	@Rule
55739258c9SLi Feng Wang 	public Logger log = Logger.getLogger(this);
56739258c9SLi Feng Wang 
57739258c9SLi Feng Wang 	@Rule
58739258c9SLi Feng Wang 	public TestName testname = new TestName();
59739258c9SLi Feng Wang 
60739258c9SLi Feng Wang 	private static DataSheet xmlResult;
61739258c9SLi Feng Wang 
62739258c9SLi Feng Wang 	private String pid = null;
63739258c9SLi Feng Wang 
6466d0652aSLi Feng Wang 	private static int iterator = 100;
65739258c9SLi Feng Wang 
66739258c9SLi Feng Wang 	private int i = 0;
67739258c9SLi Feng Wang 
68739258c9SLi Feng Wang 	/**
69739258c9SLi Feng Wang 	 * @throws java.lang.Exception
70739258c9SLi Feng Wang 	 */
71739258c9SLi Feng Wang 	@BeforeClass
beforeClass()72739258c9SLi Feng Wang 	public static void beforeClass() throws Exception {
73688c272fSLi Feng Wang 		xmlResult = new DataSheet(getFile("output/svt_writer.xml"));
74ac2ddd9cSLi Feng Wang 		xmlResult.addRow("Data", "Method", "No", "Consumed Time(MS)", "Memory(VSZ)", "Memory(RSS)", "Handles(Windows Only)");
75739258c9SLi Feng Wang 	}
76739258c9SLi Feng Wang 
77739258c9SLi Feng Wang 	@AfterClass
afterClass()78739258c9SLi Feng Wang 	public static void afterClass() throws Exception {
79739258c9SLi Feng Wang 		app.stop();
80739258c9SLi Feng Wang 	}
81739258c9SLi Feng Wang 
82739258c9SLi Feng Wang 	@Before
before()83739258c9SLi Feng Wang 	public void before()throws Exception{
84739258c9SLi Feng Wang 		app.start(true);
85739258c9SLi Feng Wang 	}
86739258c9SLi Feng Wang 
87739258c9SLi Feng Wang 	@Test
saveNewSWWithPic()88739258c9SLi Feng Wang 	public void saveNewSWWithPic() throws Exception {
89739258c9SLi Feng Wang 		String pic = prepareData("image/blue_256x256.jpg");
90739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
91739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
92739258c9SLi Feng Wang 			createNewSW();
93739258c9SLi Feng Wang 			writer.menuItem("Insert->Picture->From File...").select();
94739258c9SLi Feng Wang 			sleep(2);
95739258c9SLi Feng Wang 			filePickerPath.setText(pic);
96739258c9SLi Feng Wang 			sleep(1);
97739258c9SLi Feng Wang 			filePickerOpen.click();
98739258c9SLi Feng Wang 			sleep(5);
99739258c9SLi Feng Wang 			typeKeys("<esc>");
100739258c9SLi Feng Wang 			sleep(2);
101739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
102739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
103739258c9SLi Feng Wang 			addRecord(i, start, end);
104739258c9SLi Feng Wang 		}
105739258c9SLi Feng Wang 	}
106739258c9SLi Feng Wang 
107739258c9SLi Feng Wang 
108739258c9SLi Feng Wang 	@Test
saveNewSWWithBullet()109739258c9SLi Feng Wang 	public void saveNewSWWithBullet() throws Exception {
110739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
111739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
112739258c9SLi Feng Wang 			createNewSW();
113739258c9SLi Feng Wang 			writer.typeKeys("The first");
114739258c9SLi Feng Wang 			writer.typeKeys("<enter>");
115739258c9SLi Feng Wang 			sleep(3);
116739258c9SLi Feng Wang 			writer.typeKeys("The second");
117739258c9SLi Feng Wang 			app.dispatch(".uno:SelectAll");
118739258c9SLi Feng Wang 			writer.menuItem("Format->Bullets and Numbering...").select();
119739258c9SLi Feng Wang 			sleep(3);
120739258c9SLi Feng Wang 			bulletPage.ok();
121739258c9SLi Feng Wang 			writer.typeKeys("<ctrl z");
122739258c9SLi Feng Wang 			sleep(1);
123739258c9SLi Feng Wang 			writer.typeKeys("<ctrl y>");
124739258c9SLi Feng Wang 			sleep(1);
125739258c9SLi Feng Wang 			writer.typeKeys("<ctrl end>");
126739258c9SLi Feng Wang 			writer.typeKeys("<enter>");
127739258c9SLi Feng Wang 			sleep(2);
128739258c9SLi Feng Wang 
129739258c9SLi Feng Wang 			writer.focus();
130739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
131739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
132739258c9SLi Feng Wang 			addRecord(i, start, end);
133739258c9SLi Feng Wang 		}
134739258c9SLi Feng Wang 	}
135739258c9SLi Feng Wang 
136739258c9SLi Feng Wang 	@Test
saveNewSWWithUnDoDelete()137739258c9SLi Feng Wang 	public void saveNewSWWithUnDoDelete()throws Exception{
138739258c9SLi Feng Wang 		if(!sdDrawingToolbar.exists()){
139739258c9SLi Feng Wang 			app.dispatch(".uno:AvailableToolbars?Toolbar:string=toolbar");
140739258c9SLi Feng Wang 		}
141739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
142739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
143739258c9SLi Feng Wang 			createNewSW();
144739258c9SLi Feng Wang 			app.dispatch(".uno:Ellipse");
145739258c9SLi Feng Wang 			writer.focus();
146739258c9SLi Feng Wang 			writer.drag(200, 200, 300, 300);
147739258c9SLi Feng Wang 			typeKeys("<Delete>");
148739258c9SLi Feng Wang 			typeKeys("<ctrl z>");
149739258c9SLi Feng Wang 			typeKeys("<ctrl y>");
150739258c9SLi Feng Wang 
151739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
152739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
153739258c9SLi Feng Wang 			addRecord(i, start, end);
154739258c9SLi Feng Wang 		}
155739258c9SLi Feng Wang 	}
156739258c9SLi Feng Wang 
157739258c9SLi Feng Wang 
158739258c9SLi Feng Wang 	@Test
saveNewSWWithSpellCheck()159739258c9SLi Feng Wang 	public void saveNewSWWithSpellCheck() throws Exception {
160739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
161739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
162739258c9SLi Feng Wang 			createNewSW();
163739258c9SLi Feng Wang 			writer.typeKeys("goood");
164739258c9SLi Feng Wang 			sleep(2);
165739258c9SLi Feng Wang 			writer.menuItem("Tools->Spelling and Grammar...").select();
166739258c9SLi Feng Wang 			sleep(2);
167739258c9SLi Feng Wang 			spellcheckDlgSuggestionList.select(0);
168739258c9SLi Feng Wang 			spellcheckDlgIgnoreOnce.click();
169739258c9SLi Feng Wang 			activeMsgBox.ok();
170739258c9SLi Feng Wang 			sleep(2);
171739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
172739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
173739258c9SLi Feng Wang 			addRecord(i, start, end);
174739258c9SLi Feng Wang 		}
175739258c9SLi Feng Wang 	}
176739258c9SLi Feng Wang 
177739258c9SLi Feng Wang 	@Test
saveNewSWWithHeaderFooter()178739258c9SLi Feng Wang 	public void saveNewSWWithHeaderFooter() throws Exception {
179739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
180739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
181739258c9SLi Feng Wang 			createNewSW();
182739258c9SLi Feng Wang 			writer.menuItem("Insert->Header->Default").select();
183739258c9SLi Feng Wang 			sleep(2);
184739258c9SLi Feng Wang 			writer.typeKeys("Header");
185739258c9SLi Feng Wang 			sleep(2);
186739258c9SLi Feng Wang 			writer.menuItem("Insert->Footer->Default").select();
187739258c9SLi Feng Wang 			sleep(2);
188739258c9SLi Feng Wang 			writer.typeKeys("Footer");
189739258c9SLi Feng Wang 			sleep(2);
190739258c9SLi Feng Wang 			writer.typeKeys("<ctrl end>");
191739258c9SLi Feng Wang 			sleep(2);
192739258c9SLi Feng Wang 			writer.typeKeys("<enter>");
193739258c9SLi Feng Wang 			sleep(2);
194739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
195739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
196739258c9SLi Feng Wang 			addRecord(i, start, end);
197739258c9SLi Feng Wang 		}
198739258c9SLi Feng Wang 	}
199739258c9SLi Feng Wang 
200739258c9SLi Feng Wang 	@Test
saveNewSWWithFrameAnchor()201739258c9SLi Feng Wang 	public void saveNewSWWithFrameAnchor() throws Exception {
202739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
203739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
204739258c9SLi Feng Wang 			createNewSW();
205739258c9SLi Feng Wang 			writer.menuItem("Insert->Frame...").select();
206739258c9SLi Feng Wang 			sleep(2);
207739258c9SLi Feng Wang 			writerFrameDlg.ok();
208739258c9SLi Feng Wang 			writer.menuItem("Format->Anchor->To Page").select();
209739258c9SLi Feng Wang 			sleep(2);
210739258c9SLi Feng Wang 			writer.menuItem("Format->Anchor->To Paragraph").select();
211739258c9SLi Feng Wang 			sleep(2);
212739258c9SLi Feng Wang 			writer.menuItem("Format->Anchor->To Character").select();
213739258c9SLi Feng Wang 			sleep(2);
214739258c9SLi Feng Wang 			writer.menuItem("Format->Anchor->As Character").select();
215739258c9SLi Feng Wang 			sleep(2);
216739258c9SLi Feng Wang 			writer.typeKeys("<esc>");
217739258c9SLi Feng Wang 			sleep(2);
218739258c9SLi Feng Wang 			writer.typeKeys("<enter>");
219739258c9SLi Feng Wang 			sleep(2);
220739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
221739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
222739258c9SLi Feng Wang 			addRecord(i, start, end);
223739258c9SLi Feng Wang 		}
224739258c9SLi Feng Wang 	}
225739258c9SLi Feng Wang 
226739258c9SLi Feng Wang 	@Test
saveNewSWWithSDAsOLE()227739258c9SLi Feng Wang 	public void saveNewSWWithSDAsOLE()throws Exception{
228739258c9SLi Feng Wang 		String linkFile = prepareData("pvt/plain_200p.odp");
229739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
230739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
231739258c9SLi Feng Wang 			createNewSW();
232739258c9SLi Feng Wang 			app.dispatch(".uno:InsertObject");
233739258c9SLi Feng Wang 			sleep(2);
234739258c9SLi Feng Wang 			insertObject.waitForExistence(60, 2);
235739258c9SLi Feng Wang 			objectFromFile.check();
236739258c9SLi Feng Wang 			objectFilePath.setText(linkFile);
237739258c9SLi Feng Wang 			objectFileLink.check();
238739258c9SLi Feng Wang 			insertObject.ok();
239739258c9SLi Feng Wang 			sleep(10);
240739258c9SLi Feng Wang 
241739258c9SLi Feng Wang 			writer.focus();
242739258c9SLi Feng Wang 			writer.doubleClick(200, 300);
243739258c9SLi Feng Wang 			sleep(15);
244739258c9SLi Feng Wang 			writer.activate();
245739258c9SLi Feng Wang 			writer.click(10, 10);
246739258c9SLi Feng Wang 			sleep(5);
247739258c9SLi Feng Wang 
248739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
249739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
250739258c9SLi Feng Wang 			addRecord(i, start, end);
251739258c9SLi Feng Wang 		}
252739258c9SLi Feng Wang 	}
253739258c9SLi Feng Wang 
254739258c9SLi Feng Wang 	@Test
saveNewSWWithTOC()255739258c9SLi Feng Wang 	public void saveNewSWWithTOC() throws Exception {
256739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
257739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
258739258c9SLi Feng Wang 			createNewSW();
259739258c9SLi Feng Wang 			for (int j = 0; j < 6; j++) {
260739258c9SLi Feng Wang 				writer.typeKeys(String.valueOf(j + 1));
261739258c9SLi Feng Wang 				writer.typeKeys("<enter>");
262739258c9SLi Feng Wang 			}
263739258c9SLi Feng Wang 			writer.typeKeys("<ctrl home>");
264739258c9SLi Feng Wang 			for (int k = 0; k < 2; k++) {
265739258c9SLi Feng Wang 				writer.typeKeys("<shift down>");
266739258c9SLi Feng Wang 			}
267739258c9SLi Feng Wang 			if (!styleAndFormattingDlg.exists()) {
268739258c9SLi Feng Wang 				app.dispatch(".uno:DesignerDialog");
269739258c9SLi Feng Wang 				sleep(2);
270739258c9SLi Feng Wang 			}
271739258c9SLi Feng Wang 
272739258c9SLi Feng Wang 			styleAndFormattingList.doubleClick(0.5, 0.25);
273739258c9SLi Feng Wang 			sleep(2);
274739258c9SLi Feng Wang 			writer.typeKeys("<down>");
275739258c9SLi Feng Wang 			writer.typeKeys("<right>");
276739258c9SLi Feng Wang 			writer.typeKeys("<left>");
277739258c9SLi Feng Wang 			for (int k = 0; k < 2; k++) {
278739258c9SLi Feng Wang 				writer.typeKeys("<shift down>");
279739258c9SLi Feng Wang 			}
280739258c9SLi Feng Wang 			styleAndFormattingList.doubleClick(0.5, 0.3);
281739258c9SLi Feng Wang 			sleep(2);
282739258c9SLi Feng Wang 			writer.typeKeys("<ctrl home>");
283739258c9SLi Feng Wang 			sleep(2);
284739258c9SLi Feng Wang 			writer.menuItem("Insert->Indexes and Tables->Indexes and Tables...").select();
285739258c9SLi Feng Wang 			sleep(2);
286739258c9SLi Feng Wang 			insertIndexDlg.ok();
287739258c9SLi Feng Wang 			sleep(2);
288739258c9SLi Feng Wang 			writer.typeKeys("<ctrl end>");
289739258c9SLi Feng Wang 			saveAndReopenNewSW(i);
290739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
291739258c9SLi Feng Wang 			addRecord(i, start, end);
292739258c9SLi Feng Wang 		}
293739258c9SLi Feng Wang 	}
294739258c9SLi Feng Wang 
295739258c9SLi Feng Wang 	@Test
splitMergeTableOnOpenedSW()296739258c9SLi Feng Wang 	public void splitMergeTableOnOpenedSW() throws Exception {
297739258c9SLi Feng Wang 		String file = prepareData("svt/swdesign.odt");
298739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
299739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
300739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
301739258c9SLi Feng Wang 			submitOpenDlg(file);
302739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
303739258c9SLi Feng Wang 			writer.typeKeys("<down>");
304739258c9SLi Feng Wang 			writer.typeKeys("<down>");
305739258c9SLi Feng Wang 			sleep(2);
306739258c9SLi Feng Wang 
307739258c9SLi Feng Wang 			writer.menuItem("Table->Split Cells").select();
308739258c9SLi Feng Wang 			sleep(2);
309739258c9SLi Feng Wang 			writerSplitCellDlg.ok();
310739258c9SLi Feng Wang 			sleep(2);
311739258c9SLi Feng Wang 
312739258c9SLi Feng Wang 			writer.typeKeys("<shift down>");
313739258c9SLi Feng Wang 			writer.typeKeys("<shift down>");
314739258c9SLi Feng Wang 			writer.typeKeys("<shift down>");
315739258c9SLi Feng Wang 			writer.typeKeys("<shift down>");
316739258c9SLi Feng Wang 			writer.typeKeys("<shift down>");
317739258c9SLi Feng Wang 			sleep(2);
318739258c9SLi Feng Wang 			writer.menuItem("Table->Merge Cells").select();
319739258c9SLi Feng Wang 			sleep(2);
320739258c9SLi Feng Wang 
321739258c9SLi Feng Wang 			writer.typeKeys("<enter>");
322739258c9SLi Feng Wang 			closeWithoutSaveSW();
323739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
324739258c9SLi Feng Wang 			addRecord(i, start, end);
325739258c9SLi Feng Wang 		}
326739258c9SLi Feng Wang 	}
327739258c9SLi Feng Wang 
328739258c9SLi Feng Wang 	@Test
addDelColumnsRowsInTableOnOpenedSW()329739258c9SLi Feng Wang 	public void addDelColumnsRowsInTableOnOpenedSW() throws Exception {
330739258c9SLi Feng Wang 		String file = prepareData("svt/swdesign.odt");
331739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
332739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
333739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
334739258c9SLi Feng Wang 			submitOpenDlg(file);
335739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
336739258c9SLi Feng Wang 			writer.typeKeys("<down>");
337739258c9SLi Feng Wang 			writer.typeKeys("<down>");
338739258c9SLi Feng Wang 			sleep(2);
339739258c9SLi Feng Wang 
340739258c9SLi Feng Wang 			app.dispatch(".uno:InsertRowDialog");
341739258c9SLi Feng Wang 			writerInsertRowsDlg.ok();
342739258c9SLi Feng Wang 			sleep(2);
343739258c9SLi Feng Wang 
344739258c9SLi Feng Wang 			writer.menuItem("Table->Delete->Rows").select();
345739258c9SLi Feng Wang 			sleep(2);
346739258c9SLi Feng Wang 
347739258c9SLi Feng Wang 			app.dispatch(".uno:InsertColumnDialog");
348739258c9SLi Feng Wang 			writerInsertColumnsDlg.ok();
349739258c9SLi Feng Wang 			sleep(2);
350739258c9SLi Feng Wang 
351739258c9SLi Feng Wang 			writer.menuItem("Table->Delete->Columns").select();
352739258c9SLi Feng Wang 			sleep(2);
353739258c9SLi Feng Wang 
354739258c9SLi Feng Wang 			closeWithoutSaveSW();
355739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
356739258c9SLi Feng Wang 			addRecord(i, start, end);
357739258c9SLi Feng Wang 		}
358739258c9SLi Feng Wang 	}
359739258c9SLi Feng Wang 
360739258c9SLi Feng Wang 	@Test
setParaPropertoesOnOpenedSW()361739258c9SLi Feng Wang 	public void setParaPropertoesOnOpenedSW() throws Exception {
362739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_200p.odt");
363739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
364739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
365739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
366739258c9SLi Feng Wang 			submitOpenDlg(file);
367739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
368739258c9SLi Feng Wang 			writer.focus();
369739258c9SLi Feng Wang 			app.dispatch(".uno:ParagraphDialog");
370739258c9SLi Feng Wang 			alignPage.select();
371739258c9SLi Feng Wang 			alignPageRight.check();
372739258c9SLi Feng Wang 			sleep(2);
373739258c9SLi Feng Wang 			alignPageVerticalAlign.select("Bottom");
374739258c9SLi Feng Wang 			sleep(2);
375739258c9SLi Feng Wang 			alignPage.ok();
376739258c9SLi Feng Wang 			sleep(2);
377739258c9SLi Feng Wang 			writer.typeKeys("<ctrl end>");
378739258c9SLi Feng Wang 			sleep(5);
379739258c9SLi Feng Wang 
380739258c9SLi Feng Wang 			closeWithoutSaveSW();
381739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
382739258c9SLi Feng Wang 			addRecord(i, start, end);
383739258c9SLi Feng Wang 		}
384739258c9SLi Feng Wang 	}
385739258c9SLi Feng Wang 
386739258c9SLi Feng Wang 	@Test
InsertPicToOpenedSW()387739258c9SLi Feng Wang 	public void InsertPicToOpenedSW() throws Exception {
388739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_200p.odt");
389739258c9SLi Feng Wang 		String pic = prepareData("image/blue_256x256.jpg");
390739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
391739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
392739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
393739258c9SLi Feng Wang 			submitOpenDlg(file);
394739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
395739258c9SLi Feng Wang 			writer.focus();
396739258c9SLi Feng Wang 			writer.menuItem("Insert->Picture->From File...").select();
397739258c9SLi Feng Wang 			sleep(2);
398739258c9SLi Feng Wang 			filePickerPath.setText(pic);
399739258c9SLi Feng Wang 			sleep(1);
400739258c9SLi Feng Wang 			filePickerOpen.click();
401739258c9SLi Feng Wang 			sleep(5);
402739258c9SLi Feng Wang 			writer.typeKeys("<esc>");
403739258c9SLi Feng Wang 			sleep(2);
404739258c9SLi Feng Wang 			closeWithoutSaveSW();
405739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
406739258c9SLi Feng Wang 			addRecord(i, start, end);
407739258c9SLi Feng Wang 		}
408739258c9SLi Feng Wang 	}
409739258c9SLi Feng Wang 
410739258c9SLi Feng Wang 	@Test
InsertOLEToOpenedSW()411739258c9SLi Feng Wang 	public void InsertOLEToOpenedSW() throws Exception {
412739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_200p.odt");
413739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
414739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
415739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
416739258c9SLi Feng Wang 			submitOpenDlg(file);
417739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
418739258c9SLi Feng Wang 			writer.focus();
419739258c9SLi Feng Wang 			app.dispatch(".uno:InsertObject");
420739258c9SLi Feng Wang 			sleep(2);
421739258c9SLi Feng Wang 			insertObject.ok();
422739258c9SLi Feng Wang 			sleep(10);
423739258c9SLi Feng Wang 			typeKeys("<esc>");
424739258c9SLi Feng Wang 			sleep(5);
425739258c9SLi Feng Wang 			typeKeys("<esc>");
426739258c9SLi Feng Wang 			sleep(5);
427739258c9SLi Feng Wang 			closeWithoutSaveSW();
428739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
429739258c9SLi Feng Wang 			addRecord(i, start, end);
430739258c9SLi Feng Wang 		}
431739258c9SLi Feng Wang 	}
432739258c9SLi Feng Wang 
433739258c9SLi Feng Wang 	@Test
InsertChartToOpenedSW()434739258c9SLi Feng Wang 	public void InsertChartToOpenedSW() throws Exception {
435739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_200p.odt");
436739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
437739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
438739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
439739258c9SLi Feng Wang 			submitOpenDlg(file);
440739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
441739258c9SLi Feng Wang 			writer.focus();
442ac2ddd9cSLi Feng Wang 			app.dispatch(".uno:InsertObjectChart");
443ac2ddd9cSLi Feng Wang //			writer.menuItem("Insert->Object->Chart...").select();
444739258c9SLi Feng Wang 			sleep(5);
445739258c9SLi Feng Wang 			typeKeys("<esc>");
446739258c9SLi Feng Wang 			sleep(5);
447739258c9SLi Feng Wang 			typeKeys("<esc>");
448739258c9SLi Feng Wang 			sleep(5);
449739258c9SLi Feng Wang 			typeKeys("<esc>");
450739258c9SLi Feng Wang 			sleep(5);
451739258c9SLi Feng Wang 			closeWithoutSaveSW();
452739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
453739258c9SLi Feng Wang 			addRecord(i, start, end);
454739258c9SLi Feng Wang 		}
455739258c9SLi Feng Wang 	}
456739258c9SLi Feng Wang 
457739258c9SLi Feng Wang 	@Test
openSWWithXForm()458739258c9SLi Feng Wang 	public void openSWWithXForm()throws Exception{
459739258c9SLi Feng Wang 		String file = prepareData("svt/sickness_self-certification_meory issue.odt");
460739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
461739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
462739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
463739258c9SLi Feng Wang 			submitOpenDlg(file);
464739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
465739258c9SLi Feng Wang 			app.dispatch(".uno:CloseDoc");
466739258c9SLi Feng Wang 
467739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
468739258c9SLi Feng Wang 			addRecord(i, start, end);
469739258c9SLi Feng Wang 		}
470739258c9SLi Feng Wang 	}
471739258c9SLi Feng Wang 
472739258c9SLi Feng Wang 	@Test
openSWWithSecuritySignature()473739258c9SLi Feng Wang 	public void openSWWithSecuritySignature()throws Exception{
474739258c9SLi Feng Wang 		String file = prepareData("svt/howtouse.odt");
475739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
476739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
477739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
478739258c9SLi Feng Wang 			submitOpenDlg(file);
479739258c9SLi Feng Wang 			writer.waitForExistence(10, 2);
480739258c9SLi Feng Wang 			app.dispatch(".uno:CloseDoc");
481739258c9SLi Feng Wang 
482739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
483739258c9SLi Feng Wang 			addRecord(i, start, end);
484739258c9SLi Feng Wang 		}
485739258c9SLi Feng Wang 	}
486739258c9SLi Feng Wang 
487739258c9SLi Feng Wang 
createNewSW()488739258c9SLi Feng Wang 	private void createNewSW() {
489739258c9SLi Feng Wang 		app.dispatch("private:factory/swriter");
490739258c9SLi Feng Wang 	}
491739258c9SLi Feng Wang 
saveAndReopenNewSW(int iterator)492739258c9SLi Feng Wang 	private void saveAndReopenNewSW(int iterator) {
493739258c9SLi Feng Wang 		String saveTo = getPath("temp/" + "tempSW_New" + iterator + ".odt");
494739258c9SLi Feng Wang 		writer.menuItem("File->Save As...").select();
495739258c9SLi Feng Wang 		FileUtil.deleteFile(saveTo);
496739258c9SLi Feng Wang 		submitSaveDlg(saveTo);
497739258c9SLi Feng Wang 		if (activeMsgBox.exists()) {
498739258c9SLi Feng Wang 			activeMsgBox.yes();
499739258c9SLi Feng Wang 			sleep(2);
500739258c9SLi Feng Wang 		}
501739258c9SLi Feng Wang 		app.dispatch(".uno:CloseDoc");
502739258c9SLi Feng Wang 		startCenterOpenButton.waitForExistence(30, 2);
503739258c9SLi Feng Wang 		startCenterOpenButton.click();
504739258c9SLi Feng Wang 		submitOpenDlg(saveTo);
505739258c9SLi Feng Wang 		sleep(1);
506739258c9SLi Feng Wang 		app.dispatch(".uno:CloseDoc");
507739258c9SLi Feng Wang 	}
508739258c9SLi Feng Wang 
closeWithoutSaveSW()509739258c9SLi Feng Wang 	private void closeWithoutSaveSW() {
510739258c9SLi Feng Wang 		writer.menuItem("File->Close").select();
511739258c9SLi Feng Wang 		if (activeMsgBox.exists()) {
512739258c9SLi Feng Wang 			activeMsgBox.no();
513739258c9SLi Feng Wang 			sleep(2);
514739258c9SLi Feng Wang 		}
515739258c9SLi Feng Wang 	}
516739258c9SLi Feng Wang 
addRecord(int i, long start, long end)517739258c9SLi Feng Wang 	private void addRecord(int i, long start, long end) {
518ac2ddd9cSLi Feng Wang 		HashMap<String, Object>  perf = aoo.getPerfData();
519ac2ddd9cSLi Feng Wang 		xmlResult.addRow("Data",testname.getMethodName(), i, (end - start),
520ac2ddd9cSLi Feng Wang 				perf.get("vsz"), perf.get("rss"), perf.get("handles"));
521*122356beSHerbert Dürr 		log.log( Level.INFO, "\t"+testname.getMethodName()+"["+i+"] took "+(end-start)+"ms");
522739258c9SLi Feng Wang 	}
523739258c9SLi Feng Wang 
524739258c9SLi Feng Wang }
525