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 --- qadevOOo/tests/java/ifc/util/_PathSettings.java | 79 ++++ .../tests/java/ifc/util/_SearchDescriptor.java | 44 ++ qadevOOo/tests/java/ifc/util/_XCancellable.java | 57 +++ qadevOOo/tests/java/ifc/util/_XChangesBatch.java | 164 ++++++++ .../tests/java/ifc/util/_XChangesNotifier.java | 213 ++++++++++ qadevOOo/tests/java/ifc/util/_XCloneable.java | 102 +++++ qadevOOo/tests/java/ifc/util/_XFlushable.java | 101 +++++ qadevOOo/tests/java/ifc/util/_XImportable.java | 192 +++++++++ qadevOOo/tests/java/ifc/util/_XModeSelector.java | 95 +++++ qadevOOo/tests/java/ifc/util/_XModifiable.java | 48 +++ .../tests/java/ifc/util/_XModifyBroadcaster.java | 73 ++++ .../java/ifc/util/_XNumberFormatsSupplier.java | 89 ++++ .../tests/java/ifc/util/_XNumberFormatter.java | 119 ++++++ qadevOOo/tests/java/ifc/util/_XProtectable.java | 75 ++++ qadevOOo/tests/java/ifc/util/_XRefreshable.java | 110 +++++ .../tests/java/ifc/util/_XReplaceDescriptor.java | 65 +++ qadevOOo/tests/java/ifc/util/_XReplaceable.java | 140 +++++++ .../tests/java/ifc/util/_XSearchDescriptor.java | 77 ++++ qadevOOo/tests/java/ifc/util/_XSearchable.java | 178 ++++++++ qadevOOo/tests/java/ifc/util/_XSortable.java | 231 +++++++++++ qadevOOo/tests/java/ifc/util/_XStringEscape.java | 55 +++ .../tests/java/ifc/util/_XStringSubstitution.java | 92 ++++ qadevOOo/tests/java/ifc/util/_XURLTransformer.java | 461 +++++++++++++++++++++ 23 files changed, 2860 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/util/_PathSettings.java create mode 100644 qadevOOo/tests/java/ifc/util/_SearchDescriptor.java create mode 100644 qadevOOo/tests/java/ifc/util/_XCancellable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XChangesBatch.java create mode 100644 qadevOOo/tests/java/ifc/util/_XChangesNotifier.java create mode 100644 qadevOOo/tests/java/ifc/util/_XCloneable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XFlushable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XImportable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XModeSelector.java create mode 100644 qadevOOo/tests/java/ifc/util/_XModifiable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XModifyBroadcaster.java create mode 100644 qadevOOo/tests/java/ifc/util/_XNumberFormatsSupplier.java create mode 100644 qadevOOo/tests/java/ifc/util/_XNumberFormatter.java create mode 100644 qadevOOo/tests/java/ifc/util/_XProtectable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XRefreshable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XReplaceDescriptor.java create mode 100644 qadevOOo/tests/java/ifc/util/_XReplaceable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XSearchDescriptor.java create mode 100644 qadevOOo/tests/java/ifc/util/_XSearchable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XSortable.java create mode 100644 qadevOOo/tests/java/ifc/util/_XStringEscape.java create mode 100644 qadevOOo/tests/java/ifc/util/_XStringSubstitution.java create mode 100644 qadevOOo/tests/java/ifc/util/_XURLTransformer.java (limited to 'qadevOOo/tests/java/ifc/util') diff --git a/qadevOOo/tests/java/ifc/util/_PathSettings.java b/qadevOOo/tests/java/ifc/util/_PathSettings.java new file mode 100644 index 000000000..7d6e42f7f --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_PathSettings.java @@ -0,0 +1,79 @@ +/* + * 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.util; + +import lib.MultiPropertyTest; +import util.utils; + +/** + * Testing com.sun.star.util.PathSettings + * service properties : + *

+ * + * Properties testing is automated by lib.MultiPropertyTest. + * @see com.sun.star.util.PathSettings + */ +public class _PathSettings extends MultiPropertyTest { + + /** + * This path list could be empty after SO installation. + * And the URL is validated to match the pattern 'file:///*' + * that's why the custom changing of this property required. + */ + public void _UIConfig() { + testProperty("UIConfig", new PropertyTester() { + @Override + public Object getNewValue(String propName, Object oldVal) { + String path = (String) oldVal; + if (path == null) path = ""; + if (path.length() > 0 && !path.endsWith(";")) { + path += ";"; + } + path += utils.getOfficeTemp(tParam.getMSF()); + return path; + } + }); + } +} + diff --git a/qadevOOo/tests/java/ifc/util/_SearchDescriptor.java b/qadevOOo/tests/java/ifc/util/_SearchDescriptor.java new file mode 100644 index 000000000..e9e883e1b --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_SearchDescriptor.java @@ -0,0 +1,44 @@ +/* + * 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.util; + +import lib.MultiPropertyTest; + +/** + * Testing com.sun.star.util.SearchDescriptor + * service properties : + *

+ * Properties testing is automated by lib.MultiPropertyTest. + * @see com.sun.star.util.SearchDescriptor + */ +public class _SearchDescriptor extends MultiPropertyTest { + +} //finish class _SearchDescriptor + diff --git a/qadevOOo/tests/java/ifc/util/_XCancellable.java b/qadevOOo/tests/java/ifc/util/_XCancellable.java new file mode 100644 index 000000000..85ab779df --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XCancellable.java @@ -0,0 +1,57 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XCancellable; + +/** +* Testing com.sun.star.util.XCancellable +* interface methods : +*

+* @see com.sun.star.util.XCancellable +*/ +public class _XCancellable extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XCancellable oObj = null ; + + /** + * Just calls the method.

+ * Has OK status if no exception has occurred.

+ */ + public void _cancel() { + oObj.cancel() ; + + tRes.tested("cancel()", true) ; + } + + /** + * Forces object recreation. + */ + @Override + public void after() { + disposeEnvironment() ; + } + +} // finish class _XCancellable + diff --git a/qadevOOo/tests/java/ifc/util/_XChangesBatch.java b/qadevOOo/tests/java/ifc/util/_XChangesBatch.java new file mode 100644 index 000000000..c0e87f3ad --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XChangesBatch.java @@ -0,0 +1,164 @@ +/* + * 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.util; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameReplace; +import com.sun.star.util.ElementChange; +import lib.MultiMethodTest; + +import com.sun.star.util.XChangesBatch; +import lib.Status; +import lib.StatusException; + +public class _XChangesBatch extends MultiMethodTest { + + public XChangesBatch oObj; + private Object changeElement = null; + private Object originalElement = null; + private String elementName = null; + private XPropertySet xProp = null; + private XNameReplace xNameReplace = null; + + /** + * add a change that can be committed + */ + @Override + protected void before() { + changeElement = tEnv.getObjRelation("XChangesBatch.ChangeElement"); + originalElement = tEnv.getObjRelation("XChangesBatch.OriginalElement"); + elementName = (String)tEnv.getObjRelation("XChangesBatch.PropertyName"); + + // to do a change, get an XPropertySet + xProp = (XPropertySet)tEnv.getObjRelation("XChangesBatch.PropertySet"); + try { + if (originalElement == null && xProp != null) + originalElement = xProp.getPropertyValue(elementName); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not get property '" + elementName + "'.", e); + } + + // or get an XNameReplace + xNameReplace = (XNameReplace)tEnv.getObjRelation("XChangesBatch.NameReplace"); + try { + if (originalElement == null && xNameReplace != null) + originalElement = xNameReplace.getByName(elementName); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not get element by name '" + elementName + "'.", e); + } + + if (changeElement == null || originalElement == null || elementName == null || (xProp == null && xNameReplace == null)) { + log.println( + (changeElement == null?"Missing property 'XChangesBatch.ChangeElement'\n":"") + + (originalElement == null?"Missing property 'XChangesBatch.OriginalElement'\n":"") + + (elementName == null?"Missing property 'XChangesBatch.PropertyName'\n":"") + + (xProp == null?"Missing property 'XChangesBatch.PropertySet'":"") + + (xNameReplace == null?"Missing property 'XChangesBatch.NameReplace'":"") + ); + throw new StatusException("Some needed object relations are missing.", new Exception()); + } + } + + public void _commitChanges() { + requiredMethod("getPendingChanges()"); + try { + log.println("Committing changes."); + oObj.commitChanges(); + } + catch(com.sun.star.lang.WrappedTargetException e) { + tRes.tested("commitChanges()", Status.exception(e)); + return; + } + try { + executeChange(originalElement); + } + catch(StatusException e) { + tRes.tested("hasPendingChanges()", Status.exception(e)); + return; + } + + try { + log.println("Commit changes back."); + oObj.commitChanges(); + } + catch(com.sun.star.lang.WrappedTargetException e) { + tRes.tested("commitChanges()", Status.exception(e)); + return; + } + tRes.tested("commitChanges()", true); + } + + public void _getPendingChanges() { + requiredMethod("hasPendingChanges()"); + ElementChange[]changes = oObj.getPendingChanges(); + if (changes == null) { + log.println("Returned changes was 'null'"); + log.println("It should have been 1 change."); + tRes.tested("getPendingChanges()", false); + } else if (changes.length != 1) { + int amount = changes.length; + log.println("Found not the right number of changes: " + amount); + log.println("It should have been 1 change."); + for (int i=0; i new Element: '" + + changes[i].Element.toString() + "' ReplacedElement: '" + + changes[i].ReplacedElement.toString() + "'"); + } + tRes.tested("getPendingChanges()", false); + } + else { + boolean result = changes[0].ReplacedElement.equals(originalElement); + result &= changes[0].Element.equals(changeElement); + tRes.tested("getPendingChanges()", result); + } + } + + public void _hasPendingChanges() { + try { + executeChange(changeElement); + } + catch(StatusException e) { + tRes.tested("hasPendingChanges()", Status.exception(e)); + return; + } + boolean hasPendingChanges = oObj.hasPendingChanges(); + tRes.tested("hasPendingChanges()", hasPendingChanges); + } + + private void executeChange(Object element) throws StatusException { + if (xProp != null) { + try { + xProp.setPropertyValue(elementName, element); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not set property '" + elementName + "'.", e); + } + } + else if (xNameReplace != null) { + try { + xNameReplace.replaceByName(elementName, element); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not replace '" + elementName + "' by name.", e); + } + } + } +} diff --git a/qadevOOo/tests/java/ifc/util/_XChangesNotifier.java b/qadevOOo/tests/java/ifc/util/_XChangesNotifier.java new file mode 100644 index 000000000..73592df4e --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XChangesNotifier.java @@ -0,0 +1,213 @@ +/* + * 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.util; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameReplace; +import com.sun.star.util.XChangesBatch; +import com.sun.star.util.XChangesListener; +import com.sun.star.util.XChangesNotifier; +import lib.StatusException; +import lib.MultiMethodTest; + +/** + * Test the XChangesNotifier interface. To produce some changes, + * XChangesBatch is used. + * @see com.sun.star.util.XChangesNotifier + * @see com.sun.star.util.XChangesBatch + */ +public class _XChangesNotifier extends MultiMethodTest { + + public XChangesNotifier oObj = null; + private XChangesBatch xBatch = null; + private Object changeElement = null; + private Object originalElement = null; + private String elementName = null; + private XPropertySet xProp = null; + private XNameReplace xNameReplace = null; + private _XChangesNotifier.MyChangesListener xListener = null; + + /** + * Own implementation of the XChangesListener interface + * @see com.sun.star.util.XChangesListener + */ + private static class MyChangesListener implements XChangesListener { + /** Just lo a call of the listener **/ + boolean bChangesOccurred = false; + + /** A change did occur + * @param changesEvent The event. + **/ + public void changesOccurred(com.sun.star.util.ChangesEvent changesEvent) { + bChangesOccurred = true; + } + + /** Disposing of the listener + * @param eventObject The event. + **/ + public void disposing(com.sun.star.lang.EventObject eventObject) { + bChangesOccurred = true; + } + + /** + * Reset the listener + */ + public void reset() { + bChangesOccurred = false; + } + + /** + * Has the listener been called? + * @return True, if the listener has been called. + */ + public boolean didChangesOccur() { + return bChangesOccurred; + } + } + + /** + * Before the test: get the 'XChangesNotifier.ChangesBatch' object relation + * and create the listener. + */ + @Override + protected void before() { + xBatch = (XChangesBatch)tEnv.getObjRelation("XChangesNotifier.ChangesBatch"); + changeElement = tEnv.getObjRelation("XChangesNotifier.ChangeElement"); + originalElement = tEnv.getObjRelation("XChangesNotifier.OriginalElement"); + elementName = (String)tEnv.getObjRelation("XChangesNotifier.PropertyName"); + + xProp = (XPropertySet)tEnv.getObjRelation("XChangesNotifier.PropertySet"); + try { + if (originalElement == null && xProp != null) + originalElement = xProp.getPropertyValue(elementName); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not get property '" + elementName + "'.", e); + } + + // or get an XNameReplace + xNameReplace = (XNameReplace)tEnv.getObjRelation("XChangesNotifier.NameReplace"); + try { + if (originalElement == null && xNameReplace != null) + originalElement = xNameReplace.getByName(elementName); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not get element by name '" + elementName + "'.", e); + } + + if (changeElement == null || originalElement == null || elementName == null || (xProp == null && xNameReplace == null) || xBatch == null) { + log.println( + (changeElement == null?"Missing property 'XChangesNotifier.ChangeElement'\n":"") + + (originalElement == null?"Missing property 'XChangesNotifier.OriginalElement'\n":"") + + (elementName == null?"Missing property 'XChangesNotifier.PropertyName'\n":"") + + (xProp == null?"Missing property 'XChangesNotifier.PropertySet'":"") + + (xNameReplace == null?"Missing property 'XChangesNotifier.NameReplace'":"") + + (xBatch == null?"Missing property 'XChangesNotifier.ChangesBatch'":"") + ); + throw new StatusException("Some needed object relations are missing.", new Exception()); + } + + xListener = new _XChangesNotifier.MyChangesListener(); + } + + /** test addChangesListener **/ + public void _addChangesListener() { + oObj.addChangesListener(xListener); + tRes.tested("addChangesListener()", true); + } + + /** test removeChangesListener **/ + public void _removeChangesListener() { + requiredMethod("addChangesListener()"); + boolean result = true; + result &= commitChanges(); + result &= xListener.didChangesOccur(); + if (!result) + log.println("Listener has not been called."); + oObj.removeChangesListener(xListener); + xListener.reset(); + result &= redoChanges(); + boolean result2 = xListener.didChangesOccur(); + if (result2) + log.println("Removed listener has been called."); + + tRes.tested("removeChangesListener()", result && !result2); + } + + /** + * Commit a change, using an implementation of the XChangesBatch interface. + * @return true, if changing worked. + */ + private boolean commitChanges() { + if (!executeChange(changeElement)) return false; + if (!xBatch.hasPendingChanges()) return false; + try { + xBatch.commitChanges(); + } + catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + return false; + } + return true; + } + + /** + * Redo the change, using an implementation of the XChangesBatch interface. + * @return true, if changing worked. + */ + private boolean redoChanges() { + if (!executeChange(originalElement)) return false; + if (!xBatch.hasPendingChanges()) return false; + try { + xBatch.commitChanges(); + } + catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + return false; + } + return true; + } + + /** + * Execute the change, use XPropertySet or XNameReplace + * @return False, if changing did throw an exception. + */ + private boolean executeChange(Object element) throws StatusException { + if (xProp != null) { + try { + xProp.setPropertyValue(elementName, element); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(log); + return false; + } + } + else if (xNameReplace != null) { + try { + xNameReplace.replaceByName(elementName, element); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(log); + return false; + } + } + return true; + } + +} diff --git a/qadevOOo/tests/java/ifc/util/_XCloneable.java b/qadevOOo/tests/java/ifc/util/_XCloneable.java new file mode 100644 index 000000000..62de17b01 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XCloneable.java @@ -0,0 +1,102 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import java.util.Arrays; + +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloneable; + +/** +* Testing com.sun.star.util.XCloneable +* interface methods : +*

+* @see com.sun.star.util.XCloneable +*/ +public class _XCloneable extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XCloneable oObj = null ; + protected XCloneable clone = null; + + /** + * calls the method.

+ * Has OK status if no exception has occurred.

+ */ + public void _createClone() { + boolean result = true; + clone = oObj.createClone(); + + //check if the implementationname equals + result &= checkImplementationName(oObj,clone); + + //check ImplementationID + result &= checkImplementationID(oObj, clone); + + tRes.tested("createClone()", result) ; + } + + protected byte[] getImplementationID(XInterface ifc) { + byte[] res = new byte[0]; + XTypeProvider provider = UnoRuntime.queryInterface(XTypeProvider.class, ifc); + if (provider != null) { + res = provider.getImplementationId(); + } + return res; + } + + protected boolean checkImplementationID(XInterface org, XInterface clone) { + boolean res = Arrays.equals(getImplementationID(org), getImplementationID(clone)); + if (res && getImplementationID(org).length > 0) { + log.println("ImplementationID equals the clone has the same id as the original Object"); + log.println("------------------------------------------------------------------------"); + } + return res; + } + + protected String getImplementationName(XInterface ifc) { + String res = ""; + XServiceInfo info = UnoRuntime.queryInterface(XServiceInfo.class, ifc); + if (info != null) { + res = info.getImplementationName(); + } + return res; + } + + protected boolean checkImplementationName(XInterface org, XInterface clone) { + boolean res = getImplementationName(org).equals( + getImplementationName(clone)); + if (!res) { + log.println("ImplementationName differs: "); + log.println("Expected: "+getImplementationName(org)); + log.println("Gained: "+getImplementationName(clone)); + log.println("----------------------------------------"); + } + return res; + } + +} // finish class _XCloneable + diff --git a/qadevOOo/tests/java/ifc/util/_XFlushable.java b/qadevOOo/tests/java/ifc/util/_XFlushable.java new file mode 100644 index 000000000..d8a56bd8d --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XFlushable.java @@ -0,0 +1,101 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XFlushListener; +import com.sun.star.util.XFlushable; + +/** + * Testing com.sun.star.util.XFlushable + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XFlushable + */ +public class _XFlushable extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XFlushable oObj = null ; + + /** + * Simple XFlushListener implementation which + * just registers if any calls to its methods were made. + */ + private static class MyFlushListener implements XFlushListener{ + boolean called = false ; + public void flushed(com.sun.star.lang.EventObject e) { + called = true ; + } + public void disposing(com.sun.star.lang.EventObject e) {} + public boolean wasFlushed() { return called; } + } + + private final MyFlushListener listener1 = new MyFlushListener(), + listener2 = new MyFlushListener() ; + + /** + * Test call method flush and checks if added listener + * was called and removed one wasn't.

+ * Has OK status if no exception has occurred.

+ * Methods to be executed before : + * {@link #_addFlushListener}, + * {@link #_removeFlushListener} + */ + public void _flush() { + executeMethod("addFlushListener()") ; + executeMethod("removeFlushListener()") ; + + oObj.flush() ; + + tRes.tested("flush()", true) ; + tRes.tested("addFlushListener()", listener2.wasFlushed()) ; + tRes.tested("removeFlushListener()", !listener1.wasFlushed()) ; + } + + /** + * Test adds two listeners, one of which will be removed then.

+ * Has OK status if the listener was called on flush() + * method call. + */ + public void _addFlushListener() { + oObj.addFlushListener(listener1) ; + oObj.addFlushListener(listener2) ; + } + + /** + * Test removes one of two listeners added before.

+ * Has OK status if the listener removed wasn't called on + * flush() method call. + * Methods to be executed before : + * {@link #_addFlushListener}, + */ + public void _removeFlushListener() { + executeMethod("addFlushListener()") ; + + oObj.removeFlushListener(listener1) ; + } + +} // finish class _XFlushable + diff --git a/qadevOOo/tests/java/ifc/util/_XImportable.java b/qadevOOo/tests/java/ifc/util/_XImportable.java new file mode 100644 index 000000000..6a36526db --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XImportable.java @@ -0,0 +1,192 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.table.XCellRange; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XImportable; + + +/** + * checks the Interface XImportable + */ +public class _XImportable extends MultiMethodTest { + public XImportable oObj; + protected PropertyValue[] descriptor = null; + protected String[] names = new String[] { + "DatabaseName", "SourceType", "SourceObject", "IsNative" + }; + protected Type[] types = new Type[] { + new Type(String.class), new Type(com.sun.star.sheet.DataImportMode.class), + new Type(String.class), new Type(Boolean.class) + }; + + /** + * creates an ImportDescriptor, the gained PropertyValues can be found + * in com.sun.star.sheet.DatabaseImportDescriptor.
+ * Returns OK state is all propertynames and types are the specified. + */ + + public void _createImportDescriptor() { + boolean res = true; + boolean locResult = false; + + descriptor = oObj.createImportDescriptor(true); + log.print("Getting when calling createImportDescriptor(true) --"); + + + log.println("done"); + + log.print("Checking PropertyNames -- "); + locResult = checkPropertyNames(descriptor, names); + log.println("Worked: " + locResult); + res &= locResult; + + log.print("Checking PropertyTypes -- "); + locResult = checkPropertyTypes(descriptor, types); + log.println("Worked: " + locResult); + res &= locResult; + + descriptor = oObj.createImportDescriptor(false); + log.print("Getting when calling createImportDescriptor(false) -- "); + + + log.println("done"); + + log.print("Checking PropertyNames -- "); + locResult = checkPropertyNames(descriptor, names); + log.println("Worked: " + locResult); + res &= locResult; + + log.print("Checking PropertyTypes -- "); + locResult = checkPropertyTypes(descriptor, types); + log.println("Worked - " + locResult); + res &= locResult; + + tRes.tested("createImportDescriptor()", res); + } + + public void _doImport() { + requiredMethod("createImportDescriptor()"); + boolean res = true; + + log.print("Setting the ImportDescriptor (Bibliograpy, Table, biblio) -- "); + descriptor[0].Value = "Bibliography"; + descriptor[1].Value = com.sun.star.sheet.DataImportMode.TABLE; + descriptor[2].Value = "biblio"; + log.println("done"); + + log.print("Importing data (Bibliograpy, Table, biblio) -- "); + oObj.doImport(descriptor); + log.println("done"); + + log.println("Checking data"); + res &= checkA1("Identifier"); + + log.print("Setting the ImportDescriptor (Bibliograpy, SQL, select Author from biblio) -- "); + descriptor[0].Value = "Bibliography"; + descriptor[1].Value = com.sun.star.sheet.DataImportMode.SQL; + descriptor[2].Value = "select Author from biblio"; + log.println("done"); + + log.print("Importing data (Bibliograpy, SQL, select Author from biblio) -- "); + oObj.doImport(descriptor); + log.println("done"); + + log.println("Checking data"); + res &= checkA1("Author"); + + tRes.tested("doImport()",res); + } + + protected void printPropertyValue(PropertyValue[] props) { + for (int i = 0; i < props.length; i++) { + log.println("\tName: " + props[i].Name); + log.println("\tValue: " + props[i].Value); + } + } + + protected boolean checkPropertyNames(PropertyValue[] props, String[] names) { + boolean res = true; + + for (int i = 0; i < props.length; i++) { + boolean locResult = props[i].Name.equals(names[i]); + + if (!locResult) { + log.println("PropertyName differs for index " + i); + log.println("\tGetting: " + props[i].Name); + log.println("\tExpected: " + names[i]); + } + + res &= locResult; + } + + return res; + } + + protected boolean checkPropertyTypes(PropertyValue[] props, Type[] types) { + boolean res = true; + + for (int i = 0; i < props.length; i++) { + Type ValueType = new Type(props[i].Value.getClass()); + boolean locResult = ValueType.equals(types[i]); + + if (!locResult) { + log.println("PropertyType differs for " + props[i].Name); + log.println("\tGetting: " + ValueType.getTypeName()); + log.println("\tExpected: " + types[i].getTypeName()); + } + + res &= locResult; + } + + return res; + } + + protected boolean checkA1(String expected) { + XCellRange range = UnoRuntime.queryInterface(XCellRange.class, tEnv.getTestObject()); + boolean res = false; + try{ + String a1 = range.getCellByPosition(0,0).getFormula(); + res = a1.equals(expected); + if (!res) { + log.println("\tResult differs from expectation"); + log.println("\tGetting: "+a1); + log.println("\tExpected: "+expected); + } else { + log.println("successful"); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't get Cell to check"); + } + return res; + } + + /** + * Dispose environment. + */ + @Override + protected void after() { + disposeEnvironment(); + } + +} \ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/util/_XModeSelector.java b/qadevOOo/tests/java/ifc/util/_XModeSelector.java new file mode 100644 index 000000000..d787eea42 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XModeSelector.java @@ -0,0 +1,95 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XModeSelector; + +/** +* Testing com.sun.star.util.XModeSelector +* interface methods : +*

+* Test is NOT multithread compliant.

+* @see com.sun.star.util.XModeSelector +*/ +public class _XModeSelector extends MultiMethodTest { + public XModeSelector oObj = null; + + String[] supportedModes; + /** + * Calls the method and as argument pass one of the supported modes + * that was returned by method getSupportedMode.

+ * Has OK status if no runtime exceptions occurred. + */ + public void _setMode() { + requiredMethod("getSupportedModes()"); + try { + oObj.setMode(supportedModes[0]); + } catch(com.sun.star.lang.NoSupportException e) { + log.println("Method setMode() doesn't support mode '" + + supportedModes[0] + "'"); + tRes.tested("setMode()", false); + return ; + } + tRes.tested("setMode()", true); + } + + /** + * Calls the method and check returned value.

+ * Has OK status if no runtime exceptions occurred + * and returned value is equal to value that was set by method setMode. + */ + public void _getMode() { + requiredMethod("setMode()"); + String curMode = oObj.getMode(); + tRes.tested("getMode()", curMode.equals(supportedModes[0])); + } + + /** + * Calls the method and checks value returned by method.

+ * Has OK status if no runtime exceptions occurred + * and returned value is not null. + */ + public void _getSupportedModes() { + supportedModes = oObj.getSupportedModes(); + tRes.tested("getSupportedModes()", supportedModes != null); + } + + /** + * Calls the method. First one of the supported modes that was returned + * by method getSupportedMode is passed as argument. + * Then the method is called again and the mode that is certainly not supported + * is passed. Checks up returned values in both cases.

+ * Has OK status if no runtime exceptions occurred, + * returned value is true in first call and is false in second call. + */ + public void _supportsMode() { + requiredMethod("getSupportedModes()"); + boolean result = oObj.supportsMode(supportedModes[0]) && + ! oObj.supportsMode(supportedModes[0] + "_ForTest"); + tRes.tested("supportsMode()", result); + } +}// finish class _XModeSelector + diff --git a/qadevOOo/tests/java/ifc/util/_XModifiable.java b/qadevOOo/tests/java/ifc/util/_XModifiable.java new file mode 100644 index 000000000..df3e00021 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XModifiable.java @@ -0,0 +1,48 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XModifiable; + + +public class _XModifiable extends MultiMethodTest { + public XModifiable oObj; + + public void _isModified() { + requiredMethod("setModified()"); + tRes.tested("isModified()", true); + } + + public void _setModified() { + boolean res = true; + + try { + oObj.setModified(true); + res = oObj.isModified(); + oObj.setModified(false); + res &= !oObj.isModified(); + } catch (com.sun.star.beans.PropertyVetoException e) { + log.println("Exception while using method " + e.getMessage()); + res = false; + } + + tRes.tested("setModified()", res); + } +} \ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/util/_XModifyBroadcaster.java b/qadevOOo/tests/java/ifc/util/_XModifyBroadcaster.java new file mode 100644 index 000000000..22fa066ab --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XModifyBroadcaster.java @@ -0,0 +1,73 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.lang.EventObject; +import com.sun.star.util.XModifyBroadcaster; +import com.sun.star.util.XModifyListener; + +/** +* Testing com.sun.star.util.XModifyBroadcaster +* interface methods : +*

+* +* Result checking is not performed. Modify +* listeners are called only in case of +* interaction with UI.

+* +* Test is NOT multithread compliant.

+* @see com.sun.star.util.XModifyBroadcaster +*/ +public class _XModifyBroadcaster extends MultiMethodTest { + public XModifyBroadcaster oObj = null; + + private static class TestModifyListener implements XModifyListener { + public void disposing ( EventObject oEvent ) {} + public void modified (EventObject aEvent ) {} + } + + private final TestModifyListener listener = new TestModifyListener(); + + /** + * Just calls the method.

+ * Has OK status if no runtime exceptions occurred + */ + public void _addModifyListener() { + log.println("'Modified' events are called only in case"+ + " of user interaction."); + oObj.addModifyListener(listener); + tRes.tested("addModifyListener()", true); + } + + /** + * Just calls the method.

+ * Has OK status if no runtime exceptions occurred + */ + public void _removeModifyListener() { + requiredMethod("addModifyListener()"); + oObj.removeModifyListener(listener); + tRes.tested("removeModifyListener()", true); + } +}// finish class _XModifyBroadcaster + diff --git a/qadevOOo/tests/java/ifc/util/_XNumberFormatsSupplier.java b/qadevOOo/tests/java/ifc/util/_XNumberFormatsSupplier.java new file mode 100644 index 000000000..65785807d --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XNumberFormatsSupplier.java @@ -0,0 +1,89 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.util.XNumberFormats; +import com.sun.star.util.XNumberFormatsSupplier; + +/** + * Testing com.sun.star.util.XNumberFormatsSupplier + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XNumberFormatsSupplier + */ +public class _XNumberFormatsSupplier extends MultiMethodTest { + + public XNumberFormatsSupplier oObj = null; + + /** + * Get format settings and checks some properties for existence.

+ * + * Has OK status if a number properties inherent to + * NumberFormatSettings service exist in the + * returned XPropertySet.

+ * + * @see com.sun.star.util.NumberFormatSettings + */ + public void _getNumberFormatSettings() { + boolean result = true ; + XPropertySet props = oObj.getNumberFormatSettings(); + + if (props != null) { + try { + result &= props.getPropertyValue("NullDate") != null && + props.getPropertyValue("StandardDecimals") != null && + props.getPropertyValue("NoZero") != null && + props.getPropertyValue("TwoDigitDateStart") != null ; + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println("Some property doesn't exist") ; + e.printStackTrace(log) ; + result = false ; + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log) ; + result = false ; + } + } else { + log.println("Method returns null") ; + result = false ; + } + + tRes.tested("getNumberFormatSettings()", result) ; + } + + /** + * Test calls the method.

+ * Has OK status if the method returns not + * null value. + */ + public void _getNumberFormats() { + XNumberFormats formats = oObj.getNumberFormats(); + + tRes.tested("getNumberFormats()", formats != null) ; + } + +} + + diff --git a/qadevOOo/tests/java/ifc/util/_XNumberFormatter.java b/qadevOOo/tests/java/ifc/util/_XNumberFormatter.java new file mode 100644 index 000000000..01f419ac7 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XNumberFormatter.java @@ -0,0 +1,119 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XNumberFormatter; + + +/** + * Testing com.sun.star.util.XNumberFormatter + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XNumberFormatter + */ +public class _XNumberFormatter extends MultiMethodTest { + + public XNumberFormatter oObj = null; + + /** + * Not implemented yet. + */ + public void _attachNumberFormatsSupplier() { + log.println("Not yet implemented"); + } + + /** + * Tries to convert a number to a string.

+ * Has OK status if the method returns not + * null value. + */ + public void _convertNumberToString() { + double dValue = 1.56; + int key = 15; + + String gString = oObj.convertNumberToString(key,dValue); + + log.println("Getting: "+gString); + tRes.tested("convertNumberToString",gString!=null); + } + + /** + * Not implemented yet. + */ + public void _convertStringToNumber() { + log.println("Not yet implemented"); + } + + /** + * Not implemented yet. + */ + public void _detectNumberFormat() { + log.println("Not yet implemented"); + } + + /** + * Not implemented yet. + */ + public void _formatString() { + log.println("Not yet implemented"); + } + + /** + * Not implemented yet. + */ + public void _getInputString() { + log.println("Not yet implemented"); + } + + /** + * Not implemented yet. + */ + public void _getNumberFormatsSupplier() { + log.println("Not yet implemented"); + } + + /** + * Not implemented yet. + */ + public void _queryColorForNumber() { + log.println("Not yet implemented"); + } + + /** + * Not implemented yet. + */ + public void _queryColorForString() { + log.println("Not yet implemented"); + } +} // finish class _XNumberFormatter + + diff --git a/qadevOOo/tests/java/ifc/util/_XProtectable.java b/qadevOOo/tests/java/ifc/util/_XProtectable.java new file mode 100644 index 000000000..127d30971 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XProtectable.java @@ -0,0 +1,75 @@ +/* + * 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.util; + +import com.sun.star.util.XProtectable; +import lib.MultiMethodTest; + +/** + * Check the XProtectable interface. + */ +public class _XProtectable extends MultiMethodTest { + public XProtectable oObj = null; + String sPassWord = "TopSecret"; + + /** + * Check, if the sheet is protected. + * Has OK status, if this is the case. + */ + public void _isProtected() { + requiredMethod("protect()"); + boolean result = oObj.isProtected(); + tRes.tested("isProtected()", result); + } + + /** + * Protect the sheet + */ + public void _protect() { + oObj.protect(sPassWord); + tRes.tested("protect()", true); + } + + /** + * Unprotect with wrong password, see if it's still protected. + * Unprotect with correct password, see if it's unprotected. + */ + public void _unprotect() { + requiredMethod("isProtected()"); + boolean result = true; + try { + oObj.unprotect("WrongPassword"); +// result = false; + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Correct Exception thrown."); + } + // just check if it's still protected + result &= oObj.isProtected(); + try { + oObj.unprotect(sPassWord); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Wrong Exception thrown: password is correct."); + result = false; + } + result &= !oObj.isProtected(); + tRes.tested("unprotect()", result); + } + +} diff --git a/qadevOOo/tests/java/ifc/util/_XRefreshable.java b/qadevOOo/tests/java/ifc/util/_XRefreshable.java new file mode 100644 index 000000000..1edfae0d5 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XRefreshable.java @@ -0,0 +1,110 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XRefreshListener; +import com.sun.star.util.XRefreshable; + +/** +* Testing com.sun.star.util.XRefreshable +* interface methods : +*

+* Test is NOT multithread compliant.

+* @see com.sun.star.util.XRefreshable +*/ +public class _XRefreshable extends MultiMethodTest { + + public XRefreshable oObj = null; + + final boolean listenerCalled[] = new boolean[1]; + + + /** + * XRefreshListener implementation which + * sets a flag when refreshed method is + * called. + */ + public class MyRefreshListener implements XRefreshListener { + public void refreshed (com.sun.star.lang.EventObject e) { + listenerCalled[0] = true; + } + + public void disposing (com.sun.star.lang.EventObject obj) {} + } + + XRefreshListener listener = new MyRefreshListener(); + + /** + * Just adds a listener.

+ * Always has OK status. + */ + public void _addRefreshListener() { + + oObj.addRefreshListener(listener) ; + tRes.tested("addRefreshListener()", true); + } + + /** + * Calls the method and checks if the listener was called.

+ * Has OK status if listener's flag is set after call. + * The following method tests are to be completed successfully before : + *

+ */ + public void _refresh() { + + requiredMethod("addRefreshListener()"); + + oObj.refresh(); + + tRes.tested("refresh()", listenerCalled[0]); + if (!listenerCalled[0]) + log.println("RefreshListener wasn't called after refresh"); + + } + + /** + * Removes the listener added before and calls refresh + * method. Listener must not be called.

+ * Has OK status if listener's flag isn't changed. + *

+ */ + public void _removeRefreshListener() { + requiredMethod("refresh()"); + listenerCalled[0] = false; + + oObj.removeRefreshListener(listener) ; + oObj.refresh(); + + tRes.tested("removeRefreshListener()", !listenerCalled[0]); + if (listenerCalled[0]) + log.println("RefreshListener was called after removing"); + } +} // finish class _XRefreshable + diff --git a/qadevOOo/tests/java/ifc/util/_XReplaceDescriptor.java b/qadevOOo/tests/java/ifc/util/_XReplaceDescriptor.java new file mode 100644 index 000000000..98249a9db --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XReplaceDescriptor.java @@ -0,0 +1,65 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XReplaceDescriptor; + +/** + * Testing com.sun.star.util.XReplaceDescriptor + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XReplaceDescriptor + */ +public class _XReplaceDescriptor extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XReplaceDescriptor oObj = null; + + /** + * Test calls the method.

+ * Has OK status if the method returns not + * null value. + */ + public void _getReplaceString(){ + log.println("test for getReplaceString() "); + tRes.tested("getReplaceString()", oObj.getReplaceString()!=null); + } + + /** + * Set a new string and checks the result.

+ * Has OK status if the string before setting differs + * from string after setting.

+ */ + public void _setReplaceString(){ + log.println("test for setReplaceString() "); + String oldReplaceStr = oObj.getReplaceString(); + oObj.setReplaceString("XReplaceDescriptor"); + String cmpReplaceStr = oObj.getReplaceString(); + tRes.tested("setReplaceString()", !(cmpReplaceStr.equals(oldReplaceStr))); + } + +} // finish class _XReplaceDescriptor + + diff --git a/qadevOOo/tests/java/ifc/util/_XReplaceable.java b/qadevOOo/tests/java/ifc/util/_XReplaceable.java new file mode 100644 index 000000000..db80a4ed3 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XReplaceable.java @@ -0,0 +1,140 @@ +/* + * 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.util; + +import com.sun.star.table.XCell; +import lib.MultiMethodTest; + +import com.sun.star.util.XReplaceDescriptor; +import com.sun.star.util.XReplaceable; +import com.sun.star.util.XSearchDescriptor; + +/** + * Testing com.sun.star.util.XReplaceable + * interface methods : + *

+ * + * The requipment for the tested object is that it + * must contain string 'xTextDoc'. Only + * in that case this interface is tested correctly.

+ * + * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XReplaceable + */ +public class _XReplaceable extends MultiMethodTest { + + public XReplaceable oObj = null; + public XReplaceDescriptor Rdesc = null; + private String mSearchString = "xTextDoc"; + private static final String mReplaceString = "** xTextDoc"; + private boolean mDispose = false; + + /** + * Creates an entry to search for, if the current object does not provide + * one. In this case, the environment is disposed after the test, since + * the inserted object may influence following tests. + * + */ + @Override + protected void before() { + Object o = tEnv.getObjRelation("SEARCHSTRING"); + if (o != null) { + mSearchString = (String)o; + } + // use object relation for XSearchable + o = tEnv.getObjRelation("XSearchable.MAKEENTRYINCELL"); + if (o != null) { + XCell[] cells = new XCell[0]; + if (o instanceof XCell) { + cells = new XCell[]{(XCell)o}; + } + else if (o instanceof XCell[]) { + cells = (XCell[])o; + } + else { + log.println("Needed object relation 'XSearchable.MAKEENTRYINCELL' is there, but is of type '" + + o.getClass().getName() + "'. Should be 'XCell' or 'XCell[]' instead."); + } + for (int i=0; i + * Has OK status if the returned descriptor is not + * null.

+ */ + public void _createReplaceDescriptor() { + + log.println("testing createReplaceDescriptor() ... "); + + Rdesc = oObj.createReplaceDescriptor(); + Rdesc.setSearchString(mSearchString); + Rdesc.setReplaceString(mReplaceString); + tRes.tested("createReplaceDescriptor()", true); + + } + + /** + * Replaces the text using descriptor created before. Then + * search is performed in the target text.

+ * + * Has OK status if the string '**' is found in + * the text.

+ * + * The following method tests are to be completed successfully before : + *

+ */ + public void _replaceAll() { + requiredMethod("createReplaceDescriptor()"); + oObj.replaceAll(Rdesc); + XSearchDescriptor SDesc = oObj.createSearchDescriptor(); + SDesc.setSearchString("**"); + boolean res = (oObj.findFirst(SDesc) != null); + // redo replacement + Rdesc.setSearchString(mReplaceString); + Rdesc.setReplaceString(mSearchString); + oObj.replaceAll(Rdesc); + res &= (oObj.findFirst(SDesc) == null); + + tRes.tested("replaceAll()",res); + } + + /** + * In case the interface itself made the entry to search for, the environment + * must be disposed + */ + @Override + protected void after() { + if(mDispose) { + disposeEnvironment(); + } + } +} + diff --git a/qadevOOo/tests/java/ifc/util/_XSearchDescriptor.java b/qadevOOo/tests/java/ifc/util/_XSearchDescriptor.java new file mode 100644 index 000000000..bc7fc1510 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XSearchDescriptor.java @@ -0,0 +1,77 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.util.XSearchDescriptor; + +/** + * Testing com.sun.star.util.XSearchDescriptor + * interface methods : + *

+ * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XSearchDescriptor + */ +public class _XSearchDescriptor extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XSearchDescriptor oObj = null; + + /** + * Test calls the method.

+ * Has OK status if the method returns not + * null value. + */ + public void _getSearchString(){ + boolean bResult = false; + String searchStr = null; + + log.println("test for getSearchString() "); + searchStr = oObj.getSearchString(); + + if (searchStr != null){ bResult = true; } + tRes.tested("getSearchString()", bResult); + } + + /** + * Set a new string and checks the result.

+ * Has OK status if the string before setting differs + * from string after setting.

+ */ + public void _setSearchString(){ + boolean bResult = false; + String oldSearchStr = null; + String cmpSearchStr = null; + String newSearchStr = "_XSearchDescriptor"; + log.println("test for setSearchString() "); + + oldSearchStr = oObj.getSearchString(); + oObj.setSearchString(newSearchStr); + cmpSearchStr = oObj.getSearchString(); + + if(!(cmpSearchStr.equals(oldSearchStr))){ bResult = true; } + tRes.tested("setSearchString()", bResult); + } + +} // finish class _XSearchDescriptor + diff --git a/qadevOOo/tests/java/ifc/util/_XSearchable.java b/qadevOOo/tests/java/ifc/util/_XSearchable.java new file mode 100644 index 000000000..5c0f6789a --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XSearchable.java @@ -0,0 +1,178 @@ +/* + * 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.util; + +import lib.MultiMethodTest; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.table.XCell; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; + +/** + * Testing com.sun.star.util.XSearchable + * interface methods : + *

+ * + * The requipment for the tested object is that it + * must contain string 'xTextDoc'. Only + * in that case this interface is tested correctly.

+ * + * Test is NOT multithread compliant.

+ * @see com.sun.star.util.XSearchable + */ +public class _XSearchable extends MultiMethodTest { + + public XSearchable oObj = null; // oObj filled by MultiMethodTest + public XSearchDescriptor Sdesc = null; + public Object start = null; + private String mSearchString = "xTextDoc"; + private boolean mDispose = false; + private boolean mExcludeFindNext = false; + + /** + * Creates an entry to search for, if the current object does not provide + * one. In this case, the environment is disposed after the test, since + * the inserted object may influence following tests. + * + */ + @Override + protected void before() { + Object o = tEnv.getObjRelation("SEARCHSTRING"); + if (o != null) { + mSearchString = (String)o; + } + o = tEnv.getObjRelation("XSearchable.MAKEENTRYINCELL"); + if (o != null) { + XCell[] cells = new XCell[0]; + if (o instanceof XCell) { + cells = new XCell[]{(XCell)o}; + } + else if (o instanceof XCell[]) { + cells = (XCell[])o; + } + else { + log.println("Needed object relation 'XSearchable.MAKEENTRYINCELL' is there, but is of type '" + + o.getClass().getName() + "'. Should be 'XCell' or 'XCell[]' instead."); + } + for (int i=0; i + * Has OK status if the method returns not + * null value. + */ + public void _createSearchDescriptor() { + + log.println("testing createSearchDescriptor() ... "); + + Sdesc = oObj.createSearchDescriptor(); + Sdesc.setSearchString(mSearchString); + tRes.tested("createSearchDescriptor()", true); + + } + + /** + * Performs search using descriptor created before.

+ * Has OK status if the method not null + * collections.

+ * The following method tests are to be completed successfully before : + *

+ */ + public void _findAll() { + + requiredMethod("createSearchDescriptor()"); + log.println("testing findAll()"); + + XIndexAccess IA = oObj.findAll(Sdesc); + tRes.tested("findAll()", IA != null); + } + + /** + * Performs search using descriptor created before. Storing the + * first occurrence result.

+ * Has OK status if the method not null + * value.

+ * The following method tests are to be completed successfully before : + *

+ */ + public void _findFirst() { + + requiredMethod("createSearchDescriptor()"); + log.println("testing findFirst()"); + start = oObj.findFirst(Sdesc); + tRes.tested("findFirst()", start != null); + } + + /** + * Performs search using descriptor and first search result + * created before.

+ * Has OK status if the method not null + * value.

+ * The following method tests are to be completed successfully before : + *

+ */ + public void _findNext() { + if (mExcludeFindNext) { + log.println("Testing findNext() excluded, because only one" + + " search result is available."); + tRes.tested("findNext()", true); + } + else{ + requiredMethod("findFirst()"); + + log.println("testing findNext()"); + Object xI = oObj.findNext(start,Sdesc); + tRes.tested("findNext()", xI != null); + } + } + + /** + * In case the interface itself made the entry to search for, the environment + * must be disposed + */ + @Override + protected void after() { + if(mDispose) { + disposeEnvironment(); + } + } +} + + diff --git a/qadevOOo/tests/java/ifc/util/_XSortable.java b/qadevOOo/tests/java/ifc/util/_XSortable.java new file mode 100644 index 000000000..e43c93c16 --- /dev/null +++ b/qadevOOo/tests/java/ifc/util/_XSortable.java @@ -0,0 +1,231 @@ +/* + * 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.util; + +import java.io.PrintWriter; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.table.TableSortField; +import com.sun.star.util.XSortable; + + +/** + * Testing com.sun.star.util.XSortable + * interface methods : + *

+ * This test needs the following object relations : + *