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 |
package testcase.gui.svt.sw; |
26 |
|
27 |
import static org.openoffice.test.common.Testspace.prepareData; |
28 |
import static testlib.gui.AppUtil.submitOpenDlg; |
29 |
import static testlib.gui.UIMap.app; |
30 |
import static testlib.gui.UIMap.writer; |
31 |
import static testlib.gui.UIMap.*; |
32 |
|
33 |
import java.io.FileOutputStream; |
34 |
import java.io.PrintStream; |
35 |
import java.util.HashMap; |
36 |
|
37 |
import org.junit.After; |
38 |
import org.junit.Before; |
39 |
import org.junit.Rule; |
40 |
import org.junit.Test; |
41 |
import org.openoffice.test.OpenOffice; |
42 |
import org.openoffice.test.common.SystemUtil; |
43 |
import org.openoffice.test.common.Testspace; |
44 |
import static org.openoffice.test.vcl.Tester.*; |
45 |
|
46 |
import testlib.gui.Log; |
47 |
|
48 |
public class OperationOnSample1 { |
49 |
|
50 |
@Rule |
51 |
public Log LOG = new Log(); |
52 |
|
53 |
private PrintStream result = null; |
54 |
|
55 |
private String pid = null; |
56 |
|
57 |
/** |
58 |
* @throws java.lang.Exception |
59 |
*/ |
60 |
@Before |
61 |
public void setUp() throws Exception { |
62 |
OpenOffice.killAll(); |
63 |
app.start(); |
64 |
result = new PrintStream(new FileOutputStream(Testspace.getFile("output/svt_sw_sample1.csv"))); |
65 |
String processSoffice = null; |
66 |
if(SystemUtil.isWindows()) |
67 |
{ |
68 |
processSoffice = ".*soffice\\.exe.*"; |
69 |
} |
70 |
else |
71 |
{ |
72 |
processSoffice = ".*soffice\\.bin.*"; |
73 |
} |
74 |
HashMap<String, Object> proccessInfo = SystemUtil.findProcess(processSoffice); |
75 |
pid = (String)proccessInfo.get("pid"); |
76 |
result.println("Iterator,Time,Memory(KB),CPU(%)"); |
77 |
LOG.info("Result will be saved to " + Testspace.getPath("output/svt_sw_sample1.csv")); |
78 |
} |
79 |
|
80 |
@After |
81 |
public void tearDown() throws Exception { |
82 |
app.close(); |
83 |
result.close(); |
84 |
} |
85 |
|
86 |
@Test |
87 |
public void operationOnSample1() throws Exception{ |
88 |
String file = prepareData("svt/ScenarioDesign.odt"); |
89 |
for(int i = 0; i < 1000; i++) |
90 |
{ |
91 |
System.out.println("This is the " + i + " round"); |
92 |
app.dispatch(".uno:Open"); |
93 |
submitOpenDlg(file); |
94 |
writer.waitForExistence(10, 2); |
95 |
writer.typeKeys("<down>"); |
96 |
writer.typeKeys("<down>"); |
97 |
sleep(2); |
98 |
|
99 |
writer.menuItem("Table->Split Cells").select(); |
100 |
sleep(2); |
101 |
Writer_SplitCellDlg.ok(); |
102 |
sleep(2); |
103 |
|
104 |
writer.typeKeys("<shift down>"); |
105 |
writer.typeKeys("<shift down>"); |
106 |
writer.typeKeys("<shift down>"); |
107 |
writer.typeKeys("<shift down>"); |
108 |
writer.typeKeys("<shift down>"); |
109 |
sleep(2); |
110 |
writer.menuItem("Table->Merge Cells").select(); |
111 |
sleep(2); |
112 |
|
113 |
writer.typeKeys("<enter>"); |
114 |
// writer.menuItem("Table->Insert->Rows...").select(); |
115 |
app.dispatch(".uno:InsertRowDialog"); |
116 |
Writer_InsertRowsDlg.ok(); |
117 |
sleep(2); |
118 |
|
119 |
writer.menuItem("Table->Delete->Rows").select(); |
120 |
sleep(2); |
121 |
|
122 |
app.dispatch(".uno:InsertColumnDialog"); |
123 |
Writer_InsertColumnsDlg.ok(); |
124 |
sleep(2); |
125 |
|
126 |
writer.menuItem("Table->Delete->Columns").select(); |
127 |
sleep(2); |
128 |
|
129 |
writer.menuItem("File->Close").select(); |
130 |
ActiveMsgBox.no(); |
131 |
sleep(2); |
132 |
|
133 |
HashMap<String, Object> perfData = SystemUtil.getProcessPerfData(pid); |
134 |
String record = i + "," + System.currentTimeMillis() + "," + perfData.get("rss") + "," + perfData.get("pcpu"); |
135 |
LOG.info("Record: " + record); |
136 |
result.println(record); |
137 |
result.flush(); |
138 |
|
139 |
sleep(3); |
140 |
} |
141 |
} |
142 |
|
143 |
} |