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/reflection/_XIdlReflection.java | 97 ++++++++++++++++++++++ .../tests/java/ifc/reflection/_XProxyFactory.java | 88 ++++++++++++++++++++ .../_XTypeDescriptionEnumerationAccess.java | 86 +++++++++++++++++++ 3 files changed, 271 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/reflection/_XIdlReflection.java create mode 100644 qadevOOo/tests/java/ifc/reflection/_XProxyFactory.java create mode 100644 qadevOOo/tests/java/ifc/reflection/_XTypeDescriptionEnumerationAccess.java (limited to 'qadevOOo/tests/java/ifc/reflection') diff --git a/qadevOOo/tests/java/ifc/reflection/_XIdlReflection.java b/qadevOOo/tests/java/ifc/reflection/_XIdlReflection.java new file mode 100644 index 000000000..f77b3ba7b --- /dev/null +++ b/qadevOOo/tests/java/ifc/reflection/_XIdlReflection.java @@ -0,0 +1,97 @@ +/* + * 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.reflection; + +import com.sun.star.reflection.XIdlClass; +import com.sun.star.reflection.XIdlReflection; +import com.sun.star.uno.TypeClass; +import lib.MultiMethodTest; + +/** +* Testing com.sun.star.reflection.XIdlReflection +* interface methods : +*

+* @see com.sun.star.reflection.XIdlReflection +*/ +public class _XIdlReflection extends MultiMethodTest{ + public XIdlReflection oObj = null; + protected static final String typeName = "com.sun.star.container.XNameAccess"; + + /** + * Test calls the method and checks returned interface + * com.sun.star.container.XNameAccess: gets the name and the + * type and checks it.

+ * Has OK status if returned name is equal to the name of the + * interface that was passed as parameter in the method call and if returned + * type is equal to com.sun.star.uno.TypeClass.INTERFACE.

+ */ + public void _forName() { + boolean result = true; + XIdlClass cls = oObj.forName(typeName); + + if (cls != null) { + log.println("Class name: " + cls.getName()); + result &= cls.getTypeClass() == TypeClass.INTERFACE; + result &= typeName.equals(cls.getName()); + } else { + log.println("Method returned null"); + result = false; + } + + tRes.tested("forName()", result); + } + + /** + * Test creates the instance of com.sun.star.io.Pipe, + * calls the method using this instance as parameter and checks returned + * value.

+ * Has OK status if the instance was created successfully, if + * returned value isn't null and no exceptions were thrown.

+ */ + public void _getType() { + Object obj = null; + + try { + obj = tParam.getMSF(). + createInstance("com.sun.star.io.Pipe") ; + } catch (com.sun.star.uno.Exception e) { + log.println("Can't create object"); + tRes.tested("getType()", false); + return; + } + + if (obj == null) { + log.println("Object wasn't created !"); + tRes.tested("getType()", false); + } + + XIdlClass cls = oObj.getType(obj); + + if (cls != null) { + log.println("The name is " + cls.getName()); + } + + tRes.tested("getType()", cls != null); + } +} + + diff --git a/qadevOOo/tests/java/ifc/reflection/_XProxyFactory.java b/qadevOOo/tests/java/ifc/reflection/_XProxyFactory.java new file mode 100644 index 000000000..f278f7372 --- /dev/null +++ b/qadevOOo/tests/java/ifc/reflection/_XProxyFactory.java @@ -0,0 +1,88 @@ +/* + * 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.reflection; + +import lib.MultiMethodTest; + +import com.sun.star.lang.XInitialization; +import com.sun.star.reflection.XProxyFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XAggregation; + +/** +/** +* Testing com.sun.star.reflection.XProxyFactory +* interface methods : +*

+* Test is NOT multithread compliant.

+* @see com.sun.star.reflection.XProxyFactory +*/ +public class _XProxyFactory extends MultiMethodTest { + /** Is initialized in super class(using reflection API) + * when instantiating the test. + */ + public XProxyFactory oObj; + + /* + * First an implementation of + * com.sun.star.lang.XInitialization interface + * is made which sets a flag when its initialize() + * method is called. Then an instance of this implementation + * is created and a proxy object is created for it. Proxy + * object is tried to query for XInitialization + * interface and it's initialize method is + * called. The goal is to check if the real object method + * was called through its proxy.

+ * Has OK status if the real object method was + * called and parameters were passed correctly. + */ + public void _createProxy() { + class MyObject implements XInitialization { + Object[] params; + + public void initialize(Object args[]) { + params = args; + } + } + + MyObject obj = new MyObject(); + + XAggregation xAggr = oObj.createProxy(obj); + + XInitialization xInit = UnoRuntime.queryInterface( + XInitialization.class, xAggr); + + Object params[] = new Object[0]; + + try { + xInit.initialize(params); + } catch(com.sun.star.uno.Exception e) { + log.println("Unexpected exception : " + e.getMessage()); + e.printStackTrace(log); + tRes.tested("createProxy()", false); + return; + } + + tRes.tested("createProxy()", + util.ValueComparer.equalValue(params, obj.params)); + } +} + diff --git a/qadevOOo/tests/java/ifc/reflection/_XTypeDescriptionEnumerationAccess.java b/qadevOOo/tests/java/ifc/reflection/_XTypeDescriptionEnumerationAccess.java new file mode 100644 index 000000000..b4efdcdd0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/reflection/_XTypeDescriptionEnumerationAccess.java @@ -0,0 +1,86 @@ +/* + * 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.reflection; + +import lib.MultiMethodTest; + +import com.sun.star.reflection.TypeDescriptionSearchDepth; +import com.sun.star.reflection.XTypeDescription; +import com.sun.star.reflection.XTypeDescriptionEnumeration; +import com.sun.star.reflection.XTypeDescriptionEnumerationAccess; +import com.sun.star.uno.TypeClass; + +/** + * Testing com.sun.star.reflection.XTypeDescriptionEnumerationAccess + *
+ * Needed object relation: + *

+ */ +public class _XTypeDescriptionEnumerationAccess extends MultiMethodTest { + public XTypeDescriptionEnumerationAccess oObj = null; + + /** + * Search the type database for all information regarding the object + * relation 'SearchString'. Search depth is infinite and information + * about all types is gathered. + */ + public void _createTypeDescriptionEnumeration() { + int i=0; + TypeClass[] tClass = new TypeClass[0]; + String sString = (String)tEnv.getObjRelation("SearchString"); + if (sString == null || sString.equals("")) { + System.out.println("Cannot get object relation 'SearchString'"); + tRes.tested("createTypeDescriptionEnumeration()", false); + return; + } + try { + XTypeDescriptionEnumeration oEnum = + oObj.createTypeDescriptionEnumeration(sString, tClass, + TypeDescriptionSearchDepth.INFINITE); + try { + log.println("Got an enumeration."); + while (true) { + XTypeDescription desc = oEnum.nextTypeDescription(); + i++; + log.println("\tdesc name: " + desc.getName()); + } + } + catch(com.sun.star.container.NoSuchElementException e) { + log.println( + "Correct exception caught for exiting enumeration."); + log.println("Returned were " + i + " type descriptions."); + } + catch(Exception e) { + log.println("Exception while accessing the enumeration."); + log.println("Index is " + i); + log.println(e.getMessage()); + tRes.tested("createTypeDescriptionEnumeration()", false); + return; + } + tRes.tested("createTypeDescriptionEnumeration()", i>0); + } + catch(Exception e) { + log.println("Cannot execute method."); + log.println(e.getMessage()); + tRes.tested("createTypeDescriptionEnumeration()", false); + } + } +} -- cgit v1.2.3