diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /qadevOOo/tests/java/ifc/view | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qadevOOo/tests/java/ifc/view')
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XControlAccess.java | 115 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XFormLayerAccess.java | 150 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java | 415 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XPrintJobBroadcaster.java | 146 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XPrintSettingsSupplier.java | 53 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XPrintable.java | 179 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XScreenCursor.java | 78 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java | 199 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/view/_XViewSettingsSupplier.java | 53 |
9 files changed, 1388 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/view/_XControlAccess.java b/qadevOOo/tests/java/ifc/view/_XControlAccess.java new file mode 100644 index 000000000..65287304c --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XControlAccess.java @@ -0,0 +1,115 @@ +/* + * 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.view; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.FormTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.view.XControlAccess; + +/** + * Testing <code>com.sun.star.view.XControlAccess</code> + * interface methods : + * <ul> + * <li><code> getControl()</code></li> + * </ul> <p> + * This test needs the following object relations : + * <ul> + * <li> <code>'DOCUMENT'</code> (of type <code>XComponent</code>): + * the document, which controller is tested here. Is used + * for adding a component (such as CommandButton) and obtaining + * its control via tested interface. </li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XControlAccess + */ +public class _XControlAccess extends MultiMethodTest { + + public XControlAccess oObj = null; + + /** + * Retrieves a document from relation, then using it adds + * a CommandButton to a document and obtains button model. + * After that button control is tried to get using the + * tested interface. <p> + * Has <b> OK </b> status if non <code>null</code> control + * is returned. <p> + * @throws StatusException If the relation was not found. + */ + public void _getControl() + throws com.sun.star.uno.Exception + { + boolean bResult = true; + try { + XComponent oDoc = (XComponent)tEnv.getObjRelation("DOCUMENT"); + if (oDoc == null) { + throw new StatusException + (Status.failed("NO 'DOCUMENT' ObjRelation!")); + } + Boolean isSheet = (Boolean) tEnv.getObjRelation("XControlAccess.isSheet"); + XDrawPage oDP = null; + if (isSheet != null) { + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, oDoc); + oDP = UnoRuntime.queryInterface(XDrawPage.class, oDPS.getDrawPages().getByIndex(0)); + } else { + + + XDrawPageSupplier oDPS = UnoRuntime.queryInterface(XDrawPageSupplier.class, oDoc); + oDP = oDPS.getDrawPage(); + } + XShapes shapes = UnoRuntime.queryInterface + (XShapes.class, oDP); + XShape button = FormTools.createControlShape + (oDoc, 100, 100, 10000, 50000, "CommandButton"); + shapes.add(button); + + XControlModel CM = ((XControlShape)button).getControl(); + log.println("Getting ControlModel " + + ((CM == null) ? "FAILED" : "OK")); + + XControl oControl = oObj.getControl(CM); + log.println("Getting Control " + ((CM == null) ? "FAILED" : "OK")); + + bResult &= oControl != null; + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Exception occurred calling the method: " + e); + bResult = false; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception occurred calling the method: " + e); + bResult = false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Exception occurred calling the method: " + e); + bResult = false; + } + tRes.tested("getControl()", bResult); + } +} + diff --git a/qadevOOo/tests/java/ifc/view/_XFormLayerAccess.java b/qadevOOo/tests/java/ifc/view/_XFormLayerAccess.java new file mode 100644 index 000000000..3d45c5474 --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XFormLayerAccess.java @@ -0,0 +1,150 @@ +/* + * 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.view; + +import com.sun.star.form.XForm; +import com.sun.star.form.runtime.XFormController; +import lib.MultiMethodTest; + +import com.sun.star.view.XFormLayerAccess; +import lib.Status; +import lib.StatusException; + + +/** + * Testing <code>com.sun.star.view.XFormLayerAccess</code> + * interface methods : + * <ul> + * <li><code> getFromController()</code></li> + * <li><code> isFormDesignMode()</code></li> + * <li><code> setFormDesignMode()</code></li> + * </ul> <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XFormLayerAccess + */ +public class _XFormLayerAccess extends MultiMethodTest { + + // oObj filled by MultiMethodTest + + public XFormLayerAccess oObj = null; + + private XForm xForm = null; + + /** + * checks if the object relation <CODE>XFormLayerAccess.XForm</CODE> + * is available + */ + @Override + public void before() { + xForm = (XForm) tEnv.getObjRelation("XFormLayerAccess.XForm"); + if (xForm == null) { + throw new StatusException(Status.failed("Object raltion 'XFormLayerAccess.XForm' is null")); + } + } + + /** + * Test disables the FormDesignMode and calls the method. <p> + * Has <b> OK </b> status if the method returns + * a not empty object of kind of com.sun.star.form.XFormController<P> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setFormDesignMode() </code></li> + * </ul> + * @see com.sun.star.view.XFormLayerAccess + */ + public void _getFromController(){ + requiredMethod("setFormDesignMode()") ; + + log.println("try to get current DesignMode..."); + boolean currentMode = oObj.isFormDesignMode(); + log.println("DesignMode is " + currentMode); + + log.println("enable DesignMode"); + oObj.setFormDesignMode(false); + + log.println("test for getFromController() "); + XFormController xFormCont = oObj.getFormController(xForm); + + if (xFormCont == null) + log.println("ERROR: Could not get FromContoller"); + + log.println("set back DesignMode to previous state"); + oObj.setFormDesignMode(currentMode); + + tRes.tested("getFromController()", xFormCont != null ); + } + + /** + * This test calls the test for <code>setFormDesignMode()</CODE>. + * Has <b> OK </b> status if the test for setFormDesignMode() returns + * <code>true</code> since the tests use <CODE>isFormDesignMode()</CODE><P> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setFormDesignMode() </code></li> + * </ul> + */ + public void _isFormDesignMode(){ + requiredMethod("setFormDesignMode()") ; + + log.println("test for isFormDesignMode() is ok since test for 'setFormDesingMode()' use it"); + tRes.tested("isFormDesignMode()", true); + } + + /** + * This test gets the current FormDesignMode, change it to the opposite and checks if the expected value of + * method isFormDesignmode() was given. Then the FormDesignmode was set back to the original value.<P> + * Has <B> OK </B> if expected values are returned. + * + */ + + public void _setFormDesignMode(){ + log.println("test for setFormDesignMode() and isFormDesignMode() "); + + log.println("try to get current DesignMode..."); + boolean currentMode = oObj.isFormDesignMode(); + log.println("DesignMode is " + currentMode); + + log.println("try to change to " + !currentMode + "..."); + oObj.setFormDesignMode(!currentMode); + log.println("try to get new DesignMode..."); + boolean newMode = oObj.isFormDesignMode(); + log.println("DesignMode is " + newMode); + + boolean bOK = (newMode != currentMode); + + if ( !bOK) + log.println("ERROR: both modes are equal"); + + log.println("set back DesignMode to " + currentMode); + oObj.setFormDesignMode(currentMode); + + log.println("try to get DesignMode..."); + boolean oldMode = oObj.isFormDesignMode(); + + bOK &= (bOK &(currentMode == oldMode)); + + if (currentMode != oldMode) + log.println("ERROR: could not change back"); + + tRes.tested("setFormDesignMode()", bOK ); + } + +} // finish class _XFormLayerAccess + diff --git a/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java b/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java new file mode 100644 index 000000000..dc775c6e1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XMultiSelectionSupplier.java @@ -0,0 +1,415 @@ +/* + * 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.view; + +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XEnumeration; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.view.XMultiSelectionSupplier; +import java.util.Comparator; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Testing <code>com.sun.star.view.XSelectionSupplier</code> + * interface methods : + * <ul> + * <li><code> addSelection()</code></li> + * <li><code> removeSelection()</code></li> + * <li><code> clearSelection()</code></li> + * <li><code> getSelectionCount()</code></li> + * <li><code> createSelectionEnumeration()</code></li> + * <li><code> createReverseSelectionEnumeration()</code></li> + * </ul> + * This test needs the following object relations : + * <ul> + * <li> <code>'Selections'</code> of type <code>Object[]</code> : + * the array of the instances which can be selected.</li> + * <li> <code>'Comparer'</code> of type <code>Comparator</code> : + * the interface for comparing of selected instances</li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XSelectionSupplier + */ +public class _XMultiSelectionSupplier extends MultiMethodTest { + + public XMultiSelectionSupplier oObj = null; + Object[] selections = null; + Comparator<Object> ObjCompare = null; + + @Override + protected void before() { + selections = (Object[])tEnv.getObjRelation("Selections"); + if (selections == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'Selections'")); + } + + ObjCompare = (Comparator<Object>)tEnv.getObjRelation("Comparer"); + } + + @Override + protected void after() { + disposeEnvironment(); + } + + /** + * Selects an instance from relation 'First'. <p> + * Has <b> OK </b> status if no exceptions were thrown. <p> + */ + public void _addSelection() { + + boolean bOK = true; + + log.println("clear selections"); + oObj.clearSelection(); + + int count = oObj.getSelectionCount(); + + bOK &= (count == 0); + + if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED"); + + for(int i = 0; i < selections.length; i++) { + try { + log.println("select object from object relation 'selections["+i+"]'"); + oObj.addSelection(selections[i]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString()); + bOK = false; + } + count = oObj.getSelectionCount(); + if (count != (i+1)){ + log.println("ERROR: add a selection but selection count ("+count+ ") " + + "is not as expected (" + (i+1) + ") => FAILED"); + bOK = false; + } + } + + log.println("try to select object relation 'selections[0]' second time..."); + try { + count = oObj.getSelectionCount(); + oObj.addSelection(selections[0]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add selection from object relation 'selections[0] a second time': " + ex.toString()); + } + if (count != oObj.getSelectionCount()){ + log.println("ERROR: the selected count ("+oObj.getSelectionCount() +") is not that before (" + count + ")"); + bOK = false; + } + + log.println("try to select invalid object..."); + try { + + oObj.addSelection(oObj); + + log.println("ERROR: expected exception 'com.sun.star.lang.IllegalArgumentException' was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected exception 'com.sun.star.lang.IllegalArgumentException' => OK"); + } + + tRes.tested("addSelection()", bOK); + } + + public void _removeSelection() { + requiredMethod("addSelection()"); + + boolean bOK = true; + + log.println("clear selections"); + oObj.clearSelection(); + + int count = oObj.getSelectionCount(); + + bOK &= (count == 0); + + if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED"); + + log.println("add some selections..."); + for(int i = 0; i < selections.length; i++) { + try { + log.println("select object from object relation 'selections["+i+"]'"); + oObj.addSelection(selections[i]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString()); + bOK = false; + } + count = oObj.getSelectionCount(); + if (count != (i+1)){ + log.println("ERROR: added a selection but selection count ("+count+ ") " + + "is not as expected (" + (i+1) + ") => FAILED"); + bOK = false; + } + } + + log.println("try now to remove selections..."); + + count = oObj.getSelectionCount(); + int oldCount = oObj.getSelectionCount(); + for(int i = 0; i < selections.length; i++) { + try { + log.println("remove selection for object relation 'selections["+i+"]'"); + oObj.removeSelection(selections[i]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not remove selection from object relation 'selections[" + i + "]': " + ex.toString()); + bOK = false; + } + count = oObj.getSelectionCount(); + if (count != (oldCount - i - 1)){ + log.println("ERROR: removed a selection but selection count ("+count+ ") " + + "is not as expected (" + (oldCount -i -1) + ") => FAILED"); + bOK = false; + } + } + + log.println("try to remove a removed selection a second time..."); + count = oObj.getSelectionCount(); + try { + oObj.removeSelection(selections[0]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not remove selection from object relation 'selections[0] a second time': " + ex.toString()); + } + if (count != oObj.getSelectionCount()){ + log.println("ERROR: the selected count ("+oObj.getSelectionCount() +") is not that before (" + count + ")"); + bOK = false; + } + + log.println("try to remove invalid object..."); + try { + + oObj.removeSelection(oObj); + + log.println("ERROR: expected exception 'com.sun.star.lang.IllegalArgumentException' was not thrown => FAILED"); + bOK = false; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("expected exception 'com.sun.star.lang.IllegalArgumentException' => OK"); + } + + tRes.tested("removeSelection()", bOK); + } + + + /** + * First test changes selection of the object : if nothing is + * currently selected or first instance ('First' relation) is + * selected then selects second instance; if second instance + * is currently selected then the first instance is selected. <p> + * Then <code>getSelection</code> is called and values set and + * get are compared. Comparison has some special cases. For + * example if selection is a Cell, then the values contained + * in cells are compared. <p> + * Has <b>OK</b> status if selection changed properly. + */ + public void _getSelectionCount() { + requiredMethod("addSelection()"); + tRes.tested("getSelectionCount()", true); + } + + public void _clearSelection() { + requiredMethod("addSelection()"); + boolean bOK = true; + + log.println("clear selections"); + oObj.clearSelection(); + + int count = oObj.getSelectionCount(); + + bOK &= (count == 0); + + if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED"); + + log.println("add some selections..."); + for(int i = 0; i < selections.length; i++) { + try { + log.println("select object from object relation 'selections["+i+"]'"); + oObj.addSelection(selections[i]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString()); + bOK = false; + } + count = oObj.getSelectionCount(); + if (count != (i+1)){ + log.println("ERROR: added a selection but selection count ("+count+ ") " + + "is not as expected (" + (i+1) + ") => FAILED"); + bOK = false; + } + } + + count = oObj.getSelectionCount(); + + log.println("clear selections..."); + oObj.clearSelection(); + + count = oObj.getSelectionCount(); + + bOK &= (count == 0); + + if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED"); + + tRes.tested("clearSelection()", bOK); + } + + public void _createSelectionEnumeration() { + requiredMethod("addSelection()"); + boolean bOK = true; + + log.println("clear selections"); + oObj.clearSelection(); + + int count = oObj.getSelectionCount(); + + bOK &= (count == 0); + + if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED"); + + log.println("add some selections..."); + for(int i = 0; i < selections.length; i++) { + try { + log.println("select object from object relation 'selections["+i+"]'"); + oObj.addSelection(selections[i]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString()); + bOK = false; + } + count = oObj.getSelectionCount(); + if (count != (i+1)){ + log.println("ERROR: added a selection but selection count ("+count+ ") " + + "is not as expected (" + (i+1) + ") => FAILED"); + bOK = false; + } + } + + log.println("create enumeration..."); + XEnumeration xEnum = oObj.createSelectionEnumeration(); + + boolean compRes = true; //compare result + int i = 0; + + while (xEnum.hasMoreElements()){ + log.println("try to get first element.."); + Object nextElement = null; + try { + nextElement = xEnum.nextElement(); + } catch (WrappedTargetException ex) { + log.println("ERROR: could not get nextElement: " + ex.toString()); + bOK = false; + } catch (NoSuchElementException ex) { + log.println("ERROR: could not get nextElement: " + ex.toString()); + bOK = false; + } + Object shouldElement = selections[i]; + i++; + + if (ObjCompare != null) { + compRes = ObjCompare.compare(shouldElement, nextElement) == 0; + } else { + compRes = util.ValueComparer.equalValue(shouldElement, nextElement); + } + + log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes); + + if (!compRes && (selections[i]) instanceof Object[]) { + if (((Object[])selections[i])[0] instanceof Integer) { + log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue()); + log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); + } + } + bOK &= compRes; + } + + tRes.tested("createSelectionEnumeration()", bOK); + } + + public void _createReverseSelectionEnumeration() { + requiredMethod("addSelection()"); + boolean bOK = true; + + log.println("clear selections"); + oObj.clearSelection(); + + int count = oObj.getSelectionCount(); + + bOK &= (count == 0); + + if ( ! bOK) log.println("ERROR: after clear selection I got a selection count of '" + count + "' => FAILED"); + + log.println("add some selections..."); + for(int i = 0; i < selections.length; i++) { + try { + log.println("select object from object relation 'selections["+i+"]'"); + oObj.addSelection(selections[i]); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add selection from object relation 'selections[" + i + "]': " + ex.toString()); + bOK = false; + } + count = oObj.getSelectionCount(); + if (count != (i+1)){ + log.println("ERROR: added a selection but selection count ("+count+ ") " + + "is not as expected (" + (i+1) + ") => FAILED"); + bOK = false; + } + } + + log.println("create enumeration..."); + XEnumeration xEnum = oObj.createSelectionEnumeration(); + + boolean compRes = true; //compare result + int i = selections.length - 1; + + while (xEnum.hasMoreElements()){ + log.println("try to get first element.."); + Object nextElement = null; + try { + nextElement = xEnum.nextElement(); + } catch (WrappedTargetException ex) { + log.println("ERROR: could not get nextElement: " + ex.toString()); + bOK = false; + } catch (NoSuchElementException ex) { + log.println("ERROR: could not get nextElement: " + ex.toString()); + bOK = false; + } + Object shouldElement = selections[i]; + i--; + + if (ObjCompare != null) { + compRes = ObjCompare.compare(shouldElement, nextElement) == 0; + } else { + compRes = util.ValueComparer.equalValue(shouldElement, nextElement); + } + + log.println("nextElement()-object and expected object 'selections["+i+"]' are equal: "+compRes); + + if (!compRes && (selections[i]) instanceof Object[]){ + if (((Object[])selections[i])[0] instanceof Integer) { + log.println("Getting: "+((Integer) ((Object[])shouldElement)[0]).intValue()); + log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); + } + } + bOK &= compRes; + } + + tRes.tested("createReverseSelectionEnumeration()", bOK); + } + +} // finish class _XMultiSelectionSupplier + + + diff --git a/qadevOOo/tests/java/ifc/view/_XPrintJobBroadcaster.java b/qadevOOo/tests/java/ifc/view/_XPrintJobBroadcaster.java new file mode 100644 index 000000000..99d30f994 --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XPrintJobBroadcaster.java @@ -0,0 +1,146 @@ +/* + * 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.view; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.view.PrintJobEvent; +import com.sun.star.view.XPrintJobBroadcaster; +import com.sun.star.view.XPrintJobListener; +import com.sun.star.view.XPrintable; +import java.io.File; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Test the XPrintJobBroadcaster interface + */ +public class _XPrintJobBroadcaster extends MultiMethodTest { + public XPrintJobBroadcaster oObj = null; + MyPrintJobListener listenerImpl = null; + + /** + * Get an object implementation of the _XPrintJobListener interface from the + * test environment. + */ + @Override + public void before() { + listenerImpl = (MyPrintJobListener)tEnv.getObjRelation("XPrintJobBroadcaster.XPrintJobListener"); + if (listenerImpl == null) { + throw new StatusException(Status.failed(" No test possible. The XPrintJobListener interface has to be implemented.")); + } + } + + /** + * add the listener, see if it's called. + */ + public void _addPrintJobListener() { + oObj.addPrintJobListener(listenerImpl); + listenerImpl.fireEvent(); + waitForEventIdle(); + tRes.tested("addPrintJobListener()", listenerImpl.actionTriggered()); + } + + /** + * remove the listener, see if it's still called. + */ + public void _removePrintJobListener() { + requiredMethod("addPrintJobListener"); + oObj.removePrintJobListener(listenerImpl); + + waitForEventIdle(); + + listenerImpl.reset(); + listenerImpl.fireEvent(); + tRes.tested("removePrintJobListener()", !listenerImpl.actionTriggered()); + } + + /** + * Implementation for testing the XPrintJobBroadcaster interface: + * a listener to add. + */ + public static class MyPrintJobListener implements XPrintJobListener { + boolean eventCalled = false; + // object to trigger the event + XPrintable xPrintable = null; + PropertyValue[]printProps = null; + String printFileName = null; + + /** + * Constructor + * @param printable An object that can be cast to an XPrintable. + */ + public MyPrintJobListener(Object printable, String printFileName) { + this.printFileName = printFileName; + xPrintable = UnoRuntime.queryInterface(XPrintable.class, printable); + printProps = new PropertyValue[2]; + printProps[0] = new PropertyValue(); + printProps[0].Name = "FileName"; + printProps[0].Value = printFileName; + printProps[0].State = com.sun.star.beans.PropertyState.DEFAULT_VALUE; + printProps[1] = new PropertyValue(); + printProps[1].Name = "Wait"; + printProps[1].Value = Boolean.TRUE; + } + + /** + * Has the action been triggered? + * @return True if "printJobEvent" has been called. + */ + public boolean actionTriggered() { + return eventCalled; + } + + /** + * Fire the event that calls the printJobEvent + */ + public void fireEvent() { + try { + xPrintable.print(printProps); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + } + } + + public void reset() { + File f = new File(printFileName); + if (f.exists()) { + boolean bDeleteOk = f.delete(); + if (!bDeleteOk) { + System.out.println("delete failed"); + } + } + eventCalled = false; + } + + /** + * The print job event: has to be called when the action is triggered. + */ + public void printJobEvent(PrintJobEvent printJobEvent) { + eventCalled = true; + } + + /** + * Disposing event: ignore. + */ + public void disposing(com.sun.star.lang.EventObject eventObject) { + } + } + +} diff --git a/qadevOOo/tests/java/ifc/view/_XPrintSettingsSupplier.java b/qadevOOo/tests/java/ifc/view/_XPrintSettingsSupplier.java new file mode 100644 index 000000000..cb11b303d --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XPrintSettingsSupplier.java @@ -0,0 +1,53 @@ +/* + * 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.view; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.view.XPrintSettingsSupplier; + + +/** + * Testing <code>com.sun.star.view.XPrintSettingsSupplier</code> + * interface methods : + * <ul> + * <li><code> getPrintSettings()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XPrintSettingsSupplier + */ +public class _XPrintSettingsSupplier extends MultiMethodTest { + + public XPrintSettingsSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getPrintSettings(){ + + XPropertySet oPSS = oObj.getPrintSettings(); + tRes.tested("getPrintSettings()", oPSS != null); + + } // finish _getPrintSettings + +} // finish class _XPrintSettingsSupplier + diff --git a/qadevOOo/tests/java/ifc/view/_XPrintable.java b/qadevOOo/tests/java/ifc/view/_XPrintable.java new file mode 100644 index 000000000..06515f66d --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XPrintable.java @@ -0,0 +1,179 @@ +/* + * 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.view; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.utils; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.view.PaperOrientation; +import com.sun.star.view.XPrintable; + +/** + * Testing <code>com.sun.star.view.XPrintable</code> + * interface methods : + * <ul> + * <li><code> getPrinter()</code></li> + * <li><code> setPrinter()</code></li> + * <li><code> print()</code></li> + * </ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XPrintable + */ +public class _XPrintable extends MultiMethodTest { + + public XPrintable oObj = null; + public PropertyValue[] the_printer = null; + + /** + * Test calls the method and stores returned value. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getPrinter(){ + + the_printer = oObj.getPrinter(); + tRes.tested("getPrinter()",the_printer != null); + } // finish _getPrinter + + /** + * Changes <code>PaperOrientation</code> property in the old + * printer configuration and sets changed value as a new printer.<p> + * + * Has <b> OK </b> status if the <code>getPrinter</code> method + * returns printer with changed property. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getPrinter() </code> : to change one property + * in existing printer configuration. </li> + * </ul> + */ + public void _setPrinter(){ + requiredMethod("getPrinter()"); + int propIdx = 0 ; + while (!"PaperOrientation".equals(the_printer[propIdx].Name)) { + propIdx++ ; + } + PaperOrientation newVal = null ; + if (the_printer[propIdx].Value == PaperOrientation.PORTRAIT) + newVal = PaperOrientation.LANDSCAPE ; + else + newVal = PaperOrientation.PORTRAIT ; + + the_printer[propIdx].Value = newVal ; + + try { + oObj.setPrinter(the_printer); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("couldn't set printer"); + ex.printStackTrace(log); + tRes.tested("setPrinter()",false); + } + + the_printer = oObj.getPrinter() ; + + propIdx = 0 ; + while (!"PaperOrientation".equals(the_printer[propIdx].Name)) { + propIdx++ ; + } + + boolean the_same = the_printer[propIdx].Value == newVal; + tRes.tested("setPrinter()", the_same); + + } // finish _setPrinter + + /** + * Printing performed into file in SOffice temp directory. + * First this file is deleted if it already exist (using + * <code>com.sun.star.ucb.SimpleFileAccess</code> service. + * After that the method with appropriate parameter is + * called.<p> + * + * Has <b> OK </b> status if the file to which printing is made + * exists. <p> + * + * @throws StatusException if service + * <code>com.sun.star.ucb.SimpleFileAccess</code> can't be + * created. + */ + public void _print() throws Exception { + boolean result = true ; + + final String file = "XPrintable.prt" ; + final String fileName = utils.getOfficeTempDirSys(tParam.getMSF())+file ; + final String fileURL = utils.getOfficeTemp(tParam.getMSF()) + file ; + + Object oFAcc = + tParam.getMSF().createInstance + ("com.sun.star.ucb.SimpleFileAccess") ; + XSimpleFileAccess fAcc = UnoRuntime.queryInterface + (XSimpleFileAccess.class, oFAcc) ; + if (fAcc == null) throw new StatusException + (Status.failed("Can't create SimpleFileAccess service")) ; + if (fAcc.exists(fileURL)) { + log.println("Old file exists and will be deleted"); + fAcc.kill(fileURL); + } + + try { + PropertyValue[] PrintOptions = new PropertyValue[2]; + PropertyValue firstProp = new PropertyValue(); + firstProp.Name = "FileName"; + log.println("Printing to :"+fileName); + firstProp.Value = fileName; + firstProp.State = com.sun.star.beans.PropertyState.DEFAULT_VALUE; + PrintOptions[0] = firstProp; + PrintOptions[1] = new PropertyValue(); + PrintOptions[1].Name = "Wait"; + PrintOptions[1].Value = Boolean.TRUE; + oObj.print(PrintOptions); + } + catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("couldn't print"); + ex.printStackTrace(log); + result = false ; + } + + try { + boolean fileExists = fAcc.exists(fileURL); + + log.println("File "+fileName+" exists = "+fileExists); + + if (result) { + result &= fileExists ; + } + } catch (com.sun.star.uno.Exception e) { + log.println("Error while checking file '" + + fileURL + "': "); + e.printStackTrace(log); + result = false ; + } + + tRes.tested("print()", result) ; + + } // finish _print + +} // finish class _XPrintable + + diff --git a/qadevOOo/tests/java/ifc/view/_XScreenCursor.java b/qadevOOo/tests/java/ifc/view/_XScreenCursor.java new file mode 100644 index 000000000..aad7257e3 --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XScreenCursor.java @@ -0,0 +1,78 @@ +/* + * 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.view; + +import lib.MultiMethodTest; + +import com.sun.star.view.XScreenCursor; + + +/** + * Testing <code>com.sun.star.view.XScreenCursor</code> + * interface methods : + * <ul> + * <li><code> screenDown()</code></li> + * <li><code> screenUp()</code></li> + * </ul> <p> + * + * Uses test parameter <b><code>soapi.test.hidewindows</code></b>. + * Methods of this interface works with view representation, + * thereby their calls have no effect when document is opened + * in hidden mode. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XScreenCursor + */ +public class _XScreenCursor extends MultiMethodTest { + + // oObj filled by MultiMethodTest + + public XScreenCursor oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value or if document is + * opened in hidden mode. + */ + public void _screenDown(){ + log.println("test for screenDown() "); + tRes.tested("screenDown()", oObj.screenDown() ); + } + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns + * <code>true</code> value or if document is + * opened in hidden mode. + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> screenDown() </code> : by default view is on the + * top of page, thereby it's needed first to move down. </li> + * </ul> + */ + public void _screenUp(){ + requiredMethod("screenDown()") ; + + log.println("test for screenUp() "); + tRes.tested("screenUp()", oObj.screenUp() ); + } + +} // finish class _XScreenCursor + diff --git a/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java b/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java new file mode 100644 index 000000000..0fa919d94 --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XSelectionSupplier.java @@ -0,0 +1,199 @@ +/* + * 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.view; + +import com.sun.star.lang.EventObject; +import com.sun.star.view.XSelectionChangeListener; +import com.sun.star.view.XSelectionSupplier; +import java.util.Comparator; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + + +/** + * Testing <code>com.sun.star.view.XSelectionSupplier</code> + * interface methods : + * <ul> + * <li><code> select()</code></li> + * <li><code> getSelection()</code></li> + * <li><code> addSelectionChangeListener()</code></li> + * <li><code> removeSelectionChangeListener()</code></li> + * </ul> + * This test needs the following object relations : + * <ul> + * <li> <code>'Selections'</code> of type <code>Object[]</code> : + * the array of the instances which can be selected.</li> + * <li> <code>'Comparer'</code> of type <code>Comparator</code> : + * the interface for comparing of selected instances</li> + * <ul> <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.view.XSelectionSupplier + */ +public class _XSelectionSupplier extends MultiMethodTest { + + public XSelectionSupplier oObj = null; + public boolean selectionChanged = false; + Object[] selections = null; + Comparator<Object> ObjCompare = null; + + @Override + protected void before() { + selections = (Object[])tEnv.getObjRelation("Selections"); + if (selections == null) { + throw new StatusException(Status.failed( + "Couldn't get relation 'Selections'")); + } + + ObjCompare = (Comparator<Object>)tEnv.getObjRelation("Comparer"); + } + + @Override + protected void after() { + disposeEnvironment(); + } + + /** + * Listener implementation which just set flag when listener + * method is called. + */ + public class MyChangeListener implements XSelectionChangeListener { + public void disposing( EventObject oEvent ) {} + public void selectionChanged(EventObject ev) { + log.println("listener called"); + selectionChanged = true; + } + + } + + XSelectionChangeListener listener = new MyChangeListener(); + + /** + * Test adds listener to the object, then selects first and + * then second instances to be sure that selection was changed.<p> + * Has <b>OK</b> status if selection listener was called. + */ + public void _addSelectionChangeListener(){ + boolean res = true; + try { + selectionChanged = false; + oObj.addSelectionChangeListener(listener); + oObj.select(selections[0]); + oObj.select(selections[1]); + res = selectionChanged; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception occurred during addSelectionChangeListener()"); + ex.printStackTrace(log); + res = false; + } + tRes.tested("addSelectionChangeListener()", res); + } + + /** + * Selects an instance from relation 'First'. <p> + * Has <b> OK </b> status if no exceptions were thrown. <p> + */ + public void _select() { + boolean res = true; + boolean locRes = true; + boolean compRes = true; + Object oldSelection = null; + try { + for(int i = 0; i < selections.length; i++) { + oldSelection = oObj.getSelection(); + locRes = oObj.select(selections[i]); + log.println("select #" + i + ": " + locRes); + Object curSelection = oObj.getSelection(); + if (locRes) { + + if (ObjCompare != null) { + compRes = ObjCompare.compare(selections[i], curSelection) == 0; + } else { + compRes = util.ValueComparer.equalValue(selections[i], curSelection); + } + log.println("selected object and current selection are equal: "+compRes); + if (!compRes && (selections[i]) instanceof Object[]){ + if (((Object[])selections[i])[0] instanceof Integer) { + log.println("Getting: "+((Integer) ((Object[])curSelection)[0]).intValue()); + log.println("Expected: "+((Integer) ((Object[])selections[i])[0]).intValue()); + } + } + res &= compRes; + } else { + compRes = util.ValueComparer.equalValue(curSelection, oldSelection); + log.println("previous selection and current selection are equal: "+compRes); + res &= compRes; + } + } + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception occurred during select()"); + ex.printStackTrace(log); + res = false; + } + + tRes.tested("select()", res); + } + + /** + * Test removes listener, then selects first and + * then second instances to be sure that selection was changed.<p> + * Has <b>OK</b> status if selection listener was not called. + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addSelectionChangeListener() </code> : to have + * the listener added. </li> + * </ul> + */ + public void _removeSelectionChangeListener() { + boolean res = false; + requiredMethod("addSelectionChangeListener()"); + try { + selectionChanged = false; + oObj.removeSelectionChangeListener(listener); + oObj.select(selections[0]); + oObj.select(selections[1]); + res = !selectionChanged; + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("Exception occurred during removeSelectionChangeListener()"); + ex.printStackTrace(log); + res = false; + } + tRes.tested("removeSelectionChangeListener()", res); + } + + /** + * First test changes selection of the object : if nothing is + * currently selected or first instance ('First' relation) is + * selected then selects second instance; if second instance + * is currently selected then the first instance is selected. <p> + * Then <code>getSelection</code> is called and values set and + * get are compared. Comparison has some special cases. For + * example if selection is a Cell, then the values contained + * in cells are compared. <p> + * Has <b>OK</b> status if selection changed properly. + */ + public void _getSelection() { + requiredMethod("select()"); + tRes.tested("getSelection()", true); + } + +} // finish class _XSelectionSupplier + + + diff --git a/qadevOOo/tests/java/ifc/view/_XViewSettingsSupplier.java b/qadevOOo/tests/java/ifc/view/_XViewSettingsSupplier.java new file mode 100644 index 000000000..e84a5b7b1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/view/_XViewSettingsSupplier.java @@ -0,0 +1,53 @@ +/* + * 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.view; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.view.XViewSettingsSupplier; + + +/** + * Testing <code>com.sun.star.view.XViewSettingsSupplier</code> + * interface methods : + * <ul> + * <li><code> getViewSettings()</code></li> + * </ul> <p> + * Test is multithread compliant. <p> + * @see com.sun.star.view.XViewSettingsSupplier + */ +public class _XViewSettingsSupplier extends MultiMethodTest { + + public XViewSettingsSupplier oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method returns not + * <code>null</code> value. + */ + public void _getViewSettings(){ + + XPropertySet oTVS = oObj.getViewSettings(); + tRes.tested("getViewSettings()", oTVS != null); + } // finish _getViewSettings + +} // finish class _XViewSettingsSupplier + + |