summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/IDList.java114
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/Tester.java298
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/VclInspector.java128
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/CommandCaller.java559
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/CommunicationException.java39
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/CommunicationListener.java23
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java269
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/Constant.java499
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/Handshaker.java75
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/SmartId.java60
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/VclHook.java104
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/client/VclHookException.java355
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java181
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclButton.java90
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclComboBox.java130
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclControl.java506
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclDialog.java56
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclDockingWin.java58
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclEditBox.java58
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclField.java64
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclListBox.java184
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenu.java70
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenuItem.java242
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclMessageBox.java166
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclStatusBar.java71
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabControl.java111
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabPage.java38
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclToolBox.java87
-rw-r--r--test/testcommon/source/org/openoffice/test/vcl/widgets/VclWindow.java128
29 files changed, 4763 insertions, 0 deletions
diff --git a/test/testcommon/source/org/openoffice/test/vcl/IDList.java b/test/testcommon/source/org/openoffice/test/vcl/IDList.java
new file mode 100644
index 000000000000..7b77704e87d8
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/IDList.java
@@ -0,0 +1,114 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ *
+ * The class is used to read an from external files to replace the id in the code.
+ */
+public class IDList {
+
+ private HashMap<String, String> map = new HashMap<String, String>();
+
+ private File dir = null;
+
+ public IDList(File dir) {
+ this.dir = dir;
+ load();
+ }
+
+
+ private void readFile(File file, HashMap<String, String> map) {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(file));
+ String line = null;
+ while ((line = reader.readLine()) != null ) {
+ line = line.trim();
+ if (line.length() == 0 /*|| line.startsWith("//")*/)
+ continue;
+ String[] parts = line.split(" ");
+ if (parts.length != 2)
+ continue;
+ map.put(parts[0], parts[1]);
+ }
+
+ } catch (IOException e) {
+ // for debug
+ e.printStackTrace();
+ } finally {
+ if (reader != null)
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+
+ public void load() {
+ if (dir == null)
+ return;
+
+ map.clear();
+ ArrayList<File> validFiles = new ArrayList<File>();
+ File[] files = dir.listFiles();
+ for (File file : files) {
+ if (file.isFile() && file.getName().endsWith(".lst")) {
+ validFiles.add(file);
+ }
+ }
+
+ // Sort by file name. Maybe the sorting is redundant!?
+ Collections.sort(validFiles, new Comparator<File>() {
+ public int compare(File o1, File o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+
+ for (File file: validFiles) {
+ readFile(file, map);
+ }
+ }
+
+ public SmartId getId(String id) {
+ String value = map.get(id);
+ if (value == null) {
+ int i = id.indexOf("_");
+ if (i >= 0) {
+ value = map.get(id.substring(++i));
+ }
+ }
+ if (value != null)
+ //The external definition overwrites the id.
+ id = value;
+
+ try {
+ //Try to convert ID to number ID for old build.
+ //From OO3.4 all IDs should be string.
+ return new SmartId(Long.parseLong(id));
+ } catch (NumberFormatException e) {
+
+ }
+ return new SmartId(id);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/Tester.java b/test/testcommon/source/org/openoffice/test/vcl/Tester.java
new file mode 100644
index 000000000000..634f24ee13a5
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/Tester.java
@@ -0,0 +1,298 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+
+/**
+ *
+ */
+public class Tester {
+ static Robot robot;
+
+ static {
+ try {
+ robot = new Robot();
+ robot.setAutoDelay(20);
+ robot.setAutoWaitForIdle(true);
+ } catch (AWTException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Tester() {
+
+ }
+
+ /**
+ *
+ * @param delay
+ */
+ public static void sleep(double delay) {
+ try {
+ Thread.sleep((long) (delay * 1000));
+ } catch (InterruptedException e) {
+ }
+ }
+
+ /**
+ * Click on the screen
+ * @param x
+ * @param y
+ */
+ public static void click(int x, int y) {
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ }
+
+ public static void doubleClick(int x, int y) {
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ }
+
+ /**
+ * Right click on the screen
+ * @param x
+ * @param y
+ */
+ public static void rightClick(int x, int y) {
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+ robot.delay(100);
+ }
+
+ public static void drag(int fromX, int fromY, int toX, int toY) {
+ robot.mouseMove(fromX, fromY);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ int x = fromX;
+ int y = fromY;
+ int dx = toX > fromX ? 1 : -1;
+ int dy = toY > fromY ? 1 : -1;
+ while (x != toX || y != toY) {
+ if (x != toX)
+ x = x + dx;
+ if (y != toY)
+ y = y + dy;
+ robot.mouseMove(x, y);
+ }
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ }
+
+ /**
+ * Type String
+ * @param text
+ */
+ public static void typeText(String text) {
+ for (int i = 0; i < text.length(); i++) {
+ char ch = text.charAt(i);
+ String[] shiftKeys = keyMap.get(ch);
+ if (shiftKeys == null)
+ throw new RuntimeException("Keys is invalid!");
+ typeShortcut(shiftKeys);
+ }
+ }
+
+ /**
+ * Type shortcut
+ * @param keys
+ */
+ public static void typeShortcut(String... keys) {
+ for(int i = 0; i < keys.length; i++) {
+ String key = keys[i];
+ key = key.toLowerCase();
+ Integer keyCode = keyCodeMap.get(key);
+ if (keyCode == null)
+ throw new RuntimeException("Invalid keys!");
+ robot.keyPress(keyCode);
+ }
+
+ for(int i = keys.length - 1; i >= 0; i--) {
+ String key = keys[i];
+ key = key.toLowerCase();
+ Integer keyCode = keyCodeMap.get(key);
+ if (keyCode == null)
+ throw new RuntimeException("Invalid keys!");
+ robot.keyRelease(keyCode);
+ }
+ }
+
+ /**
+ * Type the keys
+ * To input shortcut, use "<key key key ...>". The keys is separated with space and surrounded with angle brackets.
+ * For example, input the word "hello" and then press Ctrl+A to select the all content.
+ * typeKeys("hello<ctrl a>");
+ *
+ *
+ *
+ * @param keys
+ */
+ public static void typeKeys(String keys) {
+ StringTokenizer tokenizer = new StringTokenizer(keys, "<>", true);
+ int state = 0;
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ switch (state) {
+ case 0:
+ if ("<".equals(token)) {
+ state = 1;
+ } else if (">".equals(token)) {
+ throw new RuntimeException("Invalid keys!");
+ } else {
+ typeText(token);
+ }
+ break;
+ case 1:
+ if (">".equals(token)) {
+ state = 0;
+ } else if ("<".equals(token)){
+ throw new RuntimeException("Invalid keys!");
+ } else {
+ if (token.startsWith("$")) {
+ String[] ckeys = customizedMap.get(token.substring(1));
+ if (ckeys == null || ckeys.length == 0)
+ throw new RuntimeException(token + " is not a customized shortcut!");
+ typeShortcut(ckeys);
+ } else {
+ String[] ckeys = token.split(" ");
+ typeShortcut(ckeys);
+ }
+ }
+ }
+ }
+ }
+ protected static HashMap<String, Integer> keyCodeMap = new HashMap<String, Integer>();
+ protected static HashMap<Character, String[]> keyMap = new HashMap<Character, String[]>();
+ protected static HashMap<String, String[]> customizedMap = new HashMap<String, String[]>();
+ static {
+ //US keyboard
+ keyCodeMap.put("esc", KeyEvent.VK_ESCAPE);
+ keyCodeMap.put("f1", KeyEvent.VK_F1);
+ keyCodeMap.put("f2", KeyEvent.VK_F2);
+ keyCodeMap.put("f3", KeyEvent.VK_F3);
+ keyCodeMap.put("f4", KeyEvent.VK_F4);
+ keyCodeMap.put("f5", KeyEvent.VK_F5);
+ keyCodeMap.put("f6", KeyEvent.VK_F6);
+ keyCodeMap.put("f7", KeyEvent.VK_F7);
+ keyCodeMap.put("f8", KeyEvent.VK_F8);
+ keyCodeMap.put("f9", KeyEvent.VK_F9);
+ keyCodeMap.put("f10", KeyEvent.VK_F10);
+ keyCodeMap.put("f11", KeyEvent.VK_F11);
+ keyCodeMap.put("f12", KeyEvent.VK_F12);
+ keyCodeMap.put("printscreen", KeyEvent.VK_PRINTSCREEN);
+ keyCodeMap.put("scrolllock", KeyEvent.VK_SCROLL_LOCK);
+ keyCodeMap.put("pause", KeyEvent.VK_PAUSE);
+ keyCodeMap.put("tab", KeyEvent.VK_TAB);
+ keyCodeMap.put("space", KeyEvent.VK_SPACE);
+ keyCodeMap.put("capslock", KeyEvent.VK_CAPS_LOCK);
+ keyCodeMap.put("shift", KeyEvent.VK_SHIFT);
+ keyCodeMap.put("ctrl", KeyEvent.VK_CONTROL);
+ keyCodeMap.put("alt", KeyEvent.VK_ALT);
+ keyCodeMap.put("bs", KeyEvent.VK_BACK_SPACE);
+ keyCodeMap.put("backspace", KeyEvent.VK_BACK_SPACE);
+ keyCodeMap.put("enter", KeyEvent.VK_ENTER);
+ keyCodeMap.put("cr", KeyEvent.VK_ENTER);
+ keyCodeMap.put("command", 157);
+ keyCodeMap.put("control", KeyEvent.VK_CONTROL);
+ keyCodeMap.put("insert", KeyEvent.VK_INSERT);
+ keyCodeMap.put("del", KeyEvent.VK_DELETE);
+ keyCodeMap.put("delete", KeyEvent.VK_DELETE);
+ keyCodeMap.put("home", KeyEvent.VK_HOME);
+ keyCodeMap.put("end", KeyEvent.VK_END);
+ keyCodeMap.put("pageup", KeyEvent.VK_PAGE_UP);
+ keyCodeMap.put("pagedown", KeyEvent.VK_PAGE_DOWN);
+ keyCodeMap.put("up", KeyEvent.VK_UP);
+ keyCodeMap.put("left", KeyEvent.VK_LEFT);
+ keyCodeMap.put("right", KeyEvent.VK_RIGHT);
+ keyCodeMap.put("down", KeyEvent.VK_DOWN);
+ keyCodeMap.put("numlock", KeyEvent.VK_NUM_LOCK);
+ keyCodeMap.put("a", KeyEvent.VK_A);
+ keyCodeMap.put("b", KeyEvent.VK_B);
+ keyCodeMap.put("c", KeyEvent.VK_C);
+ keyCodeMap.put("d", KeyEvent.VK_D);
+ keyCodeMap.put("e", KeyEvent.VK_E);
+ keyCodeMap.put("f", KeyEvent.VK_F);
+ keyCodeMap.put("g", KeyEvent.VK_G);
+ keyCodeMap.put("h", KeyEvent.VK_H);
+ keyCodeMap.put("i", KeyEvent.VK_I);
+ keyCodeMap.put("j", KeyEvent.VK_J);
+ keyCodeMap.put("k", KeyEvent.VK_K);
+ keyCodeMap.put("l", KeyEvent.VK_L);
+ keyCodeMap.put("m", KeyEvent.VK_M);
+ keyCodeMap.put("n", KeyEvent.VK_N);
+ keyCodeMap.put("o", KeyEvent.VK_O);
+ keyCodeMap.put("p", KeyEvent.VK_P);
+ keyCodeMap.put("q", KeyEvent.VK_Q);
+ keyCodeMap.put("r", KeyEvent.VK_R);
+ keyCodeMap.put("s", KeyEvent.VK_S);
+ keyCodeMap.put("t", KeyEvent.VK_T);
+ keyCodeMap.put("u", KeyEvent.VK_U);
+ keyCodeMap.put("v", KeyEvent.VK_V);
+ keyCodeMap.put("w", KeyEvent.VK_W);
+ keyCodeMap.put("x", KeyEvent.VK_X);
+ keyCodeMap.put("y", KeyEvent.VK_Y);
+ keyCodeMap.put("z", KeyEvent.VK_Z);
+ keyCodeMap.put("0", KeyEvent.VK_0);
+ keyCodeMap.put("1", KeyEvent.VK_1);
+ keyCodeMap.put("2", KeyEvent.VK_2);
+ keyCodeMap.put("3", KeyEvent.VK_3);
+ keyCodeMap.put("4", KeyEvent.VK_4);
+ keyCodeMap.put("5", KeyEvent.VK_5);
+ keyCodeMap.put("6", KeyEvent.VK_6);
+ keyCodeMap.put("7", KeyEvent.VK_7);
+ keyCodeMap.put("8", KeyEvent.VK_8);
+ keyCodeMap.put("9", KeyEvent.VK_9);
+ keyCodeMap.put("`", KeyEvent.VK_BACK_QUOTE);
+ keyCodeMap.put("-", KeyEvent.VK_MINUS);
+ keyCodeMap.put("=", KeyEvent.VK_EQUALS);
+ keyCodeMap.put("[", KeyEvent.VK_OPEN_BRACKET);
+ keyCodeMap.put("]", KeyEvent.VK_CLOSE_BRACKET);
+ keyCodeMap.put("\\", KeyEvent.VK_BACK_SLASH);
+ keyCodeMap.put(";", KeyEvent.VK_SEMICOLON);
+ keyCodeMap.put("\'", KeyEvent.VK_QUOTE);
+ keyCodeMap.put(",", KeyEvent.VK_COMMA);
+ keyCodeMap.put(".", KeyEvent.VK_PERIOD);
+ keyCodeMap.put("/", KeyEvent.VK_SLASH);
+
+
+ String chars = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
+ String shiftChars = "~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?";
+ for(int i = 0; i < chars.length(); i++) {
+ keyMap.put(chars.charAt(i), new String[]{chars.substring(i, i + 1)});
+ keyMap.put(shiftChars.charAt(i), new String[]{"shift", chars.substring(i, i + 1)});
+ }
+ keyMap.put(' ', new String[]{"space"});
+ keyMap.put('\t', new String[]{"tab"});
+ }
+
+ public static void setCustomizedShortcut(String name, String... keys) {
+ customizedMap.put(name, keys);
+ }
+
+ public static void main(String[] args) {
+ Tester.sleep(3);
+ Tester.typeKeys(" ");
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/VclInspector.java b/test/testcommon/source/org/openoffice/test/vcl/VclInspector.java
new file mode 100644
index 000000000000..73c039443074
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/VclInspector.java
@@ -0,0 +1,128 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JToolBar;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.table.DefaultTableModel;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+import org.openoffice.test.vcl.client.VclHook;
+import org.openoffice.test.vcl.client.CommandCaller.WinInfoReceiver;
+
+/**
+ * Use the application to inspect vcl widgets in the openoffice.
+ *
+ */
+public class VclInspector extends JFrame implements WinInfoReceiver {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private JTable winInfoEditor = null;
+
+ public VclInspector(){
+ super("VCL Inspector");
+ }
+
+
+ private void init() {
+ try {
+ UIManager.getInstalledLookAndFeels();
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e1) {
+ }
+
+ setSize(800, 600);
+
+ JToolBar toolBar = new JToolBar("Tools");
+ JButton button = new JButton("Inspect");
+ button.setToolTipText("Inspect VCL controls.");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ inspect();
+ }
+ });
+ toolBar.add(button);
+
+ add(toolBar, BorderLayout.PAGE_START);
+ String col[] = {"Type", "ID", "ToolTip"};
+ DefaultTableModel model = new DefaultTableModel(null ,col);
+ winInfoEditor = new JTable(model);
+ winInfoEditor.getColumnModel().getColumn(0).setMaxWidth(60);
+ winInfoEditor.getColumnModel().getColumn(1).setMaxWidth(100);
+ JScrollPane pane1 = new JScrollPane(winInfoEditor);
+
+ add(pane1, BorderLayout.CENTER);
+
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ VclHook.getCommunicationManager().stop();
+ System.exit(0);
+ };
+
+ });
+ }
+
+ public void open() {
+ init();
+ setVisible(true);
+ }
+
+
+
+ public void addWinInfo(final SmartId id, final long type, final String t) {
+ final String tooltip = t.replaceAll("%.*%.*:", "");
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ ((DefaultTableModel)winInfoEditor.getModel()).addRow(new Object[]{type, id, tooltip});
+ }
+ });
+
+ }
+
+ public void onStartReceiving() {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ ((DefaultTableModel)winInfoEditor.getModel()).setRowCount(0);
+ }
+ });
+ }
+
+
+ public void inspect() {
+ VclHook.invokeCommand(Constant.RC_DisplayHid, new Object[]{Boolean.TRUE});
+ }
+
+ public static void main(String[] args) {
+ VclInspector inspector = new VclInspector();
+ VclHook.getCommandCaller().setWinInfoReceiver(inspector);
+ inspector.open();
+ }
+
+
+ public void onFinishReceiving() {
+
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/CommandCaller.java b/test/testcommon/source/org/openoffice/test/vcl/client/CommandCaller.java
new file mode 100644
index 000000000000..2bf6932f317d
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/CommandCaller.java
@@ -0,0 +1,559 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * The class is used to send a statement to the automation server.
+ *
+ *
+ */
+public class CommandCaller implements CommunicationListener, Constant {
+
+ public static interface WinInfoReceiver {
+ void onStartReceiving();
+ void addWinInfo(SmartId id, long type, String t1);
+ void onFinishReceiving();
+
+ }
+
+ private ByteArrayOutputStream dataOutput = new ByteArrayOutputStream(1024);
+
+ private ByteArrayInputStream dataInput = null;
+
+ private CommunicationManager communicationManager = null;
+
+ private int sequence = 0;
+
+ private WinInfoReceiver winInfoReceiver = null;
+
+ private boolean receivingWinInfo = false;
+
+ /**Store the response**/
+ private Object response = null;
+
+ private SmartId responseExceptionId = null;
+
+ private String responseExceptionMessage = null;
+
+ /**A variable to indicate if the server answered the request **/
+ private boolean answered = false;
+
+ public CommandCaller(CommunicationManager communicationManager) {
+ this.communicationManager = communicationManager;
+ }
+
+ private void write(byte[] bytes) {
+ try {
+ dataOutput.write(bytes);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private byte[] read(int len) {
+ byte[] bytes = new byte[len];
+ try {
+ dataInput.read(bytes);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return bytes;
+ }
+
+
+ /**
+ * Write the data type
+ * @param i
+ */
+ private void writeChar(int i) {
+ byte[] bytes = new byte[2];
+ bytes[1] = (byte) ((i & 0xFF00) >> 8);
+ bytes[0] = (byte) (i & 0x00FF);
+ write(bytes);
+ }
+
+ private int readChar() {
+ byte[] bytes = read(2);
+ return (bytes[0] & 0x00FF) + ((bytes[1] & 0x00FF) << 8);
+ }
+
+
+ /**
+ * Check the type of next data
+ * The bytes used to identify the type will not be read out from the stream
+ * @return
+ */
+ private int nextType() {
+ dataInput.mark(0);
+ int type = readChar();
+ dataInput.reset();
+ return type;
+ }
+
+ /**
+ * Write an unsigned 16-bit integer
+ * @param i
+ */
+ private void writeUShort(int i) {
+ writeChar(BinUSHORT);
+ writeChar(i);
+ }
+
+ /**
+ * Read an unsigned 16-bit integer
+ * @return
+ */
+ private int readUShort() {
+ if (readChar() != BinUSHORT)
+ throw new RuntimeException("Bad data!");
+
+ byte[] bytes = read(2);
+ return (bytes[0] & 0x00FF) + ((bytes[1] & 0x00FF) << 8);
+ }
+
+ /**
+ * Write an unsigned 32-bit integer
+ * @param i
+ */
+ private void writeULong(long i) {
+ writeChar(BinULONG);
+ byte[] bytes = new byte[4];
+ bytes[3] = (byte) ((i & 0xFF000000L) >> 24);
+ bytes[2] = (byte) ((i & 0x00FF0000L) >> 16);
+ bytes[1] = (byte) ((i & 0x0000FF00L) >> 8);
+ bytes[0] = (byte) ((i & 0x000000FFL));
+ write(bytes);
+ }
+
+ /**
+ * Read an unsigned 32-bit integer
+ * @return
+ */
+ private long readULong() {
+ if (readChar() != BinULONG)
+ throw new RuntimeException("Bad data!");
+ byte[] bytes = read(4);
+ return (bytes[0] & 0x00FFL) + ((bytes[1] & 0x00FFL) << 8) + ((bytes[2] & 0x00FFL) << 16) + ((bytes[3] & 0x00FFL) << 24);
+ }
+
+ /**
+ * Write boolean
+ * @param bBool
+ */
+ private void writeBoolean(boolean bBool) {
+ writeChar(BinBool);
+ write(new byte[] { bBool ? (byte) 1 : 0 });
+ }
+
+ /**
+ * Read boolean
+ * @return
+ */
+ private boolean readBoolean() {
+ if (readChar() != BinBool)
+ throw new RuntimeException("Bad data!");
+ byte[] bytes = read(1);
+ return bytes[0] != 0;
+ }
+
+ /**
+ * Write a string
+ * @param str
+ */
+ private void writeString(String str) {
+ writeChar(BinString);
+ int len = str.length();
+ if (len > 0xFFFF) {
+ throw new RuntimeException("String is too long.");
+ }
+ writeChar(len);
+ char[] chars = str.toCharArray();
+ for (int i = 0 ; i < len; i++)
+ writeChar(chars[i]);
+ }
+
+ /**
+ * Read a string
+ * @return
+ */
+ private String readString() {
+ if (readChar() != BinString)
+ throw new RuntimeException("Bad data!");
+ int len = readChar();
+ char[] chars = new char[len];
+ for (int i = 0; i < len; i++) {
+ chars[i] = (char) readChar();
+ }
+ return new String(chars);
+ }
+
+ private void writeParams(Object[] args) {
+ int nParams = PARAM_NONE;
+ int nNr1=0;
+ int nNr2=0;
+ int nNr3=0;
+ int nNr4=0;
+ long nLNr1=0;
+ String aString1=null;
+ String aString2=null;
+ boolean bBool1=false;
+ boolean bBool2=false;
+
+ if (args != null) {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] instanceof Short || args[i] instanceof Integer) {
+ int c = ((Number) args[i]).intValue();
+ if ((nParams & PARAM_USHORT_1) == 0) {
+ nParams |= PARAM_USHORT_1;
+ nNr1 = c;
+ } else if ((nParams & PARAM_USHORT_2) == 0) {
+ nParams |= PARAM_USHORT_2;
+ nNr2 = c;
+ } else if ((nParams & PARAM_USHORT_3) == 0) {
+ nParams |= PARAM_USHORT_3;
+ nNr3 = c;
+ } else if ((nParams & PARAM_USHORT_4) == 0) {
+ nParams |= PARAM_USHORT_4;
+ nNr4 = c;
+ } else {
+ //TODO error
+ }
+ } else if (args[i] instanceof Long) {
+ long l = ((Long) args[i]).longValue();
+ nParams |= PARAM_ULONG_1;
+ nLNr1 = l;
+ } else if (args[i] instanceof Boolean) {
+ if ((nParams & PARAM_BOOL_1) == 0) {
+ nParams |= PARAM_BOOL_1;
+ bBool1 = ((Boolean) args[i]).booleanValue();
+ } else if ((nParams & PARAM_BOOL_2) == 0) {
+ nParams |= PARAM_BOOL_2;
+ bBool2 = ((Boolean) args[i]).booleanValue();
+ } else {
+ //TODO error
+ }
+
+ } else if (args[i] instanceof String) {
+ if ((nParams & PARAM_STR_1) == 0) {
+ nParams |= PARAM_STR_1;
+ aString1 = (String) args[i];
+ } else if ((nParams & PARAM_STR_2) == 0) {
+ nParams |= PARAM_STR_2;
+ aString2 = (String) args[i];
+ } else {
+ //TODO error
+ }
+ }
+ }
+ }
+
+ writeUShort(nParams);
+ if ((nParams & PARAM_USHORT_1) != 0) {
+ writeUShort(nNr1);
+ }
+
+ if ((nParams & PARAM_USHORT_2) != 0) {
+ writeUShort(nNr2);
+ }
+
+ if ((nParams & PARAM_USHORT_3) != 0) {
+ writeUShort(nNr3);
+ }
+
+ if ((nParams & PARAM_USHORT_4) != 0) {
+ writeUShort(nNr4);
+ }
+
+ if ((nParams & PARAM_ULONG_1) != 0) {
+ writeULong(nLNr1);
+ }
+
+ if ((nParams & PARAM_STR_1) != 0) {
+ writeString(aString1);
+ }
+
+ if ((nParams & PARAM_STR_2) != 0) {
+ writeString(aString2);
+ }
+
+ if ((nParams & PARAM_BOOL_1) != 0) {
+ writeBoolean(bBool1);
+ }
+ if ((nParams & PARAM_BOOL_2) != 0) {
+ writeBoolean(bBool2);
+ }
+
+ }
+
+ private void send() {
+ byte[] data = dataOutput.toByteArray();
+ dataOutput.reset();
+ int protocal = CM_PROTOCOL_OLDSTYLE;
+ byte[] header = new byte[]{(byte)((protocal >>> 8) & 0xFF), (byte) ((protocal >>> 0) & 0xFF)};
+ communicationManager.sendPackage(CH_SimpleMultiChannel, header, data);
+ }
+
+ /**
+ * The data arrives
+ */
+ public synchronized void received(int headerType, byte[] header, byte[] data) {
+ if (headerType != CommunicationManager.CH_Handshake) {
+ dataInput = new ByteArrayInputStream(data);
+ handleResponse();
+ dataInput = null;
+ answered = true;
+ notifyAll();
+ }
+ }
+
+ /**
+ * This method is called when the communication is started.
+ */
+ public void start() {
+ }
+
+ /**
+ * This method is called when the communication is closed
+ */
+ public synchronized void stop() {
+ answered = true;
+ notifyAll();
+ }
+
+
+ private SmartId readId() {
+ int type = nextType();
+ if ( type == BinString) {
+ return new SmartId(readString());
+ } else if (type == BinULONG) {
+ return new SmartId(readULong());
+ }
+
+ throw new RuntimeException("Bad data!");
+ }
+
+ private void handleResponse() {
+ this.response = null;
+ this.responseExceptionId = null;
+ this.responseExceptionMessage = null;
+
+ while (dataInput.available() >= 2) {
+ int id = readUShort();
+ switch (id) {
+ case SIReturn:
+ int returnType = readUShort();
+ SmartId sid = readId();
+ int nNr1 = 0;
+ long nLNr1 = 0;
+ String aString1 = null;
+ boolean bBool1 = false;
+ int params = readUShort();
+ if ((params & PARAM_USHORT_1) != 0)
+ nNr1 = readUShort();
+ if ((params & PARAM_ULONG_1) != 0)
+ nLNr1 = readULong();
+ if ((params & PARAM_STR_1) != 0)
+ aString1 = readString();
+ if ((params & PARAM_BOOL_1) != 0)
+ bBool1 = readBoolean();
+ if ((params & PARAM_SBXVALUE_1) != 0) {
+ // Don't support????
+ }
+
+ switch (returnType) {
+ case RET_Sequence:
+ if (sid.getId() != sequence)
+ this.responseExceptionMessage = "Bad sequence of command.";
+ break;
+ case RET_Value:
+ List<Object> ret = new ArrayList<Object>();
+ if ((params & PARAM_USHORT_1) != 0)
+ ret.add(new Integer(nNr1));
+ if ((params & PARAM_ULONG_1) != 0)
+ ret.add(new Long(nLNr1));
+ if ((params & PARAM_STR_1) != 0)
+ ret.add(aString1);
+ if ((params & PARAM_BOOL_1) != 0)
+ ret.add(new Boolean(bBool1));
+ this.response = ret.size() == 1 ? ret.get(0): ret;
+ break;
+ case RET_WinInfo:
+ if (bBool1) {
+ receivingWinInfo = true;
+ if (winInfoReceiver != null)
+ winInfoReceiver.onStartReceiving();
+ } else {
+ if (winInfoReceiver != null)
+ winInfoReceiver.addWinInfo(sid, nLNr1, aString1);
+ }
+ break;
+ }
+
+ break;
+ case SIReturnError:
+ this.responseExceptionId = readId();
+ this.responseExceptionMessage = readString();
+ break;
+ }
+ }
+
+ if (receivingWinInfo) {
+ if (winInfoReceiver != null)
+ winInfoReceiver.onFinishReceiving();
+ receivingWinInfo = false;
+ }
+ }
+
+
+ public void setWinInfoReceiver(WinInfoReceiver receiver) {
+ this.winInfoReceiver = receiver;
+ }
+
+ private void callFlow(int nArt) {
+ writeUShort(SIFlow);
+ writeUShort(nArt);
+ writeUShort(PARAM_NONE);
+ }
+
+
+ private void callFlow(int nArt, long nLNr1) {
+ writeUShort(SIFlow);
+ writeUShort(nArt);
+ writeUShort(PARAM_ULONG_1);
+ writeULong(nLNr1);
+ }
+
+ /**
+ * Tell automation server to execute a 'StatementCommand'
+ * @param methodId The method ID
+ * @param args the arguments. The arguments can be Integer, Long, Boolean and String.
+ * @return The return can be Integer, Long, String and Boolean or an Object[] includes these types of object.
+ */
+ public synchronized Object callCommand(int methodId, Object[] args) {
+ beginBlock();
+ writeUShort(SICommand);
+ writeUShort(methodId);
+ writeParams(args);
+ endBlock();
+
+ if ((methodId & M_WITH_RETURN) != 0) {
+ return response;
+ }
+
+ return null;
+ }
+
+ /**
+ * Tell automation server to execute a 'StatementControl'
+ * @param uid the control ID
+ * @param methodId the method ID defined Constant class
+ * @param args the arguments. The arguments can be Integer, Long, Boolean and String.
+ * @return The return can be Integer, Long, String and Boolean or an Object[] includes these types of object.
+ */
+ public synchronized Object callControl(SmartId uid, int methodId, Object[] args){
+ beginBlock();
+ if (uid.getSid() != null) {
+ writeUShort(SIStringControl);
+ writeString(uid.getSid());
+ } else {
+ writeUShort(SIControl);
+ writeULong(uid.getId());
+ }
+
+ writeUShort(methodId);
+ writeParams(args);
+ endBlock();
+
+ if ((methodId & M_WITH_RETURN) != 0) {
+ return response;
+ }
+
+ return null;
+ }
+
+ /**
+ * Tell automation server to execute a 'StatementUNOSlot'
+ * @param url the UNO slot url
+ */
+ public synchronized void callUNOSlot(String url) {
+ beginBlock();
+ writeUShort(SIUnoSlot);
+ writeString(url);
+ endBlock();
+ }
+
+ /**
+ * Tell automation server to execute a 'StatementSlot'
+ * @param id the slot ID
+ * @param args the slot args
+ */
+ public synchronized void callSlot(int id, Object[] args) {
+ beginBlock();
+ writeUShort(SISlot);
+ writeUShort(id);
+ if (args.length % 2 != 0)
+ throw new RuntimeException("bad arg");
+ writeUShort(args.length / 2);
+ for (int i = 0; i < args.length; i++) {
+ if (!(args[i] instanceof String))
+ throw new RuntimeException("bad arg");
+ writeString((String)args[i]);
+ i++;
+ if (args[i] instanceof Boolean) {
+ writeBoolean((Boolean)args[i]);
+ } else if (args[i] instanceof String) {
+ writeString((String)args[i]);
+ } else if (args[i] instanceof Short || args[i] instanceof Integer) {
+ writeUShort(((Number) args[i]).intValue());
+ } else if (args[i] instanceof Long) {
+ writeULong((Long) args[i]);
+ } else {
+ throw new RuntimeException("bad arg");
+ }
+ }
+ endBlock();
+ }
+
+
+ private void beginBlock() {
+ callFlow(F_Sequence, ++sequence);
+ }
+
+ private void endBlock() {
+ callFlow(F_EndCommandBlock);
+ answered = false;
+ send();
+ int MAX_RETRY = 240;//max waiting time is two minutes.
+ for (int i = 0; !answered && i < MAX_RETRY; i++) {
+ try {
+ wait(500);
+ } catch (InterruptedException e) {
+
+ }
+ }
+
+ // Still answered
+ if (!answered) {
+ communicationManager.stop();
+ throw new CommunicationException("Failed to get data from automation server!");
+ }
+
+ if (responseExceptionId != null || responseExceptionMessage != null)
+ throw new VclHookException(responseExceptionId, responseExceptionMessage);
+
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationException.java b/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationException.java
new file mode 100644
index 000000000000..3ec1d51bc9b3
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationException.java
@@ -0,0 +1,39 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+/**
+ * Exception that occurs when socket communication has a problem.
+ *
+ */
+public class CommunicationException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public CommunicationException() {
+ super();
+ }
+
+ public CommunicationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CommunicationException(String message) {
+ super(message);
+ }
+
+ public CommunicationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationListener.java b/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationListener.java
new file mode 100644
index 000000000000..4a5068d4a331
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationListener.java
@@ -0,0 +1,23 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+/**
+ * Callback when data package is arriving.
+ *
+ */
+public interface CommunicationListener {
+
+ public void start();
+
+ public void received(int headerType, byte[] header, byte[] data);
+
+ public void stop();
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java b/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java
new file mode 100644
index 000000000000..7528d44ee69c
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/CommunicationManager.java
@@ -0,0 +1,269 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.List;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Manage the communication with the automation server.
+ * It's used to establish the connection, send and receive data package.
+ * Data package format:
+ *
+ * | [Force Multi Channel (0xFFFFFFFF)] | Data Length (32 bits) | Check Byte (8 bits) | Header Length (16 bits) | Header Data | Body Data |
+ *
+ * To handle the received data, add a communication listener to the manager.
+ * The listner will be called back when data package arrives.
+ *
+ */
+public class CommunicationManager implements Runnable, Constant{
+
+ private static Logger logger = Logger.getLogger("CommunicationManager");
+
+ private final static int DEFAULT_PORT = 12479;
+
+ private String host = "localhost";
+
+ private int port = DEFAULT_PORT;
+
+ private Socket socket = null;
+
+ private int reconnectInterval = 4000;
+
+ private int reconnectCount = 3;
+
+ private List<CommunicationListener> listeners = new Vector<CommunicationListener>();
+
+ /**
+ * Create a communication manager with the default host and port.
+ * The default host is local and the default port is 12479.
+ *
+ */
+ public CommunicationManager() {
+ try {
+ String portValue = System.getProperty("openoffice.automation.port");
+ if (portValue != null)
+ port = Integer.parseInt(portValue);
+ } catch (NumberFormatException e) {
+ // use default
+ }
+ }
+
+ /**
+ * Create a communication manager with the given host and port
+ * @param host
+ * @param port
+ */
+ public CommunicationManager(String host, int port) {
+ this.host = host;
+ this.port = port;
+ }
+
+
+ /**
+ * Get the max count retrying to connect the server
+ * @return
+ */
+ public int getReconnectCount() {
+ return reconnectCount;
+ }
+
+ /**
+ * Set the max count retrying to connect the server
+ * @param reconnectCount
+ */
+ public void setReconnectCount(int reconnectCount) {
+ this.reconnectCount = reconnectCount;
+ }
+
+ /**
+ * Get the interval between retrying to connect the server
+ * @return
+ */
+ public int getReconnectInterval() {
+ return reconnectInterval;
+ }
+
+ /**
+ * Set the interval between retrying to connect the server
+ * @param reconnectInterval
+ */
+ public void setReconnectInterval(int reconnectInterval) {
+ this.reconnectInterval = reconnectInterval;
+ }
+
+ /**
+ * Send a data package to server
+ * @param headerType the package header type
+ * @param header the data in the header
+ * @param data the data in the body
+ */
+ public synchronized void sendPackage(int headerType, byte[] header, byte[] data) throws CommunicationException {
+ if (socket == null)
+ start();
+
+ try {
+ if (header == null)
+ header = new byte[0];
+
+ if (data == null)
+ data = new byte[0];
+
+ DataOutputStream os = new DataOutputStream(socket.getOutputStream());
+ int len = 1 + 2 + 2 + header.length + data.length;
+ // Total len
+ os.writeInt(len);
+ // Check byte
+ os.writeByte(calcCheckByte(len));
+ // Header len
+ os.writeChar(2 + header.length);
+ // Header
+ os.writeChar(headerType);
+ os.write(header);
+ // Data
+ os.write(data);
+ os.flush();
+ } catch (IOException e) {
+ stop();
+ throw new CommunicationException("Failed to send data to automation server!", e);
+ }
+ }
+
+ /**
+ * Start a new thread to read the data sent by sever
+ */
+ public void run() {
+ try {
+ while (socket != null) {
+ DataInputStream is = new DataInputStream(socket.getInputStream());
+
+ int len = is.readInt();
+ if (len == 0xFFFFFFFF)
+ len = is.readInt();
+
+ byte checkByte = is.readByte();
+ if (calcCheckByte(len) != checkByte)
+ throw new CommunicationException("Bad data package. Wrong check byte.");
+
+ int headerLen = is.readUnsignedShort();
+ int headerType = is.readUnsignedShort();
+ byte[] header = new byte[headerLen - 2];
+ is.readFully(header);
+ byte[] data = new byte[len - headerLen - 3];
+ is.readFully(data);
+ for (int i = 0; i < listeners.size(); i++)
+ ((CommunicationListener) listeners.get(i)).received(headerType, header, data);
+ }
+ } catch (Exception e) {
+ logger.log(Level.FINEST, "Failed to receive data!", e);
+ stop();
+ }
+ }
+
+ /**
+ * Add a communication listener
+ * @param listener
+ */
+ public void addListener(CommunicationListener listener) {
+ if (listener != null && !listeners.contains(listener))
+ listeners.add(listener);
+ }
+
+
+ /**
+ * Stop the communication manager.
+ *
+ */
+ public synchronized void stop() {
+ if (socket == null)
+ return;
+
+ try {
+ socket.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ socket = null;
+ logger.log(Level.CONFIG, "Stop Communication Manager");
+ for (int i = 0; i < listeners.size(); i++)
+ ((CommunicationListener) listeners.get(i)).stop();
+ }
+
+ public synchronized boolean isConnected() {
+ return socket != null;
+ }
+
+
+ public synchronized void connect() throws IOException {
+ if (socket != null)
+ return;
+
+ try{
+ socket = new Socket();
+ socket.setTcpNoDelay(true);
+ socket.setSoTimeout(240 * 1000); // if in 4 minutes we get nothing from server, an exception will thrown.
+ socket.connect(new InetSocketAddress(host, port));
+ Thread thread = new Thread(this);
+ thread.setDaemon(true);
+ thread.start();
+ } catch (IOException e){
+ socket = null;
+ throw e;
+ }
+ }
+
+ /**
+ * Start the communication manager.
+ *
+ */
+ public synchronized void start() {
+ logger.log(Level.CONFIG, "Start Communication Manager");
+ //connect and retry if fails
+ for (int i = 0; i < reconnectCount; i++) {
+ try {
+ connect();
+ return;
+ } catch (IOException e) {
+ logger.log(Level.FINEST, "Failed to connect! Tried " + i, e);
+ }
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ //ignore
+ }
+ }
+
+ throw new CommunicationException("Failed to connect automation server!");
+ }
+
+
+ private static byte calcCheckByte(int i) {
+ int nRes = 0;
+ int[] bytes = new int[4];
+ bytes[0] = (i >>> 24) & 0x00FF;
+ bytes[1] = (i >>> 16) & 0x00FF;
+ bytes[2] = (i >>> 8) & 0x00FF;
+ bytes[3] = (i >>> 0) & 0x00FF;
+ nRes += bytes[0] ^ 0xf0;
+ nRes += bytes[1] ^ 0x0f;
+ nRes += bytes[2] ^ 0xf0;
+ nRes += bytes[3] ^ 0x0f;
+ nRes ^= (nRes >>> 8);
+ return (byte) nRes;
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java b/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java
new file mode 100644
index 000000000000..887a1613c276
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java
@@ -0,0 +1,499 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+/**
+ * Define all constant variables
+ *
+ */
+public interface Constant {
+
+ public final static int CH_NoHeader = 0x0000;
+
+ public final static int CH_SimpleMultiChannel = 0x0001;
+
+ public final static int CH_Handshake = 0x0002;
+
+ public final static int CH_REQUEST_HandshakeAlive = 0x0101;
+
+ public final static int CH_RESPONSE_HandshakeAlive = 0x0102;
+
+ public final static int CH_REQUEST_ShutdownLink = 0x0104;
+
+ public final static int CH_ShutdownLink = 0x0105;
+
+ public final static int CH_SUPPORT_OPTIONS = 0x0103;
+
+ public final static int CH_SetApplication = 0x0106;
+
+ public final static int CM_PROTOCOL_OLDSTYLE = 0x0001;
+
+ public final static int CM_PROTOCOL_MARS = 0x0001;
+
+ public final static int CM_PROTOCOL_BROADCASTER = 0x0002;
+
+ public final static int CM_PROTOCOL_USER_START = 0x0100;
+
+ public static final char SIControl = 3;
+
+ public static final char SISlot = 4;
+
+ public static final char SIFlow = 5;
+
+ public static final char SICommand = 6;
+
+ public static final char SIUnoSlot = 7;
+
+ public static final char SIStringControl = 8;
+
+ public static final char SIReturnBlock = 11;
+
+ public static final char SIReturn = 12;
+
+ public static final char SIReturnError = 13;
+
+ public static final char RET_Sequence = 132;
+
+ public static final char RET_Value = 133;
+
+ public static final char RET_WinInfo = 134;
+
+ public static final char RET_ProfileInfo = 135;
+
+ public static final char RET_DirectLoging = 136;
+
+ public static final char RET_MacroRecorder = 137;
+
+ public static final char BinUSHORT = 11;
+
+ public static final char BinULONG = 14;
+
+ public static final char BinString = 12;
+
+ public static final char BinBool = 13;
+
+ public static final char BinSbxValue = 15;
+
+ public static final char PARAM_NONE = 0x0000;
+
+ public static final char PARAM_USHORT_1 = 0x0001;
+
+ public static final char PARAM_USHORT_2 = 0x0002;
+
+ public static final char PARAM_USHORT_3 = 0x0100;
+
+ public static final char PARAM_USHORT_4 = 0x0200;
+
+ public static final char PARAM_ULONG_1 = 0x0004;
+
+ public static final char PARAM_ULONG_2 = 0x0008;
+
+ public static final char PARAM_STR_1 = 0x0010;
+
+ public static final char PARAM_STR_2 = 0x0020;
+
+ public static final char PARAM_BOOL_1 = 0x0040;
+
+ public static final char PARAM_BOOL_2 = 0x0080;
+
+ public static final char PARAM_SBXVALUE_1 = 0x0400;
+
+ public static final char F_EndCommandBlock = 101;
+
+ public static final char F_Sequence = 102;
+
+ public static final char M_WITH_RETURN = 0x0200;
+
+ public static final char M_KEY_STRING = 0x0400;
+
+ public static final char M_SOFFICE = 0x0800;
+
+ public static final char M_MOZILLA = 0x1000;
+
+ // for MacroRecorder
+ public static final char M_RET_NUM_CONTROL = 0x2000; // decode ULong as
+ // Control (For
+ // Tabpages,
+ // Toolboxes, ... )
+
+ public static final char M_Select = 21;
+
+ public static final char M_SetNoSelection = 22;
+
+ public static final char M_SetText = 23;
+
+ public static final char M_More = 24;
+
+ public static final char M_Less = 25;
+
+ public static final char M_ToMin = 26;
+
+ public static final char M_ToMax = 27;
+
+ public static final char M_Check = 28;
+
+ public static final char M_UnCheck = 29;
+
+ public static final char M_TriState = 30;
+
+ public static final char M_SetPage = 31;
+
+ public static final char M_Click = 32;
+
+ public static final char M_Close = 33; // Push Buttons on Dialog (Auch More
+ // Button)
+
+ public static final char M_Cancel = 34;
+
+ public static final char M_OK = 35;
+
+ public static final char M_Help = 36;
+
+ public static final char M_Default = 37; // Push defaultbutton on Dialog
+
+ public static final char M_Yes = 38;
+
+ public static final char M_No = 39;
+
+ public static final char M_Repeat = 40;
+
+ public static final char M_Open = 41;
+
+ public static final char M_Pick = 42;
+
+ public static final char M_Move = 43;
+
+ public static final char M_Size = 44;
+
+ public static final char M_Minimize = 45;
+
+ public static final char M_Maximize = 46;
+
+ public static final char M_Dock = 47;
+
+ public static final char M_Undock = 48;
+
+ public static final char M_TypeKeys = (M_KEY_STRING | 50);
+
+ public static final char M_MouseDown = 51;
+
+ public static final char M_MouseUp = 52;
+
+ public static final char M_MouseMove = 53;
+
+ public static final char M_MouseDoubleClick = 54;
+
+ public static final char M_SnapShot = 55;
+
+ public static final char M_SetNextToolBox = 56;
+
+ public static final char M_OpenContextMenu = 57;
+
+ public static final char M_MultiSelect = 58;
+
+ // Filedialog
+ public static final char M_SetPath = 60;
+
+ public static final char M_SetCurFilter = 61;
+
+ // Printdialog
+ public static final char M_SetPrinter = 70;
+
+ public static final char M_CheckRange = 71;
+
+ public static final char M_SetRangeText = 72;
+
+ public static final char M_SetFirstPage = 73;
+
+ public static final char M_SetLastPage = 74;
+
+ public static final char M_CheckCollate = 75;
+
+ public static final char M_SetPageId = 76;
+
+ public static final char M_SetPageNr = 77;
+
+ public static final char M_AnimateMouse = 78;
+
+ public static final char M_TearOff = 79;
+
+ public static final char M_FadeIn = 80;
+
+ public static final char M_FadeOut = 81;
+
+ public static final char M_Pin = 82;
+
+ public static final char M_UseMenu = 83; // Use the menu of the next
+ // possible parent of given
+ // Window
+
+ public static final char M_OpenMenu = 84; // MenuButtons and Menus in
+ // ToolBoxes
+
+ public static final char M_Restore = 85; // Window Control together with
+ // M_Maximize and M_Minimize
+
+ public static final char M_DisplayPercent = 200;
+
+ public static final char M_LAST_NO_RETURN = 200;
+
+ public static final char M_Exists = (M_WITH_RETURN | 1);
+
+ public static final char M_NotExists = (M_WITH_RETURN | 2);
+
+ public static final char M_IsEnabled = (M_WITH_RETURN | 3);
+
+ public static final char M_IsVisible = (M_WITH_RETURN | 4);
+
+ public static final char M_IsWritable = (M_WITH_RETURN | 5);
+
+ public static final char M_GetPage = (M_WITH_RETURN | 6);
+
+ public static final char M_IsChecked = (M_WITH_RETURN | 7);
+
+ public static final char M_IsTristate = (M_WITH_RETURN | 8);
+
+ public static final char M_GetState = (M_WITH_RETURN | 9);
+
+ public static final char M_GetText = (M_WITH_RETURN | 10);
+
+ public static final char M_GetSelCount = (M_WITH_RETURN | 11);
+
+ public static final char M_GetSelIndex = (M_WITH_RETURN | 12);
+
+ public static final char M_GetSelText = (M_WITH_RETURN | 13);
+
+ public static final char M_GetItemCount = (M_WITH_RETURN | 14);
+
+ public static final char M_GetItemText = (M_WITH_RETURN | 15);
+
+ public static final char M_IsOpen = (M_WITH_RETURN | 16);
+
+ public static final char M_Caption = (M_WITH_RETURN | 17);
+
+ public static final char M_IsMax = (M_WITH_RETURN | 18);
+
+ public static final char M_IsDocked = (M_WITH_RETURN | 19);
+
+ public static final char M_GetRT = (M_WITH_RETURN | 20);
+
+ public static final char M_GetPageId = (M_WITH_RETURN | 21);
+
+ public static final char M_GetPageCount = (M_WITH_RETURN | 22);
+
+ public static final char M_GetPosX = (M_WITH_RETURN | 23);
+
+ public static final char M_GetPosY = (M_WITH_RETURN | 24);
+
+ public static final char M_GetSizeX = (M_WITH_RETURN | 25);
+
+ public static final char M_GetSizeY = (M_WITH_RETURN | 26);
+
+ public static final char M_GetNextToolBox = (M_WITH_RETURN | 27);
+
+ public static final char M_GetButtonCount = (M_WITH_RETURN | 28);
+
+ public static final char M_GetButtonId = (M_WITH_RETURN | 29);
+
+ public static final char M_IsFadeIn = (M_WITH_RETURN | 30);
+
+ public static final char M_IsPin = (M_WITH_RETURN | 31);
+
+ // Statusbar
+ public static final char M_StatusGetText = (M_WITH_RETURN | 32);
+
+ public static final char M_StatusIsProgress = (M_WITH_RETURN | 33);
+
+ public static final char M_StatusGetItemCount = (M_WITH_RETURN | 34);
+
+ public static final char M_StatusGetItemId = (M_WITH_RETURN | 35);
+
+ //
+ public static final char M_GetMouseStyle = (M_WITH_RETURN | 36);
+
+ // support for Messagebox with checkbox
+ public static final char M_GetCheckBoxText = (M_WITH_RETURN | 37);
+
+ // Scrollbars
+ public static final char M_HasScrollBar = (M_WITH_RETURN | 38);
+
+ public static final char M_IsScrollBarEnabled = (M_WITH_RETURN | 39);
+
+ // Dieser befehl wird nur intern im Controller (sts library) verwendet. Sie
+ // tauchen nicht im Testtool auf!
+ public static final char _M_IsEnabled = (M_WITH_RETURN | 50);
+
+ public static final char M_GetFixedTextCount = (M_WITH_RETURN | 51);
+
+ public static final char M_GetFixedText = (M_WITH_RETURN | 52);
+
+ public static final char M_IsMin = (M_WITH_RETURN | 53);
+
+ public static final char M_IsRestore = (M_WITH_RETURN | 54);
+
+ public static final char M_GetItemType = (M_WITH_RETURN | 55);
+
+ // Commands for (Edit)BrowseBox
+ public static final char M_GetColumnCount = (M_WITH_RETURN | 56);
+
+ public static final char M_GetRowCount = (M_WITH_RETURN | 57);
+
+ public static final char M_IsEditing = (M_WITH_RETURN | 58);
+
+ public static final char M_IsItemEnabled = (M_WITH_RETURN | 59);
+
+ // Symphony Special
+ public static final char M_GetHelpText = (M_WITH_RETURN | 90);
+ public static final char M_GetQuickHelpText = (M_WITH_RETURN | 91);
+ public static final char M_GetScreenRectangle = (M_WITH_RETURN | 92);
+ public static final char M_HasFocus = (M_WITH_RETURN | 93);
+ public static final char M_GetItemHelpText = (M_WITH_RETURN | 94);
+ public static final char M_GetItemQuickHelpText = (M_WITH_RETURN | 95);
+ public static final char M_GetItemText2 = (M_WITH_RETURN | 96);
+ // Symphony Special End
+
+ public static final char RC_AppAbort = (M_SOFFICE | M_MOZILLA | 1);
+
+ public static final char RC_SetClipboard = (M_SOFFICE | M_MOZILLA | 2);
+
+ public static final char RC_NoDebug = (M_SOFFICE | M_MOZILLA | 3);
+
+ public static final char RC_Debug = (M_SOFFICE | M_MOZILLA | 4);
+
+ public static final char RC_GPF = (M_SOFFICE | M_MOZILLA | 5);
+
+ public static final char RC_DisplayHid = (M_SOFFICE | M_MOZILLA | 6);
+
+ public static final char RC_AppDelay = (M_SOFFICE | M_MOZILLA | 7);
+
+ public static final char RC_UseBindings = (M_SOFFICE | 8);
+
+ public static final char RC_Profile = (M_SOFFICE | M_MOZILLA | 9);
+
+ // =(Popup);Menu
+ public static final char RC_MenuSelect = (M_SOFFICE | M_MOZILLA | 10);
+
+ public static final char RC_SetControlType = (M_SOFFICE | 11);
+
+ // RemoteFileAccess
+ public static final char RC_Kill = (M_SOFFICE | 12);
+
+ public static final char RC_RmDir = (M_SOFFICE | 13);
+
+ public static final char RC_MkDir = (M_SOFFICE | 14);
+
+ public static final char RC_FileCopy = (M_SOFFICE | 15);
+
+ public static final char RC_Name = (M_SOFFICE | 16);
+
+ public static final char RC_CaptureAssertions = (M_SOFFICE | M_MOZILLA | 17);
+
+ public static final char RC_Assert = (M_SOFFICE | M_MOZILLA | 18);
+
+ public static final char RC_MenuOpen = (M_SOFFICE | M_MOZILLA | 19);
+
+ public static final char RC_TypeKeysDelay = (M_SOFFICE | M_MOZILLA | 20);
+
+ public static final char RC_ShowBar = (M_MOZILLA | 21);
+
+ public static final char RC_LoadURL = (M_MOZILLA | 22);
+
+ public static final char RC_CloseSysDialog = (M_SOFFICE | 23);
+
+ public static final char RC_SAXRelease = (M_SOFFICE | 24);
+
+ public static final char RC_RecordMacro = (M_SOFFICE | 25);
+
+ public static final char RC_ActivateDocument = (M_SOFFICE | 26);
+
+ public static final char RC_CatchGPF = (M_SOFFICE | 27);
+
+ // Befehle mit Returnwert
+ public static final char RC_GetClipboard = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 1);
+
+ public static final char RC_WinTree = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 2);
+
+ public static final char RC_ResetApplication = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 3);
+
+ public static final char RC_GetNextCloseWindow = (M_SOFFICE | M_WITH_RETURN | 4);
+
+ public static final char RC_ApplicationBusy = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 5);
+
+ // =(Popup);Menu
+ public static final char RC_MenuGetItemCount = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 6);
+
+ public static final char RC_MenuGetItemId = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 7);
+
+ public static final char RC_MenuGetItemPos = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 8);
+
+ public static final char RC_MenuIsSeperator = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 9);
+
+ public static final char RC_MenuIsItemChecked = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 10);
+
+ public static final char RC_MenuIsItemEnabled = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 11);
+
+ public static final char RC_MenuGetItemText = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 12);
+
+ // RemoteFileAccess
+ public static final char RC_Dir = (M_SOFFICE | M_WITH_RETURN | 18);
+
+ public static final char RC_FileLen = (M_SOFFICE | M_WITH_RETURN | 19);
+
+ public static final char RC_FileDateTime = (M_SOFFICE | M_WITH_RETURN | 20);
+
+ public static final char RC_Translate = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 21);
+
+ public static final char RC_GetMouseStyle = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 22);
+
+ public static final char RC_UnpackStorage = (M_SOFFICE | M_WITH_RETURN | 23);
+
+ public static final char RC_IsBarVisible = (M_MOZILLA | M_WITH_RETURN | 24);
+
+ public static final char RC_MenuGetItemCommand = (M_SOFFICE | M_MOZILLA | M_WITH_RETURN | 25);
+
+ public static final char RC_ExistsSysDialog = (M_SOFFICE | M_WITH_RETURN | 26);
+
+ public static final char RC_SAXCheckWellformed = (M_SOFFICE | M_WITH_RETURN | 27);
+
+ public static final char RC_SAXReadFile = (M_SOFFICE | M_WITH_RETURN | 28);
+
+ public static final char RC_SAXGetNodeType = (M_SOFFICE | M_WITH_RETURN | 29);
+
+ public static final char RC_SAXGetElementName = (M_SOFFICE | M_WITH_RETURN | 30);
+
+ public static final char RC_SAXGetChars = (M_SOFFICE | M_WITH_RETURN | 31);
+
+ public static final char RC_SAXGetChildCount = (M_SOFFICE | M_WITH_RETURN | 32);
+
+ public static final char RC_SAXGetAttributeCount = (M_SOFFICE | M_WITH_RETURN | 33);
+
+ public static final char RC_SAXGetAttributeName = (M_SOFFICE | M_WITH_RETURN | 34);
+
+ public static final char RC_SAXGetAttributeValue = (M_SOFFICE | M_WITH_RETURN | 35);
+
+ public static final char RC_SAXSeekElement = (M_SOFFICE | M_WITH_RETURN | 36);
+
+ public static final char RC_SAXHasElement = (M_SOFFICE | M_WITH_RETURN | 37);
+
+ public static final char RC_SAXGetElementPath = (M_SOFFICE | M_WITH_RETURN | 38);
+
+ public static final char RC_GetDocumentCount = (M_SOFFICE | M_WITH_RETURN | 39);
+
+ public static final char RC_GetSystemLanguage = (M_SOFFICE | M_WITH_RETURN | 40);
+
+ public static final char RC_IsProduct = (M_SOFFICE | M_WITH_RETURN | 41);
+
+ public static final char RC_MenuHasSubMenu = (M_SOFFICE | M_WITH_RETURN | 42);
+
+ public static final char RC_UsePostEvents = (M_SOFFICE | M_WITH_RETURN | 43);
+
+ public static final char RC_WaitSlot = (M_SOFFICE | M_WITH_RETURN | 44);
+
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/Handshaker.java b/test/testcommon/source/org/openoffice/test/vcl/client/Handshaker.java
new file mode 100644
index 000000000000..edfd5f6d4d96
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/Handshaker.java
@@ -0,0 +1,75 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ * The class is used to handle handshake package
+ *
+ */
+public class Handshaker implements CommunicationListener, Constant {
+
+ private static Logger logger = Logger.getLogger("com.ibm.vclhook");
+
+ private CommunicationManager communicationManager = null;
+
+ public Handshaker(CommunicationManager communicationManager) {
+ this.communicationManager = communicationManager;
+ this.communicationManager.addListener(this);
+ }
+
+ public void received(int headerType, byte[] header, byte[] data) {
+ if (headerType == CH_Handshake) {
+ int handshakeType = data[1] + ((data[0] & 255) << 8);
+ switch (handshakeType) {
+ case CH_REQUEST_HandshakeAlive:
+ logger.log(Level.CONFIG, "Receive Handshake - CH_REQUEST_HandshakeAlive");
+ sendHandshake(CH_RESPONSE_HandshakeAlive);
+ break;
+ case CH_REQUEST_ShutdownLink:
+ logger.log(Level.CONFIG, "Receive Handshake - CH_REQUEST_ShutdownLink");
+ sendHandshake(CH_ShutdownLink);
+ break;
+ case CH_ShutdownLink:
+ logger.log(Level.CONFIG, "Receive Handshake - CH_ShutdownLink");
+ communicationManager.stop();
+ break;
+ case CH_SetApplication:
+ //String len
+// int len = data[2] + ((data[3] & 255) << 8);
+// String app = new String(data, 4, data.length - 4);
+ logger.log(Level.CONFIG, "Receive Handshake - CH_SetApplication - app");
+ //sendHandshake(CH_SetApplication);
+ break;
+ default:
+ }
+ }
+ }
+ public void sendHandshake(int handshakeType) {
+ sendHandshake(handshakeType, new byte[0]);
+ }
+ public void sendHandshake(int handshakeType, byte[] data) {
+ byte[] realData = new byte[data.length + 2];
+ realData[0] = (byte) ((handshakeType >>> 8) & 0xFF);
+ realData[1] = (byte) ((handshakeType >>> 0) & 0xFF);
+ System.arraycopy(data, 0, realData, 2, data.length);
+ communicationManager.sendPackage(CH_Handshake, null, realData);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/SmartId.java b/test/testcommon/source/org/openoffice/test/vcl/client/SmartId.java
new file mode 100644
index 000000000000..0471ad38fb9b
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/SmartId.java
@@ -0,0 +1,60 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+
+/**
+ * ID of GUI controls may have two types: number or string.
+ * From AOO3.4, all IDs should be string.
+ */
+public class SmartId {
+
+ private long id = 0;
+
+ private String sid = null;
+
+ public SmartId(long id) {
+ super();
+ this.id = id;
+ }
+
+ public SmartId(String sid) {
+ super();
+ this.sid = sid;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getSid() {
+ return sid;
+ }
+
+ public String toString() {
+ if (sid == null)
+ return Long.toString(id);
+ else
+ return sid;
+ }
+
+ public int hashCode() {
+ if (sid == null)
+ return new Long(id).hashCode();
+ return sid.hashCode();
+ }
+
+ public boolean equals (Object o) {
+ if (!(o instanceof SmartId))
+ return false;
+ SmartId id2 = (SmartId) o;
+ return id2.id == this.id && ((this.sid == null && id2.sid == null) || (this.sid != null && this.sid.equals(id2.sid)));
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/VclHook.java b/test/testcommon/source/org/openoffice/test/vcl/client/VclHook.java
new file mode 100644
index 000000000000..3f013049be2b
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/VclHook.java
@@ -0,0 +1,104 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+import java.io.IOException;
+
+
+
+/**
+ * The entry to remotely invoke the methods supported by the automation server
+ *
+ */
+public class VclHook {
+
+ private static final String DEFAULT_HOST = "localhost";
+
+ private static final int DEFAULT_PORT = 12479;
+
+ private static CommunicationManager communicationManager = null;
+
+ private static CommandCaller commandCaller = null;
+
+ private static Handshaker handshaker = null;
+
+ static {
+ init();
+ }
+
+ private static void init() {
+ String host = System.getProperty("AutomationServerHost", DEFAULT_HOST);
+ int port = DEFAULT_PORT;
+ try {
+ port = Integer.parseInt(System.getProperty("AutomationServerPort"));
+ } catch(NumberFormatException e) {
+
+ }
+ communicationManager = new CommunicationManager(host, port);
+ commandCaller = new CommandCaller(communicationManager);
+ communicationManager.addListener(commandCaller);
+ handshaker = new Handshaker(communicationManager);
+ communicationManager.addListener(handshaker);
+ }
+
+ public static CommandCaller getCommandCaller() {
+ return commandCaller;
+ }
+
+ public static CommunicationManager getCommunicationManager() {
+ return communicationManager;
+ }
+
+ public static boolean available() {
+ try {
+ communicationManager.connect();
+ } catch (IOException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public static Object invokeControl(SmartId uid, int methodId, Object[] args) {
+ return commandCaller.callControl(uid, methodId, args);
+ }
+
+ public static Object invokeControl(SmartId uid, int methodId) {
+ return commandCaller.callControl(uid, methodId, null);
+ }
+
+ public static Object invokeCommand(int methodId, Object... args) {
+ return commandCaller.callCommand(methodId, args);
+ }
+
+ public static Object invokeCommand(int methodId) {
+ return commandCaller.callCommand(methodId, null);
+ }
+
+ public static void invokeUNOSlot(String url) {
+ commandCaller.callUNOSlot(url);
+ }
+
+ public static void invokeSlot(int id) {
+ commandCaller.callSlot(id, new Object[]{});
+ }
+
+ public static void invokeSlot(int id, String arg0, Object val0) {
+ commandCaller.callSlot(id, new Object[]{arg0, val0});
+ }
+
+ public static void invokeSlot(int id, String arg0, Object val0, String arg1, Object val1) {
+ commandCaller.callSlot(id, new Object[]{arg0, val0, arg1, val1});
+ }
+
+ public static void invokeSlot(int id, String arg0, Object val0, String arg1, Object val1, String arg2, Object val2) {
+ commandCaller.callSlot(id, new Object[]{arg0, val0, arg1, val1, arg2, val2});
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/client/VclHookException.java b/test/testcommon/source/org/openoffice/test/vcl/client/VclHookException.java
new file mode 100644
index 000000000000..99b38caebfd7
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/client/VclHookException.java
@@ -0,0 +1,355 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.client;
+
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * The exception during executing the remote method.
+ *
+ */
+public class VclHookException extends RuntimeException {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The messages are from basic\source\app\svtmsg.src
+ */
+ /***ERROR****/
+ public static final int SVT_START = 22000;
+
+ public static final int S_GPF_ABORT =( SVT_START + 0 );
+ public static final int S_APP_SHUTDOWN =( SVT_START + 1 );
+ public static final int S_SID_EXECUTE_FAILED_NO_DISPATCHER =( SVT_START + 2 );
+ public static final int S_SID_EXECUTE_FAILED =( SVT_START + 3 );
+ public static final int S_UNO_PROPERTY_NITIALIZE_FAILED =( SVT_START + 4 );
+ public static final int S_RESETAPPLICATION_FAILED_COMPLEX =( SVT_START + 5 );
+ public static final int S_RESETAPPLICATION_FAILED_UNKNOWN =( SVT_START + 6 );
+ public static final int S_NO_ACTIVE_WINDOW =( SVT_START + 7 );
+ public static final int S_NO_DIALOG_IN_GETACTIVE =( SVT_START + 8 );
+ public static final int S_NO_POPUP =( SVT_START + 9 );
+ public static final int S_NO_SUBMENU =( SVT_START + 10 );
+ public static final int S_CONTROLTYPE_NOT_SUPPORTED =( SVT_START + 11 );
+ public static final int S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES =( SVT_START + 12 );
+ public static final int S_NO_MORE_FILES =( SVT_START + 13 );
+ public static final int S_UNKNOWN_METHOD =( SVT_START + 14 );
+ public static final int S_INVALID_PARAMETERS =( SVT_START + 15 );
+ public static final int S_POINTER_OUTSIDE_APPWIN =( SVT_START + 16 );
+ public static final int S_UNKNOWN_COMMAND =( SVT_START + 17 );
+ public static final int S_WIN_NOT_FOUND =( SVT_START + 18 );
+ public static final int S_WIN_INVISIBLE =( SVT_START + 19 );
+ public static final int S_WIN_DISABLED =( SVT_START + 20 );
+ public static final int S_NUMBER_TOO_BIG =( SVT_START + 21 );
+ public static final int S_NUMBER_TOO_SMALL =( SVT_START + 22 );
+ public static final int S_WINDOW_DISAPPEARED =( SVT_START + 23 );
+ public static final int S_ERROR_SAVING_IMAGE =( SVT_START + 24 );
+ public static final int S_INVALID_POSITION =( SVT_START + 25 );
+ public static final int S_SPLITWIN_NOT_FOUND =( SVT_START + 26 );
+ public static final int S_INTERNAL_ERROR =( SVT_START + 27 );
+ public static final int S_NO_STATUSBAR =( SVT_START + 28 );
+ public static final int S_ITEMS_INVISIBLE =( SVT_START + 29 );
+ public static final int S_TABPAGE_NOT_FOUND =( SVT_START + 30 );
+ public static final int S_TRISTATE_NOT_ALLOWED =( SVT_START + 31 );
+ public static final int S_ERROR_IN_SET_TEXT =( SVT_START + 32 );
+ public static final int S_ATTEMPT_TO_WRITE_READONLY =( SVT_START + 33 );
+ public static final int S_NO_SELECT_FALSE =( SVT_START + 34 );
+ public static final int S_ENTRY_NOT_FOUND =( SVT_START + 35 );
+ public static final int S_METHOD_FAILED =( SVT_START + 36 );
+ public static final int S_HELPID_ON_TOOLBOX_NOT_FOUND =( SVT_START + 37 );
+ public static final int S_BUTTON_DISABLED_ON_TOOLBOX =( SVT_START + 38 );
+ public static final int S_BUTTON_HIDDEN_ON_TOOLBOX =( SVT_START + 39 );
+ public static final int S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX =( SVT_START + 40 );
+ public static final int S_TEAROFF_FAILED =( SVT_START + 41 );
+ public static final int S_NO_SELECTED_ENTRY_DEPRECATED =( SVT_START + 42 ); // Has to stay in for old res files
+ public static final int S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED =( SVT_START + 43 );
+ public static final int S_ALLOWED_ONLY_IN_FLOATING_MODE =( SVT_START + 44 );
+ public static final int S_ALLOWED_ONLY_IN_DOCKING_MODE =( SVT_START + 45 );
+ public static final int S_SIZE_NOT_CHANGEABLE =( SVT_START + 46 );
+ public static final int S_NO_OK_BUTTON =( SVT_START + 47 );
+ public static final int S_NO_CANCEL_BUTTON =( SVT_START + 48 );
+ public static final int S_NO_YES_BUTTON =( SVT_START + 49 );
+ public static final int S_NO_NO_BUTTON =( SVT_START + 50 );
+ public static final int S_NO_RETRY_BUTTON =( SVT_START + 51 );
+ public static final int S_NO_HELP_BUTTON =( SVT_START + 52 );
+ public static final int S_NO_DEFAULT_BUTTON =( SVT_START + 53 );
+ public static final int S_BUTTON_ID_NOT_THERE =( SVT_START + 54 );
+ public static final int S_BUTTONID_REQUIRED =( SVT_START + 55 );
+ public static final int S_UNKNOWN_TYPE =( SVT_START + 56 );
+ public static final int S_UNPACKING_STORAGE_FAILED =( SVT_START + 57 );
+ public static final int S_NO_LIST_BOX_BUTTON =( SVT_START + 58 );
+ public static final int S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER =( SVT_START + 59 );
+ public static final int S_UNO_URL_EXECUTE_FAILED_NO_FRAME =( SVT_START + 60 );
+ public static final int S_NO_MENU =( SVT_START + 61 );
+ public static final int S_NO_SELECTED_ENTRY =( SVT_START + 62 );
+ public static final int S_UNO_URL_EXECUTE_FAILED_DISABLED =( SVT_START + 63 );
+ public static final int S_NO_SCROLLBAR =( SVT_START + 64 );
+ public static final int S_NO_SAX_PARSER =( SVT_START + 65 );
+ public static final int S_CANNOT_CREATE_DIRECTORY =( SVT_START + 66 );
+ public static final int S_DIRECTORY_NOT_EMPTY =( SVT_START + 67 );
+ public static final int S_DEPRECATED =( SVT_START + 68 );
+ public static final int S_SIZE_BELOW_MINIMUM =( SVT_START + 69 );
+ public static final int S_CANNOT_FIND_FLOATING_WIN =( SVT_START + 70 );
+ public static final int S_NO_LIST_BOX_STRING =( SVT_START + 71 );
+ public static final int S_SLOT_IN_EXECUTE =( SVT_START + 72 );
+
+ public static Properties MESSAGES = new Properties();
+
+ static {
+ MESSAGES.put(new Integer(S_GPF_ABORT), "Program aborted with GPF");
+ MESSAGES.put(new Integer(S_APP_SHUTDOWN), "Application has been shut down");
+ MESSAGES.put(new Integer(S_SID_EXECUTE_FAILED_NO_DISPATCHER), "Slot ID cannot be executed. No ActiveDispatcher");
+ MESSAGES.put(new Integer(S_SID_EXECUTE_FAILED), "Slot ID could not be executed");
+ MESSAGES.put(new Integer(S_UNO_PROPERTY_NITIALIZE_FAILED), "UnoSlot: Properties could not be initialized");
+ MESSAGES.put(new Integer(S_RESETAPPLICATION_FAILED_COMPLEX),
+ "ResetApplication failed: too complex");
+ MESSAGES.put(new Integer(S_RESETAPPLICATION_FAILED_UNKNOWN),
+ "ResetApplication failed: unknown window type");
+ MESSAGES.put(new Integer(S_NO_ACTIVE_WINDOW),
+ "No active window found (GetNextCloseWindow)");
+ MESSAGES.put(new Integer(S_NO_DIALOG_IN_GETACTIVE),
+ "GetActive does not return a dialog! Inform development");
+ MESSAGES.put(new Integer(S_NO_POPUP), "Pop-up menu not open");
+ MESSAGES.put(new Integer(S_NO_SUBMENU), "Submenu does not exist");
+ MESSAGES.put(new Integer(S_CONTROLTYPE_NOT_SUPPORTED),
+ "ControlType ($Arg1) is not supported");
+ MESSAGES.put(new Integer(S_SELECTION_BY_ATTRIBUTE_ONLY_DIRECTORIES),
+ "Selection by attributes only possible for directories");
+ MESSAGES.put(new Integer(S_NO_MORE_FILES), "No more files");
+ MESSAGES.put(new Integer(S_UNKNOWN_METHOD),
+ "Unknown method '($Arg1)' on ($Arg2)");
+ MESSAGES.put(new Integer(S_INVALID_PARAMETERS), "Invalid Parameters");
+ MESSAGES.put(new Integer(S_POINTER_OUTSIDE_APPWIN),
+ "Pointer not inside application window at '($Arg1)'");
+ MESSAGES.put(new Integer(S_UNKNOWN_COMMAND),
+ "Unknown command '($Arg1)'");
+ MESSAGES.put(new Integer(S_WIN_NOT_FOUND), "($Arg1) could not be found");
+ MESSAGES.put(new Integer(S_WIN_INVISIBLE), "($Arg1) is not visible");
+ MESSAGES.put(new Integer(S_WIN_DISABLED), "($Arg1) could not be accessed. Disabled");
+ MESSAGES.put(new Integer(S_NUMBER_TOO_BIG),
+ "Entry number ($Arg2) is too large in ($Arg1). Max. allowed is ($Arg3)");
+ MESSAGES.put(new Integer(S_NUMBER_TOO_SMALL),
+ "The entry number ($Arg2) is too small in ($Arg1). Min allowed is ($Arg3)");
+ MESSAGES.put(new Integer(S_WINDOW_DISAPPEARED), "Window disappeared in the meantime at ($Arg1)");
+ MESSAGES.put(new Integer(S_ERROR_SAVING_IMAGE), "Error #($Arg1) when saving the image");
+ MESSAGES.put(new Integer(S_INVALID_POSITION),
+ "Invalid position at ($Arg1)");
+ MESSAGES.put(new Integer(S_SPLITWIN_NOT_FOUND),
+ "SplitWindow not found at ($Arg1)");
+ MESSAGES
+ .put(new Integer(S_INTERNAL_ERROR), "Internal error at ($Arg1)");
+ MESSAGES.put(new Integer(S_NO_STATUSBAR), "No status bar at ($Arg1)");
+ MESSAGES.put(new Integer(S_ITEMS_INVISIBLE),
+ "The items are hidden at ($Arg1)");
+ MESSAGES.put(new Integer(S_TABPAGE_NOT_FOUND),
+ "Tab page not found at ($Arg1)");
+ MESSAGES.put(new Integer(S_TRISTATE_NOT_ALLOWED),
+ "Tristate cannot be set at ($Arg1)");
+ MESSAGES.put(new Integer(S_ERROR_IN_SET_TEXT),
+ "Set text did not function");
+ MESSAGES.put(new Integer(S_ATTEMPT_TO_WRITE_READONLY),
+ "Attempt to write on read-only ($Arg1)");
+ MESSAGES.put(new Integer(S_NO_SELECT_FALSE),
+ "Select FALSE not allowed. Use MultiSelect at ($Arg1)");
+ MESSAGES.put(new Integer(S_ENTRY_NOT_FOUND),
+ "\"($Arg2)\" entry at ($Arg1) not found");
+ MESSAGES.put(new Integer(S_METHOD_FAILED),
+ "($Arg1) of entry \"($Arg2)\" failed");
+ MESSAGES.put(new Integer(S_HELPID_ON_TOOLBOX_NOT_FOUND),
+ "HelpID in ToolBox not found at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_BUTTON_DISABLED_ON_TOOLBOX),
+ "The button is disabled in ToolBox at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_BUTTON_HIDDEN_ON_TOOLBOX),
+ "The button is hidden in ToolBox at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX),
+ "Button cannot be made visible in ToolBox at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_TEAROFF_FAILED),
+ "TearOff failed in ToolBox at ($Arg1)");
+
+ // Has to stay in for old res files
+ MESSAGES.put(new Integer(S_NO_SELECTED_ENTRY_DEPRECATED),
+ "No entry is selected in TreeListBox at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_SELECTED_ENTRY),
+ "No entry is selected in ($Arg2) at ($Arg1)");
+
+ MESSAGES
+ .put(new Integer(S_SELECT_DESELECT_VIA_STRING_NOT_IMPLEMENTED),
+ "Select/Deselect with MESSAGES.put(new Integer(not implemented at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_ALLOWED_ONLY_IN_FLOATING_MODE),
+ "Method only allowed in floating mode at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_ALLOWED_ONLY_IN_DOCKING_MODE),
+ "Method only allowed in docking mode at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_SIZE_NOT_CHANGEABLE),
+ "Size cannot be altered at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_OK_BUTTON),
+ "There is no OK button at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_CANCEL_BUTTON),
+ "There is no Cancel button at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_YES_BUTTON),
+ "There is no Yes button at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_NO_BUTTON),
+ "There is no No button at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_RETRY_BUTTON),
+ "There is no Repeat button at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_HELP_BUTTON),
+ "There is no Help button at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_NO_DEFAULT_BUTTON),
+ "There is no Default button defined at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_BUTTON_ID_NOT_THERE),
+ "There is no button with ID ($Arg1) at ($Arg2)");
+
+ MESSAGES.put(new Integer(S_BUTTONID_REQUIRED),
+ "A button ID needs to be given at ($Arg1)");
+
+ MESSAGES
+ .put(new Integer(S_UNKNOWN_TYPE),
+ "Unknown object type ($Arg1) from UId or method '($Arg2)' not supported");
+
+ MESSAGES.put(new Integer(S_UNPACKING_STORAGE_FAILED),
+ "Unpacking storage \"($Arg1)\" to \"($Arg2)\" failed");
+
+ MESSAGES.put(new Integer(S_NO_LIST_BOX_BUTTON),
+ "ListBoxButton does not exist in ($Arg1)");
+
+ MESSAGES
+ .put(new Integer(S_UNO_URL_EXECUTE_FAILED_NO_DISPATCHER),
+ "UNO URL \"($Arg1)\" could not be executed: No dispatcher was found.");
+
+ MESSAGES
+ .put(new Integer(S_UNO_URL_EXECUTE_FAILED_NO_FRAME),
+ "UNO URL \"($Arg1)\" could not be executed: No ActiveFrame on desktop.");
+
+ MESSAGES.put(new Integer(S_NO_MENU), "There is no menu at ($Arg1)");
+
+ MESSAGES.put(new Integer(S_UNO_URL_EXECUTE_FAILED_DISABLED),
+ "UNO URL \"($Arg1)\" could not be run: Disabled");
+
+ MESSAGES.put(new Integer(S_NO_SCROLLBAR), "No scroll bar at ($Arg1)");
+
+ MESSAGES
+ .put(new Integer(S_NO_SAX_PARSER),
+ "No SAX Parser when using ($Arg1). Initialize with 'SAXReadFile' first.");
+
+ MESSAGES.put(new Integer(S_CANNOT_CREATE_DIRECTORY),
+ "Cannot create Directory: \"($Arg1)\"");
+
+ MESSAGES
+ .put(new Integer(S_DIRECTORY_NOT_EMPTY),
+ "Directory has to be Empty to unpack to. Directory: \"($Arg1)\"");
+
+ MESSAGES.put(new Integer(S_DEPRECATED),
+ "Deprecated! Please change the script.");
+
+ MESSAGES.put(new Integer(S_SIZE_BELOW_MINIMUM),
+ "The Size is below the minimum. x=($Arg1) ,y=($Arg2)");
+
+ MESSAGES
+ .put(new Integer(S_CANNOT_FIND_FLOATING_WIN),
+ "Cannot find FloatingWindow for floating DockingWindow at ($Arg1).");
+
+ MESSAGES.put(new Integer(S_NO_LIST_BOX_STRING),
+ "String does not exist in ($Arg1)");
+
+ MESSAGES.put(new Integer(S_SLOT_IN_EXECUTE),
+ "Another Slot is being executed already.");
+
+ }
+
+ private SmartId id = null;
+
+ private String message = null;
+
+ private int code = -1;
+
+ private Properties properties = new Properties();
+
+ public VclHookException(String message) {
+ this(null, message);
+ }
+
+ public VclHookException(SmartId id, String message) {
+ this.id = id;
+ this.message = message;
+ if (id != null)
+ parse();
+ }
+
+
+ public String getMessage() {
+ return this.message;
+ }
+
+
+ private void parse() {
+ if (message == null)
+ return;
+
+ //Replace some key
+ message = message.replaceAll("%Method=([^%]*)%", "$1");
+ message = message.replaceAll("%RType=([^%]*)%", "$1");
+ message = message.replaceAll("%RCommand=([^%]*)%", "$1");
+ message = message.replaceAll("%UId=([^%]*)%", "$1");
+
+ // Parse String into Properties
+ int start = -1, sep = -1, end =-1, pos = 0;
+ String key = null;
+ String value= null;
+ while( (start = message.indexOf('%', pos)) != -1
+ && (sep = message.indexOf('=', start + 1)) != -1
+ && (end = message.indexOf('%', sep + 1)) != -1) {
+ key = message.substring(start + 1, sep);
+ value = message.substring(sep + 1, end);
+ pos = end + 1;
+ properties.put(key, value);
+ }
+
+ String resId = properties.getProperty("ResId");
+ if (resId == null)
+ return;
+ this.code = Integer.parseInt(resId);
+ String originalMsg = (String) MESSAGES.get(this.code);
+ if (originalMsg == null)
+ return;
+
+ Pattern pattern = Pattern.compile("\\(\\$([^\\)]*)\\)");
+ Matcher matcher = pattern.matcher(originalMsg);
+ StringBuffer result = new StringBuffer();
+ while (matcher.find()) {
+ String rep = properties.getProperty(matcher.group(1), matcher.group()).replace("$", "\\$");
+ matcher.appendReplacement(result, rep);
+ }
+ matcher.appendTail(result);
+ message = "ID:" + id + " - " + result.toString();
+ }
+
+
+ public int getCode() {
+ return this.code;
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java
new file mode 100644
index 000000000000..4aee02e5a5b7
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclApp.java
@@ -0,0 +1,181 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+
+import java.util.Properties;
+
+import org.openoffice.test.common.FileUtil;
+import org.openoffice.test.common.SystemUtil;
+import org.openoffice.test.vcl.Tester;
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.VclHook;
+
+public class VclApp {
+ String home = null;
+
+ public static final String CMD_KILL_WINDOWS = "taskkill /F /IM soffice.bin /IM soffice.exe";
+
+ public static final String CMD_KILL_LINUX = "killall -9 soffice soffice.bin";
+
+ String cmdKill = null;
+
+ String cmdStart = null;
+
+ String versionFile = null;
+
+ Properties version = null;
+
+ String port = System.getProperty("openoffice.automation.port", "12479");
+
+ public VclApp(String appHome) {
+ setHome(appHome);
+ }
+
+ public VclApp() {
+ this(null);
+ }
+
+ public void setHome(String home) {
+ this.home = home;
+ if (home == null)
+ home = System.getProperty("openoffice.home");
+ if (home == null)
+ home = System.getenv("OPENOFFICE_HOME");
+ if (home == null)
+ home = "unkown";
+
+ versionFile = "versionrc";
+
+ cmdKill = CMD_KILL_LINUX;
+ cmdStart = "cd \"" + home + "\" ; ./soffice";
+ if (SystemUtil.isWindows()) {
+ cmdKill = CMD_KILL_WINDOWS;
+ cmdStart = "\"" + home + "\\soffice.exe\"";
+ versionFile = "version.ini";
+
+ } else if (SystemUtil.isMac()) {
+
+ } else {
+
+ }
+
+ }
+ public String getHome() {
+ return home;
+ }
+
+ public void kill() {
+ SystemUtil.execScript(cmdKill, false);
+ }
+
+ public int start(String args) {
+ if (args == null)
+ args = "";
+
+ return SystemUtil.execScript(cmdStart + " -norestore -quickstart=no -nofirststartwizard -enableautomation -automationport=" + port + " " + args, true);
+ }
+
+ public void start() {
+ start(null);
+ }
+
+ /**
+ * Activate the document window at the given index
+ *
+ * @param i
+ * @return
+ */
+ public void activateDoc(int i) {
+ VclHook.invokeCommand(Constant.RC_ActivateDocument,
+ new Object[] { i + 1 });
+ }
+
+ public void reset() {
+ VclHook.invokeCommand(Constant.RC_ResetApplication);
+ }
+
+ public boolean existsSysDialog() {
+ return (Boolean) VclHook.invokeCommand(Constant.RC_ExistsSysDialog);
+ }
+
+ public void closeSysDialog() {
+ VclHook.invokeCommand(Constant.RC_CloseSysDialog);
+ }
+
+ public String getClipboard() {
+ return (String) VclHook.invokeCommand(Constant.RC_GetClipboard);
+ }
+
+ public void setClipboard(String content) {
+ VclHook.invokeCommand(Constant.RC_SetClipboard, content);
+ }
+
+ public boolean exists() {
+ return VclHook.available();
+ }
+
+ /**
+ * Check if the control exists in a period of time
+ */
+ public boolean exists(double iTimeout) {
+ return exists(iTimeout, 1);
+ }
+
+ /**
+ * Check if the control exists in a period of time
+ */
+ public boolean exists(double iTimeout, double interval) {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < iTimeout * 1000) {
+ if (exists())
+ return true;
+ Tester.sleep(interval);
+ }
+
+ return exists();
+ }
+
+ public void waitForExistence(double iTimeout, double interval) {
+ if (!exists(iTimeout, interval))
+ throw new RuntimeException("OpenOffice is not found!");
+ }
+
+ /**
+ * Get document window count
+ *
+ * @return
+ */
+ public int getDocCount() {
+ return (Integer) VclHook.invokeCommand(Constant.RC_GetDocumentCount);
+ }
+
+ public Properties getVersion() {
+ if (version == null)
+ version = FileUtil.loadProperties(home + "/" + versionFile);
+ return version;
+ }
+
+
+ public void dispatch(String url) {
+ VclHook.invokeUNOSlot(url);
+ }
+
+ private static final int CONST_WSTimeout = 701;
+// private static final int CONST_WSAborted = 702; // Not used now!
+// private static final int CONST_WSFinished = 703; //
+
+ public void dispatch(String url, double time) {
+ VclHook.invokeUNOSlot(url);
+ int result = (Integer) VclHook.invokeCommand(Constant.RC_WaitSlot, (int) time * 1000);
+ if (result == CONST_WSTimeout)
+ throw new RuntimeException("Timeout to execute the dispatch!");
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclButton.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclButton.java
new file mode 100644
index 000000000000..c6b71fa85855
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclButton.java
@@ -0,0 +1,90 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+
+/**
+ *
+ * Button/CheckBox/RadioBox/TriStateBox
+ *
+ */
+public class VclButton extends VclControl {
+
+ /**
+ * Construct the control with its String id
+ * @param uid
+ */
+ public VclButton(String uid) {
+ super(uid);
+ }
+
+
+ public VclButton(SmartId id) {
+ super(id);
+ }
+
+ /**
+ *
+ * Click the check box
+ */
+ public void click() {
+ invoke(Constant.M_Click);
+ }
+
+ /**
+ * Check if the check box is tristate
+ */
+ public boolean isTristate() {
+ return (Boolean)invoke(Constant.M_IsTristate);
+ }
+
+ /**
+ * Set the check box to triState status
+ */
+ public void triState() {
+ invoke(Constant.M_TriState);
+ }
+
+ /**
+ * Check if the check box is checked
+ */
+ public boolean isChecked() {
+ return (Boolean) invoke(Constant.M_IsChecked);
+ }
+
+ /**
+ * Set the check box to checked status
+ *
+ */
+ public void check() {
+ invoke(Constant.M_Check);
+ }
+
+ /**
+ * Set the check box to unchecked status
+ */
+ public void uncheck() {
+ invoke(Constant.M_UnCheck);
+ }
+
+ /**
+ * Set the status to checked or unchecked
+ * @param checked
+ */
+ public void setChecked(boolean checked) {
+ if (checked)
+ this.check();
+ else
+ this.uncheck();
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclComboBox.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclComboBox.java
new file mode 100644
index 000000000000..61d8ed3542cc
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclComboBox.java
@@ -0,0 +1,130 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ * Proxy used to access Vcl Combo Box
+ *
+ */
+public class VclComboBox extends VclControl {
+
+ public VclComboBox(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Define VclComboBox with String id
+ *
+ * @param uid
+ */
+ public VclComboBox(String uid) {
+ super(uid);
+ }
+
+ /**
+ * Get the item count
+ */
+ public int getItemCount() {
+ return ((Long) invoke(Constant.M_GetItemCount)).intValue();
+ }
+
+ /**
+ * Get the text of the index-th item.
+ * @index The index starts from 0.
+ */
+ public String getItemText(int index) {
+ return (String) invoke(Constant.M_GetItemText, new Object[] {index + 1});
+ }
+
+ /**
+ * Get the index of the selected item.
+ * @index The index starts from 0.
+ */
+ public int getSelIndex() {
+ int index = ((Long) invoke(Constant.M_GetSelIndex)).intValue();
+ return index - 1;
+ }
+
+ /**
+ * Get the text of the selected item.
+ */
+ public String getSelText() {
+ return (String) invoke(Constant.M_GetSelText);
+ }
+
+ /**
+ * Get the text in the combo box
+ */
+ public String getText() {
+ // Fix: Use M_Caption to get the text. M_GetText does not work
+ return (invoke(Constant.M_Caption)).toString();
+ }
+
+ /**
+ * Get the text of all items
+ */
+ public String[] getItemsText() {
+ int count = getItemCount();
+ String[] res = new String[count];
+ for (int i = 0; i < count; i++) {
+ res[i] = getItemText(i);
+ }
+ return res;
+ }
+
+ /**
+ * Select the index-th item.
+ * @index The index starts from 0.
+ */
+ public void select(int index) {
+ invoke(Constant.M_Select, new Object[] {index + 1});
+ }
+
+ /**
+ * Select the item with the given text
+ */
+ public void select(String text) {
+ invoke(Constant.M_Select, new Object[] {text});
+ }
+
+ /**
+ * Sets no selection in a list (Sometimes this corresponds to the first
+ * entry in the list)
+ *
+ */
+ public void setNoSelection() {
+ invoke(Constant.M_SetNoSelection);
+ }
+
+ /**
+ * Set the text of the combo box
+ */
+ public void setText(String text) {
+ invoke(Constant.M_SetText, new Object[] {text});
+ }
+
+ /**
+ * Check if the list box has the specified item
+ * @param str
+ * @return
+ */
+ public boolean hasItem(String str) {
+ int len = getItemCount();
+ for (int i = 0; i < len; i++) {
+ String text = getItemText(i);
+ if (str.equals(text))
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclControl.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclControl.java
new file mode 100644
index 000000000000..50f5288c76f2
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclControl.java
@@ -0,0 +1,506 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import java.awt.Rectangle;
+import java.io.IOException;
+
+import org.openoffice.test.common.Condition;
+import org.openoffice.test.vcl.Tester;
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+import org.openoffice.test.vcl.client.VclHook;
+
+/**
+ * VCL control proxy
+ */
+public class VclControl {
+
+ public final static long ACTIVE = 0;
+
+ public final static int WINDOW_BASE = 0x0100;
+
+ public final static int WINDOW_FIRST = (WINDOW_BASE + 0x30);
+
+ public final static int WINDOW_MESSBOX = (WINDOW_FIRST);
+
+ public final static int WINDOW_INFOBOX = (WINDOW_FIRST + 0x01);
+
+ public final static int WINDOW_WARNINGBOX = (WINDOW_FIRST + 0x02);
+
+ public final static int WINDOW_ERRORBOX = (WINDOW_FIRST + 0x03);
+
+ public final static int WINDOW_QUERYBOX = (WINDOW_FIRST + 0x04);
+
+ public final static int WINDOW_WINDOW = (WINDOW_FIRST + 0x05);
+
+ public final static int WINDOW_SYSWINDOW = (WINDOW_FIRST + 0x06);
+
+ public final static int WINDOW_WORKWINDOW = (WINDOW_FIRST + 0x07);
+
+ // public final static int WINDOW_MDIWINDOW = (WINDOW_FIRST + 0x08);
+ public final static int WINDOW_FLOATINGWINDOW = (WINDOW_FIRST + 0x09);
+
+ public final static int WINDOW_DIALOG = (WINDOW_FIRST + 0x0a);
+
+ public final static int WINDOW_MODELESSDIALOG = (WINDOW_FIRST + 0x0b);
+
+ public final static int WINDOW_MODALDIALOG = (WINDOW_FIRST + 0x0c);
+
+ public final static int WINDOW_SYSTEMDIALOG = (WINDOW_FIRST + 0x0d);
+
+ public final static int WINDOW_PATHDIALOG = (WINDOW_FIRST + 0x0e);
+
+ public final static int WINDOW_FILEDIALOG = (WINDOW_FIRST + 0x0f);
+
+ public final static int WINDOW_PRINTERSETUPDIALOG = (WINDOW_FIRST + 0x10);
+
+ public final static int WINDOW_PRINTDIALOG = (WINDOW_FIRST + 0x11);
+
+ public final static int WINDOW_COLORDIALOG = (WINDOW_FIRST + 0x12);
+
+ public final static int WINDOW_FONTDIALOG = (WINDOW_FIRST + 0x13);
+
+ public final static int WINDOW_CONTROL = (WINDOW_FIRST + 0x14);
+
+ public final static int WINDOW_BUTTON = (WINDOW_FIRST + 0x15);
+
+ public final static int WINDOW_PUSHBUTTON = (WINDOW_FIRST + 0x16);
+
+ public final static int WINDOW_OKBUTTON = (WINDOW_FIRST + 0x17);
+
+ public final static int WINDOW_CANCELBUTTON = (WINDOW_FIRST + 0x18);
+
+ public final static int WINDOW_HELPBUTTON = (WINDOW_FIRST + 0x19);
+
+ public final static int WINDOW_IMAGEBUTTON = (WINDOW_FIRST + 0x1a);
+
+ public final static int WINDOW_MENUBUTTON = (WINDOW_FIRST + 0x1b);
+
+ public final static int WINDOW_MOREBUTTON = (WINDOW_FIRST + 0x1c);
+
+ public final static int WINDOW_SPINBUTTON = (WINDOW_FIRST + 0x1d);
+
+ public final static int WINDOW_RADIOBUTTON = (WINDOW_FIRST + 0x1e);
+
+ public final static int WINDOW_IMAGERADIOBUTTON = (WINDOW_FIRST + 0x1f);
+
+ public final static int WINDOW_CHECKBOX = (WINDOW_FIRST + 0x20);
+
+ public final static int WINDOW_TRISTATEBOX = (WINDOW_FIRST + 0x21);
+
+ public final static int WINDOW_EDIT = (WINDOW_FIRST + 0x22);
+
+ public final static int WINDOW_MULTILINEEDIT = (WINDOW_FIRST + 0x23);
+
+ public final static int WINDOW_COMBOBOX = (WINDOW_FIRST + 0x24);
+
+ public final static int WINDOW_LISTBOX = (WINDOW_FIRST + 0x25);
+
+ public final static int WINDOW_MULTILISTBOX = (WINDOW_FIRST + 0x26);
+
+ public final static int WINDOW_FIXEDTEXT = (WINDOW_FIRST + 0x27);
+
+ public final static int WINDOW_FIXEDLINE = (WINDOW_FIRST + 0x28);
+
+ public final static int WINDOW_FIXEDBITMAP = (WINDOW_FIRST + 0x29);
+
+ public final static int WINDOW_FIXEDIMAGE = (WINDOW_FIRST + 0x2a);
+
+ public final static int WINDOW_GROUPBOX = (WINDOW_FIRST + 0x2c);
+
+ public final static int WINDOW_SCROLLBAR = (WINDOW_FIRST + 0x2d);
+
+ public final static int WINDOW_SCROLLBARBOX = (WINDOW_FIRST + 0x2e);
+
+ public final static int WINDOW_SPLITTER = (WINDOW_FIRST + 0x2f);
+
+ public final static int WINDOW_SPLITWINDOW = (WINDOW_FIRST + 0x30);
+
+ public final static int WINDOW_SPINFIELD = (WINDOW_FIRST + 0x31);
+
+ public final static int WINDOW_PATTERNFIELD = (WINDOW_FIRST + 0x32);
+
+ public final static int WINDOW_NUMERICFIELD = (WINDOW_FIRST + 0x33);
+
+ public final static int WINDOW_METRICFIELD = (WINDOW_FIRST + 0x34);
+
+ public final static int WINDOW_CURRENCYFIELD = (WINDOW_FIRST + 0x35);
+
+ public final static int WINDOW_DATEFIELD = (WINDOW_FIRST + 0x36);
+
+ public final static int WINDOW_TIMEFIELD = (WINDOW_FIRST + 0x37);
+
+ public final static int WINDOW_PATTERNBOX = (WINDOW_FIRST + 0x38);
+
+ public final static int WINDOW_NUMERICBOX = (WINDOW_FIRST + 0x39);
+
+ public final static int WINDOW_METRICBOX = (WINDOW_FIRST + 0x3a);
+
+ public final static int WINDOW_CURRENCYBOX = (WINDOW_FIRST + 0x3b);
+
+ public final static int WINDOW_DATEBOX = (WINDOW_FIRST + 0x3c);
+
+ public final static int WINDOW_TIMEBOX = (WINDOW_FIRST + 0x3d);
+
+ public final static int WINDOW_LONGCURRENCYFIELD = (WINDOW_FIRST + 0x3e);
+
+ public final static int WINDOW_LONGCURRENCYBOX = (WINDOW_FIRST + 0x3f);
+
+ public final static int WINDOW_TOOLBOX = (WINDOW_FIRST + 0x41);
+
+ public final static int WINDOW_DOCKINGWINDOW = (WINDOW_FIRST + 0x42);
+
+ public final static int WINDOW_STATUSBAR = (WINDOW_FIRST + 0x43);
+
+ public final static int WINDOW_TABPAGE = (WINDOW_FIRST + 0x44);
+
+ public final static int WINDOW_TABCONTROL = (WINDOW_FIRST + 0x45);
+
+ public final static int WINDOW_TABDIALOG = (WINDOW_FIRST + 0x46);
+
+ public final static int WINDOW_BORDERWINDOW = (WINDOW_FIRST + 0x47);
+
+ public final static int WINDOW_BUTTONDIALOG = (WINDOW_FIRST + 0x48);
+
+ public final static int WINDOW_SYSTEMCHILDWINDOW = (WINDOW_FIRST + 0x49);
+
+ public final static int WINDOW_FIXEDBORDER = (WINDOW_FIRST + 0x4a);
+
+ public final static int WINDOW_SLIDER = (WINDOW_FIRST + 0x4b);
+
+ public final static int WINDOW_MENUBARWINDOW = (WINDOW_FIRST + 0x4c);
+
+ public final static int WINDOW_TREELISTBOX = (WINDOW_FIRST + 0x4d);
+
+ public final static int WINDOW_HELPTEXTWINDOW = (WINDOW_FIRST + 0x4e);
+
+ public final static int WINDOW_INTROWINDOW = (WINDOW_FIRST + 0x4f);
+
+ public final static int WINDOW_LISTBOXWINDOW = (WINDOW_FIRST + 0x50);
+
+ public final static int WINDOW_DOCKINGAREA = (WINDOW_FIRST + 0x51);
+
+ public final static int WINDOW_VALUESETLISTBOX = (WINDOW_FIRST + 0x55);
+
+ public final static int WINDOW_LAST = (WINDOW_DOCKINGAREA);
+
+ protected SmartId uid = null;
+
+ protected int type = -1;
+
+ /**
+ * Construct using smart ID
+ * @param id
+ */
+ public VclControl(SmartId id) {
+ this.uid = id;
+ }
+
+ /**
+ * Construct using string ID or a
+ * string indicating to dynamically find a control with the following
+ * pattern: <br>
+ * .find:ContainerControlID ControlType ControlIndex<br>
+ * A space is needed to separate ContainerControlID ControlType and
+ * ControlIndex.<br>
+ * ".find:" is fixed prefix to tell automation server to dynamically find a
+ * control.<br>
+ * ContainerControlID is container control ID which is searched in<br>
+ * ControlType gives the target control type <br>
+ * ControlIndex is the index of target control<br>
+ * e.g.<br>
+ * new VclControl(".find:52821 326 2")
+ *
+ * @param uid
+ */
+ public VclControl(String uid) {
+ this.uid = new SmartId(uid);
+ }
+
+ /**
+ * Get the ID of the control
+ *
+ * @return
+ */
+ public SmartId getUID() {
+ return this.uid;
+ }
+
+ public void click() {
+ invoke(Constant.M_Click);
+ }
+
+ /**
+ * Click
+ *
+ * @param locator
+ * @param x
+ * @param y
+ */
+ public void click(int x, int y) {
+ Rectangle rect = getValidScreenRectangle();
+ Tester.click((int) rect.x + x, (int) rect.y + y);
+ }
+
+ public void doubleClick(int x, int y) {
+ Rectangle rect = getValidScreenRectangle();
+ Tester.doubleClick((int) rect.x + x, (int) rect.y + y);
+ }
+
+ public void click(double xPercent, double yPercent) {
+ Rectangle rect = getValidScreenRectangle();
+ Tester.click((int)(rect.x + xPercent * rect.width), (int) (rect.y + yPercent * rect.height));
+ }
+
+ public void doubleClick(double xPercent, double yPercent) {
+ Rectangle rect = getValidScreenRectangle();
+ Tester.doubleClick((int)(rect.x + xPercent * rect.width), (int) (rect.y + yPercent * rect.height));
+ }
+
+ public void rightClick(int x, int y) {
+ Rectangle rect = getValidScreenRectangle();
+ Tester.rightClick((int) rect.x + x, (int) rect.y + y);
+ }
+
+ public void drag(int fromX, int fromY, int toX, int toY) {
+ Rectangle rect = getValidScreenRectangle();
+ Tester.drag((int) rect.x + fromX, (int) rect.y + fromY, (int) rect.x + toX, (int) rect.y + toY);
+ }
+
+ /**
+ * Return the caption of control
+ *
+ * @return
+ */
+ public String getCaption() {
+ return (String) invoke(Constant.M_Caption);
+ }
+
+ /**
+ * Returns if the control is enabled
+ *
+ * @return Returns true if the control is enabled, otherwise false is
+ * returned.
+ */
+ public boolean isEnabled() {
+ return (Boolean) invoke(Constant.M_IsEnabled);
+ }
+
+ /**
+ * Returns if the control is checked
+ *
+ * @return Returns true if the control is enabled, otherwise false is
+ * returned.
+ */
+ public boolean isChecked() {
+ return (Boolean) invoke(Constant.M_IsChecked);
+ }
+
+ /**
+ * Return the count of fixed text in the control
+ *
+ * @return
+ */
+ protected int getFixedTextCount() {
+ return (Integer) invoke(Constant.M_GetFixedTextCount);
+
+ }
+
+ /**
+ * Return the fixed text in the control
+ *
+ * @param i
+ * the index of fixed text
+ * @return the text of fixed text
+ */
+ protected String getFixedText(int i) {
+ return (String) invoke(Constant.M_GetFixedText, new Object[] { new Integer(i + 1) });
+ }
+
+ /**
+ * Operate the control via VclHook
+ *
+ * @param methodId
+ * @param args
+ * @return
+ */
+ public Object invoke(int methodId, Object... args) {
+ return VclHook.invokeControl(getUID(), methodId, args);
+ }
+
+ /**
+ *
+ * @param methodId
+ * @return
+ */
+ public Object invoke(int methodId) {
+ return VclHook.invokeControl(getUID(), methodId, null);
+ }
+
+ /**
+ * Internal use
+ *
+ */
+ protected void useMenu() {
+ invoke(Constant.M_UseMenu);
+ }
+
+ /**
+ * TODO implement it. This is test tool implementation to input keyboard
+ * keys.
+ *
+ */
+ public void inputKeys(String keys) {
+ invoke(Constant.M_TypeKeys, new Object[] { keys });
+ }
+
+ /**
+ * Check if the control exists in a period of time
+ */
+ public boolean exists(double iTimeout) {
+ return exists(iTimeout, 1);
+ }
+
+ /**
+ * Check if the control exists in a period of time
+ */
+ public boolean exists(double iTimeout, double interval) {
+ return new Condition() {
+ @Override
+ public boolean value() {
+ return VclControl.this.exists();
+ }
+ }.test(iTimeout, interval);
+ }
+
+ /**
+ * Wait for the control to exist in a period of time. If the time is out, an
+ * ObjectNotFoundException will be throwed.
+ *
+ * @param iTimeout
+ * @param interval
+ */
+ public void waitForExistence(double iTimeout, double interval) {
+ new Condition() {
+ @Override
+ public boolean value() {
+ return VclControl.this.exists();
+ }
+ }.waitForTrue( this + " is not found!", iTimeout, interval);
+ }
+
+
+ public void waitForEnabled(double iTimeout, double interval) {
+ new Condition() {
+
+ @Override
+ public boolean value() {
+ return VclControl.this.isEnabled();
+ }
+
+ }.waitForTrue("Time out to wait the control to be enabled!", iTimeout, interval);
+ }
+
+ public void waitForDisabled(double iTimeout, double interval) {
+ new Condition() {
+
+ @Override
+ public boolean value() {
+ return !VclControl.this.isEnabled();
+ }
+
+ }.waitForTrue("Time out to wait the control to be disabled!", iTimeout, interval);
+ }
+
+ public void waitForText(final String text, double iTimeout, double interval) {
+ new Condition() {
+
+ @Override
+ public boolean value() {
+ return text.equals(VclControl.this.getCaption());
+ }
+
+ }.waitForTrue("Time out to wait the control to show the text: " + text, iTimeout, interval);
+ }
+
+
+ public int getType() {
+ if (type == -1)
+ type = ((Long) invoke(Constant.M_GetRT)).intValue();
+ return type;
+ }
+
+ /**
+ * Returns if the control exists
+ *
+ * @return Returns true if the control is existed, otherwise false is
+ * returned.
+ *
+ */
+ public boolean exists() {
+ // If the communication is not established. return false
+ try {
+ VclHook.getCommunicationManager().connect();
+ } catch (IOException e) {
+ return false;
+ }
+ return (Boolean) invoke(Constant.M_Exists);
+ }
+
+ public void focus() {
+ inputKeys("");
+ }
+
+ public Rectangle getScreenRectangle() {
+ String ret = (String) invoke(Constant.M_GetScreenRectangle, new Object[] { Boolean.FALSE });
+ if (ret == null)
+ return null;
+ String[] data = ret.split(",");
+ int x = Integer.parseInt(data[0]);
+ int y = Integer.parseInt(data[1]);
+ int w = Integer.parseInt(data[2]);
+ int h = Integer.parseInt(data[3]);
+ return new Rectangle(x, y, w, h);
+ }
+
+ public Rectangle getValidScreenRectangle() {
+ Rectangle rect = getScreenRectangle();
+ if (rect == null)
+ throw new RuntimeException(this + " - screen rectangle could not be computed! Maybe it is not showing!");
+ return rect;
+ }
+
+ public VclMenuItem menuItem(String path) {
+ return new VclMenuItem(new VclMenu(this), path);
+ }
+ /**
+ * Opens the context menu of the control.
+ * <p>
+ * The context menu opens at the position of the mouse.
+ * <p>
+ * To open the context menu at a specific position in a window, you have to
+ * first move the mouse to the position before using this method.
+ * <p>
+ *
+ * @param
+ */
+ public void openContextMenu() {
+ invoke(Constant.M_OpenContextMenu);
+ }
+
+
+ public String toString() {
+ if (uid != null)
+ return uid.toString();
+ else
+ return null;
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclDialog.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclDialog.java
new file mode 100644
index 000000000000..6d680d372746
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclDialog.java
@@ -0,0 +1,56 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+
+
+/**
+ * Proxy to access the VCL dialog
+ */
+public class VclDialog extends VclWindow {
+
+ /**
+ * Define the dialog with its string ID
+ * @param id
+ */
+ public VclDialog(String uid) {
+ super(uid);
+ }
+
+
+ public VclDialog(SmartId id) {
+ super(id);
+ }
+
+
+ /**
+ * Closes a dialog by pressing the Cancel button.
+ */
+ public void cancel() {
+ invoke(Constant.M_Cancel);
+ }
+
+ /**
+ * Closes a dialog with the Default button.
+ */
+ public void restoreDefaults() {
+ invoke(Constant.M_Default);
+ }
+
+ /**
+ * Closes a dialog with the OK button.
+ */
+ public void ok() {
+ invoke(Constant.M_OK);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclDockingWin.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclDockingWin.java
new file mode 100644
index 000000000000..052a069d8ae0
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclDockingWin.java
@@ -0,0 +1,58 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+
+
+/**
+ * Proxy used to access VCL Docking window
+ *
+ */
+public class VclDockingWin extends VclWindow {
+ /**
+ * Define VCL Docking window
+ * @param uid the string id
+ */
+ public VclDockingWin(String uid) {
+ super(uid);
+ }
+
+ public VclDockingWin(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Docks a window on one edge of the desktop.
+ */
+ public void dock() {
+ if (!isDocked())
+ invoke(Constant.M_Dock);
+ }
+
+ /**
+ * Undocks a docking window.
+ */
+ public void undock() {
+ if (isDocked())
+ invoke(Constant.M_Undock);
+ }
+
+ /**
+ * Returns the docking state.
+ * @return Returns TRUE if the window is docking, otherwise FALSE is
+ * returned.
+ */
+ public boolean isDocked() {
+ return (Boolean) invoke(Constant.M_IsDocked);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclEditBox.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclEditBox.java
new file mode 100644
index 000000000000..6d7d324df596
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclEditBox.java
@@ -0,0 +1,58 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ * Proxy used to access VCL EditField/MultiLineEditField
+ *
+ */
+public class VclEditBox extends VclControl {
+
+ /**
+ * Construct the control with its string ID
+ * @param uid
+ */
+ public VclEditBox(String uid) {
+ super(uid);
+ }
+
+ public VclEditBox(SmartId smartId) {
+ super(smartId);
+ }
+
+ /**
+ * Set the text of edit box
+ * @param str
+ */
+ public void setText(String str) {
+ invoke(Constant.M_SetText, new Object[]{str});
+ }
+
+
+ /**
+ * Is the edit box writable?
+ * @return true if it is writable, false otherwise
+ */
+ public boolean isWritable() {
+ return (Boolean)invoke(Constant.M_IsWritable);
+ }
+
+
+ /**
+ * Get the text of edit box
+ * @return the text of edit box
+ */
+ public String getText(){
+ return (String) invoke(Constant.M_GetText);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclField.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclField.java
new file mode 100644
index 000000000000..8f163187dae8
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclField.java
@@ -0,0 +1,64 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ * Proxy used to access all VCL field controls
+ *
+ */
+public class VclField extends VclEditBox{
+
+ public VclField(SmartId smartId) {
+ super(smartId);
+ }
+
+ /**
+ * Construct the field control with its string ID
+ * @param uid
+ */
+ public VclField(String uid) {
+ super(uid);
+ }
+
+ /**
+ * Move one entry higher of Field
+ *
+ */
+ public void more() {
+ invoke(Constant.M_More);
+ }
+
+ /**
+ * Move one entry lower of Field
+ *
+ */
+ public void less() {
+ invoke(Constant.M_Less);
+ }
+
+ /**
+ * Goes to the maximum value of Field
+ *
+ */
+ public void toMax() {
+ invoke(Constant.M_ToMax);
+ }
+
+
+ /**
+ * Goes to the minimum value of Field
+ */
+ public void toMin() {
+ invoke(Constant.M_ToMin);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclListBox.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclListBox.java
new file mode 100644
index 000000000000..13ce8ab5c19e
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclListBox.java
@@ -0,0 +1,184 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+
+public class VclListBox extends VclControl {
+
+ /**
+ * Construct the list box with its string ID
+ * @param uid
+ */
+ public VclListBox(String uid) {
+ super(uid);
+ }
+
+ public VclListBox(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Returns the number of entries in a TreeListBox.
+ *
+ * @return Number of list box entries. Error if the return value is -1.
+ */
+ public int getItemCount() {
+ return ((Long) invoke(Constant.M_GetItemCount)).intValue();
+ }
+
+ /**
+ * Get the text of the specified entry in the tree list box Notice:
+ * index,col starting from 0
+ *
+ * @param index
+ * @param col
+ * @return
+ */
+ public String getItemText(int index, int col) {
+ return (String) invoke(Constant.M_GetItemText, new Object[] { new Integer(index + 1), new Integer(col + 1) });
+ }
+
+ /**
+ * Get the text of the specified node Notice: index starting from 0
+ *
+ * @param index
+ * @return
+ */
+ public String getItemText(int index) {
+ return getItemText(index, 0);
+ }
+
+ /**
+ * Returns the number of selected entries in a TreeListbox(you can select
+ * more than one entry).
+ *
+ * @return The number of selected entries. Error is the return value is -1.
+ */
+ public int getSelCount() {
+ return ((Long) invoke(Constant.M_GetSelCount)).intValue();
+ }
+
+ /**
+ * Returns the index number of the selected entry in the TreeListBox.
+ * Notice: index starting from 0
+ *
+ * @return The index number of selected entries. Error is the return value
+ * is -1.
+ */
+ public int getSelIndex() {
+ return ((Long) invoke(Constant.M_GetSelIndex)).intValue() - 1;
+ }
+
+ /**
+ * Get the text of the selected item
+ */
+ public String getSelText() {
+ return (String) invoke(Constant.M_GetSelText);
+ }
+
+ /**
+ * Select the specified node via its index Notice: index starting from 0
+ *
+ * @param index
+ */
+ public void select(int index) {
+ invoke(Constant.M_Select, new Object[] { new Integer(index + 1) });
+ }
+
+ /**
+ * Selects the text of an entry.
+ *
+ * @param str
+ * the item string
+ */
+ public void select(String text) {
+ if (getType() == 324) {
+ int count = getItemCount();
+ for (int i = 0; i < count; i++) {
+ if (text.equals(getItemText(i))) {
+ select(i);
+ return;
+ }
+ }
+
+ throw new RuntimeException(text + " is not found in the list box");
+ } else {
+ invoke(Constant.M_Select, new Object[] { text });
+ }
+ }
+
+ /**
+ * Append one item to be selected after selected some items.
+ *
+ * @param i
+ * the index of the item
+ */
+ public void multiSelect(int i) {
+ invoke(Constant.M_MultiSelect, new Object[] { new Integer(i + 1) });
+ }
+
+ /**
+ * Append one item to be selected after selected some items.
+ *
+ * @param text
+ * the text of the item
+ */
+ public void multiSelect(String text) {
+ invoke(Constant.M_MultiSelect, new Object[] { text });
+ }
+
+ /**
+ * get all items'text.
+ *
+ */
+ public String[] getItemsText() {
+ int count = getItemCount();
+ String[] res = new String[count];
+ for (int i = 0; i < count; i++) {
+ res[i] = getItemText(i);
+ }
+ return res;
+ }
+
+ /**
+ *
+ * @param text
+ * @return
+ */
+ public int getItemIndex(String text) {
+ int count = getItemCount();
+ for (int i = 0; i < count; i++) {
+ if (text.equals(getItemText(i)))
+ return i;
+ }
+
+ throw new RuntimeException(text + " is not found in the list box");
+ }
+
+
+ /**
+ * Check if the list box has the specified item
+ *
+ * @param str
+ * @return
+ */
+ public boolean hasItem(String str) {
+ int len = getItemCount();
+ for (int i = 0; i < len; i++) {
+ String text = getItemText(i);
+ if (str.equals(text))
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenu.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenu.java
new file mode 100644
index 000000000000..1643ef50ead2
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenu.java
@@ -0,0 +1,70 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.VclHook;
+
+/**
+ * Define VCL menu on a window
+ *
+ */
+public class VclMenu {
+
+ private VclControl window = null;
+
+ /**
+ * Construct the popup menu
+ *
+ */
+ public VclMenu() {
+
+ }
+
+ /**
+ * Construct the menu on the given window
+ *
+ * @param window
+ */
+ public VclMenu(VclControl window) {
+ this.window = window;
+ }
+
+ /**
+ * Returns the numbers of menu items (including the menu separators)
+ *
+ * @return Number of menu items in a menu . -1 : Return value error
+ *
+ */
+ public int getItemCount() {
+ use();
+ return ((Long) VclHook.invokeCommand(Constant.RC_MenuGetItemCount)).intValue();
+ }
+
+ /**
+ * Return the menu item at the n-th index
+ *
+ * @param index
+ * @return null when the item is separator
+ */
+ public VclMenuItem getItem(int index) {
+ use();
+ long id = ((Long) VclHook.invokeCommand(Constant.RC_MenuGetItemId, new Object[] { new Integer(index + 1) })).intValue();
+ if (id == 0)
+ return null;
+ return new VclMenuItem(this, (int) id);
+ }
+
+ protected void use() {
+ if (window != null) {
+ window.useMenu();
+ }
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenuItem.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenuItem.java
new file mode 100644
index 000000000000..e06d5ec339d5
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMenuItem.java
@@ -0,0 +1,242 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.common.SystemUtil;
+import org.openoffice.test.vcl.Tester;
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.VclHook;
+
+/**
+ *
+ */
+public class VclMenuItem {
+
+ private int id = -1;
+
+ private String[] path = null;
+
+ private VclMenu menu = null;
+
+ /**
+ * Construct menu item with its ID
+ *
+ * @param id
+ */
+ public VclMenuItem(int id) {
+ this.id = id;
+ }
+
+ /**
+ * Construct menu item with its path like
+ * "RootMenuItem->Level1Item->Level2Item".
+ *
+ * @param path
+ */
+ public VclMenuItem(String path) {
+ this.path = path.split("->");
+ }
+
+ /**
+ * Vcl Menu Item on menu bar
+ *
+ * @param menu
+ * @param id
+ */
+ public VclMenuItem(VclMenu menu, int id) {
+ this.id = id;
+ this.menu = menu;
+ }
+
+ /**
+ * Vcl Menu Item on menu bar
+ *
+ * @param menu
+ * @param path
+ */
+ public VclMenuItem(VclMenu menu, String path) {
+ this.path = path.split("->");
+ this.menu = menu;
+ }
+
+ private Object invoke(int methodId) {
+ int id = getId();
+ if (id == -1)
+ throw new RuntimeException("Menu item '" + path[path.length - 1] + "' can be found!");
+ return VclHook.invokeCommand(methodId, new Object[] { id });
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getId() {
+ VclMenu menu = new VclMenu();
+ if (path != null) {
+ int count = menu.getItemCount();
+ for (int i = 0; i < count; i++) {
+ VclMenuItem item = menu.getItem(i);
+ if (item == null)
+ continue;
+ String itemText = path[path.length - 1];
+ if (item.getTextWithoutMneumonic().contains(itemText)) {
+ return item.getId();
+ }
+ }
+
+ return -1;
+ }
+
+ return this.id;
+ }
+
+ /**
+ * Select the menu item
+ *
+ */
+ public void select() {
+ if (menu != null)
+ menu.use();
+ for (int i = 0; i < path.length; i++) {
+ new VclMenuItem(path[i]).pick();
+ Tester.sleep(0.5);
+ }
+ }
+
+ private void pick() {
+ invoke(Constant.RC_MenuSelect);
+ }
+
+ /**
+ * Select the parent of the item
+ *
+ */
+ public void selectParent() {
+ if (menu != null)
+ menu.use();
+ for (int i = 0; i < path.length - 1; i++)
+ new VclMenuItem(path[i]).pick();
+ }
+
+ /**
+ * Check if the menu item exists
+ *
+ * @return
+ */
+ public boolean exists() {
+ return getId() != -1;
+ }
+
+ /**
+ * Check if the menu item is selected!
+ *
+ * @return
+ */
+ public boolean isSelected() {
+ return ((Boolean) invoke(Constant.RC_MenuIsItemChecked)).booleanValue();
+ }
+
+ /**
+ * Check if the menu item is enabled
+ *
+ * @return
+ */
+ public boolean isEnabled() {
+ return ((Boolean) invoke(Constant.RC_MenuIsItemEnabled)).booleanValue();
+ }
+
+ /**
+ * Get the menu item position
+ *
+ * @return
+ */
+ public int getPosition() {
+ return ((Long) invoke(Constant.RC_MenuGetItemPos)).intValue();
+ }
+
+ /**
+ * Get the menu item text
+ *
+ * @return
+ */
+ public String getText() {
+ return (String) invoke(Constant.RC_MenuGetItemText);
+ }
+
+ /**
+ * Get the command id which is UNO-Slot
+ *
+ * @return
+ */
+ public String getCommand() {
+ return (String) invoke(Constant.RC_MenuGetItemCommand);
+ }
+
+ /**
+ * Get the accelerator character
+ */
+ public int getAccelerator() {
+ String text = this.getText();
+ if (text == null)
+ return 0;
+ int index = text.indexOf("~");
+ return index != -1 && index + 1 < text.length() ? text.charAt(index + 1) : 0;
+ }
+
+ /**
+ * Get text without mneumonic
+ */
+ public String getTextWithoutMneumonic() {
+ String text = this.getText();
+ return text != null ? text.replace("~", "") : text;
+ }
+
+ /**
+ * Check if the menu item is showing
+ */
+ public boolean isShowing() {
+ return exists();
+ }
+
+ /**
+ * Check if the menu item has sub menu
+ *
+ * @return
+ */
+ public boolean hasSubMenu() {
+ return (Boolean) invoke(Constant.RC_MenuHasSubMenu);
+ }
+
+ public String toString() {
+ return "ID:" + getId() + ", Text:" + getText() + ", Selected:" + isSelected() + ", Enabled:" + isEnabled() + ", Command:" + getCommand()
+ + ", Position:" + getPosition();
+ }
+
+ /**
+ * Check if the widget exists in a period of time
+ */
+ public boolean exists(double iTimeout) {
+ return exists(iTimeout, 1);
+ }
+
+ /**
+ * Check if the widget exists in a period of time
+ */
+ public boolean exists(double iTimeout, double interval) {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < iTimeout * 1000) {
+ if (exists())
+ return true;
+ SystemUtil.sleep(interval);
+ }
+
+ return exists();
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMessageBox.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMessageBox.java
new file mode 100644
index 000000000000..39c4f46ffcbc
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclMessageBox.java
@@ -0,0 +1,166 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+import org.openoffice.test.vcl.client.VclHookException;
+
+/**
+ * VCL message box proxy.
+ *
+ */
+public class VclMessageBox extends VclControl {
+
+ private String message = null;
+
+
+ public VclMessageBox(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Construct the active message box with a given message.
+ * The message can be used to distinguish message boxes.
+ * @param msg
+ */
+ public VclMessageBox(SmartId id, String msg) {
+ super(id);
+ this.message = msg;
+ }
+
+ public VclMessageBox(String id, String msg) {
+ super(id);
+ this.message = msg;
+ }
+
+ /**
+ * Get the message on the message box
+ * @return
+ */
+ public String getMessage() {
+ return (String) invoke(Constant.M_GetText);
+ }
+
+ public boolean exists() {
+ try {
+ boolean exists = super.exists();
+ if (!exists)
+ return false;
+
+ if (WINDOW_MESSBOX != getType())
+ return false;
+
+ if (message != null) {
+ String msg = getMessage();
+ return msg.contains(message);
+ }
+
+ return true;
+ } catch (VclHookException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Click the yes button on the message box
+ *
+ */
+ public void yes(){
+ invoke(Constant.M_Yes);
+ }
+
+ /**
+ * Click the no button on the message box
+ *
+ */
+ public void no(){
+ invoke(Constant.M_No);
+ }
+
+
+ /**
+ * Closes a dialog by pressing the Cancel button.
+ */
+ public void cancel() {
+ invoke(Constant.M_Cancel);
+ }
+
+ /**
+ * Closes a dialog with the Close button.
+ */
+ public void close() {
+ invoke(Constant.M_Close);
+ }
+
+ /**
+ * Closes a dialog with the Default button.
+ */
+ public void doDefault() {
+ invoke(Constant.M_Default);
+ }
+
+ /**
+ * Presses the Help button to open the help topic for the dialog.
+ *
+ */
+ public void help() {
+ invoke(Constant.M_Help);
+ }
+
+ /**
+ * Closes a dialog with the OK button.
+ */
+ public void ok() {
+ invoke(Constant.M_OK);
+ }
+
+
+ /**
+ * Closes a dialog with the OK button.
+ */
+ public void repeat() {
+ invoke(Constant.M_Repeat);
+ }
+
+ /**
+ * Get the check box text if it exists
+ *
+ * @return the check box text
+ */
+ public String getCheckBoxText() {
+ return (String) invoke(Constant.M_GetCheckBoxText);
+ }
+
+ /**
+ * Get the status of check box on the message box
+ * @return
+ */
+ public boolean isChecked() {
+ return (Boolean) invoke(Constant.M_IsChecked);
+ }
+
+ /**
+ * Check the check box on the message box
+ *
+ */
+ public void check() {
+ invoke(Constant.M_Check);
+ }
+
+ /**
+ * Uncheck the check box on the message box
+ *
+ */
+ public void uncheck() {
+ invoke(Constant.M_UnCheck);
+ }
+
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclStatusBar.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclStatusBar.java
new file mode 100644
index 000000000000..a2f4aced2436
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclStatusBar.java
@@ -0,0 +1,71 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ * VCL status bar proxy
+ *
+ */
+public class VclStatusBar extends VclControl {
+
+ public VclStatusBar(SmartId id) {
+ super(id);
+ }
+
+ public VclStatusBar(String uid) {
+ super(uid);
+ }
+
+ /**
+ * Get the text of the item with the given ID
+ * @param id
+ * @return
+ */
+ public String getItemTextById(int id) {
+ return (String) invoke(Constant.M_StatusGetText, new Object[]{id});
+ }
+
+ /**
+ * Get the text of the item at the given index
+ * @param i
+ * @return
+ */
+ public String getItemText(int i) {
+ return getItemTextById(getItemId(i));
+ }
+
+ /**
+ * Get the item count
+ * @return
+ */
+ public int getItemCount() {
+ return ((Long) invoke(Constant.M_StatusGetItemCount)).intValue();
+ }
+
+ /**
+ * Get the item ID at the given index
+ * @param i
+ * @return
+ */
+ public int getItemId(int i) {
+ return ((Long) invoke(Constant.M_StatusGetItemId, new Object[]{i + 1})).intValue();
+ }
+
+ /**
+ * Check if the status box is progress box.
+ * @return
+ */
+ public boolean isProgress() {
+ return (Boolean) invoke(Constant.M_StatusIsProgress);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabControl.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabControl.java
new file mode 100644
index 000000000000..630e05ffe658
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabControl.java
@@ -0,0 +1,111 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ * Proxy to access VCL tab control
+ *
+ */
+public class VclTabControl extends VclControl {
+
+ /**
+ * Construct the tab folder with its string ID
+ * @param uid
+ */
+ public VclTabControl(String uid) {
+ super(uid);
+ }
+
+ public VclTabControl(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Get the current page
+ * @return
+ */
+ public int getPage() {
+ return ((Long) invoke(Constant.M_GetPage)).intValue();
+ }
+
+ /**
+ * Returns the number of tab pages in the TabControl.
+ * <p>
+ *
+ * @return number of tab pages in the dialog. -1 : Return value error
+ * <p>
+ */
+ public int getPageCount() {
+ return ((Long) invoke(Constant.M_GetPageCount)).intValue();
+ }
+
+ /**
+ * Returns the TabpageID of current Tab Page in the Tab dialog. This not the
+ * UniqueID and is only needed for the SetPageID instruction..
+ * <p>
+ *
+ * @return TabpageID used in SetPageID instruction; -1 : Return value error
+ * <p>
+ */
+ public int getPageId() {
+ return ((Long) invoke(Constant.M_GetPageId)).intValue();
+ }
+
+ /**
+ * Returns the TabpageID of specified Tab page in the Tab dialog. This not
+ * the UniqueID and is only needed for the SetPageID instruction..
+ * <p>
+ *
+ * @param nTabID :
+ * Specified Tab Page which order from 1. eg. A tab dialog have
+ * two Tab pages, nTabID is 2 if you want to get the TabpageID of
+ * second Tab page
+ * @return TabpageID used in SetPageID instruction; -1 : Return value error
+ * <p>
+ */
+ public int getPageId(short nTabID) {
+ return ((Long) invoke(Constant.M_GetPageId, new Object[] { nTabID }))
+ .intValue();
+ }
+
+ /**
+ * Changes to the tab page that has the TabpageID that you specify.
+ * <p>
+ *
+ * @param id
+ * TabpageID of tab page
+ */
+ public void setPageId(int id) {
+ invoke(Constant.M_SetPageId, new Object[] { id });
+ }
+
+ /**
+ * Change to the tab page you specify
+ * <p>
+ *
+ * @param nTabResID
+ * The resource ID of the specified Tab page in Tab Dialog
+ */
+ public void setPage(long nTabResID) {
+ invoke(Constant.M_SetPage, new Object[] { nTabResID });
+ }
+
+ /**
+ * Change to the specified tab page
+ * @param widget the TabPage widget (Type: 372)
+ * @throws Exception
+ */
+ public void setPage(VclControl widget) {
+ setPage(widget.getUID().getId());
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabPage.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabPage.java
new file mode 100644
index 000000000000..1c492daea620
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTabPage.java
@@ -0,0 +1,38 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.SmartId;
+
+
+public class VclTabPage extends VclDialog {
+
+ private VclTabControl tabControl = null;
+
+ public VclTabPage(SmartId id, VclTabControl tabControl) {
+ super(id);
+ this.tabControl = tabControl;
+ }
+
+ public VclTabPage(String uid, VclTabControl tabControl) {
+ super(uid);
+ this.tabControl = tabControl;
+ }
+
+
+ /**
+ * Selects the tab page to be active.
+ *
+ */
+ public void select() {
+ if (tabControl != null)
+ tabControl.setPage(this.getUID().getId());
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclToolBox.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclToolBox.java
new file mode 100644
index 000000000000..0cb042e9763d
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclToolBox.java
@@ -0,0 +1,87 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+
+/**
+ * Proxy to access the VCL tool box
+ *
+ * Type: WINDOW_TOOLBOX
+ *
+ */
+public class VclToolBox extends VclDockingWin {
+
+ public VclToolBox(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Define a vcl tool bar
+ * @param uid the string id
+ */
+ public VclToolBox(String uid) {
+ super(uid);
+ }
+
+ /**
+ * Click the down arrow of tool bar to show the menu
+ *
+ */
+ public void openMenu() {
+ invoke(Constant.M_OpenContextMenu);
+ }
+
+ /**
+ * Returns the count of items in the tool bar
+ *
+ * @return the count
+ */
+ public int getItemCount() {
+ return ((Long) invoke(Constant.M_GetItemCount)).intValue();
+ }
+
+ /**
+ * Get the text of the index-th item
+ * @param index
+ * @return
+ */
+ public String getItemText(int index) {
+ return (String) invoke(Constant.M_GetItemText2, new Object[] {index + 1});
+ }
+
+ /**
+ * Get the quick tooltip text of the index-th item
+ * @param index
+ * @return
+ */
+ public String getItemQuickToolTipText(int index) {
+ return (String) invoke(Constant.M_GetItemQuickHelpText, new Object[] {index + 1});
+ }
+
+ /**
+ * Get the tooltip text of the index-th item
+ * @param index
+ * @return
+ */
+ public String getItemToolTipText(int index) {
+ return (String) invoke(Constant.M_GetItemHelpText, new Object[] {index + 1});
+ }
+
+ /**
+ * Get the name of the next tool bar
+ * @return
+ */
+ public String getNextToolBar() {
+ return (String) invoke(Constant.M_GetNextToolBox);
+ }
+}
diff --git a/test/testcommon/source/org/openoffice/test/vcl/widgets/VclWindow.java b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclWindow.java
new file mode 100644
index 000000000000..6bb933831fc7
--- /dev/null
+++ b/test/testcommon/source/org/openoffice/test/vcl/widgets/VclWindow.java
@@ -0,0 +1,128 @@
+/************************************************************************
+ *
+ * Licensed Materials - Property of IBM.
+ * (C) Copyright IBM Corporation 2003, 2012. All Rights Reserved.
+ * U.S. Government Users Restricted Rights:
+ * Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+ *
+ ************************************************************************/
+
+package org.openoffice.test.vcl.widgets;
+
+import java.awt.Point;
+
+import org.openoffice.test.vcl.client.Constant;
+import org.openoffice.test.vcl.client.SmartId;
+
+/**
+ * Proxy to access a VCL window.
+ *
+ */
+public class VclWindow extends VclControl {
+
+ /**
+ * Define a VCL window
+ * @param uid the string id
+ */
+ public VclWindow(String uid) {
+ super(uid);
+ }
+
+ public VclWindow(SmartId id) {
+ super(id);
+ }
+
+ /**
+ * Get the title of the window
+ * @return
+ */
+ public String getText() {
+ return getCaption();
+ }
+
+ /**
+ * Presses the Help button to open the help topic for the window
+ *
+ */
+ public void help() {
+ invoke(Constant.M_Help);
+ }
+
+ /**
+ * Closes a window with the Close button.
+ */
+ public void close() {
+ invoke(Constant.M_Close);
+ }
+
+ /**
+ * Move the window by percent
+ *
+ * @param x
+ * @param y
+ */
+ public void move(int x, int y) {
+ invoke(Constant.M_Move, new Object[]{new Integer(x), new Integer(y)});
+ }
+
+ /**
+ * Move the window by pixel
+ * @param p
+ */
+ public void move(Point p) {
+ move(p.x, p.y);
+ }
+
+
+
+ /**
+ * Returns the state of the window (maximize or minimize).
+ * <p>
+ *
+ * @return Returns TRUE if the window is maximized, otherwise FALSE is
+ * returned.
+ */
+ public boolean isMax() {
+ return (Boolean)invoke(Constant.M_IsMax);
+ }
+
+ /**
+ * Maximizes a window so that the contents of the window are visible.
+ */
+ public void maximize() {
+ invoke(Constant.M_Maximize);
+ }
+
+ /**
+ * Minimizes a window so that only the title bar of the window is visible
+ */
+ public void minimize() {
+ invoke(Constant.M_Minimize);
+ }
+
+
+ /**
+ * Resize the window
+ * @param x
+ * @param y
+ */
+ public void resize(int x, int y) {
+ invoke(Constant.M_Size, new Object[]{new Integer(x), new Integer(y)});
+ }
+
+ /**
+ * Restore the window
+ *
+ */
+ public void restore() {
+ invoke(Constant.M_Restore);
+ }
+
+ /**
+ * Activate the window
+ */
+ public void activate() {
+ // focus it
+ focus();
+ }
+}