Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / stoc / test / testcorefl.cxx
blob4a1313ffd762ae18f4fe199fcf00bbdf1143b460
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/main.h>
21 #include <osl/diagnose.h>
23 #include <cppuhelper/servicefactory.hxx>
24 #include <cppuhelper/weak.hxx>
25 #include <cppuhelper/implbase1.hxx>
27 #include <ModuleA/XInterface1.hpp>
28 #include <ModuleC/XInterfaceA.hpp>
29 #include <ModuleC/XInterfaceB.hpp>
30 #include <ModuleC/ModuleC.hpp>
32 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
33 #include <com/sun/star/lang/XComponent.hpp>
34 #include <com/sun/star/reflection/XIdlReflection.hpp>
35 #include <com/sun/star/reflection/XIdlField2.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/registry/XSimpleRegistry.hpp>
38 #include <com/sun/star/registry/XImplementationRegistration.hpp>
40 #include <rtl/ustrbuf.hxx>
42 #include <stdio.h>
44 using namespace cppu;
45 using namespace osl;
46 using namespace ModuleA;
47 using namespace ModuleB;
48 using namespace ModuleC;
49 using namespace ModuleA::ModuleB;
50 using namespace com::sun::star;
51 using namespace com::sun::star::uno;
52 using namespace com::sun::star::lang;
53 using namespace com::sun::star::beans;
54 using namespace com::sun::star::registry;
55 using namespace com::sun::star::reflection;
56 using namespace com::sun::star::container;
58 using ::rtl::OUString;
59 using ::rtl::OUStringToOString;
60 using ::rtl::OString;
62 //==================================================================================================
63 class OInterfaceA : public WeakImplHelper1< XInterfaceA >
65 public:
67 virtual void SAL_CALL methodA(void) throw (RuntimeException)
70 virtual void SAL_CALL methodB(sal_Int16 /*aShort*/) throw (RuntimeException)
72 virtual Sequence< StructB > SAL_CALL methodC(const StructC& /*aStructC*/, StructA& /*aStructA*/) throw (RuntimeException)
73 { return Sequence< StructB >(); }
76 //==================================================================================================
77 static inline bool uik_equals( const Uik & rUik1, const Uik & rUik2 )
79 return (rUik1.m_Data1 == rUik2.m_Data1 &&
80 rUik1.m_Data2 == rUik2.m_Data2 &&
81 rUik1.m_Data3 == rUik2.m_Data3 &&
82 rUik1.m_Data4 == rUik2.m_Data4 &&
83 rUik1.m_Data5 == rUik2.m_Data5);
85 //==================================================================================================
86 static sal_Bool test_corefl( const Reference< XIdlReflection > & xRefl )
88 Reference< XIdlClass > xClass;
89 Reference< XHierarchicalNameAccess > xHNameAccess( xRefl, UNO_QUERY );
90 OSL_ENSURE(xHNameAccess.is(), "### cannot get XHierarchicalNameAccess!" );
92 OSL_ENSURE(xRefl->forName(OUString("ModuleA.StructA"))->getName() == OUString("ModuleA.StructA"), "test_RegCoreReflection(): error 2b");
93 OSL_ENSURE(xRefl->forName(OUString("ModuleA.ExceptionB"))->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 2c");
94 OSL_ENSURE(xRefl->forName(OUString("ModuleA.ModuleB.EnumA")).is(), "test_RegCoreReflection(): error 2e");
97 OSL_ENSURE(*(const sal_Bool *)xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstBoolean")).getValue() == aConstBoolean, "test_RegCoreReflection(): error 4c");
98 OSL_ENSURE(*(const sal_Int8 *)xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstByte")).getValue() == aConstByte, "test_RegCoreReflection(): error 4e");
99 OSL_ENSURE(xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstShort")) == aConstShort, "test_RegCoreReflection(): error 4g");
100 OSL_ENSURE(xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstUShort")) == aConstUShort, "test_RegCoreReflection(): error 4i");
101 OSL_ENSURE(xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstLong")) == aConstLong, "test_RegCoreReflection(): error 4k");
102 OSL_ENSURE(xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstULong")) == aConstULong, "test_RegCoreReflection(): error 4m");
103 // OSL_ENSURE(xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstFloat")) == aConstFloat, "test_RegCoreReflection(): error 4o");
104 // OSL_ENSURE(xHNameAccess->getByHierarchicalName(OUString("ModuleC.aConstDouble")) == aConstDouble, "test_RegCoreReflection(): error 4q");
106 // Enums
108 xClass = xRefl->forName(OUString("ModuleA.ModuleB.EnumA"));
110 OSL_ENSURE(xClass.is(), "test_RegCoreReflection(): error 5");
112 Sequence<Reference< XIdlField > > fields = xClass->getFields();
114 OSL_ENSURE(
115 (fields.getLength() == 3) &&
116 (fields.getArray()[0]->getName() == OUString( "VAL_1" )) &&
117 (*(EnumA*)fields.getArray()[0]->get(Any()).getValue() == EnumA_VAL_1) &&
118 (fields.getArray()[1]->getName() == OUString( "VAL_2" )) &&
119 (*(EnumA*)fields.getArray()[1]->get(Any()).getValue() == EnumA_VAL_2) &&
120 (fields.getArray()[2]->getName() == OUString( "VAL_3" )) &&
121 (*(EnumA*)fields.getArray()[2]->get(Any()).getValue() == EnumA_VAL_3),
122 "test_RegCoreReflection(): error 6");
125 // Interface
127 Reference< XIdlClass > xA = xRefl->forName( OUString("ModuleC.XInterfaceB") );
129 xClass = xRefl->forName(OUString("ModuleC.XInterfaceB"));
131 OSL_ENSURE(xClass == xA, "test_RegCoreReflection(): error 7");
132 OSL_ENSURE(xClass.is(), "test_RegCoreReflection(): error 7a");
134 typelib_TypeDescription * pTD = 0;
135 OUString aModuleName( "ModuleC.XInterfaceB" );
136 typelib_typedescription_getByName( &pTD, aModuleName.pData );
137 OSL_ENSURE( pTD, "### cannot get typedescription for ModuleC.XInterfaceB!" );
139 OSL_ENSURE( uik_equals( *(Uik *)&((typelib_InterfaceTypeDescription *)pTD)->aUik,
140 xClass->getUik() ),
141 "test_RegCoreReflection(): error 8" );
142 typelib_typedescription_release( pTD );
144 OSL_ENSURE(xClass->getSuperclasses().getLength() == 1, "test_RegCoreReflection(): error 9");
145 OSL_ENSURE(xClass->getSuperclasses().getArray()[0]->getName() == OUString("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 10");
146 OSL_ENSURE(xClass->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11");
147 OSL_ENSURE(xA->getMethods().getLength() == 7, "test_RegCoreReflection(): error 11a");
148 OSL_ENSURE(xClass->getMethods().getArray()[3]->getName() == OUString("methodA"), "test_RegCoreReflection(): 12");
149 OSL_ENSURE(xClass->getMethods().getArray()[3]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 13");
150 OSL_ENSURE(xClass->getMethods().getArray()[3]->getParameterTypes().getLength() == 0, "test_RegCoreReflection(): error 14");
151 OSL_ENSURE(xClass->getMethods().getArray()[3]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 15");
152 OSL_ENSURE(xClass->getMethods().getArray()[4]->getName() == OUString( "methodB" ), "test_RegCoreReflection(): error 16");
153 OSL_ENSURE(xClass->getMethods().getArray()[4]->getMode() == MethodMode_ONEWAY, "test_RegCoreReflection(): error 16a");
154 OSL_ENSURE(xClass->getMethods().getArray()[4]->getReturnType()->getTypeClass() == TypeClass_VOID, "test_RegCoreReflection(): error 16");
155 OSL_ENSURE(xClass->getMethods().getArray()[4]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 17");
156 OSL_ENSURE(xClass->getMethods().getArray()[4]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_SHORT, "test_RegCoreReflection(): error 18");
157 OSL_ENSURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aName == OUString( "aShort" ), "test_RegCoreReflection(): error 18a");
158 OSL_ENSURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aType == xRefl->forName( OUString( "short" ) ), "test_RegCoreReflection(): error 18b");
159 OSL_ENSURE(xClass->getMethods().getArray()[4]->getParameterInfos().getArray()[0].aMode == ParamMode_IN, "test_RegCoreReflection(): error 18c");
160 OSL_ENSURE(xClass->getMethods().getArray()[4]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 19");
161 OSL_ENSURE(xClass->getMethods().getArray()[5]->getName() == OUString("methodC"), "test_RegCoreReflection(): error 20");
162 OSL_ENSURE(xClass->getMethods().getArray()[5]->getMode() == MethodMode_TWOWAY, "test_RegCoreReflection(): error 20a");
163 OSL_ENSURE(xClass->getMethods().getArray()[5]->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 21");
164 OSL_ENSURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 22");
165 OSL_ENSURE(xClass->getMethods().getArray()[5]->getReturnType()->getComponentType()->getName() == OUString("ModuleA.StructB"), "test_RegCoreReflection(): error 23");
166 OSL_ENSURE(xClass->getMethods().getArray()[5]->getParameterTypes().getLength() == 2, "test_RegCoreReflection(): error 24");
167 OSL_ENSURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 25");
168 OSL_ENSURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[0]->getName() == OUString("ModuleA.StructC"), "test_RegCoreReflection(): error 26");
169 OSL_ENSURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 27");
170 OSL_ENSURE(xClass->getMethods().getArray()[5]->getParameterTypes().getArray()[1]->getName() == OUString("ModuleA.StructA"), "test_RegCoreReflection(): error 28");
171 OSL_ENSURE(xClass->getMethods().getArray()[5]->getExceptionTypes().getLength() == 0, "test_RegCoreReflection(): error 29");
172 OSL_ENSURE(xClass->getMethods().getArray()[6]->getName() == OUString("methodD"), "test_RegCoreReflection(): error 30");
173 OSL_ENSURE(xClass->getMethods().getArray()[6]->getReturnType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 31");
174 OSL_ENSURE(xClass->getMethods().getArray()[6]->getReturnType()->getName() == OUString("ModuleC.XInterfaceA"), "test_RegCoreReflection(): error 32");
175 OSL_ENSURE(xClass->getMethods().getArray()[6]->getParameterTypes().getLength() == 1, "test_RegCoreReflection(): error 33");
176 OSL_ENSURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getTypeClass() == TypeClass_ENUM, "test_RegCoreReflection(): error 34");
177 OSL_ENSURE(xClass->getMethods().getArray()[6]->getParameterTypes().getArray()[0]->getName() == OUString("ModuleA.ModuleB.EnumA"), "test_RegCoreReflection(): error 35");
178 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getLength() == 3, "test_RegCoreReflection(): error 36");
179 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 37");
180 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[0]->getName() == OUString("ModuleA.ExceptionA"), "test_RegCoreReflection(): error 38");
181 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 38");
182 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[1]->getName() == OUString("ModuleA.ExceptionB"), "test_RegCoreReflection(): error 39");
183 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getTypeClass() == TypeClass_EXCEPTION, "test_RegCoreReflection(): error 40");
184 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getName() == OUString("ModuleA.ExceptionC"), "test_RegCoreReflection(): error 41");
185 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getLength() == 3, "test_RegCoreReflection(): error 42");
186 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getTypeClass() == TypeClass_BOOLEAN, "test_RegCoreReflection(): error 43");
187 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[0]->getType()->getName() == OUString("boolean"), "test_RegCoreReflection(): error 43a");
188 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getTypeClass() == TypeClass_STRUCT, "test_RegCoreReflection(): error 44");
189 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[1]->getType()->getName() == OUString("ModuleA.StructC"), "test_RegCoreReflection(): error 45");
190 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getTypeClass() == TypeClass_INTERFACE, "test_RegCoreReflection(): error 46");
191 OSL_ENSURE(xClass->getMethods().getArray()[6]->getExceptionTypes().getArray()[2]->getFields().getArray()[2]->getType()->getName() == OUString("ModuleA.XInterface1"), "test_RegCoreReflection(): error 47");
193 // SequenceReflections
195 OSL_ENSURE(xRefl->forName( OUString("[]ModuleA.StructA") )->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 48");
196 OSL_ENSURE(xRefl->forName( OUString("[]ModuleA.StructA") )->getComponentType().is(), "test_RegCoreReflection(): error 49");
197 OSL_ENSURE(xRefl->forName( OUString("[][]ModuleA.StructA") )->getComponentType()->getComponentType()->getName() == OUString("ModuleA.StructA"), "test_RegCoreReflection(): error 50");
198 OSL_ENSURE(xRefl->forName( OUString("[]com.sun.star.uno.XInterface") ) == xRefl->forName(OUString( "ModuleA.StructC" ))->getField(OUString("aInterfaceSeq"))->getType(), "test_RegCoreReflection(): error 51");
200 StructC aStructC;
201 aStructC.aLong = aConstLong;
202 aStructC.aShort = aConstShort;
203 aStructC.aFloat = aConstFloat;
204 aStructC.aDouble = aConstDouble;
205 aStructC.aInterfaceSeq = Sequence<Reference<XInterface > >();
207 Any aAny;
209 xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aInterfaceSeq"))->getType()->createObject(aAny);
211 OSL_ENSURE(aAny.getValueType() == ::getCppuType( (const Sequence<Reference< XInterface > > *)0 ), "test_RegCoreReflection(): error 51a");
213 Any aStructAny(&aStructC, ::getCppuType( (const StructC *) 0 ));
215 sal_Int32 nLong = aConstLong * 2;
216 aAny.setValue( &nLong, ::getCppuType( (const sal_Int32 *)0 ) );
218 OSL_ENSURE(*(sal_Int32*)xRefl->forName(OUString( "ModuleA.StructA" ))->getField(OUString( "aLong" ))->get(
219 Any(&aStructC, ::getCppuType( (const StructC *)0 ))).getValue() == aConstLong, "test_RegCoreReflection(): error 52");
220 OSL_ENSURE(xRefl->forName(OUString("ModuleA.StructA"))->getField(OUString( "aLong" ))->getAccessMode() == FieldAccessMode_READWRITE, "test_RegCoreReflection(): error 52a");
221 Reference< XIdlField2 > rField ( xRefl->forName(OUString( "ModuleA.StructC" ))->getField(OUString( "aLong" )) , UNO_QUERY );
222 rField->set(aStructAny, aAny);
223 OSL_ENSURE(*(sal_Int32*)xRefl->forName(OUString("ModuleA.StructB"))->getField(OUString( "aLong" ))->get(aStructAny).getValue() == *(sal_Int32*)aAny.getValue(), "test_RegCoreReflection(): error 53");
225 xRefl->forName( OUString("[]ModuleA.StructA") )->createObject(aAny);
227 OSL_ENSURE( aAny.getValueTypeName() == "[]ModuleA.StructA", "test_RegCoreReflection(): error 54" );
228 xRefl->forName(OUString("[][]ModuleA.StructA"))->createObject(aAny);
230 OSL_ENSURE( aAny.getValueTypeName() == "[][]ModuleA.StructA", "test_RegCoreReflection(): error 56" );
232 // xClass = xRefl->forName(OUString( "com.sun.star.beans.XIntroTest" ));
234 // OSL_ENSURE(xClass.is(), "test_RegCoreReflection(): error 58");
235 // OSL_ENSURE(xClass->getMethod(OUString("getStrings"))->getReturnType()->getTypeClass() == TypeClass_SEQUENCE, "test_RegCoreReflection(): error 59");
236 // OSL_ENSURE(xClass->getMethod(OUString("getStrings"))->getReturnType()->getComponentType()->getName() == OUString("string"), "test_RegCoreReflection(): error 60");
238 // xClass->getMethod(OUString("getStrings"))->getReturnType()->createObject(aAny);
239 // OSL_ENSURE( aAny.getValueTypeName() == "[]string", "test_RegCoreReflection(): error 61" );
241 OSL_ENSURE(xRefl->forName(OUString("[][][]unsigned long"))->getComponentType()->getComponentType()->getComponentType()->getTypeClass() == TypeClass_UNSIGNED_LONG, "test_RegCoreReflection(): error 62");
245 fprintf( stderr, "%1\n" );
246 Any bla = xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aString"))->get(Any());
247 OSL_ENSURE(sal_False, "test_RegCoreReflection(): error 63");
248 return sal_False;
250 catch (IllegalArgumentException &)
256 fprintf( stderr, "%2\n" );
257 Any blup;
258 blup <<= aStructC;
259 Any gulp;
260 rField = Reference< XIdlField2 > ( xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aString")) , UNO_QUERY);
261 rField->set( blup, gulp);
262 // xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aString"))->set(blup, gulp);
263 OSL_ENSURE(sal_False, "test_RegCoreReflection(): error 64");
264 return sal_False;
266 catch (IllegalArgumentException &)
272 fprintf( stderr, "%3\n" );
273 Any gulp;
274 gulp <<= 3.14f;
275 Any blup;
276 blup <<= aStructC;
277 rField = Reference< XIdlField2 > (
278 xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aString")) , UNO_QUERY);
279 xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aString"))->set(blup, gulp);
280 OSL_ENSURE(sal_False, "test_RegCoreReflection(): error 65");
281 return sal_False;
283 catch (IllegalArgumentException &)
287 Any gulp;
288 gulp <<= OUString(OUString("Test"));
289 Any blup;
290 blup <<= aStructC;
291 xRefl->forName(OUString("ModuleA.StructC"))->getField(OUString("aString"))->set(blup, gulp);
293 Reference< XInterfaceA > xAI = new OInterfaceA();
297 Sequence< Any > params;
298 fprintf( stderr, "%4\n" );
300 Any a;
301 a <<= xAI;
302 Any bla = xRefl->forName(OUString("ModuleC.XInterfaceA"))->getMethod(OUString("methodC"))->invoke(a, params);
303 OSL_ENSURE(sal_False, "test_RegCoreReflection(): error 66");
304 return sal_False;
306 catch (IllegalArgumentException &)
310 StructA aStructA;
313 Sequence< Any > params(2);
315 params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
316 params.getArray()[1].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
318 Any a;
319 a <<= xAI;
320 Any bla = xRefl->forName(OUString("ModuleC.XInterfaceA"))->getMethod(OUString("methodC"))->invoke(a, params);
324 Sequence< Any > params(2);
326 params.getArray()[0].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
327 params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
329 Any a;
330 a <<= xAI;
331 Any bla = xRefl->forName(OUString("ModuleC.XInterfaceA"))->getMethod(OUString("methodC"))->invoke(a, params);
332 OSL_ENSURE(sal_False, "test_RegCoreReflection(): error 67");
333 return sal_False;
335 catch (IllegalArgumentException &)
339 Sequence< Any > params(2);
341 params.getArray()[0].setValue(&aStructC, ::getCppuType( (const StructC *)0 ));
342 params.getArray()[1].setValue(&aStructA, ::getCppuType( (const StructA *)0 ));
344 Any a;
345 a <<= xAI;
346 bool result = (xRefl->forName(OUString("ModuleC.XInterfaceA"))->getMethod(OUString("methodC"))->invoke(a, params).getValueType()
347 == ::getCppuType( (const Sequence<StructB> *)0 )); (void)result;
348 OSL_ENSURE(result, "test_RegCoreReflection(): error 68");
350 return sal_True;
353 SAL_IMPLEMENT_MAIN()
355 sal_Bool bSucc = sal_False;
358 OUString aLibName( "reflection.uno" SAL_DLLEXTENSION );
360 Reference< XMultiServiceFactory > xMgr(
361 createRegistryServiceFactory(
362 OUString( "stoctest.rdb" ) ) );
363 Reference< XComponentContext > xContext;
364 Reference< beans::XPropertySet > xProps( xMgr, UNO_QUERY );
365 OSL_ASSERT( xProps.is() );
366 xProps->getPropertyValue(
367 OUString( "DefaultContext" ) ) >>=
368 xContext;
369 OSL_ASSERT( xContext.is() );
371 Reference< XIdlReflection > xRefl;
372 xContext->getValueByName(
373 OUString( "/singletons/com.sun.star.reflection.theCoreReflection") )
374 >>= xRefl;
375 OSL_ENSURE(
376 xRefl.is(), "### CoreReflection singleton not accessable!?" );
378 bSucc = test_corefl( xRefl );
380 Reference< XComponent >( xContext, UNO_QUERY )->dispose();
382 catch (const Exception & rExc)
384 OSL_FAIL( "### exception occurred!" );
385 OString aMsg(
386 OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
387 OSL_TRACE( "### exception occurred: " );
388 OSL_TRACE( "%s", aMsg.getStr() );
389 OSL_TRACE( "\n" );
392 printf( "testcorefl %s !\n", (bSucc ? "succeeded" : "failed") );
393 return (bSucc ? 0 : -1);
396 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */