tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / stoc / test / testsmgr2.cxx
blob2e40c0444dca8df45f0557ef4d1959dc8d8fbecd
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 .
21 #include <stdio.h>
23 #include <sal/main.h>
24 #include <cppuhelper/bootstrap.hxx>
26 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/registry/XSimpleRegistry.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/lang/DisposedException.hpp>
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <com/sun/star/uno/XComponentContext.hpp>
34 using namespace ::cppu;
35 using namespace css::uno;
36 using namespace css::lang;
37 using namespace css::container;
38 using namespace css::registry;
40 SAL_IMPLEMENT_MAIN()
42 try
45 Reference< XSimpleRegistry > r1 = createSimpleRegistry();
46 Reference< XSimpleRegistry > r2 = createSimpleRegistry();
47 r1->open( OUString( "test1.rdb" ), sal_True, sal_False );
48 r2->open( OUString( "test2.rdb" ), sal_True, sal_False );
49 Reference< XSimpleRegistry > r = createNestedRegistry( );
50 Reference< XInitialization > rInit( r, UNO_QUERY );
51 Sequence< Any > seq( 2 );
52 seq[0] <<= r1;
53 seq[1] <<= r2;
54 rInit->initialize( seq );
56 Reference< XComponentContext > rComp = bootstrap_InitialComponentContext( r );
58 Reference< XContentEnumerationAccess > xCtAccess( rComp->getServiceManager(), UNO_QUERY );
60 Reference< XEnumeration > rEnum =
61 xCtAccess->createContentEnumeration( OUString( "com.sun.star.bridge.Bridge" ) );
63 sal_Int32 n = 0;
64 while( rEnum->hasMoreElements() )
66 Reference< XServiceInfo > r3;
67 rEnum->nextElement() >>= r3;
68 OString o = OUStringToOString( r3->getImplementationName() , RTL_TEXTENCODING_ASCII_US );
69 printf( "%s\n" , o.getStr() );
70 Sequence< OUString > seq2 = r3->getSupportedServiceNames();
71 for( int i = 0 ;i < seq2.getLength() ; i ++ )
73 o = OUStringToOString( seq2[i] , RTL_TEXTENCODING_ASCII_US );
74 printf( " %s\n" , o.getStr() );
76 n ++;
78 // there are two services in two registries !
79 OSL_ASSERT( 2 == n );
80 if( 2 == n )
82 printf( "test passed\n" );
85 Reference< XComponent > xComp( rComp, UNO_QUERY );
86 xComp->dispose();
87 try
89 xCtAccess->createContentEnumeration(
90 OUString( "blabla" ) );
92 catch (DisposedException &)
94 printf( "already disposed results in DisposedException: ok.\n" );
95 return 0;
97 fprintf( stderr, "missing DisposedException!\n" );
98 return 1;
100 catch ( const Exception & e )
102 OString o = OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US );
103 printf( "%s\n" , o.getStr() );
104 OSL_ASSERT( 0 );
105 return 1;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */