1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testcorefl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_stoc.hxx"
35 #include <osl/diagnose.h>
37 #if OSL_DEBUG_LEVEL > 0
38 #define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
40 #define TEST_ENSHURE(c, m) OSL_VERIFY(c)
43 #include <cppuhelper/servicefactory.hxx>
44 #include <cppuhelper/weak.hxx>
45 #include <cppuhelper/implbase1.hxx>
47 #include <ModuleA/XInterface1.hpp>
48 #include <ModuleC/XInterfaceA.hpp>
49 #include <ModuleC/XInterfaceB.hpp>
50 #include <ModuleC/ModuleC.hpp>
52 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
53 #include <com/sun/star/lang/XComponent.hpp>
54 #include <com/sun/star/reflection/XIdlReflection.hpp>
55 #include <com/sun/star/reflection/XIdlField2.hpp>
56 #include <com/sun/star/beans/XPropertySet.hpp>
57 #include <com/sun/star/registry/XSimpleRegistry.hpp>
58 #include <com/sun/star/registry/XImplementationRegistration.hpp>
60 #include <rtl/ustrbuf.hxx>
68 using namespace ModuleA
;
69 using namespace ModuleB
;
70 using namespace ModuleC
;
71 using namespace ModuleA::ModuleB
;
72 using namespace com::sun::star
;
73 using namespace com::sun::star::uno
;
74 using namespace com::sun::star::lang
;
75 using namespace com::sun::star::beans
;
76 using namespace com::sun::star::registry
;
77 using namespace com::sun::star::reflection
;
78 using namespace com::sun::star::container
;
81 //==================================================================================================
82 class OInterfaceA
: public WeakImplHelper1
< XInterfaceA
>
86 virtual void SAL_CALL
methodA(void) throw (RuntimeException
)
89 virtual void SAL_CALL
methodB(sal_Int16
/*aShort*/) throw (RuntimeException
)
91 virtual Sequence
< StructB
> SAL_CALL
methodC(const StructC
& /*aStructC*/, StructA
& /*aStructA*/) throw (RuntimeException
)
92 { return Sequence
< StructB
>(); }
95 //==================================================================================================
96 static inline bool uik_equals( const Uik
& rUik1
, const Uik
& rUik2
)
98 return (rUik1
.m_Data1
== rUik2
.m_Data1
&&
99 rUik1
.m_Data2
== rUik2
.m_Data2
&&
100 rUik1
.m_Data3
== rUik2
.m_Data3
&&
101 rUik1
.m_Data4
== rUik2
.m_Data4
&&
102 rUik1
.m_Data5
== rUik2
.m_Data5
);
104 //==================================================================================================
105 static sal_Bool
test_corefl( const Reference
< XIdlReflection
> & xRefl
)
107 Reference
< XIdlClass
> xClass
;
108 Reference
< XHierarchicalNameAccess
> xHNameAccess( xRefl
, UNO_QUERY
);
109 TEST_ENSHURE(xHNameAccess
.is(), "### cannot get XHierarchicalNameAccess!" );
111 TEST_ENSHURE(xRefl
->forName(OUString::createFromAscii("ModuleA.StructA"))->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 2b");
112 TEST_ENSHURE(xRefl
->forName(OUString::createFromAscii("ModuleA.ExceptionB"))->getTypeClass() == TypeClass_EXCEPTION
, "test_RegCoreReflection(): error 2c");
113 TEST_ENSHURE(xRefl
->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA")).is(), "test_RegCoreReflection(): error 2e");
116 TEST_ENSHURE(*(const sal_Bool
*)xHNameAccess
->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstBoolean")).getValue() == aConstBoolean
, "test_RegCoreReflection(): error 4c");
117 TEST_ENSHURE(*(const sal_Int8
*)xHNameAccess
->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstByte")).getValue() == aConstByte
, "test_RegCoreReflection(): error 4e");
118 TEST_ENSHURE(xHNameAccess
->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstShort")) == aConstShort
, "test_RegCoreReflection(): error 4g");
119 TEST_ENSHURE(xHNameAccess
->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstUShort")) == aConstUShort
, "test_RegCoreReflection(): error 4i");
120 TEST_ENSHURE(xHNameAccess
->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstLong")) == aConstLong
, "test_RegCoreReflection(): error 4k");
121 TEST_ENSHURE(xHNameAccess
->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstULong")) == aConstULong
, "test_RegCoreReflection(): error 4m");
122 // TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstFloat")) == aConstFloat, "test_RegCoreReflection(): error 4o");
123 // TEST_ENSHURE(xHNameAccess->getByHierarchicalName(OUString::createFromAscii("ModuleC.aConstDouble")) == aConstDouble, "test_RegCoreReflection(): error 4q");
127 xClass
= xRefl
->forName(OUString::createFromAscii("ModuleA.ModuleB.EnumA"));
129 TEST_ENSHURE(xClass
.is(), "test_RegCoreReflection(): error 5");
131 Sequence
<Reference
< XIdlField
> > fields
= xClass
->getFields();
134 (fields
.getLength() == 3) &&
135 (fields
.getArray()[0]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_1") )) &&
136 (*(EnumA
*)fields
.getArray()[0]->get(Any()).getValue() == EnumA_VAL_1
) &&
137 (fields
.getArray()[1]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_2") )) &&
138 (*(EnumA
*)fields
.getArray()[1]->get(Any()).getValue() == EnumA_VAL_2
) &&
139 (fields
.getArray()[2]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("VAL_3") )) &&
140 (*(EnumA
*)fields
.getArray()[2]->get(Any()).getValue() == EnumA_VAL_3
),
141 "test_RegCoreReflection(): error 6");
146 Reference
< XIdlClass
> xA
= xRefl
->forName( OUString::createFromAscii("ModuleC.XInterfaceB") );
148 xClass
= xRefl
->forName(OUString::createFromAscii("ModuleC.XInterfaceB"));
150 TEST_ENSHURE(xClass
== xA
, "test_RegCoreReflection(): error 7");
151 TEST_ENSHURE(xClass
.is(), "test_RegCoreReflection(): error 7a");
153 typelib_TypeDescription
* pTD
= 0;
154 OUString
aModuleName( RTL_CONSTASCII_USTRINGPARAM("ModuleC.XInterfaceB") );
155 typelib_typedescription_getByName( &pTD
, aModuleName
.pData
);
156 TEST_ENSHURE( pTD
, "### cannot get typedescription for ModuleC.XInterfaceB!" );
158 TEST_ENSHURE( uik_equals( *(Uik
*)&((typelib_InterfaceTypeDescription
*)pTD
)->aUik
,
160 "test_RegCoreReflection(): error 8" );
161 typelib_typedescription_release( pTD
);
163 TEST_ENSHURE(xClass
->getSuperclasses().getLength() == 1, "test_RegCoreReflection(): error 9");
164 TEST_ENSHURE(xClass
->getSuperclasses().getArray()[0]->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 10");
165 TEST_ENSHURE(xClass
->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11");
166 TEST_ENSHURE(xA
->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11a");
167 TEST_ENSHURE(xClass
->getMethods().getArray()[3]->getName() == OUString::createFromAscii("methodA"), "test_RegCoreReflection(): 12");
168 TEST_ENSHURE(xClass
->getMethods().getArray()[3]->getReturnType()->getTypeClass() == TypeClass_VOID
, "test_RegCoreReflection(): error 13");
169 TEST_ENSHURE(xClass
->getMethods().getArray()[3]->getParameterTypes().getLength() == 0, "test_RegCoreReflection(): error 14");
170 TEST_ENSHURE(xClass
->getMethods().getArray()[3]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 15");
171 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getName() == OUString( RTL_CONSTASCII_USTRINGPARAM("methodB") ), "test_RegCoreReflection(): error 16");
172 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getMode() == MethodMode_ONEWAY
, "test_RegCoreReflection(): error 16a");
173 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getReturnType()->getTypeClass() == TypeClass_VOID
, "test_RegCoreReflection(): error 16");
174 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 17");
175 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_SHORT
, "test_RegCoreReflection(): error 18");
176 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aName
== OUString( RTL_CONSTASCII_USTRINGPARAM("aShort") ), "test_RegCoreReflection(): error 18a");
177 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aType
== xRefl
->forName( OUString( RTL_CONSTASCII_USTRINGPARAM("short") ) ), "test_RegCoreReflection(): error 18b");
178 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aMode
== ParamMode_IN
, "test_RegCoreReflection(): error 18c");
179 TEST_ENSHURE(xClass
->getMethods().getArray()[4]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 19");
180 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getName() == OUString::createFromAscii("methodC"), "test_RegCoreReflection(): error 20");
181 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getMode() == MethodMode_TWOWAY
, "test_RegCoreReflection(): error 20a");
182 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getReturnType()->getTypeClass() == TypeClass_SEQUENCE
, "test_RegCoreReflection(): error 21");
183 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getReturnType()->getComponentType()->getTypeClass() == TypeClass_STRUCT
, "test_RegCoreReflection(): error 22");
184 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructB"), "test_RegCoreReflection(): error 23");
185 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getParameterTypes().getLength() == 2, "test_RegCoreReflection(): error 24");
186 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_STRUCT
, "test_RegCoreReflection(): error 25");
187 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 26");
188 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getTypeClass() == TypeClass_STRUCT
, "test_RegCoreReflection(): error 27");
189 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 28");
190 TEST_ENSHURE(xClass
->getMethods().getArray()[5]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 29");
191 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getName() == OUString::createFromAscii("methodD"), "test_RegCoreReflection(): error 30");
192 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getReturnType()->getTypeClass() == TypeClass_INTERFACE
, "test_RegCoreReflection(): error 31");
193 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getReturnType()->getName() == OUString::createFromAscii("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 32");
194 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 33");
195 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_ENUM
, "test_RegCoreReflection(): error 34");
196 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ModuleB.EnumA"), "test_RegCoreReflection(): error 35");
197 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getLength() == 3, "test_RegCoreReflection(): error 36");
198 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getTypeClass() == TypeClass_EXCEPTION
, "test_RegCoreReflection(): error 37");
199 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getName() == OUString::createFromAscii("ModuleA.ExceptionA"), "test_RegCoreReflection(): error 38");
200 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getTypeClass() == TypeClass_EXCEPTION
, "test_RegCoreReflection(): error 38");
201 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getName() == OUString::createFromAscii("ModuleA.ExceptionB"), "test_RegCoreReflection(): error 39");
202 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getTypeClass() == TypeClass_EXCEPTION
, "test_RegCoreReflection(): error 40");
203 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getName() == OUString::createFromAscii("ModuleA.ExceptionC"), "test_RegCoreReflection(): error 41");
204 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getLength() == 3, "test_RegCoreReflection(): error 42");
205 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getTypeClass() == TypeClass_BOOLEAN
, "test_RegCoreReflection(): error 43");
206 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getName() == OUString::createFromAscii("boolean"), "test_RegCoreReflection(): error 43a");
207 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getTypeClass() == TypeClass_STRUCT
, "test_RegCoreReflection(): error 44");
208 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getName() == OUString::createFromAscii("ModuleA.StructC"), "test_RegCoreReflection(): error 45");
209 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getTypeClass() == TypeClass_INTERFACE
, "test_RegCoreReflection(): error 46");
210 TEST_ENSHURE(xClass
->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getName() == OUString::createFromAscii("ModuleA.XInterface1"), "test_RegCoreReflection(): error 47");
212 // SequenceReflections
214 TEST_ENSHURE(xRefl
->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getTypeClass() == TypeClass_SEQUENCE
, "test_RegCoreReflection(): error 48");
215 TEST_ENSHURE(xRefl
->forName( OUString::createFromAscii("[]ModuleA.StructA") )->getComponentType().is(), "test_RegCoreReflection(): error 49");
216 TEST_ENSHURE(xRefl
->forName( OUString::createFromAscii("[][]ModuleA.StructA") )->getComponentType()->getComponentType()->getName() == OUString::createFromAscii("ModuleA.StructA"), "test_RegCoreReflection(): error 50");
217 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");
220 aStructC
.aLong
= aConstLong
;
221 aStructC
.aShort
= aConstShort
;
222 aStructC
.aFloat
= aConstFloat
;
223 aStructC
.aDouble
= aConstDouble
;
224 aStructC
.aInterfaceSeq
= Sequence
<Reference
<XInterface
> >();
228 xRefl
->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aInterfaceSeq"))->getType()->createObject(aAny
);
230 TEST_ENSHURE(aAny
.getValueType() == ::getCppuType( (const Sequence
<Reference
< XInterface
> > *)0 ), "test_RegCoreReflection(): error 51a");
232 Any
aStructAny(&aStructC
, ::getCppuType( (const StructC
*) 0 ));
234 sal_Int32 nLong
= aConstLong
* 2;
235 aAny
.setValue( &nLong
, ::getCppuType( (const sal_Int32
*)0 ) );
237 TEST_ENSHURE(*(sal_Int32
*)xRefl
->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructA") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->get(
238 Any(&aStructC
, ::getCppuType( (const StructC
*)0 ))).getValue() == aConstLong
, "test_RegCoreReflection(): error 52");
239 TEST_ENSHURE(xRefl
->forName(OUString::createFromAscii("ModuleA.StructA"))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") ))->getAccessMode() == FieldAccessMode_READWRITE
, "test_RegCoreReflection(): error 52a");
240 Reference
< XIdlField2
> rField ( xRefl
->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("ModuleA.StructC") ))->getField(OUString( RTL_CONSTASCII_USTRINGPARAM("aLong") )) , UNO_QUERY
);
241 rField
->set(aStructAny
, aAny
);
242 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");
244 xRefl
->forName( OUString::createFromAscii("[]ModuleA.StructA") )->createObject(aAny
);
246 TEST_ENSHURE(aAny
.getValueTypeName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("[]ModuleA.StructA")), "test_RegCoreReflection(): error 54");
247 xRefl
->forName(OUString::createFromAscii("[][]ModuleA.StructA"))->createObject(aAny
);
249 TEST_ENSHURE(aAny
.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[][]ModuleA.StructA") ), "test_RegCoreReflection(): error 56");
251 // xClass = xRefl->forName(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.XIntroTest") ));
253 // TEST_ENSHURE(xClass.is(), "test_RegCoreReflection(): error 58");
254 // TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 59");
255 // TEST_ENSHURE(xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->getComponentType()->getName() == OUString::createFromAscii("string"), "test_RegCoreReflection(): error 60");
257 // xClass->getMethod(OUString::createFromAscii("getStrings"))->getReturnType()->createObject(aAny);
258 // TEST_ENSHURE(aAny.getValueTypeName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("[]string") ), "test_RegCoreReflection(): error 61");
260 TEST_ENSHURE(xRefl
->forName(OUString::createFromAscii("[][][]unsigned long"))->getComponentType()->getComponentType()->getComponentType()->getTypeClass() == TypeClass_UNSIGNED_LONG
, "test_RegCoreReflection(): error 62");
264 fprintf( stderr
, "%1\n" );
265 Any bla
= xRefl
->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->get(Any());
266 TEST_ENSHURE(sal_False
, "test_RegCoreReflection(): error 63");
269 catch (IllegalArgumentException
&)
275 fprintf( stderr
, "%2\n" );
279 rField
= Reference
< XIdlField2
> ( xRefl
->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY
);
280 rField
->set( blup
, gulp
);
281 // xRefl->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup, gulp);
282 TEST_ENSHURE(sal_False
, "test_RegCoreReflection(): error 64");
285 catch (IllegalArgumentException
&)
291 fprintf( stderr
, "%3\n" );
296 rField
= Reference
< XIdlField2
> (
297 xRefl
->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString")) , UNO_QUERY
);
298 xRefl
->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup
, gulp
);
299 TEST_ENSHURE(sal_False
, "test_RegCoreReflection(): error 65");
302 catch (IllegalArgumentException
&)
307 gulp
<<= OUString(OUString::createFromAscii("Test"));
310 xRefl
->forName(OUString::createFromAscii("ModuleA.StructC"))->getField(OUString::createFromAscii("aString"))->set(blup
, gulp
);
312 Reference
< XInterfaceA
> xAI
= new OInterfaceA();
316 Sequence
< Any
> params
;
317 fprintf( stderr
, "%4\n" );
321 Any bla
= xRefl
->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a
, params
);
322 TEST_ENSHURE(sal_False
, "test_RegCoreReflection(): error 66");
325 catch (IllegalArgumentException
&)
332 Sequence
< Any
> params(2);
334 params
.getArray()[0].setValue(&aStructC
, ::getCppuType( (const StructC
*)0 ));
335 params
.getArray()[1].setValue(&aStructC
, ::getCppuType( (const StructC
*)0 ));
339 Any bla
= xRefl
->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a
, params
);
343 Sequence
< Any
> params(2);
345 params
.getArray()[0].setValue(&aStructA
, ::getCppuType( (const StructA
*)0 ));
346 params
.getArray()[1].setValue(&aStructA
, ::getCppuType( (const StructA
*)0 ));
350 Any bla
= xRefl
->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a
, params
);
351 TEST_ENSHURE(sal_False
, "test_RegCoreReflection(): error 67");
354 catch (IllegalArgumentException
&)
358 Sequence
< Any
> params(2);
360 params
.getArray()[0].setValue(&aStructC
, ::getCppuType( (const StructC
*)0 ));
361 params
.getArray()[1].setValue(&aStructA
, ::getCppuType( (const StructA
*)0 ));
365 TEST_ENSHURE(xRefl
->forName(OUString::createFromAscii("ModuleC.XInterfaceA"))->getMethod(OUString::createFromAscii("methodC"))->invoke(a
, params
).getValueType()
366 == ::getCppuType( (const Sequence
<StructB
> *)0 ), "test_RegCoreReflection(): error 68");
373 sal_Bool bSucc
= sal_False
;
376 OUString
aLibName( RTL_CONSTASCII_USTRINGPARAM(
377 "reflection.uno" SAL_DLLEXTENSION
) );
379 Reference
< XMultiServiceFactory
> xMgr(
380 createRegistryServiceFactory(
381 OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) );
382 Reference
< XComponentContext
> xContext
;
383 Reference
< beans::XPropertySet
> xProps( xMgr
, UNO_QUERY
);
384 OSL_ASSERT( xProps
.is() );
385 xProps
->getPropertyValue(
386 OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>=
388 OSL_ASSERT( xContext
.is() );
390 Reference
< XIdlReflection
> xRefl
;
391 xContext
->getValueByName(
393 RTL_CONSTASCII_USTRINGPARAM(
394 "/singletons/com.sun.star.reflection.theCoreReflection")) )
397 xRefl
.is(), "### CoreReflection singleton not accessable!?" );
399 bSucc
= test_corefl( xRefl
);
401 Reference
< XComponent
>( xContext
, UNO_QUERY
)->dispose();
403 catch (Exception
& rExc
)
405 OSL_ENSURE( sal_False
, "### exception occured!" );
407 OUStringToOString( rExc
.Message
, RTL_TEXTENCODING_ASCII_US
) );
408 OSL_TRACE( "### exception occured: " );
409 OSL_TRACE( aMsg
.getStr() );
413 printf( "testcorefl %s !\n", (bSucc
? "succeeded" : "failed") );
414 return (bSucc
? 0 : -1);