xref: /aoo41x/main/stoc/test/testcorefl.cxx (revision 647a425c)
1*647a425cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*647a425cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*647a425cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*647a425cSAndrew Rist  * distributed with this work for additional information
6*647a425cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*647a425cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*647a425cSAndrew Rist  * "License"); you may not use this file except in compliance
9*647a425cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*647a425cSAndrew Rist  *
11*647a425cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*647a425cSAndrew Rist  *
13*647a425cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*647a425cSAndrew Rist  * software distributed under the License is distributed on an
15*647a425cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*647a425cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*647a425cSAndrew Rist  * specific language governing permissions and limitations
18*647a425cSAndrew Rist  * under the License.
19*647a425cSAndrew Rist  *
20*647a425cSAndrew Rist  *************************************************************/
21*647a425cSAndrew Rist 
22*647a425cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_stoc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/main.h>
28cdf0e10cSrcweir #include <osl/diagnose.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
31cdf0e10cSrcweir #define TEST_ENSHURE(c, m)   OSL_ENSURE(c, m)
32cdf0e10cSrcweir #else
33cdf0e10cSrcweir #define TEST_ENSHURE(c, m)   OSL_VERIFY(c)
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
37cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
38cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <ModuleA/XInterface1.hpp>
41cdf0e10cSrcweir #include <ModuleC/XInterfaceA.hpp>
42cdf0e10cSrcweir #include <ModuleC/XInterfaceB.hpp>
43cdf0e10cSrcweir #include <ModuleC/ModuleC.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
46cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
47cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlReflection.hpp>
48cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlField2.hpp>
49cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
50cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp>
51cdf0e10cSrcweir #include <com/sun/star/registry/XImplementationRegistration.hpp>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <stdio.h>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace rtl;
59cdf0e10cSrcweir using namespace cppu;
60cdf0e10cSrcweir using namespace osl;
61cdf0e10cSrcweir using namespace ModuleA;
62cdf0e10cSrcweir using namespace ModuleB;
63cdf0e10cSrcweir using namespace ModuleC;
64cdf0e10cSrcweir using namespace ModuleA::ModuleB;
65cdf0e10cSrcweir using namespace com::sun::star;
66cdf0e10cSrcweir using namespace com::sun::star::uno;
67cdf0e10cSrcweir using namespace com::sun::star::lang;
68cdf0e10cSrcweir using namespace com::sun::star::beans;
69cdf0e10cSrcweir using namespace com::sun::star::registry;
70cdf0e10cSrcweir using namespace com::sun::star::reflection;
71cdf0e10cSrcweir using namespace com::sun::star::container;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //==================================================================================================
75cdf0e10cSrcweir class OInterfaceA : public WeakImplHelper1< XInterfaceA >
76cdf0e10cSrcweir {
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir 
methodA(void)79cdf0e10cSrcweir     virtual void SAL_CALL methodA(void) throw (RuntimeException)
80cdf0e10cSrcweir 		{}
81cdf0e10cSrcweir 
methodB(sal_Int16)82cdf0e10cSrcweir     virtual void SAL_CALL methodB(sal_Int16 /*aShort*/) throw (RuntimeException)
83cdf0e10cSrcweir 		{}
methodC(const StructC &,StructA &)84cdf0e10cSrcweir     virtual Sequence< StructB > SAL_CALL methodC(const StructC& /*aStructC*/, StructA& /*aStructA*/) throw (RuntimeException)
85cdf0e10cSrcweir 		{ return Sequence< StructB >(); }
86cdf0e10cSrcweir };
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //==================================================================================================
uik_equals(const Uik & rUik1,const Uik & rUik2)89cdf0e10cSrcweir static inline bool uik_equals( const Uik & rUik1, const Uik & rUik2 )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	return (rUik1.m_Data1 == rUik2.m_Data1 &&
92cdf0e10cSrcweir 			rUik1.m_Data2 == rUik2.m_Data2 &&
93cdf0e10cSrcweir 			rUik1.m_Data3 == rUik2.m_Data3 &&
94cdf0e10cSrcweir 			rUik1.m_Data4 == rUik2.m_Data4 &&
95cdf0e10cSrcweir 			rUik1.m_Data5 == rUik2.m_Data5);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir //==================================================================================================
test_corefl(const Reference<XIdlReflection> & xRefl)98cdf0e10cSrcweir static sal_Bool test_corefl( const Reference< XIdlReflection > & xRefl )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir 	Reference< XIdlClass > xClass;
101cdf0e10cSrcweir 	Reference< XHierarchicalNameAccess > xHNameAccess( xRefl, UNO_QUERY );
102cdf0e10cSrcweir 	TEST_ENSHURE(xHNameAccess.is(), "### cannot get XHierarchicalNameAccess!" );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 2b");
105cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ExceptionB"))->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 2c");
106cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA")).is(), "test_RegCoreReflection(): error 2e");
107cdf0e10cSrcweir 	// const
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	TEST_ENSHURE(*(const sal_Bool *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstBoolean")).getValue() == aConstBoolean, "test_RegCoreReflection(): error 4c");
110cdf0e10cSrcweir 	TEST_ENSHURE(*(const sal_Int8 *)xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstByte")).getValue() == aConstByte, "test_RegCoreReflection(): error 4e");
111cdf0e10cSrcweir 	TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstShort")) == aConstShort, "test_RegCoreReflection(): error 4g");
112cdf0e10cSrcweir 	TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstUShort")) == aConstUShort, "test_RegCoreReflection(): error 4i");
113cdf0e10cSrcweir 	TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstLong")) == aConstLong, "test_RegCoreReflection(): error 4k");
114cdf0e10cSrcweir 	TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstULong")) == aConstULong, "test_RegCoreReflection(): error 4m");
115cdf0e10cSrcweir //  	TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstFloat")) == aConstFloat, "test_RegCoreReflection(): error 4o");
116cdf0e10cSrcweir //  	TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstDouble")) == aConstDouble, "test_RegCoreReflection(): error 4q");
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	// Enums
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	xClass = xRefl->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA"));
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 5");
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	Sequence<Reference< XIdlField > > fields = xClass->getFields();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	TEST_ENSHURE(
127cdf0e10cSrcweir 		(fields.getLength() == 3) &&
128cdf0e10cSrcweir 		(fields.getArray()[0]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_1") )) &&
129cdf0e10cSrcweir 		(*(EnumA*)fields.getArray()[0]->get(Any()).getValue() == EnumA_VAL_1) &&
130cdf0e10cSrcweir 		(fields.getArray()[1]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_2") )) &&
131cdf0e10cSrcweir 		(*(EnumA*)fields.getArray()[1]->get(Any()).getValue() == EnumA_VAL_2) &&
132cdf0e10cSrcweir 		(fields.getArray()[2]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_3") )) &&
133cdf0e10cSrcweir 		(*(EnumA*)fields.getArray()[2]->get(Any()).getValue() == EnumA_VAL_3),
134cdf0e10cSrcweir 		"test_RegCoreReflection(): error 6");
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	// Interface
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	Reference< XIdlClass > xA = xRefl->forName( OUString::createFromAscii("ModuleC.XInterfaceB") );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	xClass = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceB"));
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	TEST_ENSHURE(xClass == xA, "test_RegCoreReflection(): error 7");
144cdf0e10cSrcweir 	TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 7a");
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	typelib_TypeDescription * pTD = 0;
147cdf0e10cSrcweir 	OUString aModuleName( RTL_CONSTASCII_USTRINGPARAM("ModuleC.XInterfaceB") );
148cdf0e10cSrcweir 	typelib_typedescription_getByName( &pTD, aModuleName.pData );
149cdf0e10cSrcweir 	TEST_ENSHURE( pTD, "### cannot get typedescription for ModuleC.XInterfaceB!" );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	TEST_ENSHURE( uik_equals( *(Uik *)&((typelib_InterfaceTypeDescription *)pTD)->aUik,
152cdf0e10cSrcweir 							  xClass->getUik() ),
153cdf0e10cSrcweir 				  "test_RegCoreReflection(): error 8" );
154cdf0e10cSrcweir 	typelib_typedescription_release( pTD );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getSuperclasses().getLength() == 1, "test_RegCoreReflection(): error 9");
157cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getSuperclasses().getArray()[0]->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 10");
158cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11");
159cdf0e10cSrcweir 	TEST_ENSHURE(xA->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11a");
160cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[3]->getName() == OUString::createFromAscii("methodA"), "test_RegCoreReflection(): 12");
161cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[3]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 13");
162cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[3]->getParameterTypes().getLength() == 0, "test_RegCoreReflection(): error 14");
163cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[3]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 15");
164cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("methodB") ), "test_RegCoreReflection(): error 16");
165cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getMode() == MethodMode_ONEWAY, "test_RegCoreReflection(): error 16a");
166cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 16");
167cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 17");
168cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_SHORT, "test_RegCoreReflection(): error 18");
169cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aName == OUString( RTL_CONSTASCII_USTRINGPARAM("aShort") ), "test_RegCoreReflection(): error 18a");
170cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aType == xRefl->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("short") ) ), "test_RegCoreReflection(): error 18b");
171cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aMode == ParamMode_IN, "test_RegCoreReflection(): error 18c");
172cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[4]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 19");
173cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getName() == OUString::createFromAscii("methodC"), "test_RegCoreReflection(): error 20");
174cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getMode() == MethodMode_TWOWAY, "test_RegCoreReflection(): error 20a");
175cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 21");
176cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 22");
177cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructB"), "test_RegCoreReflection(): error 23");
178cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getLength() == 2, "test_RegCoreReflection(): error 24");
179cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 25");
180cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 26");
181cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 27");
182cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 28");
183cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[5]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 29");
184cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getName() == OUString::createFromAscii("methodD"), "test_RegCoreReflection(): error 30");
185cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 31");
186cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getReturnType()->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 32");
187cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 33");
188cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_ENUM, "test_RegCoreReflection(): error 34");
189cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ModuleB.EnumA"), "test_RegCoreReflection(): error 35");
190cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getLength() == 3, "test_RegCoreReflection(): error 36");
191cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 37");
192cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ExceptionA"), "test_RegCoreReflection(): error 38");
193cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 38");
194cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.ExceptionB"), "test_RegCoreReflection(): error 39");
195cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 40");
196cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getName() == OUString::createFromAscii("ModuleA.ExceptionC"), "test_RegCoreReflection(): error 41");
197cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getLength() == 3, "test_RegCoreReflection(): error 42");
198cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getTypeClass() == TypeClass_BOOLEAN, "test_RegCoreReflection(): error 43");
199cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getName() == OUString::createFromAscii("boolean"), "test_RegCoreReflection(): error 43a");
200cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 44");
201cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 45");
202cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 46");
203cdf0e10cSrcweir 	TEST_ENSHURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getName() == OUString::createFromAscii("ModuleA.XInterface1"), "test_RegCoreReflection(): error 47");
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	// SequenceReflections
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 48");
208cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getComponentType().is(), "test_RegCoreReflection(): error 49");
209cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[][]ModuleA.StructA") )->getComponentType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 50");
210cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName( OUString::createFromAscii("[]com.sun.star.uno.XInterface") ) == xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType(), "test_RegCoreReflection(): error 51");
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 	StructC aStructC;
213cdf0e10cSrcweir 	aStructC.aLong = aConstLong;
214cdf0e10cSrcweir 	aStructC.aShort = aConstShort;
215cdf0e10cSrcweir 	aStructC.aFloat = aConstFloat;
216cdf0e10cSrcweir 	aStructC.aDouble = aConstDouble;
217cdf0e10cSrcweir 	aStructC.aInterfaceSeq = Sequence<Reference<XInterface > >();
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	Any aAny;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType()->createObject(aAny);
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	TEST_ENSHURE(aAny.getValueType() == ::getCppuType( (const Sequence<Reference< XInterface > > *)0 ), "test_RegCoreReflection(): error 51a");
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	Any aStructAny(&aStructC, ::getCppuType( (const StructC *) 0 ));
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	sal_Int32 nLong = aConstLong * 2;
228cdf0e10cSrcweir 	aAny.setValue( &nLong, ::getCppuType( (const sal_Int32 *)0 ) );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructA") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(
231cdf0e10cSrcweir 		Any(&aStructC, ::getCppuType( (const StructC *)0 ))).getValue() == aConstLong, "test_RegCoreReflection(): error 52");
232cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleA.StructA"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->getAccessMode() == FieldAccessMode_READWRITE, "test_RegCoreReflection(): error 52a");
233cdf0e10cSrcweir     Reference< XIdlField2 > rField ( xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") )) , UNO_QUERY );
234cdf0e10cSrcweir     rField->set(aStructAny, aAny);
235cdf0e10cSrcweir 	TEST_ENSHURE(*(sal_Int32*)xRefl->forName(OUString::createFromAscii("ModuleA.StructB"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(aStructAny).getValue() == *(sal_Int32*)aAny.getValue(), "test_RegCoreReflection(): error 53");
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	xRefl->forName( OUString::createFromAscii("[]ModuleA.StructA") )->createObject(aAny);
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("[]ModuleA.StructA")), "test_RegCoreReflection(): error 54");
240cdf0e10cSrcweir 	xRefl->forName(OUString::createFromAscii("[][]ModuleA.StructA"))->createObject(aAny);
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 	TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[][]ModuleA.StructA") ), "test_RegCoreReflection(): error 56");
243cdf0e10cSrcweir 
244cdf0e10cSrcweir //  	xClass = xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.XIntroTest") ));
245cdf0e10cSrcweir 
246cdf0e10cSrcweir //  	TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 58");
247cdf0e10cSrcweir //  	TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 59");
248cdf0e10cSrcweir //  	TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("string"), "test_RegCoreReflection(): error 60");
249cdf0e10cSrcweir 
250cdf0e10cSrcweir //  	xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->createObject(aAny);
251cdf0e10cSrcweir //  	TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[]string") ),  "test_RegCoreReflection(): error 61");
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("[][][]unsigned long"))->getComponentType()->getComponentType()->getComponentType()->getTypeClass() == TypeClass_UNSIGNED_LONG, "test_RegCoreReflection(): error 62");
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	try
256cdf0e10cSrcweir 	{
257cdf0e10cSrcweir         fprintf( stderr, "%1\n" );
258cdf0e10cSrcweir 		Any bla = xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->get(Any());
259cdf0e10cSrcweir 		TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 63");
260cdf0e10cSrcweir 		return sal_False;
261cdf0e10cSrcweir 	}
262cdf0e10cSrcweir 	catch (IllegalArgumentException &)
263cdf0e10cSrcweir 	{
264cdf0e10cSrcweir 	}
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	try
267cdf0e10cSrcweir 	{
268cdf0e10cSrcweir         fprintf( stderr, "%2\n" );
269cdf0e10cSrcweir 		Any blup;
270cdf0e10cSrcweir 		blup <<= aStructC;
271cdf0e10cSrcweir 		Any gulp;
272cdf0e10cSrcweir         rField = Reference< XIdlField2 > ( xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY);
273cdf0e10cSrcweir         rField->set( blup, gulp);
274cdf0e10cSrcweir //  		xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
275cdf0e10cSrcweir 		TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 64");
276cdf0e10cSrcweir 		return sal_False;
277cdf0e10cSrcweir 	}
278cdf0e10cSrcweir 	catch (IllegalArgumentException &)
279cdf0e10cSrcweir 	{
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	try
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir         fprintf( stderr, "%3\n" );
285cdf0e10cSrcweir 		Any gulp;
286cdf0e10cSrcweir 		gulp <<= 3.14f;
287cdf0e10cSrcweir 		Any blup;
288cdf0e10cSrcweir 		blup <<= aStructC;
289cdf0e10cSrcweir         rField = Reference< XIdlField2 > (
290cdf0e10cSrcweir             xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY);
291cdf0e10cSrcweir 		xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
292cdf0e10cSrcweir 		TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 65");
293cdf0e10cSrcweir 		return sal_False;
294cdf0e10cSrcweir 	}
295cdf0e10cSrcweir 	catch (IllegalArgumentException &)
296cdf0e10cSrcweir 	{
297cdf0e10cSrcweir 	}
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	Any gulp;
300cdf0e10cSrcweir 	gulp <<= OUString(OUString::createFromAscii("Test"));
301cdf0e10cSrcweir 	Any blup;
302cdf0e10cSrcweir 	blup <<= aStructC;
303cdf0e10cSrcweir 	xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 	Reference< XInterfaceA > xAI = new OInterfaceA();
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 	try
308cdf0e10cSrcweir 	{
309cdf0e10cSrcweir 		Sequence< Any > params;
310cdf0e10cSrcweir         fprintf( stderr, "%4\n" );
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		Any a;
313cdf0e10cSrcweir 		a <<= xAI;
314cdf0e10cSrcweir 		Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
315cdf0e10cSrcweir 		TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 66");
316cdf0e10cSrcweir 		return sal_False;
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir 	catch (IllegalArgumentException &)
319cdf0e10cSrcweir 	{
320cdf0e10cSrcweir 	}
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 	StructA aStructA;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	{
325cdf0e10cSrcweir 		Sequence< Any > params(2);
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 		params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
328cdf0e10cSrcweir 		params.getArray()[1].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 		Any a;
331cdf0e10cSrcweir 		a <<= xAI;
332cdf0e10cSrcweir 		Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
333cdf0e10cSrcweir 	}
334cdf0e10cSrcweir 	try
335cdf0e10cSrcweir 	{
336cdf0e10cSrcweir 		Sequence< Any > params(2);
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 		params.getArray()[0].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
339cdf0e10cSrcweir 		params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 		Any a;
342cdf0e10cSrcweir 		a <<= xAI;
343cdf0e10cSrcweir 		Any bla = xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params);
344cdf0e10cSrcweir 		TEST_ENSHURE(sal_False, "test_RegCoreReflection(): error 67");
345cdf0e10cSrcweir 		return sal_False;
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir 	catch (IllegalArgumentException &)
348cdf0e10cSrcweir 	{
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 	Sequence< Any > params(2);
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
354cdf0e10cSrcweir 	params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	Any a;
357cdf0e10cSrcweir 	a <<= xAI;
358cdf0e10cSrcweir 	TEST_ENSHURE(xRefl->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a, params).getValueType()
359cdf0e10cSrcweir 		== ::getCppuType( (const Sequence<StructB> *)0 ), "test_RegCoreReflection(): error 68");
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	return sal_True;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir 
SAL_IMPLEMENT_MAIN()364cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
365cdf0e10cSrcweir {
366cdf0e10cSrcweir 	sal_Bool bSucc = sal_False;
367cdf0e10cSrcweir 	try
368cdf0e10cSrcweir 	{
369cdf0e10cSrcweir 		OUString aLibName( RTL_CONSTASCII_USTRINGPARAM(
370cdf0e10cSrcweir                                "reflection.uno" SAL_DLLEXTENSION) );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir         Reference< XMultiServiceFactory > xMgr(
373cdf0e10cSrcweir             createRegistryServiceFactory(
374cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
375cdf0e10cSrcweir         Reference< XComponentContext > xContext;
376cdf0e10cSrcweir         Reference< beans::XPropertySet > xProps( xMgr, UNO_QUERY );
377cdf0e10cSrcweir         OSL_ASSERT( xProps.is() );
378cdf0e10cSrcweir         xProps->getPropertyValue(
379cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>=
380cdf0e10cSrcweir             xContext;
381cdf0e10cSrcweir         OSL_ASSERT( xContext.is() );
382cdf0e10cSrcweir 
383cdf0e10cSrcweir         Reference< XIdlReflection > xRefl;
384cdf0e10cSrcweir         xContext->getValueByName(
385cdf0e10cSrcweir             OUString(
386cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
387cdf0e10cSrcweir                     "/singletons/com.sun.star.reflection.theCoreReflection")) )
388cdf0e10cSrcweir                         >>= xRefl;
389cdf0e10cSrcweir         OSL_ENSURE(
390cdf0e10cSrcweir             xRefl.is(), "### CoreReflection singleton not accessable!?" );
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 		bSucc = test_corefl( xRefl );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir         Reference< XComponent >( xContext, UNO_QUERY )->dispose();
395cdf0e10cSrcweir 	}
396cdf0e10cSrcweir 	catch (Exception & rExc)
397cdf0e10cSrcweir 	{
398cdf0e10cSrcweir 		OSL_ENSURE( sal_False, "### exception occured!" );
399cdf0e10cSrcweir 		OString aMsg(
400cdf0e10cSrcweir             OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
401cdf0e10cSrcweir 		OSL_TRACE( "### exception occured: " );
402cdf0e10cSrcweir 		OSL_TRACE( aMsg.getStr() );
403cdf0e10cSrcweir 		OSL_TRACE( "\n" );
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	printf( "testcorefl %s !\n", (bSucc ? "succeeded" : "failed") );
407cdf0e10cSrcweir 	return (bSucc ? 0 : -1);
408cdf0e10cSrcweir }
409