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 |
package testcase.gui.svt.sc; |
29 |
|
30 |
import static org.openoffice.test.common.Testspace.prepareData; |
31 |
import static testlib.gui.AppUtil.typeKeys; |
32 |
import static org.openoffice.test.vcl.Tester.sleep; |
33 |
import static org.openoffice.test.vcl.Tester.typeKeys; |
34 |
import static testlib.gui.AppUtil.submitOpenDlg; |
35 |
import static testlib.gui.UIMap.SCAfterCurrentSheet; |
36 |
import static testlib.gui.UIMap.SCInsertSheetDlg; |
37 |
import static testlib.gui.UIMap.SCNewSheetName; |
38 |
import static testlib.gui.UIMap.app; |
39 |
import static testlib.gui.UIMap.writer; |
40 |
import static testlib.gui.UIMap.*; |
41 |
|
42 |
import java.io.FileOutputStream; |
43 |
import java.io.PrintStream; |
44 |
import java.util.HashMap; |
45 |
|
46 |
import org.junit.After; |
47 |
import org.junit.Before; |
48 |
import org.junit.Rule; |
49 |
import org.junit.Test; |
50 |
import org.openoffice.test.OpenOffice; |
51 |
import org.openoffice.test.common.SystemUtil; |
52 |
import org.openoffice.test.common.Testspace; |
53 |
|
54 |
import testlib.gui.CalcUtil; |
55 |
import testlib.gui.Log; |
56 |
|
57 |
public class OperationOnSampleFile { |
58 |
@Rule |
59 |
public Log LOG = new Log(); |
60 |
|
61 |
private PrintStream result = null; |
62 |
|
63 |
private String pid = null; |
64 |
|
65 |
/** |
66 |
* @throws java.lang.Exception |
67 |
*/ |
68 |
@Before |
69 |
public void setUp() throws Exception { |
70 |
OpenOffice.killAll(); |
71 |
app.start(); |
72 |
result = new PrintStream(new FileOutputStream(Testspace.getFile("output/svt_sc_sample1.csv"))); |
73 |
HashMap<String, Object> proccessInfo = SystemUtil.findProcess(".*(soffice\\.bin|soffice.*-env).*"); |
74 |
pid = (String)proccessInfo.get("pid"); |
75 |
result.println("Iterator,Time,Memory(KB),CPU(%)"); |
76 |
LOG.info("Result will be saved to " + Testspace.getPath("output/svt_sc_sample1.csv")); |
77 |
} |
78 |
|
79 |
@After |
80 |
public void tearDown() throws Exception { |
81 |
app.close(); |
82 |
result.close(); |
83 |
} |
84 |
|
85 |
@Test |
86 |
public void operationOnSampleFile() throws Exception { |
87 |
String file = prepareData("svt/complex.ods"); |
88 |
String pic = prepareData("svt/Sunset.jpg"); |
89 |
String [][] inputStr = { { "Area", "Item", "Count" }, { "1", "2", "3" }, |
90 |
{ "4", "5", "6" }, { "7", "8", "9" }, { "10", "11", "12" }}; |
91 |
for(int i = 0; i < 1000; i++) |
92 |
{ |
93 |
app.dispatch(".uno:Open"); |
94 |
submitOpenDlg(file); |
95 |
calc.waitForExistence(20, 2); |
96 |
sleep(2); |
97 |
|
98 |
//Insert Chart |
99 |
app.dispatch(".uno:Insert"); |
100 |
SCAfterCurrentSheet.check(); |
101 |
SCNewSheetName.setText("Instant Chart"); |
102 |
SCInsertSheetDlg.ok(); |
103 |
sleep(5); |
104 |
inputCells(inputStr); |
105 |
sleep(2); |
106 |
CalcUtil.selectRange("A1:C5"); |
107 |
calc.menuItem("Insert->Chart...").select(); |
108 |
sleep(1); |
109 |
Chart_Wizard.ok(); |
110 |
sleep(5); |
111 |
calc.typeKeys("<esc>"); |
112 |
sleep(5); |
113 |
calc.typeKeys("<esc>"); |
114 |
sleep(5); |
115 |
calc.typeKeys("<esc>"); |
116 |
sleep(5); |
117 |
|
118 |
//Insert Graphic and Fontwork |
119 |
app.dispatch(".uno:Insert"); |
120 |
SCAfterCurrentSheet.check(); |
121 |
SCNewSheetName.setText("Instant Graphic and fontwork"); |
122 |
SCInsertSheetDlg.ok(); |
123 |
sleep(5); |
124 |
calc.menuItem("Insert->Picture->From File...").select(); |
125 |
sleep(2); |
126 |
FilePicker_Path.setText(pic); |
127 |
sleep(1); |
128 |
FilePicker_Open.click(); |
129 |
sleep(5); |
130 |
calc.typeKeys("<esc>"); |
131 |
sleep(2); |
132 |
calc.menuItem("View->Toolbars->Fontwork").select(); |
133 |
sleep(2); |
134 |
app.dispatch(".uno:FontworkGalleryFloater"); |
135 |
sleep(2); |
136 |
typeKeys("<right>"); |
137 |
FontworkGalleryDlg.ok(); |
138 |
sleep(2); |
139 |
calc.typeKeys("<esc>"); |
140 |
sleep(2); |
141 |
|
142 |
// Close file |
143 |
calc.menuItem("File->Close").select(); |
144 |
ActiveMsgBox.no(); |
145 |
sleep(2); |
146 |
|
147 |
HashMap<String, Object> perfData = SystemUtil.getProcessPerfData(pid); |
148 |
String record = i + "," + System.currentTimeMillis() + "," + perfData.get("rss") + "," + perfData.get("pcpu"); |
149 |
LOG.info("Record: " + record); |
150 |
result.println(record); |
151 |
result.flush(); |
152 |
|
153 |
sleep(3); |
154 |
|
155 |
} |
156 |
|
157 |
|
158 |
} |
159 |
public static void inputCells(String [][]inputs) |
160 |
{ |
161 |
String back = ""; |
162 |
for (int i = 0; i < inputs.length; i++) { |
163 |
calc.typeKeys(back); |
164 |
sleep(1); |
165 |
back = ""; |
166 |
for (int j = 0; j < inputs[i].length; j++) { |
167 |
typeKeys(inputs[i][j]); |
168 |
typeKeys("<Right>"); |
169 |
sleep(0.5); |
170 |
back += "<Left>"; |
171 |
} |
172 |
back += "<enter>"; |
173 |
} |
174 |
sleep(2); |
175 |
} |
176 |
} |