AppTool.java (b4d2d410) AppTool.java (f46d12a6)
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

--- 8 unchanged lines hidden (view full) ---

17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22package testlib.gui;
23
24import static org.openoffice.test.common.Testspace.*;
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

--- 8 unchanged lines hidden (view full) ---

17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22package testlib.gui;
23
24import static org.openoffice.test.common.Testspace.*;
25import static org.openoffice.test.vcl.Tester.*;
26import static testlib.gui.AppTool.*;
27import static testlib.gui.UIMap.*;
28
29import org.openoffice.test.common.Condition;
30import org.openoffice.test.common.FileUtil;
31import org.openoffice.test.common.SystemUtil;
32import org.openoffice.test.common.Testspace;
33import org.openoffice.test.vcl.Tester;
34import org.openoffice.test.vcl.widgets.VclWindow;

--- 79 unchanged lines hidden (view full) ---

114
115 public static void typeKeys(String keys) {
116 Tester.typeKeys(keys);
117 }
118
119 public static void openStartcenter() {
120 if (startcenter.exists())
121 return;
25import static testlib.gui.UIMap.*;
26
27import org.openoffice.test.common.Condition;
28import org.openoffice.test.common.FileUtil;
29import org.openoffice.test.common.SystemUtil;
30import org.openoffice.test.common.Testspace;
31import org.openoffice.test.vcl.Tester;
32import org.openoffice.test.vcl.widgets.VclWindow;

--- 79 unchanged lines hidden (view full) ---

112
113 public static void typeKeys(String keys) {
114 Tester.typeKeys(keys);
115 }
116
117 public static void openStartcenter() {
118 if (startcenter.exists())
119 return;
122
120
123 if (SystemUtil.isMac()) {
124 SystemUtil.execScript("osascript -e 'tell app \"OpenOffice.org\" to activate'");
125 typeKeys("<command n>");
126 }
121 if (SystemUtil.isMac()) {
122 SystemUtil.execScript("osascript -e 'tell app \"OpenOffice.org\" to activate'");
123 typeKeys("<command n>");
124 }
127
125
128 }
129
130 public static String copyAll() {
131 app.setClipboard(".d.i.r.t.y.");
132 try {
133 app.dispatch(".uno:SelectAll");
134 } catch (Exception e) {
135 app.dispatch(".uno:Select");
136 }
137 app.dispatch(".uno:Copy");
138 return app.getClipboard();
139 }
140
141 public static void submitOpenDlg(String path) {
142 filePickerPath.setText(path);
143 filePickerOpen.click();
126 }
127
128 public static String copyAll() {
129 app.setClipboard(".d.i.r.t.y.");
130 try {
131 app.dispatch(".uno:SelectAll");
132 } catch (Exception e) {
133 app.dispatch(".uno:Select");
134 }
135 app.dispatch(".uno:Copy");
136 return app.getClipboard();
137 }
138
139 public static void submitOpenDlg(String path) {
140 filePickerPath.setText(path);
141 filePickerOpen.click();
144 sleep(1);
145 }
146
147 public static void submitSaveDlg(String path) {
148 fileSavePath.setText(path);
142 }
143
144 public static void submitSaveDlg(String path) {
145 fileSavePath.setText(path);
149
150 String extName = FileUtil.getFileExtName(path).toLowerCase();
146 String extName = FileUtil.getFileExtName(path).toLowerCase();
151
152 String[] filters = fileSaveFileType.getItemsText();
153 int i = 0;
154 for (; i < filters.length; i++) {
155 String f = filters[i];
156 int dotIndex = f.lastIndexOf(".");
157 if (dotIndex == -1)
158 continue;
159 if (extName.equals(f.substring(dotIndex + 1, f.length() - 1)))
160 break;
161 }
162 if (i == filters.length)
163 throw new RuntimeException("Can't find the supported doc format!");
164
165 fileSaveFileType.select(i);
166 fileSaveSave.click();
147 String[] filters = fileSaveFileType.getItemsText();
148 int i = 0;
149 for (; i < filters.length; i++) {
150 String f = filters[i];
151 int dotIndex = f.lastIndexOf(".");
152 if (dotIndex == -1)
153 continue;
154 if (extName.equals(f.substring(dotIndex + 1, f.length() - 1)))
155 break;
156 }
157 if (i == filters.length)
158 throw new RuntimeException("Can't find the supported doc format!");
159
160 fileSaveFileType.select(i);
161 fileSaveSave.click();
167 sleep(1);
168 }
169
170 public static void submitSaveDlg(String path, String ext) {
171 fileSavePath.setText(path);
172 if (ext != null) {
173 // change filter
174 String[] filters = fileSaveFileType.getItemsText();
175 int i = 0;

--- 4 unchanged lines hidden (view full) ---

180 continue;
181 if (ext.equals(f.substring(dotIndex + 1, f.length() - 1)))
182 break;
183 }
184 if (i == filters.length)
185 throw new RuntimeException("Can't find the supported doc format!");
186 }
187 fileSaveFileType.click();
162 }
163
164 public static void submitSaveDlg(String path, String ext) {
165 fileSavePath.setText(path);
166 if (ext != null) {
167 // change filter
168 String[] filters = fileSaveFileType.getItemsText();
169 int i = 0;

--- 4 unchanged lines hidden (view full) ---

174 continue;
175 if (ext.equals(f.substring(dotIndex + 1, f.length() - 1)))
176 break;
177 }
178 if (i == filters.length)
179 throw new RuntimeException("Can't find the supported doc format!");
180 }
181 fileSaveFileType.click();
188 sleep(1);
189 }
190
191 public static void handleBlocker(final VclWindow... windows) {
192 new Condition() {
193 @Override
194 public boolean value() {
195 if (activeMsgBox.exists()) {
196 try {

--- 29 unchanged lines hidden (view full) ---

226 }
227 }
228
229 return true;
230 }
231
232 }.waitForTrue("Time out wait window to be active.", 120, 2);
233 }
182 }
183
184 public static void handleBlocker(final VclWindow... windows) {
185 new Condition() {
186 @Override
187 public boolean value() {
188 if (activeMsgBox.exists()) {
189 try {

--- 29 unchanged lines hidden (view full) ---

219 }
220 }
221
222 return true;
223 }
224
225 }.waitForTrue("Time out wait window to be active.", 120, 2);
226 }
227
228 public static void insertPicture(String path) {
229 app.dispatch(".uno:InsertGraphic");
230 submitOpenDlg(getPath(path));
231 }
234}
232}