incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1368324 - in /incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test: OpenOffice.java vcl/Tester.java vcl/client/Constant.java vcl/widgets/VclTreeListBox.java
Date Thu, 02 Aug 2012 00:40:23 GMT
Author: liuzhe
Date: Thu Aug  2 00:40:23 2012
New Revision: 1368324

URL: http://svn.apache.org/viewvc?rev=1368324&view=rev
Log:
#120384# - Create VclTreeListBox for WINDOW_TREELISTBOX controls. 
Patch By: Li Lin Yi
Review By: Liu Zhe

Added:
    incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTreeListBox.java
Modified:
    incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/OpenOffice.java
    incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/Tester.java
    incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java

Modified: incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/OpenOffice.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/OpenOffice.java?rev=1368324&r1=1368323&r2=1368324&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/OpenOffice.java (original)
+++ incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/OpenOffice.java Thu
Aug  2 00:40:23 2012
@@ -121,14 +121,14 @@ public class OpenOffice {
 		
 		versionProps = FileUtil.loadProperties(versionFile);
 		addArgs(id);
-		addArgs("-nofirststartwizard", "-norestore", "-quickstart=no");
-		addRegistryModifications("<item oor:path=\"/org.openoffice.Office.Common/Misc\"><prop
oor:name=\"UseSystemFileDialog\" oor:op=\"fuse\"><value>false</value></prop></item>",
-				"<item oor:path=\"/org.openoffice.Office.Common/Security/Scripting\"><prop oor:name=\"MacroSecurityLevel\"
oor:op=\"fuse\"><value>0</value></prop></item>");
 	}
 
 	public static OpenOffice getDefault() {
 		if (defaultInstance == null) {
 			defaultInstance = new OpenOffice();
+			defaultInstance.addArgs("-nofirststartwizard", "-norestore", "-quickstart=no");
+			defaultInstance.addRegistryModifications("<item oor:path=\"/org.openoffice.Office.Common/Misc\"><prop
oor:name=\"UseSystemFileDialog\" oor:op=\"fuse\"><value>false</value></prop></item>",
+					"<item oor:path=\"/org.openoffice.Office.Common/Security/Scripting\"><prop
oor:name=\"MacroSecurityLevel\" oor:op=\"fuse\"><value>0</value></prop></item>");
 		}
 
 		return defaultInstance;
@@ -230,6 +230,7 @@ public class OpenOffice {
 	public void kill() {
 		SystemUtil.killProcess(".*soffice.*" + id + ".*");
 		process = null;
+		SystemUtil.sleep(1);
 	}
 
 	/**

Modified: incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/Tester.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/Tester.java?rev=1368324&r1=1368323&r2=1368324&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/Tester.java (original)
+++ incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/Tester.java Thu
Aug  2 00:40:23 2012
@@ -40,7 +40,7 @@ public class Tester {
 	static {
 		try {
 			robot = new Robot();
-		    robot.setAutoDelay(5);
+		    robot.setAutoDelay(10);
 		    robot.setAutoWaitForIdle(true);
 		} catch (AWTException e) {
 			e.printStackTrace();

Modified: incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java?rev=1368324&r1=1368323&r2=1368324&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java
(original)
+++ incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/client/Constant.java
Thu Aug  2 00:40:23 2012
@@ -362,6 +362,10 @@ public interface Constant {
 	public static final char M_IsEditing = (M_WITH_RETURN | 58);
 
 	public static final char M_IsItemEnabled = (M_WITH_RETURN | 59);
+	
+	// For TreeListBox
+	public static final char M_Collapse = (M_WITH_RETURN | 60);
+	public static final char M_Expand = (M_WITH_RETURN | 61);
 
 	// Symphony Special
 	public static final char M_GetHelpText = (M_WITH_RETURN | 90);

Added: incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTreeListBox.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTreeListBox.java?rev=1368324&view=auto
==============================================================================
--- incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTreeListBox.java
(added)
+++ incubator/ooo/trunk/main/test/testcommon/source/org/openoffice/test/vcl/widgets/VclTreeListBox.java
Thu Aug  2 00:40:23 2012
@@ -0,0 +1,387 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+
+
+package org.openoffice.test.vcl.widgets;
+import org.openoffice.test.vcl.client.Constant;
+
+
+public class VclTreeListBox extends VclControl {
+
+	/**
+	 * Construct the tree with its String ID
+	 * @param id
+	 */
+	public VclTreeListBox(String id) {
+		super(id);
+	}
+	
+	
+	public VclTreeListBox(VclApp app, String id) {
+		super(app, id);
+	}
+
+	/**
+	 * Returns the number of entries in a TreeListBox. Namely all the expanded node.
+	 * 
+	 * @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. <br>
+	 * In some tree list box, there is a hidden column, so if you can get the item text, pls
add 1 to the column
+	 * @param row
+	 * @param col
+	 * @return
+	 */
+	public String getItemText(int row, int col) {
+		return (String) invoke(Constant.M_GetItemText, new Object[]{row + 1, col + 1});
+	}
+
+	/**
+	 * Returns the text of the first string column of the row at the given index
+	 * Notice: index starting from 0
+	 * @param index
+	 * @return
+	 */
+	public String getItemText(int index) {
+		return (String) invoke(Constant.M_GetItemText, new Object[] {index + 1});
+	}
+	
+	/**
+	 * 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() {
+		int index = ((Long) invoke(Constant.M_GetSelIndex)).intValue();
+		return index - 1;
+	}
+
+	/**
+	 * Returns the text of the first string column of the first selected entry
+	 * 
+	 * @return
+	 */
+	public String getSelText() {
+		return (String) invoke(Constant.M_GetSelText, new Object[]{1});
+	}
+
+	/**
+	 * Returns the text of the n-th column of the first selected entry.
+	 * If the column is not a string, a VCLException will be throwed.
+	 * @param col the column index starting from 0
+	 * @return
+	 */
+	public String getSelText(int col) {
+		return (String) invoke(Constant.M_GetSelText, new Object[]{col + 1});	
+	}
+
+	/**
+	 * Returns the text of the n-th column of the n-th selected entry.
+	 * @param index the selected entry index  starting from 0
+	 * @param col the column index  starting from 0
+	 * @return
+	 */
+	public String getSelText(int index, int col) {
+		return invoke(Constant.M_GetSelText, new Object[]{(index + 1), (col + 1)}).toString();
+	}
+
+	
+	/**
+	 * Select the entry at the given index
+	 * @param index starting from 0
+	 */
+	public void select(int index) {
+		invoke(Constant.M_Select, new Object[]{index+1});
+	}
+
+	/**
+	 * Unselect the entry at the given index
+	 * @param index starting from 0
+	 */
+	public void unselect(int index) {
+		invoke(Constant.M_Select, new Object[]{index + 1, false});
+	}
+	
+	/**
+	 * Collapse the specified entry
+	 * Notice: index starting from 0
+	 * @param index the node index
+	 */
+	public void collapse(int index) {
+//		select(index);
+//		Tester.typeKeys("<left>");
+		invoke(Constant.M_Collapse, new Object[]{index + 1, false});
+	}
+	
+	/**
+	 * Expand the specified entry
+	 * Notice: index starting from 0
+	 * @param index the entry index
+	 */
+	public void expand(int index) {
+//		select(index);
+//		Tester.typeKeys("<right>");
+		invoke(Constant.M_Expand, new Object[]{index + 1, false});
+	}
+	
+    /** 
+     * Select the node via its text
+     * @param str
+     * @return the index of the node
+     */
+    public void select(String str) {
+    	select(str, 0);
+	}
+    
+    /**
+     * Select the entry with the given string and after the given index
+     * @param str
+     * @param start
+     */
+    public void select(String str, int start) {
+    	int len = getItemCount();
+		for (int i = start; i < len; i++) {
+			String text = getItemText(i);
+			if (str.equals(text)) {
+				select(i);
+				return;
+			}
+		}
+    	throw new RuntimeException(str + " is not found in the tree");
+    }
+    
+    
+	/**
+	 * Return the text of all items 
+	 * @return A String[] includes all items text
+	 */
+	public String[] getAllItemsText() {
+		int len = getItemCount();
+		String[] ret = new String[len];
+		for (int i = 0; i < len; i++) {
+			ret[i] = getItemText(i);
+		}
+		return ret;
+	}
+	
+	/**
+	 * 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;
+	}
+	/**
+	 * 
+	 * @return
+	 */
+	public boolean isChecked(int row) {
+		return ((Boolean)invoke(Constant.M_IsChecked, new Object[]{new Integer(row+1)})).booleanValue();
+	}
+	
+	public boolean isChecked(int row, int col) {
+		return ((Boolean)invoke(Constant.M_IsChecked, new Object[]{new Integer(row+1), new Integer(col+1)})).booleanValue();
+	}
+	
+	/**
+	 * @param 
+	 * @return
+	 */
+	public boolean isShowing(String str) {
+		boolean ret = false;
+		int len = getItemCount();
+		for (int i = 0; i < len; i++) {
+			String text = getItemText(i);
+			if (str.equals(text)) {
+				ret = true;
+			}
+		}
+		return ret;
+	}
+	
+	/**
+	 * Check if the selected node is tristate
+	 * @return
+	 */
+	public boolean isTristate(int row) {
+		return ((Boolean)invoke(Constant.M_IsTristate, new Object[]{new Integer(row+1)})).booleanValue();
+	}
+	
+	public boolean isTristate(int row, int col) {
+		return ((Boolean)invoke(Constant.M_IsTristate, new Object[]{new Integer(row+1), new Integer(col+1)})).booleanValue();
+	}
+	
+	/**
+	 * Check if the selected node is tristate
+	 * @return
+	 */
+	public boolean isTristate() {
+		return ((Boolean)invoke(Constant.M_IsTristate)).booleanValue();
+	}
+	
+	/**
+	 * Get the state of the selected node
+	 * @return
+	 */
+	public int getState() {
+		return ((Long)invoke(Constant.M_GetState)).intValue();
+	}
+	
+	/**
+	 * Get the state of the selected node
+	 * @return
+	 */
+	public int getState(int row) {
+		return ((Long)invoke(Constant.M_GetState, new Object[]{new Integer(row+1)})).intValue();
+	}
+	
+	public int getState(int row, int col) {
+		return ((Long)invoke(Constant.M_GetState, new Object[]{new Integer(row+1), new Integer(col+1)})).intValue();
+	}
+	
+	/**
+	 * check the selected node 
+	 *
+	 */
+	public void check()  {
+		invoke(Constant.M_Check);
+	}
+	
+	public void check(int row)  {
+		invoke(Constant.M_Check, new Object[]{new Integer(row+1)});
+	}
+	
+	public void check(int row, int col)  {
+		invoke(Constant.M_Check, new Object[]{new Integer(row+1), new Integer(col+1)});
+	}
+	
+	/**
+	 * uncheck the selected node
+	 *
+	 */
+	public void unCheck() {
+		invoke(Constant.M_UnCheck);
+	}
+	
+	public void unCheck(int row) {
+		invoke(Constant.M_UnCheck, new Object[]{new Integer(row+1)});
+	}
+	
+	public void unCheck(int row, int col) {
+		invoke(Constant.M_UnCheck, new Object[]{new Integer(row+1), new Integer(col+1)});
+	}
+	
+	/**
+	 * Set the selected node to tristate
+	 *
+	 */
+    public void triState() {
+    	invoke(Constant.M_TriState);
+	}
+    
+    
+    public void triState(int row) {
+    	invoke(Constant.M_TriState, new Object[]{new Integer(row+1)});
+	}
+    
+    public void triState(int row, int col) {
+    	invoke(Constant.M_TriState, new Object[]{new Integer(row+1), new Integer(col+1)});
+	}
+    
+    /**
+	 * Collapse all nodes in the tree list box.
+	 *
+	 */
+	public void collapseAll() {//?after expandAll, can not collapse the first node
+		for (int i = 0; i <  getItemCount(); i++) {
+			collapse(i);
+		}
+	}
+	
+	/**
+	 * Expand all nodes in the tree list box
+	 *
+	 */
+	public void expandAll() {
+		for (int i = 0; i <  getItemCount(); i++) {
+			expand(i);
+		}
+	}
+	
+	/**
+	 * Select the specified node by path. 
+	 * @param path The node path likes "Node1->Node2->Node3"
+	 * @return true if the node exists, false otherwise
+	 */
+	public void selectByPath(String path) {
+		collapseAll();
+		String[] items = path.split("->");
+		int i = 0;
+		for (String s : items) {
+			int len = getItemCount();
+			for (; i < len; i++) {
+				String text = getItemText(i);
+				if (s.equals(text)) {
+					expand(i);
+					break;
+				}
+			}
+			if (i == len) {
+				throw new RuntimeException("Menu item '" + path + "' is not found in the tree");
+			}
+		}
+	}
+	
+	/**
+	 * Get the column type of the given row
+	 * @param row
+	 * @param col
+	 * @return
+	 */
+	public int getItemType(int row, int col) {
+		return (Integer)invoke(Constant.M_GetItemType, new Object[]{row + 1, col + 1});
+	}
+}



Mime
View raw message