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