xref: /AOO41X/test/testgui/source/svt/gui/sc/BasicFuncOnCalc.java (revision 739258c9671d8507a59563ee38ab2b7939f6ffa6)
1*739258c9SLi Feng Wang /**************************************************************
2*739258c9SLi Feng Wang  *
3*739258c9SLi Feng Wang  * Licensed to the Apache Software Foundation (ASF) under one
4*739258c9SLi Feng Wang  * or more contributor license agreements.  See the NOTICE file
5*739258c9SLi Feng Wang  * distributed with this work for additional information
6*739258c9SLi Feng Wang  * regarding copyright ownership.  The ASF licenses this file
7*739258c9SLi Feng Wang  * to you under the Apache License, Version 2.0 (the
8*739258c9SLi Feng Wang  * "License"); you may not use this file except in compliance
9*739258c9SLi Feng Wang  * with the License.  You may obtain a copy of the License at
10*739258c9SLi Feng Wang  *
11*739258c9SLi Feng Wang  *   http://www.apache.org/licenses/LICENSE-2.0
12*739258c9SLi Feng Wang  *
13*739258c9SLi Feng Wang  * Unless required by applicable law or agreed to in writing,
14*739258c9SLi Feng Wang  * software distributed under the License is distributed on an
15*739258c9SLi Feng Wang  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*739258c9SLi Feng Wang  * KIND, either express or implied.  See the License for the
17*739258c9SLi Feng Wang  * specific language governing permissions and limitations
18*739258c9SLi Feng Wang  * under the License.
19*739258c9SLi Feng Wang  *
20*739258c9SLi Feng Wang  *************************************************************/
21*739258c9SLi Feng Wang 
22*739258c9SLi Feng Wang /**
23*739258c9SLi Feng Wang  *
24*739258c9SLi Feng Wang  */
25*739258c9SLi Feng Wang 
26*739258c9SLi Feng Wang package svt.gui.sc;
27*739258c9SLi Feng Wang 
28*739258c9SLi Feng Wang import static org.openoffice.test.common.Testspace.*;
29*739258c9SLi Feng Wang import static org.openoffice.test.vcl.Tester.*;
30*739258c9SLi Feng Wang import static testlib.gui.AppTool.*;
31*739258c9SLi Feng Wang import static testlib.gui.UIMap.*;
32*739258c9SLi Feng Wang 
33*739258c9SLi Feng Wang import java.io.FileOutputStream;
34*739258c9SLi Feng Wang import java.io.PrintStream;
35*739258c9SLi Feng Wang import java.util.HashMap;
36*739258c9SLi Feng Wang 
37*739258c9SLi Feng Wang import org.junit.After;
38*739258c9SLi Feng Wang import org.junit.AfterClass;
39*739258c9SLi Feng Wang import org.junit.Before;
40*739258c9SLi Feng Wang import org.junit.BeforeClass;
41*739258c9SLi Feng Wang import org.junit.Ignore;
42*739258c9SLi Feng Wang import org.junit.Rule;
43*739258c9SLi Feng Wang import org.junit.Test;
44*739258c9SLi Feng Wang import org.junit.rules.TestName;
45*739258c9SLi Feng Wang import org.openoffice.test.OpenOffice;
46*739258c9SLi Feng Wang import org.openoffice.test.common.DataSheet;
47*739258c9SLi Feng Wang import org.openoffice.test.common.FileUtil;
48*739258c9SLi Feng Wang import org.openoffice.test.common.Logger;
49*739258c9SLi Feng Wang import org.openoffice.test.common.SystemUtil;
50*739258c9SLi Feng Wang import org.openoffice.test.common.Testspace;
51*739258c9SLi Feng Wang 
52*739258c9SLi Feng Wang import testlib.gui.SCTool;
53*739258c9SLi Feng Wang 
54*739258c9SLi Feng Wang public class BasicFuncOnCalc {
55*739258c9SLi Feng Wang 	@Rule
56*739258c9SLi Feng Wang 	public Logger log = Logger.getLogger(this);
57*739258c9SLi Feng Wang 
58*739258c9SLi Feng Wang 	@Rule
59*739258c9SLi Feng Wang 	public TestName testname = new TestName();
60*739258c9SLi Feng Wang 
61*739258c9SLi Feng Wang 	private static DataSheet xmlResult;
62*739258c9SLi Feng Wang 
63*739258c9SLi Feng Wang 	private String pid = null;
64*739258c9SLi Feng Wang 
65*739258c9SLi Feng Wang 	private static int iterator = 100;
66*739258c9SLi Feng Wang 
67*739258c9SLi Feng Wang 	private int i = 0;
68*739258c9SLi Feng Wang 
69*739258c9SLi Feng Wang 	/**
70*739258c9SLi Feng Wang 	 * @throws java.lang.Exception
71*739258c9SLi Feng Wang 	 */
72*739258c9SLi Feng Wang 	@BeforeClass
73*739258c9SLi Feng Wang 	public static void beforeClass() throws Exception {
74*739258c9SLi Feng Wang 
75*739258c9SLi Feng Wang 		xmlResult = new DataSheet(getFile("output/svt_gui_sc.xml"));
76*739258c9SLi Feng Wang 		xmlResult.addRow("BasicFuncOnCalc", "Method", "Iterator",
77*739258c9SLi Feng Wang 				"Consumed Time(MS)", "Memory(KB)", "CPU(%)");
78*739258c9SLi Feng Wang 	}
79*739258c9SLi Feng Wang 
80*739258c9SLi Feng Wang 	@AfterClass
81*739258c9SLi Feng Wang 	public static void afterClass() throws Exception {
82*739258c9SLi Feng Wang 		app.stop();
83*739258c9SLi Feng Wang 	}
84*739258c9SLi Feng Wang 
85*739258c9SLi Feng Wang 	@Before
86*739258c9SLi Feng Wang 	public void before()throws Exception{
87*739258c9SLi Feng Wang 		app.start(true);
88*739258c9SLi Feng Wang 	}
89*739258c9SLi Feng Wang 
90*739258c9SLi Feng Wang 
91*739258c9SLi Feng Wang 	@Test
92*739258c9SLi Feng Wang 	public void saveNewSCWithNumberFormat() {
93*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
94*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
95*739258c9SLi Feng Wang 			createNewSC();
96*739258c9SLi Feng Wang 			SCTool.selectRange("A1");
97*739258c9SLi Feng Wang 			typeKeys("0.3");
98*739258c9SLi Feng Wang 			sleep(1);
99*739258c9SLi Feng Wang 			app.dispatch(".uno:FormatCellDialog");
100*739258c9SLi Feng Wang 			sleep(2);
101*739258c9SLi Feng Wang 			scFormatCode.setText("0%");
102*739258c9SLi Feng Wang 			typeKeys("<enter>");
103*739258c9SLi Feng Wang 			sleep(1);
104*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
105*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
106*739258c9SLi Feng Wang 			addRecord(i, start, end);
107*739258c9SLi Feng Wang 		}
108*739258c9SLi Feng Wang 	}
109*739258c9SLi Feng Wang 
110*739258c9SLi Feng Wang 	@Test
111*739258c9SLi Feng Wang 	public void saveNewSCWithPrintRange() throws Exception {
112*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
113*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
114*739258c9SLi Feng Wang 			createNewSC();
115*739258c9SLi Feng Wang 			app.dispatch(".uno:EditPrintArea");
116*739258c9SLi Feng Wang 			sleep(1);
117*739258c9SLi Feng Wang 			scPrintAreaType.select("- user defined -");
118*739258c9SLi Feng Wang 			scPrintArea.setText("$A$1:$C$4");
119*739258c9SLi Feng Wang 			typeKeys("<enter>");
120*739258c9SLi Feng Wang 			SCTool.selectRange("A1");
121*739258c9SLi Feng Wang 			typeKeys("test");
122*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
123*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
124*739258c9SLi Feng Wang 			addRecord(i, start, end);
125*739258c9SLi Feng Wang 		}
126*739258c9SLi Feng Wang 	}
127*739258c9SLi Feng Wang 
128*739258c9SLi Feng Wang 	@Test
129*739258c9SLi Feng Wang 	public void saveNewSCWithText() throws Exception {
130*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
131*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
132*739258c9SLi Feng Wang 			createNewSC();
133*739258c9SLi Feng Wang 			SCTool.selectRange("A1");
134*739258c9SLi Feng Wang 			typeKeys("test");
135*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
136*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
137*739258c9SLi Feng Wang 			addRecord(i, start, end);
138*739258c9SLi Feng Wang 		}
139*739258c9SLi Feng Wang 	}
140*739258c9SLi Feng Wang 
141*739258c9SLi Feng Wang 	@Test
142*739258c9SLi Feng Wang 	public void saveNewSCWithDataSort() throws Exception {
143*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
144*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
145*739258c9SLi Feng Wang 			createNewSC();
146*739258c9SLi Feng Wang 			SCTool.selectRange("A1");
147*739258c9SLi Feng Wang 			typeKeys("3<down>2<down>5<down>1<down>6<down>4<down>10<down>8<down>9<down>7");
148*739258c9SLi Feng Wang 			sleep(1);
149*739258c9SLi Feng Wang 			app.dispatch(".uno:DataSort");
150*739258c9SLi Feng Wang 			sortOptionsPage.select();
151*739258c9SLi Feng Wang 			sortOptionsPageRangeContainsColumnLabels.uncheck();
152*739258c9SLi Feng Wang 			sortPage.select();
153*739258c9SLi Feng Wang 			sortPageBy1.select(1); // "Column A"
154*739258c9SLi Feng Wang 			sortPageAscending1.check();
155*739258c9SLi Feng Wang 			sortPage.ok();
156*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
157*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
158*739258c9SLi Feng Wang 			addRecord(i, start, end);
159*739258c9SLi Feng Wang 		}
160*739258c9SLi Feng Wang 	}
161*739258c9SLi Feng Wang 
162*739258c9SLi Feng Wang 	@Test
163*739258c9SLi Feng Wang 	public void saveNewSCWithInsertSheets() throws Exception {
164*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
165*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
166*739258c9SLi Feng Wang 			createNewSC();
167*739258c9SLi Feng Wang 			app.dispatch(".uno:Insert");
168*739258c9SLi Feng Wang 			scAfterCurrentSheet.check();
169*739258c9SLi Feng Wang 			scNewSheetName.setText("Instant Filter");
170*739258c9SLi Feng Wang 			scInsertSheetDlg.ok();
171*739258c9SLi Feng Wang 			sleep(5);
172*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
173*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
174*739258c9SLi Feng Wang 			addRecord(i, start, end);
175*739258c9SLi Feng Wang 		}
176*739258c9SLi Feng Wang 	}
177*739258c9SLi Feng Wang 
178*739258c9SLi Feng Wang 	@Test
179*739258c9SLi Feng Wang 	public void saveNewSCWithStandardFilter() throws Exception {
180*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
181*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
182*739258c9SLi Feng Wang 			createNewSC();
183*739258c9SLi Feng Wang 			SCTool.selectRange("A1");
184*739258c9SLi Feng Wang 			typeKeys("A<down>1<down>2<down>3<down>1<down>2<down>3<down>1<down>2<down>3");
185*739258c9SLi Feng Wang 			sleep(1);
186*739258c9SLi Feng Wang 			SCTool.selectRange("A1");
187*739258c9SLi Feng Wang 			app.dispatch(".uno:DataFilterStandardFilter");
188*739258c9SLi Feng Wang 			sleep(2);
189*739258c9SLi Feng Wang 			filterValue1.setText("1");
190*739258c9SLi Feng Wang 			standardFilterDlg.ok();
191*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
192*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
193*739258c9SLi Feng Wang 			addRecord(i, start, end);
194*739258c9SLi Feng Wang 		}
195*739258c9SLi Feng Wang 	}
196*739258c9SLi Feng Wang 
197*739258c9SLi Feng Wang 	@Test
198*739258c9SLi Feng Wang 	public void saveNewSCWithInsertPic() throws Exception {
199*739258c9SLi Feng Wang 		String pic = prepareData("image/blue_256x256.jpg");
200*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
201*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
202*739258c9SLi Feng Wang 			createNewSC();
203*739258c9SLi Feng Wang 			calc.menuItem("Insert->Picture->From File...").select();
204*739258c9SLi Feng Wang 			sleep(2);
205*739258c9SLi Feng Wang 			filePickerPath.setText(pic);
206*739258c9SLi Feng Wang 			sleep(1);
207*739258c9SLi Feng Wang 			filePickerOpen.click();
208*739258c9SLi Feng Wang 			sleep(2);
209*739258c9SLi Feng Wang 			typeKeys("<esc>");
210*739258c9SLi Feng Wang 			sleep(2);
211*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
212*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
213*739258c9SLi Feng Wang 			addRecord(i, start, end);
214*739258c9SLi Feng Wang 		}
215*739258c9SLi Feng Wang 	}
216*739258c9SLi Feng Wang 
217*739258c9SLi Feng Wang 	@Test
218*739258c9SLi Feng Wang 	public void saveNewSCWithValidaty() throws Exception {
219*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
220*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
221*739258c9SLi Feng Wang 			createNewSC();
222*739258c9SLi Feng Wang 			app.dispatch(".uno:Insert");
223*739258c9SLi Feng Wang 			scAfterCurrentSheet.check();
224*739258c9SLi Feng Wang 			scNewSheetName.setText("Data Validate");
225*739258c9SLi Feng Wang 			scInsertSheetDlg.ok();
226*739258c9SLi Feng Wang 			sleep(5);
227*739258c9SLi Feng Wang 			SCTool.selectRange("B2:E5");
228*739258c9SLi Feng Wang 			sleep(2);
229*739258c9SLi Feng Wang 
230*739258c9SLi Feng Wang 			app.dispatch(".uno:Validation");
231*739258c9SLi Feng Wang 			scValidityCriteriaTabpage.select();
232*739258c9SLi Feng Wang 			scValidityCriteriaAllowList.select("Whole Numbers");
233*739258c9SLi Feng Wang 			scValidityDecimalCompareOperator.select("greater than");
234*739258c9SLi Feng Wang 			scValiditySourceInput.setText("1");
235*739258c9SLi Feng Wang 			scValidityErrorAlertTabPage.select();
236*739258c9SLi Feng Wang 			scValidityShowErrorMessage.check();
237*739258c9SLi Feng Wang 			scValidityErrorMessageTitle.setText("Error");
238*739258c9SLi Feng Wang 			scValidityErrorMessage.setText("Must greater than 1");
239*739258c9SLi Feng Wang 			scValidityErrorAlertTabPage.ok();
240*739258c9SLi Feng Wang 
241*739258c9SLi Feng Wang 			SCTool.selectRange("B2");
242*739258c9SLi Feng Wang 			typeKeys("0<enter>");
243*739258c9SLi Feng Wang 			activeMsgBox.ok();
244*739258c9SLi Feng Wang 			sleep(1);
245*739258c9SLi Feng Wang 
246*739258c9SLi Feng Wang 			SCTool.selectRange("E5");
247*739258c9SLi Feng Wang 			typeKeys("1<enter>");
248*739258c9SLi Feng Wang 			activeMsgBox.ok();
249*739258c9SLi Feng Wang 			sleep(1);
250*739258c9SLi Feng Wang 
251*739258c9SLi Feng Wang 			SCTool.selectRange("E2");
252*739258c9SLi Feng Wang 			typeKeys("2<enter>");
253*739258c9SLi Feng Wang 			sleep(5);
254*739258c9SLi Feng Wang 			saveAndReopenNewSC(i);
255*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
256*739258c9SLi Feng Wang 			addRecord(i, start, end);
257*739258c9SLi Feng Wang 		}
258*739258c9SLi Feng Wang 	}
259*739258c9SLi Feng Wang 
260*739258c9SLi Feng Wang 	@Test
261*739258c9SLi Feng Wang 	public void insertChartToOpenedSC() throws Exception {
262*739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_11s.ods");
263*739258c9SLi Feng Wang 		String[][] inputStr = { { "Area", "Item", "Count" }, { "1", "2", "3" },
264*739258c9SLi Feng Wang 				{ "4", "5", "6" }, { "7", "8", "9" }, { "10", "11", "12" } };
265*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
266*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
267*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
268*739258c9SLi Feng Wang 			submitOpenDlg(file);
269*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
270*739258c9SLi Feng Wang 			sleep(2);
271*739258c9SLi Feng Wang 
272*739258c9SLi Feng Wang 			// Insert Chart
273*739258c9SLi Feng Wang 			app.dispatch(".uno:Insert");
274*739258c9SLi Feng Wang 			scAfterCurrentSheet.check();
275*739258c9SLi Feng Wang 			scNewSheetName.setText("Instant Chart");
276*739258c9SLi Feng Wang 			scInsertSheetDlg.ok();
277*739258c9SLi Feng Wang 			sleep(5);
278*739258c9SLi Feng Wang 			inputCells(inputStr);
279*739258c9SLi Feng Wang 			sleep(2);
280*739258c9SLi Feng Wang 			SCTool.selectRange("A1:C5");
281*739258c9SLi Feng Wang 			calc.menuItem("Insert->Chart...").select();
282*739258c9SLi Feng Wang 			sleep(1);
283*739258c9SLi Feng Wang 			chartWizard.ok();
284*739258c9SLi Feng Wang 			sleep(5);
285*739258c9SLi Feng Wang 			calc.typeKeys("<esc>");
286*739258c9SLi Feng Wang 			sleep(5);
287*739258c9SLi Feng Wang 			calc.typeKeys("<esc>");
288*739258c9SLi Feng Wang 			sleep(5);
289*739258c9SLi Feng Wang 			calc.typeKeys("<esc>");
290*739258c9SLi Feng Wang 			sleep(5);
291*739258c9SLi Feng Wang 			closeWithoutSaveSC();
292*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
293*739258c9SLi Feng Wang 			addRecord(i, start, end);
294*739258c9SLi Feng Wang 		}
295*739258c9SLi Feng Wang 	}
296*739258c9SLi Feng Wang 
297*739258c9SLi Feng Wang 	@Test
298*739258c9SLi Feng Wang 	public void insertPicToOpenedSC() throws Exception {
299*739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_11s.ods");
300*739258c9SLi Feng Wang 		String pic = prepareData("image/blue_256x256.jpg");
301*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
302*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
303*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
304*739258c9SLi Feng Wang 			submitOpenDlg(file);
305*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
306*739258c9SLi Feng Wang 			sleep(2);
307*739258c9SLi Feng Wang 
308*739258c9SLi Feng Wang 			// Insert Chart
309*739258c9SLi Feng Wang 			app.dispatch(".uno:Insert");
310*739258c9SLi Feng Wang 			scAfterCurrentSheet.check();
311*739258c9SLi Feng Wang 			scNewSheetName.setText("Instant Graphic");
312*739258c9SLi Feng Wang 			scInsertSheetDlg.ok();
313*739258c9SLi Feng Wang 			sleep(5);
314*739258c9SLi Feng Wang 			calc.menuItem("Insert->Picture->From File...").select();
315*739258c9SLi Feng Wang 			sleep(2);
316*739258c9SLi Feng Wang 			filePickerPath.setText(pic);
317*739258c9SLi Feng Wang 			sleep(1);
318*739258c9SLi Feng Wang 			filePickerOpen.click();
319*739258c9SLi Feng Wang 			sleep(5);
320*739258c9SLi Feng Wang 			calc.typeKeys("<esc>");
321*739258c9SLi Feng Wang 			sleep(2);
322*739258c9SLi Feng Wang 			closeWithoutSaveSC();
323*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
324*739258c9SLi Feng Wang 			addRecord(i, start, end);
325*739258c9SLi Feng Wang 		}
326*739258c9SLi Feng Wang 	}
327*739258c9SLi Feng Wang 
328*739258c9SLi Feng Wang 	@Test
329*739258c9SLi Feng Wang 	public void insertFontWorkToOpenedSC() throws Exception {
330*739258c9SLi Feng Wang 		String file = prepareData("pvt/plain_11s.ods");
331*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
332*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
333*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
334*739258c9SLi Feng Wang 			submitOpenDlg(file);
335*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
336*739258c9SLi Feng Wang 			sleep(2);
337*739258c9SLi Feng Wang 
338*739258c9SLi Feng Wang 			calc.menuItem("View->Toolbars->Fontwork").select();
339*739258c9SLi Feng Wang 			sleep(2);
340*739258c9SLi Feng Wang 			app.dispatch(".uno:FontworkGalleryFloater");
341*739258c9SLi Feng Wang 			sleep(2);
342*739258c9SLi Feng Wang 			typeKeys("<right>");
343*739258c9SLi Feng Wang 			fontworkGalleryDlg.ok();
344*739258c9SLi Feng Wang 			sleep(2);
345*739258c9SLi Feng Wang 			calc.typeKeys("<esc>");
346*739258c9SLi Feng Wang 			sleep(2);
347*739258c9SLi Feng Wang 
348*739258c9SLi Feng Wang 			closeWithoutSaveSC();
349*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
350*739258c9SLi Feng Wang 			addRecord(i, start, end);
351*739258c9SLi Feng Wang 		}
352*739258c9SLi Feng Wang 	}
353*739258c9SLi Feng Wang 
354*739258c9SLi Feng Wang 	@Test
355*739258c9SLi Feng Wang 	public void switchFileContainingChart() throws Exception {
356*739258c9SLi Feng Wang 		String file1 = prepareData("svt/64K_Chart1.ods");
357*739258c9SLi Feng Wang 		String file2 = prepareData("svt/64K_Chart2.ods");
358*739258c9SLi Feng Wang 		String file3 = prepareData("svt/64K_Chart3.ods");
359*739258c9SLi Feng Wang 		String file4 = prepareData("svt/64K_Chart4.ods");
360*739258c9SLi Feng Wang 		String file5 = prepareData("svt/64K_Chart5.ods");
361*739258c9SLi Feng Wang 		String file6 = prepareData("svt/64K_Chart6.ods");
362*739258c9SLi Feng Wang 
363*739258c9SLi Feng Wang 		for (i = 1; i <= iterator; i++) {
364*739258c9SLi Feng Wang 			long start = System.currentTimeMillis();
365*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
366*739258c9SLi Feng Wang 			submitOpenDlg(file1);
367*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
368*739258c9SLi Feng Wang 			sleep(2);
369*739258c9SLi Feng Wang 
370*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
371*739258c9SLi Feng Wang 			submitOpenDlg(file2);
372*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
373*739258c9SLi Feng Wang 			sleep(2);
374*739258c9SLi Feng Wang 
375*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
376*739258c9SLi Feng Wang 			submitOpenDlg(file3);
377*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
378*739258c9SLi Feng Wang 			sleep(2);
379*739258c9SLi Feng Wang 
380*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
381*739258c9SLi Feng Wang 			submitOpenDlg(file4);
382*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
383*739258c9SLi Feng Wang 			sleep(2);
384*739258c9SLi Feng Wang 
385*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
386*739258c9SLi Feng Wang 			submitOpenDlg(file5);
387*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
388*739258c9SLi Feng Wang 			sleep(2);
389*739258c9SLi Feng Wang 
390*739258c9SLi Feng Wang 			app.dispatch(".uno:Open");
391*739258c9SLi Feng Wang 			submitOpenDlg(file6);
392*739258c9SLi Feng Wang 			calc.waitForExistence(20, 2);
393*739258c9SLi Feng Wang 
394*739258c9SLi Feng Wang 			sleep(2);
395*739258c9SLi Feng Wang 
396*739258c9SLi Feng Wang 			selectCertainFile(2);
397*739258c9SLi Feng Wang 			sleep(2);
398*739258c9SLi Feng Wang 			selectCertainFile(3);
399*739258c9SLi Feng Wang 			sleep(2);
400*739258c9SLi Feng Wang 			selectCertainFile(5);
401*739258c9SLi Feng Wang 			sleep(2);
402*739258c9SLi Feng Wang 
403*739258c9SLi Feng Wang 			closeAlldocuments();
404*739258c9SLi Feng Wang 			sleep(3);
405*739258c9SLi Feng Wang 			long end = System.currentTimeMillis();
406*739258c9SLi Feng Wang 			addRecord(i, start, end);
407*739258c9SLi Feng Wang 		}
408*739258c9SLi Feng Wang 	}
409*739258c9SLi Feng Wang 
410*739258c9SLi Feng Wang 	public void selectCertainFile(int k) {
411*739258c9SLi Feng Wang 		calc.menuItem("Window").select();
412*739258c9SLi Feng Wang 		k += 5;
413*739258c9SLi Feng Wang 		for (int i = 0; i < k; i++) {
414*739258c9SLi Feng Wang 			typeKeys("<down>");
415*739258c9SLi Feng Wang 		}
416*739258c9SLi Feng Wang 		typeKeys("<enter>");
417*739258c9SLi Feng Wang 		sleep(2);
418*739258c9SLi Feng Wang 	}
419*739258c9SLi Feng Wang 
420*739258c9SLi Feng Wang 	public void closeAlldocuments() {
421*739258c9SLi Feng Wang 		for (int index = 3; index < 9; index++) {
422*739258c9SLi Feng Wang 			calc.menuItem("File->Close").select();
423*739258c9SLi Feng Wang 			sleep(2);
424*739258c9SLi Feng Wang 		}
425*739258c9SLi Feng Wang 
426*739258c9SLi Feng Wang 	}
427*739258c9SLi Feng Wang 
428*739258c9SLi Feng Wang 	public static void inputCells(String[][] inputs) {
429*739258c9SLi Feng Wang 		String back = "";
430*739258c9SLi Feng Wang 		for (int i = 0; i < inputs.length; i++) {
431*739258c9SLi Feng Wang 			calc.typeKeys(back);
432*739258c9SLi Feng Wang 			sleep(1);
433*739258c9SLi Feng Wang 			back = "";
434*739258c9SLi Feng Wang 			for (int j = 0; j < inputs[i].length; j++) {
435*739258c9SLi Feng Wang 				typeKeys(inputs[i][j]);
436*739258c9SLi Feng Wang 				typeKeys("<Right>");
437*739258c9SLi Feng Wang 				sleep(0.5);
438*739258c9SLi Feng Wang 				back += "<Left>";
439*739258c9SLi Feng Wang 			}
440*739258c9SLi Feng Wang 			back += "<enter>";
441*739258c9SLi Feng Wang 		}
442*739258c9SLi Feng Wang 		sleep(2);
443*739258c9SLi Feng Wang 	}
444*739258c9SLi Feng Wang 
445*739258c9SLi Feng Wang 	private void createNewSC() {
446*739258c9SLi Feng Wang 		app.dispatch("private:factory/scalc");
447*739258c9SLi Feng Wang 	}
448*739258c9SLi Feng Wang 
449*739258c9SLi Feng Wang 	private void saveAndReopenNewSC(int iterator) {
450*739258c9SLi Feng Wang 		String saveTo = getPath("temp/" + "tempSC_New" + iterator + ".ods");
451*739258c9SLi Feng Wang 		calc.menuItem("File->Save As...").select();
452*739258c9SLi Feng Wang 		FileUtil.deleteFile(saveTo);
453*739258c9SLi Feng Wang 		submitSaveDlg(saveTo);
454*739258c9SLi Feng Wang 		if (activeMsgBox.exists()) {
455*739258c9SLi Feng Wang 			activeMsgBox.yes();
456*739258c9SLi Feng Wang 			sleep(2);
457*739258c9SLi Feng Wang 		}
458*739258c9SLi Feng Wang 		app.dispatch(".uno:CloseDoc");
459*739258c9SLi Feng Wang 		// sleep(2);
460*739258c9SLi Feng Wang 		startCenterOpenButton.waitForExistence(30, 2);
461*739258c9SLi Feng Wang 		startCenterOpenButton.click();
462*739258c9SLi Feng Wang 		submitOpenDlg(saveTo);
463*739258c9SLi Feng Wang 		sleep(1);
464*739258c9SLi Feng Wang 		app.dispatch(".uno:CloseDoc");
465*739258c9SLi Feng Wang 	}
466*739258c9SLi Feng Wang 
467*739258c9SLi Feng Wang 	private void closeWithoutSaveSC() {
468*739258c9SLi Feng Wang 		calc.menuItem("File->Close").select();
469*739258c9SLi Feng Wang 		activeMsgBox.no();
470*739258c9SLi Feng Wang 		sleep(2);
471*739258c9SLi Feng Wang 	}
472*739258c9SLi Feng Wang 
473*739258c9SLi Feng Wang 	private HashMap<String, Object> getPerfData() {
474*739258c9SLi Feng Wang 		HashMap<String, Object> proccessInfo = SystemUtil
475*739258c9SLi Feng Wang 				.findProcess(".*(soffice\\.bin|soffice\\.exe|soffice).*");
476*739258c9SLi Feng Wang 		String pid = (String) proccessInfo.get("pid");
477*739258c9SLi Feng Wang 		return SystemUtil.getProcessPerfData(pid);
478*739258c9SLi Feng Wang 	}
479*739258c9SLi Feng Wang 
480*739258c9SLi Feng Wang 	private void addRecord(int i, long start, long end) {
481*739258c9SLi Feng Wang 		HashMap<String, Object> perf = getPerfData();
482*739258c9SLi Feng Wang 		xmlResult.addRow("BasicFuncOnCalc",testname.getMethodName(), i, (end - start),
483*739258c9SLi Feng Wang 				perf.get("rss"), perf.get("pcpu"));
484*739258c9SLi Feng Wang 	}
485*739258c9SLi Feng Wang }
486