From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../tests/java/ifc/document/_ExportFilter.java | 42 +++++ .../tests/java/ifc/document/_ImportFilter.java | 43 +++++ qadevOOo/tests/java/ifc/document/_LinkTarget.java | 66 +++++++ .../tests/java/ifc/document/_OfficeDocument.java | 36 ++++ qadevOOo/tests/java/ifc/document/_Settings.java | 160 +++++++++++++++++ .../tests/java/ifc/document/_XActionLockable.java | 100 +++++++++++ .../java/ifc/document/_XDocumentInsertable.java | 190 +++++++++++++++++++++ .../ifc/document/_XEmbeddedObjectSupplier.java | 47 +++++ .../java/ifc/document/_XEventBroadcaster.java | 74 ++++++++ .../tests/java/ifc/document/_XEventsSupplier.java | 51 ++++++ qadevOOo/tests/java/ifc/document/_XExporter.java | 82 +++++++++ qadevOOo/tests/java/ifc/document/_XFilter.java | 177 +++++++++++++++++++ qadevOOo/tests/java/ifc/document/_XImporter.java | 68 ++++++++ .../java/ifc/document/_XLinkTargetSupplier.java | 48 ++++++ .../tests/java/ifc/document/_XMimeTypeInfo.java | 80 +++++++++ .../tests/java/ifc/document/_XTypeDetection.java | 115 +++++++++++++ .../java/ifc/document/_XViewDataSupplier.java | 109 ++++++++++++ 17 files changed, 1488 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/document/_ExportFilter.java create mode 100644 qadevOOo/tests/java/ifc/document/_ImportFilter.java create mode 100644 qadevOOo/tests/java/ifc/document/_LinkTarget.java create mode 100644 qadevOOo/tests/java/ifc/document/_OfficeDocument.java create mode 100644 qadevOOo/tests/java/ifc/document/_Settings.java create mode 100644 qadevOOo/tests/java/ifc/document/_XActionLockable.java create mode 100644 qadevOOo/tests/java/ifc/document/_XDocumentInsertable.java create mode 100644 qadevOOo/tests/java/ifc/document/_XEmbeddedObjectSupplier.java create mode 100644 qadevOOo/tests/java/ifc/document/_XEventBroadcaster.java create mode 100644 qadevOOo/tests/java/ifc/document/_XEventsSupplier.java create mode 100644 qadevOOo/tests/java/ifc/document/_XExporter.java create mode 100644 qadevOOo/tests/java/ifc/document/_XFilter.java create mode 100644 qadevOOo/tests/java/ifc/document/_XImporter.java create mode 100644 qadevOOo/tests/java/ifc/document/_XLinkTargetSupplier.java create mode 100644 qadevOOo/tests/java/ifc/document/_XMimeTypeInfo.java create mode 100644 qadevOOo/tests/java/ifc/document/_XTypeDetection.java create mode 100644 qadevOOo/tests/java/ifc/document/_XViewDataSupplier.java (limited to 'qadevOOo/tests/java/ifc/document') diff --git a/qadevOOo/tests/java/ifc/document/_ExportFilter.java b/qadevOOo/tests/java/ifc/document/_ExportFilter.java new file mode 100644 index 000000000..7fcbdb711 --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_ExportFilter.java @@ -0,0 +1,42 @@ +/* + * 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.document; + +import lib.MultiPropertyTest; + +/** +* Testing com.sun.star.document.ExportFilter +* service properties : +*

+* Properties testing is automated by lib.MultiPropertyTest. +* @see com.sun.star.document.ExportFilter +*/ +public class _ExportFilter extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/document/_ImportFilter.java b/qadevOOo/tests/java/ifc/document/_ImportFilter.java new file mode 100644 index 000000000..aef27e02d --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_ImportFilter.java @@ -0,0 +1,43 @@ +/* + * 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.document; + +/** +* Testing com.sun.star.document.ImportFilter +* service properties : +*

+* Properties testing is automated by lib.MultiPropertyTest. +* @see com.sun.star.document.ImportFilter +*/ +import lib.MultiPropertyTest; + +public class _ImportFilter extends MultiPropertyTest { + + +} + diff --git a/qadevOOo/tests/java/ifc/document/_LinkTarget.java b/qadevOOo/tests/java/ifc/document/_LinkTarget.java new file mode 100644 index 000000000..f39c5d694 --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_LinkTarget.java @@ -0,0 +1,66 @@ +/* + * 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.document; + +import lib.MultiPropertyTest; + +/** +* Testing com.sun.star.document.LinkTarget +* service properties : +*

+* Properties testing is automated by lib.MultiPropertyTest. +* @see com.sun.star.document.LinkTarget +*/ +public class _LinkTarget extends MultiPropertyTest { + +/* + public XPropertySet oObj = null; // oObj filled by MultiMethodTest + + public void _LinkDisplayName() { + // check if Service is available + XServiceInfo xInfo = (XServiceInfo) + UnoRuntime.queryInterface(XServiceInfo.class, oObj); + String [] sa = xInfo.getSupportedServiceNames(); + + for (int i = 0; i < sa.length; i++) { + System.out.println(sa[i]); + } + + if ( ! xInfo.supportsService("com.sun.star.document.LinkTarget")) { + log.println("Service not available !!!!!!!!!!!!!"); + tRes.tested("Supported", false); + } + //the only property is read only + try { + String LDN = (String) oObj.getPropertyValue("LinkDisplayName"); + tRes.tested("LinkDisplayName",LDN!=null); + } + catch (Exception ex) { + log.println("Exception occurred during LinkDisplayName"); + ex.printStackTrace(log); + tRes.tested("LinkDisplayName",false); + } + + }// EOF LinkDisplayName +*/ + +} + diff --git a/qadevOOo/tests/java/ifc/document/_OfficeDocument.java b/qadevOOo/tests/java/ifc/document/_OfficeDocument.java new file mode 100644 index 000000000..7b1c2abde --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_OfficeDocument.java @@ -0,0 +1,36 @@ +/* + * 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.document; + +import lib.MultiPropertyTest; + +/** +* Testing com.sun.star.document.OfficeDocument +* service properties : +*

+* Properties testing is automated by lib.MultiPropertyTest. +* @see com.sun.star.document.OfficeDocument +*/ +public class _OfficeDocument extends MultiPropertyTest { + +} + diff --git a/qadevOOo/tests/java/ifc/document/_Settings.java b/qadevOOo/tests/java/ifc/document/_Settings.java new file mode 100644 index 000000000..a0b0f87b6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_Settings.java @@ -0,0 +1,160 @@ +/* + * 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.document; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.i18n.XForbiddenCharacters; +import com.sun.star.uno.UnoRuntime; +import java.lang.reflect.Method; + +import lib.MultiPropertyTest; +import lib.Status; +import lib.StatusException; + + +/* + * Generic test for all properties contained in this service + */ +public class _Settings extends MultiPropertyTest { + + /** + * This property accepts only values in a range of 1-3 + * @see com.sun.star.document.PrinterIndependentLayout + */ + public void _PrinterIndependentLayout() { + try{ + Short oldVal = (Short) oObj.getPropertyValue("PrinterIndependentLayout"); + Short newVal = oldVal.intValue() == 1 ? Short.valueOf("3") : Short.valueOf("1"); + + + testProperty("PrinterIndependentLayout", oldVal, newVal); + + } catch (com.sun.star.beans.UnknownPropertyException e) { + throw new StatusException(e, Status.failed("the property 'PrinterIndependentLayout' is unknown.")); + } catch (com.sun.star.lang.WrappedTargetException e) { + throw new StatusException(e, Status.failed("the property 'PrinterIndependentLayout' could not be tested.")); + } + } + + public void _PrinterName() { + Object[] oServices = null; + Exception ex = null; + + try { + Class cPrinterJob = Class.forName("java.awt.print.PrinterJob"); + Method lookupMethod = cPrinterJob.getDeclaredMethod("lookupPrintServices", new Class[0]); + Object retValue = lookupMethod.invoke(cPrinterJob, new Object[0]); + oServices = (Object[])retValue; + } + catch(java.lang.ClassNotFoundException e) { + ex = e; + } + catch(java.lang.NoSuchMethodException e) { + ex = e; + } + catch(java.lang.IllegalAccessException e) { + ex = e; + } + catch(java.lang.reflect.InvocationTargetException e) { + ex = e; + } + + if (ex != null) { + // get Java version: + String javaVersion = System.getProperty("java.version"); + throw new StatusException(Status.failed( + "Cannot execute test with current Java version (Java 1.4 required) " + + javaVersion + ": " + ex.getMessage())); + } + + if (oServices.length > 1) { + testProperty("PrinterName", getPrinterNameWithReflection(oServices[0]), + getPrinterNameWithReflection(oServices[1])); + } else { + log.println( + "checking this property needs at least two printers to be installed on your system"); + throw new StatusException(Status.failed( + "only one printer installed so I can't change it")); + } + } + + public void _ForbiddenCharacters() { + boolean res = true; + + try { + //check if it is read only as specified + res &= isReadOnly("ForbiddenCharacters"); + + if (!isReadOnly("ForbiddenCharacters")) { + log.println( + "The Property 'ForbiddenCharacters' isn't readOnly as specified"); + } + + //check if the property has the right type + Object pValue = oObj.getPropertyValue("ForbiddenCharacters"); + XForbiddenCharacters fc = UnoRuntime.queryInterface( + XForbiddenCharacters.class, + pValue); + res &= (fc != null); + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println( + "Exception while checking property 'ForbiddenCharacters' " + + e.getMessage()); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println( + "Exception while checking property 'ForbiddenCharacters' " + + e.getMessage()); + } + + tRes.tested("ForbiddenCharacters", res); + } + + protected boolean isReadOnly(String PropertyName) { + boolean res = false; + Property[] props = oObj.getPropertySetInfo().getProperties(); + + for (int i = 0; i < props.length; i++) { + if (props[i].Name.equals(PropertyName)) { + res = ((props[i].Attributes & PropertyAttribute.READONLY) != 0); + } + } + + return res; + } + + private String getPrinterNameWithReflection(Object pService) { + String pName = null; + try { + Class cPrintService = Class.forName("javax.print.PrintService"); + Method getNameMethod = cPrintService.getDeclaredMethod("getName", new Class[0]); + Object retValue = getNameMethod.invoke(pService, new Object[0]); + pName = (String)retValue; + } + // ignore all exceptions: we already ran into one of these if Java is too old + catch(java.lang.ClassNotFoundException e) { + } + catch(java.lang.NoSuchMethodException e) { + } + catch(java.lang.IllegalAccessException e) { + } + catch(java.lang.reflect.InvocationTargetException e) { + } + return pName; + } +} diff --git a/qadevOOo/tests/java/ifc/document/_XActionLockable.java b/qadevOOo/tests/java/ifc/document/_XActionLockable.java new file mode 100644 index 000000000..8276eb62a --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_XActionLockable.java @@ -0,0 +1,100 @@ +/* + * 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.document; + +import lib.MultiMethodTest; + +import com.sun.star.document.XActionLockable; + +/** +* Testing com.sun.star.document.XActionLockable +* interface methods : +*

+* Test is NOT multithread compliant.

+* @see com.sun.star.document.XActionLockable +*/ +public class _XActionLockable extends MultiMethodTest { + public XActionLockable oObj = null; + + /** + * Method addActionLock called first and then + * checked value returned by isActionLocked().

+ * Has OK status if no runtime exceptions occurred + * and returned value is true. + */ + public void _isActionLocked() { + //determines if at least one lock exists + oObj.addActionLock(); + boolean result = oObj.isActionLocked(); + tRes.tested("isActionLocked()", result); + } + + /** + * Just calls the method.

+ * Has OK status if no runtime exceptions occurred + */ + public void _addActionLock() { + requiredMethod("resetActionLocks()"); + oObj.addActionLock(); + tRes.tested("addActionLock()", true); + } + + /** + * Calls the method and check value returned by isActionLocked().

+ * Has OK status if no runtime exceptions occurred + * and returned value is false. + */ + public void _removeActionLock() { + requiredMethod("addActionLock()"); + oObj.removeActionLock(); + boolean result = ! oObj.isActionLocked(); + tRes.tested("removeActionLock()", result); + } + + /** + * Calls the method with specific value.

+ * Has OK status if no runtime exceptions occurred + */ + public void _setActionLocks() { + oObj.setActionLocks( nLock ); + tRes.tested("setActionLocks()", true); + } + + static final short nLock = 8; + + /** + * Calls the method and checks returned value.

+ * Has OK status if the component is not currently + * locked and returned value is the same as locks number + * set by setActionLocks method test. + */ + public void _resetActionLocks() { + requiredMethod("setActionLocks()"); + short nLocksBeforeReset = oObj.resetActionLocks(); + boolean result = !oObj.isActionLocked() && nLocksBeforeReset == nLock; + tRes.tested("resetActionLocks()", result); + } +}// finish class _XActionLockable + diff --git a/qadevOOo/tests/java/ifc/document/_XDocumentInsertable.java b/qadevOOo/tests/java/ifc/document/_XDocumentInsertable.java new file mode 100644 index 000000000..c3417118e --- /dev/null +++ b/qadevOOo/tests/java/ifc/document/_XDocumentInsertable.java @@ -0,0 +1,190 @@ +/* + * 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.document; + +import com.sun.star.io.IOException; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.utils; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.document.XDocumentInsertable; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; + + +/** +* Testing com.sun.star.document.XDocumentInsertable +* interface methods : +*

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