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 |
package testcase.gui.svt.sc; |
27 |
|
28 |
import static org.openoffice.test.common.Testspace.prepareData; |
29 |
import static org.openoffice.test.vcl.Tester.sleep; |
30 |
import static org.openoffice.test.vcl.Tester.typeKeys; |
31 |
import static testlib.gui.AppUtil.submitOpenDlg; |
32 |
import static testlib.gui.UIMap.ActiveMsgBox; |
33 |
import static testlib.gui.UIMap.app; |
34 |
import static testlib.gui.UIMap.calc; |
35 |
|
36 |
import java.io.FileOutputStream; |
37 |
import java.io.PrintStream; |
38 |
import java.util.HashMap; |
39 |
|
40 |
import org.junit.After; |
41 |
import org.junit.Before; |
42 |
import org.junit.Rule; |
43 |
import org.junit.Test; |
44 |
import org.openoffice.test.OpenOffice; |
45 |
import org.openoffice.test.common.SystemUtil; |
46 |
import org.openoffice.test.common.Testspace; |
47 |
|
48 |
import testlib.gui.Log; |
49 |
|
50 |
public class SwitchFilesContainingChart { |
51 |
@Rule |
52 |
public Log LOG = new Log(); |
53 |
|
54 |
private PrintStream result = null; |
55 |
|
56 |
private String pid = null; |
57 |
|
58 |
/** |
59 |
* @throws java.lang.Exception |
60 |
*/ |
61 |
@Before |
62 |
public void setUp() throws Exception { |
63 |
OpenOffice.killAll(); |
64 |
app.start(); |
65 |
result = new PrintStream(new FileOutputStream(Testspace.getFile("output/svt_sc_switchFiles.csv"))); |
66 |
HashMap<String, Object> proccessInfo = SystemUtil.findProcess(".*(soffice\\.bin|soffice.*-env).*"); |
67 |
pid = (String)proccessInfo.get("pid"); |
68 |
result.println("Iterator,Time,Memory(KB),CPU(%)"); |
69 |
LOG.info("Result will be saved to " + Testspace.getPath("output/svt_sc_switchFiles.csv")); |
70 |
} |
71 |
|
72 |
@After |
73 |
public void tearDown() throws Exception { |
74 |
app.close(); |
75 |
result.close(); |
76 |
} |
77 |
|
78 |
@Test |
79 |
public void SwitchFileContainingChart() throws Exception { |
80 |
String file1 = prepareData("svt/sc_chart edit mod close_1.ods"); |
81 |
String file2 = prepareData("svt/sc_chart edit mod close_2.ods"); |
82 |
String file3 = prepareData("svt/sc_chart edit mod close_3.ods"); |
83 |
String file4 = prepareData("svt/sc_chart edit mod close_4.ods"); |
84 |
String file5 = prepareData("svt/sc_chart edit mod close_5.ods"); |
85 |
String file6 = prepareData("svt/sc_chart edit mod close_6.ods"); |
86 |
|
87 |
for(int i = 0; i < 500; i++) |
88 |
{ |
89 |
app.dispatch(".uno:Open"); |
90 |
submitOpenDlg(file1); |
91 |
calc.waitForExistence(20, 2); |
92 |
sleep(2); |
93 |
|
94 |
app.dispatch(".uno:Open"); |
95 |
submitOpenDlg(file2); |
96 |
calc.waitForExistence(20, 2); |
97 |
sleep(2); |
98 |
|
99 |
app.dispatch(".uno:Open"); |
100 |
submitOpenDlg(file3); |
101 |
calc.waitForExistence(20, 2); |
102 |
sleep(2); |
103 |
|
104 |
app.dispatch(".uno:Open"); |
105 |
submitOpenDlg(file4); |
106 |
calc.waitForExistence(20, 2); |
107 |
sleep(2); |
108 |
|
109 |
app.dispatch(".uno:Open"); |
110 |
submitOpenDlg(file5); |
111 |
calc.waitForExistence(20, 2); |
112 |
sleep(2); |
113 |
|
114 |
app.dispatch(".uno:Open"); |
115 |
submitOpenDlg(file6); |
116 |
calc.waitForExistence(20, 2); |
117 |
|
118 |
sleep(2); |
119 |
|
120 |
selectCertainFile(2); |
121 |
sleep(2); |
122 |
selectCertainFile(6); |
123 |
sleep(2); |
124 |
selectCertainFile(8); |
125 |
sleep(2); |
126 |
|
127 |
closeAlldocuments(); |
128 |
sleep(5); |
129 |
|
130 |
HashMap<String, Object> perfData = SystemUtil.getProcessPerfData(pid); |
131 |
String record = i + "," + System.currentTimeMillis() + "," + perfData.get("rss") + "," + perfData.get("pcpu"); |
132 |
LOG.info("Record: " + record); |
133 |
result.println(record); |
134 |
result.flush(); |
135 |
|
136 |
sleep(3); |
137 |
} |
138 |
|
139 |
|
140 |
} |
141 |
|
142 |
public void selectCertainFile(int k){ |
143 |
calc.menuItem("Window").select(); |
144 |
k += 5; |
145 |
for(int i=0;i<k;i++){ |
146 |
typeKeys("<down>"); |
147 |
} |
148 |
typeKeys("<enter>"); |
149 |
sleep(2); |
150 |
// DocWindow.scEdit.doubleClick(atPoint(438,131)); |
151 |
} |
152 |
|
153 |
public void closeAlldocuments(){ |
154 |
for(int index=3;index<9;index++){ |
155 |
//SelectActivedocument(4); |
156 |
calc.menuItem("File->Close").select(); |
157 |
sleep(2); |
158 |
} |
159 |
|
160 |
} |
161 |
|
162 |
} |