From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../tests/java/ifc/awt/tree/_TreeControlModel.java | 28 + .../java/ifc/awt/tree/_XMutableTreeDataModel.java | 90 +++ .../tests/java/ifc/awt/tree/_XMutableTreeNode.java | 285 +++++++++ .../tests/java/ifc/awt/tree/_XTreeControl.java | 640 +++++++++++++++++++++ .../tests/java/ifc/awt/tree/_XTreeDataModel.java | 171 ++++++ qadevOOo/tests/java/ifc/awt/tree/_XTreeNode.java | 259 +++++++++ 6 files changed, 1473 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/awt/tree/_TreeControlModel.java create mode 100644 qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeDataModel.java create mode 100644 qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeNode.java create mode 100644 qadevOOo/tests/java/ifc/awt/tree/_XTreeControl.java create mode 100644 qadevOOo/tests/java/ifc/awt/tree/_XTreeDataModel.java create mode 100644 qadevOOo/tests/java/ifc/awt/tree/_XTreeNode.java (limited to 'qadevOOo/tests/java/ifc/awt/tree') diff --git a/qadevOOo/tests/java/ifc/awt/tree/_TreeControlModel.java b/qadevOOo/tests/java/ifc/awt/tree/_TreeControlModel.java new file mode 100644 index 000000000..2cf028c07 --- /dev/null +++ b/qadevOOo/tests/java/ifc/awt/tree/_TreeControlModel.java @@ -0,0 +1,28 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + +package ifc.awt.tree; + +import lib.MultiPropertyTest; + +/* +* Testing com.sun.star.awt.tree.TreeControlModel +* service properties
+* @see com.sun.star.awt.tree.TreeControlModel +*/ +public class _TreeControlModel extends MultiPropertyTest { } diff --git a/qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeDataModel.java b/qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeDataModel.java new file mode 100644 index 000000000..5b5976055 --- /dev/null +++ b/qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeDataModel.java @@ -0,0 +1,90 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + +package ifc.awt.tree; + +import com.sun.star.awt.tree.XMutableTreeDataModel; +import com.sun.star.awt.tree.XMutableTreeNode; +import lib.MultiMethodTest; + +/** +* Testing com.sun.star.awt.tree.XMutableTreeDataModel +* interface methods : +*

+* Test is NOT multithread compliant.

+ +* @see com.sun.star.awt.tree.XMutableTreeDataModel +*/ +public class _XMutableTreeDataModel extends MultiMethodTest { + + public XMutableTreeDataModel oObj = null; + + private XMutableTreeNode mNewNode = null; + + /** + * Sets the title to some string.

+ * Has OK status if no runtime exceptions occurs. + */ + public void _createNode() { + + mNewNode = oObj.createNode("Hallo Welt", true); + + tRes.tested("createNode()", true) ; + } + + /** + * Gets the title and compares it to the value set in + * setTitle method test.

+ * Has OK status is set/get values are equal. + * The following method tests are to be completed successfully before : + *

+ */ + public void _setRoot() { + requiredMethod("createNode()") ; + + boolean bOK = true; + try { + + oObj.setRoot(mNewNode); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: while trying to set a new root an IllegalArgumentException was thrown:\n" + ex.toString()); + } + + try { + + oObj.setRoot(null); + bOK = false; + log.println("ERROR: while trying to set a null object as root expected IllegalArgumentException was not thrown."); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected IllegalArgumentException was thrown => ok"); + + } + + tRes.tested("setRoot()", bOK); + + } + +} + + diff --git a/qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeNode.java b/qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeNode.java new file mode 100644 index 000000000..76c7e6cac --- /dev/null +++ b/qadevOOo/tests/java/ifc/awt/tree/_XMutableTreeNode.java @@ -0,0 +1,285 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + +package ifc.awt.tree; + +import com.sun.star.awt.tree.XMutableTreeNode; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Testing com.sun.star.awt.tree.XTreeDataModel + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * + * @see com.sun.star.awt.tree.XTreeDataModel + */ +public class _XMutableTreeNode extends MultiMethodTest { + + public XMutableTreeNode oObj = null; + + private XMutableTreeNodeCreator nodeCreator = null; + + public interface XMutableTreeNodeCreator{ + XMutableTreeNode createNode(String name); + } + + @Override + public void before(){ + nodeCreator = (XMutableTreeNodeCreator) tEnv.getObjRelation("XMutableTreeNodeCreator"); + if (nodeCreator == null){ + throw new StatusException(Status.failed( + "Couldn't get relation 'XMutableTreeNodeCreator'")); + } + + } + + public void _appendChild(){ + boolean bOK = true; + + log.println("try to append a valid node..."); + + XMutableTreeNode myNode = nodeCreator.createNode("myNodeToAppend"); + + try { + oObj.appendChild(myNode); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not append a valid node: " + ex.toString()); + bOK = false; + } + + log.println("try to append the node a second time..."); + try { + + oObj.appendChild(myNode); + log.println("ERROR: expected IllegalArgumentException was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected IllegalArgumentException was thrown => OK"); + } + + log.println("try to append the object itself..."); + try { + + oObj.appendChild(oObj); + log.println("ERROR: expected IllegalArgumentException was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected IllegalArgumentException was thrown => OK"); + } + + tRes.tested("appendChild()", bOK); + } + + public void _insertChildByIndex(){ + boolean bOK = true; + + XMutableTreeNode myNode = nodeCreator.createNode("myNodeToInsert"); + + try { + log.println("try to insert a valid node..."); + oObj.insertChildByIndex(0, myNode); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not insert a valid node: " + ex.toString()); + bOK = false; + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: could not insert a valid node on index '0': " + ex.toString()); + bOK = false; + } + + try { + log.println("try to insert a valid node a second time..."); + oObj.insertChildByIndex(0, myNode); + log.println("ERROR: expected IllegalArgumentException was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected IllegalArgumentException wa thrown => OK"); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: wrong IndexOutOfBoundsException was thrown. Expected is IllegalArgumentException => FAILED"); + bOK = false; + } + + XMutableTreeNode myNode2 = nodeCreator.createNode("myNodeToInsert2"); + + try { + log.println("try to insert a valid node on invalid index '-3'..."); + oObj.insertChildByIndex(-3, myNode2); + log.println("ERROR: expected IndexOutOfBoundsException was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: wrong IllegalArgumentException was thrown. Expected is IndexOutOfBoundsException => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("Expected IndexOutOfBoundsException was thrown => OK"); + } + + try { + log.println("try to insert the object itself..."); + oObj.insertChildByIndex(0, oObj); + log.println("ERROR: expected IllegalArgumentException was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected IllegalArgumentException was thrown => OK"); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("unexpected IndexOutOfBoundsException was thrown, expected was IllegalArgumentException => FAILED"); + bOK = false; + } + + tRes.tested("insertChildByIndex()", bOK); + } + + public void _removeChildByIndex(){ + + requiredMethod("insertChildByIndex()"); + boolean bOK = true; + + try { + log.println("try to remove node at index '0'..."); + oObj.removeChildByIndex(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: IndexOutOfBoundsException was thrown => FAILED"); + bOK = false; + } + + try { + log.println("try to remove node at invalid index '-3'"); + oObj.removeChildByIndex(-3); + log.println("ERROR: expected IndexOutOfBoundsException was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("expected IndexOutOfBoundsException was thrown => OK"); + } + tRes.tested("removeChildByIndex()", bOK); + } + + public void _setHasChildrenOnDemand(){ + boolean bOK = true; + + log.println("setHasChildrenOnDemand(true)"); + oObj.setHasChildrenOnDemand(true); + + log.println("setHasChildrenOnDemand(false)"); + oObj.setHasChildrenOnDemand(false); + + tRes.tested("setHasChildrenOnDemand()", bOK); + } + + public void _setDisplayValue(){ + boolean bOK = true; + + log.println("setDisplayValue(\"MyTestValue\")"); + oObj.setDisplayValue("MyTestValue"); + + log.println("setDisplayValue(null)"); + oObj.setDisplayValue(null); + + log.println("oObj.setDisplayValue(oObj)"); + oObj.setDisplayValue(oObj); + + tRes.tested("setDisplayValue()", bOK); + } + + public void _setNodeGraphicURL(){ + boolean bOK = true; + + log.println("setNodeGraphicURL(\"MyTestURL\")"); + oObj.setNodeGraphicURL("MyTestURL"); + + log.println("setNodeGraphicURL(null)"); + oObj.setNodeGraphicURL(null); + + tRes.tested("setNodeGraphicURL()", bOK); + } + + public void _setExpandedGraphicURL(){ + boolean bOK = true; + + log.println("setExpandedGraphicURL(\"myExpandedURL\")"); + oObj.setExpandedGraphicURL("myExpandedURL"); + + log.println("setExpandedGraphicURL(null)"); + oObj.setExpandedGraphicURL(null); + + tRes.tested("setExpandedGraphicURL()", bOK); + } + + public void _setCollapsedGraphicURL(){ + boolean bOK = true; + + log.println("setCollapsedGraphicURL(\"myCollapsedURL\")"); + oObj.setCollapsedGraphicURL("myCollapsedURL"); + + log.println("setCollapsedGraphicURL(null)"); + oObj.setCollapsedGraphicURL(null); + + tRes.tested("setCollapsedGraphicURL()", bOK); + } + + public void _DataValue(){ + boolean bOK = true; + + log.println("setDataValue(\"myDataValue\")"); + oObj.setDataValue("myDataValue"); + + String sDataValue = (String) oObj.getDataValue(); + + if ( ! sDataValue.equals("myDataValue")) { + log.println("ERROR: getDataValue does not return the value which is inserted before:\n" + + "\texpected: myDataValue\n" + + "\tgot: " + sDataValue); + bOK = false; + } + + log.println("setDataValue(null)"); + oObj.setDataValue(null); + + Object oDataValue = oObj.getDataValue(); + if ( oDataValue != null) { + log.println("ERROR: getDataValue does not return the value which is inserted before:\n" + + "\texpected: null\n" + + "\tgot: " + oDataValue.toString()); + bOK = false; + } + + log.println("oObj.setDisplayValue(oObj)"); + oObj.setDisplayValue(oObj); + + oDataValue = oObj.getDataValue(); + if ( oDataValue != null) { + log.println("ERROR: getDataValue does not return the value which is inserted before:\n" + + "\texpected: " + oObj.toString() +"\n" + + "\tgot: " + oDataValue.toString()); + bOK = false; + } + + tRes.tested("DataValue()", bOK); + } + +} diff --git a/qadevOOo/tests/java/ifc/awt/tree/_XTreeControl.java b/qadevOOo/tests/java/ifc/awt/tree/_XTreeControl.java new file mode 100644 index 000000000..e3c124d0a --- /dev/null +++ b/qadevOOo/tests/java/ifc/awt/tree/_XTreeControl.java @@ -0,0 +1,640 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + +package ifc.awt.tree; + +import com.sun.star.awt.tree.ExpandVetoException; +import com.sun.star.awt.tree.TreeExpansionEvent; +import com.sun.star.awt.tree.XMutableTreeNode; +import com.sun.star.awt.tree.XTreeControl; +import com.sun.star.awt.tree.XTreeEditListener; +import com.sun.star.awt.tree.XTreeExpansionListener; +import com.sun.star.awt.tree.XTreeNode; +import com.sun.star.lang.EventObject; +import com.sun.star.util.VetoException; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Testing com.sun.star.awt.tree.XTreeControl + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * + * @see com.sun.star.awt.tree.XTreeControl + */ +public class _XTreeControl extends MultiMethodTest { + + public XTreeControl oObj = null; + + private XMutableTreeNode mXNode = null; + + XTreeExpansionListener mTreeExpansionListener1 = new TreeExpansionListenerImpl1(); + + XTreeExpansionListener mTreeExpansionListener2 = new TreeExpansionListenerImpl2(); + + XTreeEditListener mTreeEditListener1 = new TreeEditListenerImpl1(); + + XTreeEditListener mTreeEditListener2 = new TreeEditListenerImpl2(); + + boolean mTreeExpanded1 = false; + boolean mTreeExpanding1 = false; + boolean mTreeCollapsed1 = false; + boolean mTreeCollapsing1 = false; + + boolean mTreeExpanded2 = false; + boolean mTreeExpanding2 = false; + boolean mTreeCollapsed2 = false; + boolean mTreeCollapsing2 = false; + + public interface XTreeDataModelListenerEvent{ + void fireEvent(); + } + + public class TreeExpansionListenerImpl1 implements XTreeExpansionListener{ + public void requestChildNodes(TreeExpansionEvent treeExpansionEvent) { + log.println("event at ExpansionListener 1: requestChildNodes"); + } + + public void treeExpanding(TreeExpansionEvent treeExpansionEvent) throws ExpandVetoException { + log.println("event at ExpansionListener 1: treeExpanding"); + mTreeExpanding1 = true; + } + + public void treeCollapsing(TreeExpansionEvent treeExpansionEvent) throws ExpandVetoException { + log.println("event at ExpansionListener 1: treeCollapsing"); + mTreeCollapsing1 = true; + } + + public void treeExpanded(TreeExpansionEvent treeExpansionEvent) { + log.println("event at ExpansionListener 1: treeExpanded"); + mTreeExpanded1 = true; + } + + public void treeCollapsed(TreeExpansionEvent treeExpansionEvent) { + log.println("event at ExpansionListener 1: treeCollapsed"); + mTreeCollapsed1 = true; + } + + public void disposing(EventObject eventObject) { + log.println("event at ExpansionListener 1: disposing"); + } + } + + public class TreeExpansionListenerImpl2 implements XTreeExpansionListener{ + public void requestChildNodes(TreeExpansionEvent treeExpansionEvent) { + log.println("event at ExpansionListener 2: requestChildNodes"); + } + + public void treeExpanding(TreeExpansionEvent treeExpansionEvent) throws ExpandVetoException { + log.println("event at ExpansionListener 2: treeExpanding"); + mTreeExpanding2 = true; + } + + public void treeCollapsing(TreeExpansionEvent treeExpansionEvent) throws ExpandVetoException { + log.println("event at ExpansionListener 2: treeCollapsing"); + mTreeCollapsing2 = true; + } + + public void treeExpanded(TreeExpansionEvent treeExpansionEvent) { + log.println("event at ExpansionListener 2: treeExpanded"); + mTreeExpanded2 = true; + } + + public void treeCollapsed(TreeExpansionEvent treeExpansionEvent) { + log.println("event at ExpansionListener 2: treeCollapsed"); + mTreeCollapsed2 = true; + } + + public void disposing(EventObject eventObject) { + log.println("event at ExpansionListener 2: disposing"); + } + + } + + public class TreeEditListenerImpl1 implements XTreeEditListener{ + public void nodeEditing(XTreeNode xTreeNode) throws VetoException { + log.println("event at EditListener 1: nodeEditing"); + } + + public void nodeEdited(XTreeNode xTreeNode, String string) { + log.println("event at EditListener 1: nodeEdited"); + } + + public void disposing(EventObject eventObject) { + log.println("event at EditListener 1: disposing"); + } + } + + public class TreeEditListenerImpl2 implements XTreeEditListener{ + public void nodeEditing(XTreeNode xTreeNode) throws VetoException { + log.println("event at EditListener 2: nodeEditing"); + } + + public void nodeEdited(XTreeNode xTreeNode, String string) { + log.println("event at EditListener 2: nodeEdited"); + } + + public void disposing(EventObject eventObject) { + log.println("event at EditListener 2: disposing"); + } + } + + private void resetTreeExpandingListener(){ + mTreeExpanded1 = false; + mTreeExpanded2 = false; + mTreeCollapsed1 = false; + mTreeCollapsed2 = false; + mTreeExpanding1 = false; + mTreeExpanding2 = false; + mTreeCollapsing1 = false; + mTreeCollapsing2 = false; + } + + @Override + public void before(){ + mXNode = (XMutableTreeNode) tEnv.getObjRelation("XTreeControl_Node"); + if (mXNode == null) { + throw new StatusException(Status.failed("ERROR: could not get object relation 'XTreeControl_Node'")); + } + } + + public void _isNodeExpanded() { + + boolean bOK = true; + + boolean isExpanded = false; + + try { + isExpanded = oObj.isNodeExpanded(mXNode); + log.println("node is expanded: " + isExpanded); + + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not query for 'isNodeExpanded()': " + ex.toString()); + } + + if (isExpanded) + try { + + log.println("try to collapse node..."); + oObj.collapseNode(mXNode); + + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } + else + try { + + log.println("try to expand node..."); + oObj.expandNode(mXNode); + + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } + + try { + + boolean isAlsoExpanded = oObj.isNodeExpanded(mXNode); + + bOK &= (isExpanded != isAlsoExpanded); + + log.println("node is expanded: " + isAlsoExpanded + " => " + bOK); + + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not query for 'isNodeExpanded()': " + ex.toString()); + } + + tRes.tested("isNodeExpanded()", bOK); + + } + public void _isNodeCollapsed(){ + + boolean bOK = true; + + boolean isCollapsed = false; + + try { + isCollapsed = oObj.isNodeCollapsed(mXNode); + log.println("node is Collapsed: " + isCollapsed); + + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not query for 'isNodeCollapsed()': " + ex.toString()); + } + + if ( ! isCollapsed) + try { + + log.println("try to collapse node..."); + oObj.collapseNode(mXNode); + + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } + else + try { + + log.println("try to expand node..."); + oObj.expandNode(mXNode); + + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } + + try { + + boolean isAlsoCollapsed = oObj.isNodeCollapsed(mXNode); + + bOK &= (isCollapsed != isAlsoCollapsed); + + log.println("node is Collapsed: " + isAlsoCollapsed + " => " + bOK); + + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not query for 'isNodeCollapsed()': " + ex.toString()); + } + + tRes.tested("isNodeCollapsed()", bOK); + + } + public void _makeNodeVisible(){ + + boolean bOK = true; + try { + + oObj.makeNodeVisible(mXNode); + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not call method 'makeNodeVisible()' successfully: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not call method 'makeNodeVisible()' successfully: " + ex.toString()); + } + try { + + bOK &= oObj.isNodeVisible(mXNode); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not call method 'isNodeVisible()' successfully: " + ex.toString()); + } + + tRes.tested("makeNodeVisible()", bOK); + + } + public void _isNodeVisible(){ + + this.requiredMethod("makeNodeVisible()"); + + boolean bOK = true; + log.println("since required method 'makeNodeVisible()' uses method 'isNodeVisible()' this test is ok."); + tRes.tested("isNodeVisible()", bOK); + + } + + public void _expandNode(){ + + this.requiredMethod("isNodeExpanded()"); + + boolean bOK = true; + log.println("since required method 'isnodeExpanded()' uses method 'expandNode()' this test is ok."); + tRes.tested("expandNode()", bOK); + + } + + public void _collapseNode(){ + + this.requiredMethod("isNodeCollapsed()"); + + boolean bOK = true; + log.println("since required method 'isnodeCollapsed()' uses method 'expandNode()' this test is ok."); + tRes.tested("collapseNode()", bOK); + + } + + public void _addTreeExpansionListener(){ + + boolean bOK = true; + + log.println("collapse Node to get an initial status..."); + try { + + oObj.collapseNode(mXNode); + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } + + log.println("add mTreeExpansionListener1..."); + oObj.addTreeExpansionListener(mTreeExpansionListener1); + + log.println("add mTreeExpansionListener2"); + oObj.addTreeExpansionListener(mTreeExpansionListener2); + + resetTreeExpandingListener(); + + log.println("expand Node..."); + try { + + oObj.expandNode(mXNode); + + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } + + bOK &= mTreeExpanded1 & mTreeExpanded2 & ! mTreeCollapsed1 & ! mTreeCollapsed2 + & mTreeExpanding1 & mTreeExpanding2 & ! mTreeCollapsing1 & ! mTreeCollapsing2; + + resetTreeExpandingListener(); + + log.println("collapse Node..."); + try { + + oObj.collapseNode(mXNode); + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } + + bOK &= ! mTreeExpanded1 & ! mTreeExpanded2 & mTreeCollapsed1 & mTreeCollapsed2 + & ! mTreeExpanding1 & ! mTreeExpanding2 & mTreeCollapsing1 & mTreeCollapsing2; + + tRes.tested("addTreeExpansionListener()", bOK); + + } + + public void _removeTreeExpansionListener(){ + + this.requiredMethod("addTreeExpansionListener()"); + + boolean bOK = true; + + log.println("collapse Node to get an initial status..."); + try { + + oObj.collapseNode(mXNode); + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } + + resetTreeExpandingListener(); + + log.println("remove mTreeExpansionListener2 ..."); + oObj.removeTreeExpansionListener(mTreeExpansionListener2); + + log.println("expand Node..."); + try { + + oObj.expandNode(mXNode); + + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not expand node: " + ex.toString()); + } + + bOK &= mTreeExpanded1 & ! mTreeExpanded2 & ! mTreeCollapsed1 & ! mTreeCollapsed2 + & mTreeExpanding1 & ! mTreeExpanding2 & ! mTreeCollapsing1 & ! mTreeCollapsing2; + + resetTreeExpandingListener(); + + log.println("collapse Node..."); + try { + + oObj.collapseNode(mXNode); + } catch (ExpandVetoException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + bOK = false; + log.println("ERROR: could not collapse node: " + ex.toString()); + } + + bOK &= ! mTreeExpanded1 & ! mTreeExpanded2 & mTreeCollapsed1 & ! mTreeCollapsed2 + & ! mTreeExpanding1 & ! mTreeExpanding2 & mTreeCollapsing1 & ! mTreeCollapsing2; + + log.println("remove mTreeExpansionListener2 ..."); + oObj.removeTreeExpansionListener(mTreeExpansionListener2); + + tRes.tested("removeTreeExpansionListener()", bOK); + + } + + public void _getNodeForLocation(){ + + boolean bOK = false; + + + tRes.tested("getNodeForLocation()", bOK); + + } + + public void _getClosestNodeForLocation(){ + + boolean bOK = false; + + log.println("try to get Node for location 100,100"); + XTreeNode myNode = oObj.getClosestNodeForLocation(100,100); + + bOK &= (myNode != null); + + tRes.tested("getClosestNodeForLocation()", bOK); + + } + + public void _isEditing(){ + + boolean bOK = false; + + log.println("not ready because of i78701"); + + tRes.tested("isEditing()", bOK); + + } + + public void _stopEditing(){ + + boolean bOK = false; + log.println("not ready because of i78701"); + + + tRes.tested("stopEditing()", bOK); + + } + + public void _cancelEditing(){ + + boolean bOK = false; + + log.println("not ready because of i78701"); + + tRes.tested("cancelEditing()", bOK); + + } + + public void _startEditingAtNode(){ + + boolean bOK = false; + + log.println("not ready because of i78701"); + + tRes.tested("startEditingAtNode()", bOK); + + } + + public void _addTreeEditListener(){ + + boolean bOK = true; + + log.println("add EditListener 1..."); + oObj.addTreeEditListener(mTreeEditListener1); + + log.println("add EditListener 2..."); + oObj.addTreeEditListener(mTreeEditListener2); + + try { + oObj.startEditingAtNode(mXNode); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not start editing at node: " + ex.toString()); + bOK = false; + } + + log.println("not ready because of i78701"); + bOK = false; + + + tRes.tested("addTreeEditListener()", bOK); + + } + + public void _removeTreeEditListener(){ + + boolean bOK = false; + + log.println("not ready because of i78701"); + + tRes.tested("removeTreeEditListener()", bOK); + + } + + public void _DefaultExpandedGraphicURL(){ + + boolean bOK = true; + + String current = oObj.getDefaultExpandedGraphicURL(); + log.println("current DefaultExpandedGraphicURL: " + current); + + String changeUrl = null; + + if (current.equals("private:graphicrepository/sd/res/triangle_right.png")) + changeUrl = "private:graphicrepository/sd/res/triangle_down.png"; + else changeUrl = "private:graphicrepository/sd/res/triangle_right.png"; + + log.println("try to set '" + changeUrl + "' as new DefaultExpandedGraphicURL"); + + oObj.setDefaultExpandedGraphicURL(changeUrl); + + String newUrl = oObj.getDefaultExpandedGraphicURL(); + + log.println("new DefaultExpandedGraphicURL: " + newUrl); + + bOK &= ! newUrl.equals(current); + + tRes.tested("DefaultExpandedGraphicURL()", bOK); + + } + + public void _DefaultCollapsedGraphicURL(){ + + boolean bOK = true; + + String current = oObj.getDefaultCollapsedGraphicURL(); + log.println("current DefaultCollapsedGraphicURL: " + current); + + String changeUrl = null; + + if (current.equals("private:graphicrepository/sd/res/triangle_right.png")) + changeUrl = "private:graphicrepository/sd/res/triangle_down.png"; + else changeUrl = "private:graphicrepository/sd/res/triangle_right.png"; + + log.println("try to set '" + changeUrl + "' as new DefaultCollapsedGraphicURL"); + oObj.setDefaultCollapsedGraphicURL(changeUrl); + + String newUrl = oObj.getDefaultCollapsedGraphicURL(); + + log.println("new DefaultCollapsedGraphicURL: " + newUrl); + + bOK &= ! newUrl.equals(current); + + tRes.tested("DefaultCollapsedGraphicURL()", bOK); + } +} + + diff --git a/qadevOOo/tests/java/ifc/awt/tree/_XTreeDataModel.java b/qadevOOo/tests/java/ifc/awt/tree/_XTreeDataModel.java new file mode 100644 index 000000000..3c544efd5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/awt/tree/_XTreeDataModel.java @@ -0,0 +1,171 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + +package ifc.awt.tree; + +import com.sun.star.awt.tree.TreeDataModelEvent; +import com.sun.star.awt.tree.XTreeDataModel; +import com.sun.star.awt.tree.XTreeDataModelListener; +import com.sun.star.lang.EventObject; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Testing com.sun.star.awt.tree.XTreeDataModel + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * + * @see com.sun.star.awt.tree.XTreeDataModel + */ +public class _XTreeDataModel extends MultiMethodTest { + + public XTreeDataModel oObj = null; + + XTreeDataModelListener mListener1 = new myEventListener1(); + + XTreeDataModelListener mListener2 = new myEventListener2(); + + XTreeDataModelListenerEvent mListenerEvent = null; + + boolean mTreeStructureChanged1 = false; + + boolean mTreeStructureChanged2 = false; + + public interface XTreeDataModelListenerEvent{ + void fireEvent(); + } + + public class myEventListener1 implements XTreeDataModelListener{ + public void treeNodesChanged(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 1: treeNodesChanged"); + } + + public void treeNodesInserted(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 1: treeNodesInserted"); + } + + public void treeNodesRemoved(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 1: treeNodesRemoved"); + } + + public void treeStructureChanged(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 1: treeStructureChanged"); + mTreeStructureChanged1 = true; + } + + public void disposing(EventObject eventObject) { + log.println("Listener 1: disposing"); + } + } + + public class myEventListener2 implements XTreeDataModelListener{ + public void treeNodesChanged(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 2: treeNodesChanged"); + } + + public void treeNodesInserted(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 2: treeNodesInserted"); + } + + public void treeNodesRemoved(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 2: treeNodesRemoved"); + } + + public void treeStructureChanged(TreeDataModelEvent treeDataModelEvent) { + log.println("Listener 2: treeStructureChanged"); + mTreeStructureChanged2 = true; + } + + public void disposing(EventObject eventObject) { + log.println("Listener 2: disposing"); + } + + } + + @Override + public void before(){ + mListenerEvent = (XTreeDataModelListenerEvent) tEnv.getObjRelation("XTreeDataModelListenerEvent"); + if (mListenerEvent == null) { + throw new StatusException(Status.failed("ERROR: could not get object relation 'XTreeDataModelListenerEvent'\n" + + "This object relation must be kind of 'ifc.awt.tree._XTreeDataModel.XTreeDataModelListenerEvent'")); + } + } + + /** + * Gets the title and compares it to the value set in + * setTitle method test.

+ * Has OK status is set/get values are equal. + * The following method tests are to be completed successfully before : + *

+ */ + public void _getRoot() { + + boolean bOK = true; + oObj.getRoot(); + + tRes.tested("getRoot()", bOK); + + } + + public void _addTreeDataModelListener(){ + + boolean bOK = true; + + log.println("add listener 1 to object..."); + oObj.addTreeDataModelListener(mListener1); + + log.println("add listener 2 to object..."); + oObj.addTreeDataModelListener(mListener2); + + mTreeStructureChanged1 = false; + mTreeStructureChanged2 = false; + + mListenerEvent.fireEvent(); + + bOK = mTreeStructureChanged1 & mTreeStructureChanged2; + + tRes.tested("addTreeDataModelListener()", bOK); + } + + public void _removeTreeDataModelListener(){ + + boolean bOK = true; + + log.println("remove listener 2 from object..."); + oObj.removeTreeDataModelListener(mListener2); + + mTreeStructureChanged1 = false; + mTreeStructureChanged2 = false; + + mListenerEvent.fireEvent(); + + bOK = mTreeStructureChanged1 & ! mTreeStructureChanged2; + + tRes.tested("removeTreeDataModelListener()", bOK); + + } +} + + diff --git a/qadevOOo/tests/java/ifc/awt/tree/_XTreeNode.java b/qadevOOo/tests/java/ifc/awt/tree/_XTreeNode.java new file mode 100644 index 000000000..f0ca8ae9f --- /dev/null +++ b/qadevOOo/tests/java/ifc/awt/tree/_XTreeNode.java @@ -0,0 +1,259 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . + */ + +package ifc.awt.tree; + +import com.sun.star.awt.tree.XTreeNode; +import com.sun.star.uno.AnyConverter; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Testing com.sun.star.awt.tree.XTreeDataModel + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * + * @see com.sun.star.awt.tree.XTreeDataModel + */ +public class _XTreeNode extends MultiMethodTest { + + public XTreeNode oObj = null; + + private int mCount = 0; + + String msDisplayValue = null; + String msExpandedGraphicURL = null; + String msCollapsedGraphicURL = null; + String msNodeGraphicURL = null; + + + @Override + public void before(){ + msDisplayValue = (String) tEnv.getObjRelation("XTreeNode_DisplayValue"); + if (msDisplayValue == null){ + throw new StatusException(Status.failed( + "Couldn't get relation 'XTreeNode_DisplayValue'")); + } + + msExpandedGraphicURL = (String) tEnv.getObjRelation("XTreeNode_ExpandedGraphicURL"); + if (msExpandedGraphicURL == null){ + throw new StatusException(Status.failed( + "Couldn't get relation 'XTreeNode_ExpandedGraphicURL'")); + } + + msCollapsedGraphicURL = (String) tEnv.getObjRelation("XTreeNode_CollapsedGraphicURL"); + if (msCollapsedGraphicURL == null){ + throw new StatusException(Status.failed( + "Couldn't get relation 'XTreeNode_CollapsedGraphicURL'")); + } + + msNodeGraphicURL = (String) tEnv.getObjRelation("XTreeNode_NodeGraphicURL"); + if(msNodeGraphicURL == null){ + throw new StatusException(Status.failed( + "Couldn't get relation 'XTreeNode_NodeGraphicURL'")); + } + + } + + /** + * Gets the title and compares it to the value set in + * setTitle method test.

+ * Has OK status is set/get values are equal. + * The following method tests are to be completed successfully before : + *

+ */ + public void _getChildAt(){ + this.requiredMethod("getChildCount()"); + boolean bOK = true; + + for (int i=0; i < mCount ; i++){ + XTreeNode xNode = null; + try { + xNode = oObj.getChildAt(i); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: getChildAt(" + i + "): " + ex.toString()); + } + if (xNode == null){ + log.println("ERROR: getChildAt(" + i + ") returns null => FAILED"); + bOK = false; + } + } + + tRes.tested("getChildAt()", bOK); + } + + + public void _getChildCount(){ + + boolean bOK = true; + mCount = oObj.getChildCount(); + log.println("got count '" + mCount + "' of children"); + if (mCount < 1 ) { + log.println("ERROR: got a count < 1. The test object must support more than zero children => FAILED"); + bOK = false; + } + tRes.tested("getChildCount()", bOK); + } + + + public void _getParent(){ + this.requiredMethod("getChildAt()"); + + boolean bOK = true; + XTreeNode xNode = null; + try { + log.println("try to getChildAt(0)"); + xNode = oObj.getChildAt(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: getChildAt(0): " + ex.toString()); + } + + log.println("try to get parent of children"); + if (xNode == null) { + log.println("missing xNode"); + tRes.tested("getParent()", false); + } + else { + XTreeNode xParrent = xNode.getParent(); + + + bOK = oObj.equals(xParrent); + log.println("original object and parent should be the same: " + bOK); + tRes.tested("getParent()", bOK); + } + } + + + public void _getIndex(){ + this.requiredMethod("getChildAt()"); + + boolean bOK = true; + XTreeNode xNode = null; + try { + log.println("try to getChildAt(0)"); + xNode = oObj.getChildAt(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: getChildAt(0): " + ex.toString()); + } + + log.println("try to get index from child..."); + int index = oObj.getIndex(xNode); + + if (index != 0){ + log.println("ERROR: getIndex() does not return '0' => FAILED"); + bOK = false; + } + + tRes.tested("getIndex()", bOK); + } + + + public void _hasChildrenOnDemand(){ + + boolean bOK = true; + + bOK = oObj.hasChildrenOnDemand(); + tRes.tested("hasChildrenOnDemand()", bOK); + } + + + public void _getDisplayValue(){ + + boolean bOK = true; + String DisplayValue = null; + Object dispVal = oObj.getDisplayValue(); + + try { + DisplayValue = AnyConverter.toString(dispVal); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not convert the returned object of 'getDisplayValue()' " + + "to String with AnyConverter: " + ex.toString()); + } + + if ( ! this.msDisplayValue.equals(DisplayValue)){ + log.println("ERROR: getNodeGraphicURL() does not return expected value:\n" + + "\tExpected: " + this.msDisplayValue +"\n" + + "\tGot: " + DisplayValue); + bOK = false; + } + + tRes.tested("getDisplayValue()", bOK); + } + + + public void _getNodeGraphicURL(){ + + boolean bOK = true; + String graphicURL = oObj.getNodeGraphicURL(); + + if ( ! this.msNodeGraphicURL.equals(graphicURL)){ + log.println("ERROR: getNodeGraphicURL() does not return expected value:\n" + + "\tExpected: " + this.msNodeGraphicURL +"\n" + + "\tGot: " + graphicURL); + bOK = false; + } + tRes.tested("getNodeGraphicURL()", bOK); + } + + + public void _getExpandedGraphicURL(){ + + boolean bOK = true; + String ExpandedGraphicURL = oObj.getExpandedGraphicURL(); + + if ( ! this.msExpandedGraphicURL.equals(ExpandedGraphicURL)){ + log.println("ERROR: getExpandedGraphicURL() does not return expected value:\n" + + "\tExpected: " + this.msExpandedGraphicURL +"\n" + + "\tGot: " + ExpandedGraphicURL); + bOK = false; + } + + tRes.tested("getExpandedGraphicURL()", bOK); + } + + + public void _getCollapsedGraphicURL(){ + + boolean bOK = true; + + String CollapsedGraphicURL = oObj.getCollapsedGraphicURL(); + + if ( ! this.msCollapsedGraphicURL.equals(CollapsedGraphicURL)){ + log.println("ERROR: getExpandedGraphicURL() does not return expected value:\n" + + "\tExpected: " + this.msCollapsedGraphicURL +"\n" + + "\tGot: " + CollapsedGraphicURL); + bOK = false; + } + + tRes.tested("getCollapsedGraphicURL()", bOK); + } + +} -- cgit v1.2.3