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 bvt.gui; |
26 |
|
27 |
|
28 |
import static org.openoffice.test.common.Testspace.*; |
29 |
import static org.openoffice.test.vcl.Tester.*; |
30 |
import static testlib.gui.AppTool.*; |
31 |
import static testlib.gui.UIMap.*; |
32 |
|
33 |
|
34 |
import java.io.File; |
35 |
import java.util.Arrays; |
36 |
|
37 |
import org.junit.AfterClass; |
38 |
|
39 |
import org.junit.Before; |
40 |
import org.junit.BeforeClass; |
41 |
import org.junit.Rule; |
42 |
import org.junit.Test; |
43 |
|
44 |
import org.openoffice.test.common.Logger; |
45 |
import org.openoffice.test.common.Testspace; |
46 |
|
47 |
|
48 |
|
49 |
/** |
50 |
* |
51 |
*/ |
52 |
public class OoxmlExport { |
53 |
|
54 |
@Rule |
55 |
public Logger log = Logger.getLogger(this); |
56 |
|
57 |
@BeforeClass |
58 |
public static void beforeClass() { |
59 |
app.clean(); |
60 |
} |
61 |
|
62 |
@AfterClass |
63 |
public static void afterClass() { |
64 |
app.stop(); |
65 |
} |
66 |
|
67 |
@Before |
68 |
public void before() { |
69 |
app.stop(); |
70 |
app.start(); |
71 |
} |
72 |
|
73 |
|
74 |
/** |
75 |
* Test Open/SaveAs ooxml file by Aoo |
76 |
* |
77 |
* @throws Exception |
78 |
*/ |
79 |
|
80 |
|
81 |
@Test |
82 |
public void testSaveAs() throws Exception { |
83 |
//for example |
84 |
//the path is "D:\\aoo\\utaoo\\testspace\\ooxmlsamples" |
85 |
File reportDir = Testspace.getFile("ooxmlsamples"); |
86 |
File[] files = reportDir.listFiles(); |
87 |
Arrays.sort(files); |
88 |
int nfiles= files.length; |
89 |
for( int i=0;i<nfiles;i++) |
90 |
{ |
91 |
File afile = files[i]; |
92 |
String path = afile.getAbsolutePath(); |
93 |
open( path ); |
94 |
sleep(5); |
95 |
String exportname = "aoo_"+ afile.getName(); |
96 |
saveDocument( exportname ); |
97 |
} |
98 |
} |
99 |
|
100 |
|
101 |
|
102 |
private void saveDocument(String file) { |
103 |
|
104 |
File reportDir = Testspace.getFile("output/exported"); |
105 |
String saveTo = reportDir + "\\" + file; |
106 |
// Save the text document |
107 |
deleteFile(saveTo); |
108 |
saveAs(saveTo); |
109 |
close(); |
110 |
open(saveTo); |
111 |
// Reopen the saved file |
112 |
sleep(3); |
113 |
close(); |
114 |
sleep(1); |
115 |
|
116 |
} |
117 |
|
118 |
} |