Line 0
Link Here
|
|
|
1 |
/************************************************************** |
2 |
* |
3 |
* Licensed to the Apache Software Foundation (ASF) under one |
4 |
* or more contributor license agreements. See the NOTICE file |
5 |
* distributed with this work for additional information |
6 |
* regarding copyright ownership. The ASF licenses this file |
7 |
* to you under the Apache License, Version 2.0 (the |
8 |
* "License"); you may not use this file except in compliance |
9 |
* with the License. You may obtain a copy of the License at |
10 |
* |
11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
12 |
* |
13 |
* Unless required by applicable law or agreed to in writing, |
14 |
* software distributed under the License is distributed on an |
15 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
16 |
* KIND, either express or implied. See the License for the |
17 |
* specific language governing permissions and limitations |
18 |
* under the License. |
19 |
* |
20 |
*************************************************************/ |
21 |
|
22 |
|
23 |
|
24 |
/** |
25 |
* |
26 |
*/ |
27 |
|
28 |
|
29 |
package testcase.performance.benchmark; |
30 |
|
31 |
import static testlib.AppUtil.*; |
32 |
import static testlib.UIMap.*; |
33 |
|
34 |
import org.junit.Before; |
35 |
import org.junit.Ignore; |
36 |
import org.junit.Rule; |
37 |
import org.junit.Test; |
38 |
import org.openoffice.test.common.Testspace; |
39 |
|
40 |
|
41 |
import java.io.File; |
42 |
import java.io.FileWriter; |
43 |
import java.io.IOException; |
44 |
|
45 |
import static org.openoffice.test.vcl.Tester.*; |
46 |
|
47 |
public class Filter { |
48 |
|
49 |
@Before |
50 |
public void setUp(){ |
51 |
app.start(); |
52 |
} |
53 |
|
54 |
@Test |
55 |
public void pvtFilter() |
56 |
{ |
57 |
String pvt_result_path = new File(System.getProperty("testspace", "../testspace")).getAbsolutePath() + "/output/pvt_filter_results.txt"; |
58 |
String testspacePath = new File(System.getProperty("testspace", "../testspace")).getAbsolutePath(); |
59 |
String counterLists = testspacePath + "\\data\\pvt_benchmark\\perfmon\\counterlist.txt"; |
60 |
String counterOutput = testspacePath + "\\output\\output_perfmon"; |
61 |
String createCounters = testspacePath + "\\data\\pvt_benchmark\\perfmon\\createCounters.bat"; |
62 |
String stopCounters = testspacePath + "\\data\\pvt_benchmark\\perfmon\\stopCounters.bat"; |
63 |
|
64 |
Testspace.prepareData("pvt_benchmark/perfmon/counterlist.txt"); |
65 |
Testspace.prepareData("pvt_benchmark/perfmon/createCounters.bat"); |
66 |
Testspace.prepareData("pvt_benchmark/perfmon/stopCounters.bat"); |
67 |
Testspace.prepareData("pvt_benchmark/output_start.ods", "/output/output_start.ods"); |
68 |
|
69 |
try { |
70 |
String []cmdargs_start = {"cmd.exe", "/C", "start", createCounters, counterOutput, counterLists}; |
71 |
java.lang.Runtime.getRuntime().exec(cmdargs_start); |
72 |
sleep(5); |
73 |
FileWriter out = new FileWriter(pvt_result_path); |
74 |
out.write("Test Start: " + System.getProperty("line.separator")); |
75 |
for(int i = 0; i < 8; i++) |
76 |
{ |
77 |
System.out.println("This is the " + i + " time"); |
78 |
// out.write("New Document Result: " + perfNew("Text Document") + System.getProperty("line.separator")); |
79 |
// out.flush(); |
80 |
// out.write("New Presentation Result: " + perfNew("Presentation") + System.getProperty("line.separator")); |
81 |
// out.flush(); |
82 |
// out.write("New Spreadsheet Result: " + perfNew("Spreadsheet") + System.getProperty("line.separator")); |
83 |
// out.flush(); |
84 |
|
85 |
out.write("Plain ODT Load Show Result: " + perfLoadShow("pvt_benchmark/sw_plain_120p_odf1.2.odt") + System.getProperty("line.separator")); |
86 |
out.flush(); |
87 |
out.write("Plain DOC Load Show Result: " + perfLoadShow("pvt_benchmark/sw_plain_120p.doc") + System.getProperty("line.separator")); |
88 |
out.flush(); |
89 |
out.write("Complex ODT Load Show Result: " + perfLoadShow("pvt_benchmark/sw_complex_100p_odf1.2.odt") + System.getProperty("line.separator")); |
90 |
out.flush(); |
91 |
out.write("Complex DOC Load Show Result: " + perfLoadShow("pvt_benchmark/sw_complex_100p.doc") + System.getProperty("line.separator")); |
92 |
out.flush(); |
93 |
out.write("Plain ODP Load Show Result: " + perfLoadShow("pvt_benchmark/sd_plain_50p_odf1.2.odp") + System.getProperty("line.separator")); |
94 |
out.flush(); |
95 |
out.write("Plain PPT Load Show Result: " + perfLoadShow("pvt_benchmark/sd_plain_50p.ppt") + System.getProperty("line.separator")); |
96 |
out.flush(); |
97 |
out.write("Complex ODP Load Show Result: " + perfLoadShow("pvt_benchmark/sd_complex_51p_odf1.2.odp") + System.getProperty("line.separator")); |
98 |
out.flush(); |
99 |
out.write("Complex PPT Load Show Result: " + perfLoadShow("pvt_benchmark/sd_complex_51p.ppt") + System.getProperty("line.separator")); |
100 |
out.flush(); |
101 |
out.write("Plain ODS Load Show Result: " + perfLoadShow("pvt_benchmark/sc_plain_4sh_5kcell_new_odf1.2.ods") + System.getProperty("line.separator")); |
102 |
out.flush(); |
103 |
out.write("Plain XLS Load Show Result: " + perfLoadShow("pvt_benchmark/sc_plain_4sh_5kcell.xls") + System.getProperty("line.separator")); |
104 |
out.flush(); |
105 |
out.write("Complex ODS Load Show Result: " + perfLoadShow("pvt_benchmark/sc_complex_13sh_4kcell_new_odf1.2.ods") + System.getProperty("line.separator")); |
106 |
out.flush(); |
107 |
out.write("Complex XLS Load Show Result: " + perfLoadShow("pvt_benchmark/sc_complex_13sh_4kcell.xls") + System.getProperty("line.separator")); |
108 |
out.flush(); |
109 |
|
110 |
out.write("Plain ODT Load Finish Result: " + perfLoadFinish("pvt_benchmark/sw_plain_120p_odf1.2.odt", 110) + System.getProperty("line.separator")); |
111 |
out.flush(); |
112 |
out.write("Plain DOC Load Finish Result: " + perfLoadFinish("pvt_benchmark/sw_plain_120p.doc", 110) + System.getProperty("line.separator")); |
113 |
out.flush(); |
114 |
out.write("Complex ODT Load Finish Result: " + perfLoadFinish("pvt_benchmark/sw_complex_100p_odf1.2.odt", 100) + System.getProperty("line.separator")); |
115 |
out.flush(); |
116 |
out.write("Complex DOC Load Finish Result: " + perfLoadFinish("pvt_benchmark/sw_complex_100p.doc", 95) + System.getProperty("line.separator")); |
117 |
out.flush(); |
118 |
out.write("Plain ODP Load Finish Result: " + perfLoadFinish("pvt_benchmark/sd_plain_50p_odf1.2.odp", 50) + System.getProperty("line.separator")); |
119 |
out.flush(); |
120 |
out.write("Plain PPT Load Finish Result: " + perfLoadFinish("pvt_benchmark/sd_plain_50p.ppt", 50) + System.getProperty("line.separator")); |
121 |
out.flush(); |
122 |
out.write("Complex ODP Load Finish Result: " + perfLoadFinish("pvt_benchmark/sd_complex_51p_odf1.2.odp", 51) + System.getProperty("line.separator")); |
123 |
out.flush(); |
124 |
out.write("Complex PPT Load Finish Result: " + perfLoadFinish("pvt_benchmark/sd_complex_51p.ppt", 51) + System.getProperty("line.separator")); |
125 |
out.flush(); |
126 |
|
127 |
out.write("Plain ODT Save Result: " + perfSave("pvt_benchmark/sw_plain_120p_odf1.2.odt") + System.getProperty("line.separator")); |
128 |
out.flush(); |
129 |
out.write("Plain DOC Save Result: " + perfSave("pvt_benchmark/sw_plain_120p.doc") + System.getProperty("line.separator")); |
130 |
out.flush(); |
131 |
out.write("Complex ODT Save Result: " + perfSave("pvt_benchmark/sw_complex_100p_odf1.2.odt") + System.getProperty("line.separator")); |
132 |
out.flush(); |
133 |
out.write("Complex DOC Save Result: " + perfSave("pvt_benchmark/sw_complex_100p.doc") + System.getProperty("line.separator")); |
134 |
out.flush(); |
135 |
out.write("Plain ODP Save Result: " + perfSave("pvt_benchmark/sd_plain_50p_odf1.2.odp") + System.getProperty("line.separator")); |
136 |
out.flush(); |
137 |
out.write("Plain PPT Save Result: " + perfSave("pvt_benchmark/sd_plain_50p.ppt") + System.getProperty("line.separator")); |
138 |
out.flush(); |
139 |
out.write("Complex ODP Save Result: " + perfSave("pvt_benchmark/sd_complex_51p_odf1.2.odp") + System.getProperty("line.separator")); |
140 |
out.flush(); |
141 |
out.write("Complex PPT Save Result: " + perfSave("pvt_benchmark/sd_complex_51p.ppt") + System.getProperty("line.separator")); |
142 |
out.flush(); |
143 |
out.write("Plain ODS Save Result: " + perfSave("pvt_benchmark/sc_plain_4sh_5kcell_new_odf1.2.ods") + System.getProperty("line.separator")); |
144 |
out.flush(); |
145 |
out.write("Plain XLS Save Result: " + perfSave("pvt_benchmark/sc_plain_4sh_5kcell.xls") + System.getProperty("line.separator")); |
146 |
out.flush(); |
147 |
out.write("Complex ODS Save Result: " + perfSave("pvt_benchmark/sc_complex_13sh_4kcell_new_odf1.2.ods") + System.getProperty("line.separator")); |
148 |
out.flush(); |
149 |
out.write("Complex XLS Save Result: " + perfSave("pvt_benchmark/sc_complex_13sh_4kcell.xls") + System.getProperty("line.separator")); |
150 |
out.flush(); |
151 |
} |
152 |
out.close(); |
153 |
String []cmdargs_end = {"cmd.exe", "/C", "start", stopCounters}; |
154 |
java.lang.Runtime.getRuntime().exec(cmdargs_end); |
155 |
|
156 |
} catch (IOException e) { |
157 |
// TODO Auto-generated catch block |
158 |
e.printStackTrace(); |
159 |
} |
160 |
|
161 |
|
162 |
GenerateReports genReport = new GenerateReports(); |
163 |
genReport.computeResults(pvt_result_path); |
164 |
|
165 |
} |
166 |
|
167 |
public long perfNew(String fileType) |
168 |
{ |
169 |
System.out.println("New " + fileType); |
170 |
startcenter.menuItem("File->New->" + fileType).select(); |
171 |
// startcenter.menuItem("File->New->Spreadsheet").select(); |
172 |
long tr = System.currentTimeMillis(); |
173 |
// System.out.println("1: " + tr); |
174 |
while(true) |
175 |
{ |
176 |
if(fileType.equals("Text Document")) |
177 |
{ |
178 |
if(writer.exists()) |
179 |
{ |
180 |
break; |
181 |
} |
182 |
} |
183 |
|
184 |
// else{ |
185 |
if(fileType.equals("Presentation")) |
186 |
{ |
187 |
// System.out.println("2: " + System.currentTimeMillis()); |
188 |
if(impress.exists()) |
189 |
{ |
190 |
// System.out.println("3: " + System.currentTimeMillis()); |
191 |
break; |
192 |
} |
193 |
} |
194 |
// else |
195 |
// { |
196 |
if(calc.exists()) |
197 |
{ |
198 |
break; |
199 |
} |
200 |
// } |
201 |
// } |
202 |
|
203 |
} |
204 |
// System.out.println("4: " + System.currentTimeMillis()); |
205 |
tr = System.currentTimeMillis() - tr; |
206 |
|
207 |
if(fileType.equals("Text Document")) |
208 |
{ |
209 |
writer.menuItem("File->Close").select(); |
210 |
} |
211 |
|
212 |
if(fileType.equals("Presentation")) |
213 |
{ |
214 |
impress.menuItem("File->Close").select(); |
215 |
} |
216 |
|
217 |
if(fileType.equals("Spreadsheet")) |
218 |
{ |
219 |
calc.menuItem("File->Close").select(); |
220 |
} |
221 |
|
222 |
return tr; |
223 |
} |
224 |
|
225 |
public long perfLoadShow(String fileName) |
226 |
{ |
227 |
System.out.println(fileName + " Load Show"); |
228 |
long tr = 0; |
229 |
String file = testFile(fileName); |
230 |
startcenter.menuItem("File->Open...").select(); |
231 |
FilePicker_Path.setText(file); |
232 |
FilePicker_Open.click(); |
233 |
// submitOpenDlg(file); |
234 |
tr = System.currentTimeMillis(); |
235 |
while(true) |
236 |
{ |
237 |
if(fileName.contains("odt") || fileName.contains("doc") || fileName.contains("docx")) |
238 |
{ |
239 |
if(writer.exists()) |
240 |
{ |
241 |
// writer.menuItem("File->Close").select(); |
242 |
break; |
243 |
} |
244 |
} |
245 |
|
246 |
if(fileName.contains("odp") || fileName.contains("ppt") || fileName.contains("pptx")) |
247 |
{ |
248 |
if(impress.exists()) |
249 |
{ |
250 |
// impress.menuItem("File->Close").select(); |
251 |
break; |
252 |
} |
253 |
} |
254 |
|
255 |
if(fileName.contains("ods") || fileName.contains("xls") || fileName.contains("xlsx")) |
256 |
{ |
257 |
if(calc.exists()) |
258 |
{ |
259 |
// calc.menuItem("File->Close").select(); |
260 |
break; |
261 |
} |
262 |
} |
263 |
} |
264 |
tr = System.currentTimeMillis() - tr; |
265 |
sleep(2); |
266 |
|
267 |
if(fileName.contains("odt") || fileName.contains("doc") || fileName.contains("docx")) |
268 |
{ |
269 |
writer.menuItem("File->Close").select(); |
270 |
} |
271 |
|
272 |
if(fileName.contains("odp") || fileName.contains("ppt") || fileName.contains("pptx")) |
273 |
{ |
274 |
impress.menuItem("File->Close").select(); |
275 |
} |
276 |
|
277 |
if(fileName.contains("ods") || fileName.contains("xls") || fileName.contains("xlsx")) |
278 |
{ |
279 |
calc.menuItem("File->Close").select(); |
280 |
} |
281 |
|
282 |
return tr; |
283 |
} |
284 |
|
285 |
public long perfLoadFinish(String fileName, int destPage) |
286 |
{ |
287 |
System.out.println(fileName + " Load Finish"); |
288 |
long tr = 0; |
289 |
String file = testFile(fileName); |
290 |
startcenter.menuItem("File->Open...").select(); |
291 |
// submitOpenDlg(file); |
292 |
FilePicker_Path.setText(file); |
293 |
FilePicker_Open.click(); |
294 |
tr = System.currentTimeMillis(); |
295 |
while(true) |
296 |
{ |
297 |
if(getLoadedPage(fileName) >= destPage) |
298 |
{ |
299 |
break; |
300 |
} |
301 |
} |
302 |
tr = System.currentTimeMillis() - tr; |
303 |
sleep(5); |
304 |
System.out.println("Load Finish Time: " + tr); |
305 |
|
306 |
if(fileName.contains("odt") || fileName.contains("doc") || fileName.contains("docx")) |
307 |
{ |
308 |
writer.menuItem("File->Close").select(); |
309 |
} |
310 |
|
311 |
if(fileName.contains("odp") || fileName.contains("ppt") || fileName.contains("pptx")) |
312 |
{ |
313 |
impress.menuItem("File->Close").select(); |
314 |
} |
315 |
|
316 |
if(fileName.contains("ods") || fileName.contains("xls") || fileName.contains("xlsx")) |
317 |
{ |
318 |
calc.menuItem("File->Close").select(); |
319 |
} |
320 |
return tr; |
321 |
} |
322 |
|
323 |
public static int getLoadedPage(String docName) |
324 |
{ |
325 |
String tmp = ""; |
326 |
if(docName.endsWith("odt") || docName.endsWith("doc") || docName.endsWith("docx")) |
327 |
{ |
328 |
tmp = statusbar("FWK_HID_STATUSBAR").getItemText(0); |
329 |
} |
330 |
if(docName.endsWith("odp") || docName.endsWith("ppt") || docName.endsWith("pptx")) |
331 |
{ |
332 |
tmp = statusbar("FWK_HID_STATUSBAR").getItemText(4); |
333 |
} |
334 |
//System.out.println(tmp); |
335 |
String s[]= tmp.split("/"); |
336 |
// System.out.println(Integer.parseInt(s[1].trim())); |
337 |
return Integer.parseInt(s[1].trim()); |
338 |
} |
339 |
|
340 |
public long perfSave(String fileName_i) |
341 |
{ |
342 |
System.out.println(fileName_i + " Save"); |
343 |
String fileName = fileName_i.substring(14); |
344 |
// System.out.println(fileName); |
345 |
long tr = 0; |
346 |
sleep(2); |
347 |
String file = testFile(fileName_i); |
348 |
startcenter.menuItem("File->Open...").select(); |
349 |
submitOpenDlg(file); |
350 |
sleep(8); |
351 |
if(fileName.startsWith("sw")){ |
352 |
if(fileName.startsWith("sw_complex")){ |
353 |
typeKeys("<ctrl Home>"); |
354 |
if(fileName.endsWith("odt")){ |
355 |
// writer.click(180,300); |
356 |
typeKeys("<PageDown>"); |
357 |
sleep(2); |
358 |
typeKeys("<PageDown>"); |
359 |
sleep(2); |
360 |
typeKeys("<PageDown>"); |
361 |
sleep(2); |
362 |
typeKeys("<Enter>"); |
363 |
sleep(2); |
364 |
typeKeys("<delete>"); |
365 |
}else{ |
366 |
// writer.click(180,300); |
367 |
// org.vclauto.Tester.typeKeys("<PGDN pgdn pgdn pgdn pgdn>"); |
368 |
// org.vclauto.Tester.typeKeys("<DOWN down>"); |
369 |
typeKeys("<Enter>"); |
370 |
sleep(2); |
371 |
// System.out.println("Enter"); |
372 |
typeKeys("<backspace>"); |
373 |
// System.out.println("backspace"); |
374 |
} |
375 |
}else{ |
376 |
// writer.click(180,300); |
377 |
// writer.click(); |
378 |
typeKeys("<enter>"); |
379 |
typeKeys("<backspace>"); |
380 |
} |
381 |
} |
382 |
else if(fileName.startsWith("sd")){ |
383 |
// writer.click(436, 326); |
384 |
// presenter.click(); |
385 |
// sleep(2); |
386 |
// org.vclauto.Tester.typeKeys("<Enter>"); |
387 |
// sleep(1); |
388 |
// org.vclauto.Tester.typeKeys("<BACKSPACE>"); |
389 |
// sleep(1); |
390 |
// org.vclauto.Tester.typeKeys("<ESC>"); |
391 |
// sleep(1); |
392 |
// org.vclauto.Tester.typeKeys("<ESC>"); |
393 |
// System.out.println("SD"); |
394 |
impress.menuItem("Insert->Slide").select(); |
395 |
// System.out.println("Insert slide"); |
396 |
sleep(5); |
397 |
impress.menuItem("Edit->Delete Slide").select(); |
398 |
// System.out.println("Delete slide"); |
399 |
sleep(5); |
400 |
|
401 |
}else{ |
402 |
// writer.click(100, 220); |
403 |
typeKeys("1"); |
404 |
typeKeys("<BACKSPACE>"); |
405 |
typeKeys("<Enter>"); |
406 |
typeKeys("<ESC>"); |
407 |
} |
408 |
sleep(5); |
409 |
|
410 |
typeKeys("<ctrl s>"); |
411 |
tr = System.currentTimeMillis(); |
412 |
|
413 |
int index = 0; |
414 |
if(fileName.endsWith("odt") || fileName.endsWith("doc") || fileName.endsWith("docx")) |
415 |
{ |
416 |
index = 5; |
417 |
} |
418 |
if(fileName.endsWith("odp") || fileName.endsWith("ppt") || fileName.endsWith("pptx")) |
419 |
{ |
420 |
index = 2; |
421 |
} |
422 |
if(fileName.endsWith("ods") || fileName.endsWith("xls") || fileName.endsWith("xlsx")) |
423 |
{ |
424 |
index = 4; |
425 |
} |
426 |
while(true) |
427 |
{ |
428 |
// System.out.println(statusbar("FWK_HID_STATUSBAR").getItemText(index)); |
429 |
if(statusbar("FWK_HID_STATUSBAR").getItemText(index).equals(" ")) |
430 |
{ |
431 |
break; |
432 |
} |
433 |
} |
434 |
tr = System.currentTimeMillis() - tr; |
435 |
|
436 |
sleep(2); |
437 |
|
438 |
if(fileName.contains("odt") || fileName.contains("doc") || fileName.contains("docx")) |
439 |
{ |
440 |
writer.menuItem("File->Close").select(); |
441 |
} |
442 |
|
443 |
if(fileName.contains("odp") || fileName.contains("ppt") || fileName.contains("pptx")) |
444 |
{ |
445 |
impress.menuItem("File->Close").select(); |
446 |
} |
447 |
|
448 |
if(fileName.contains("ods") || fileName.contains("xls") || fileName.contains("xlsx")) |
449 |
{ |
450 |
calc.menuItem("File->Close").select(); |
451 |
} |
452 |
return tr; |
453 |
} |
454 |
|
455 |
} |