fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / config / test / test.cxx
blobfa676c6d640286eeb18ebb45ad59110809db9135
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 //_________________________________________________________________________________________________________________
22 // switches
23 // use it to enable test scenarios
24 //_________________________________________________________________________________________________________________
26 #define TEST_DYNAMICMENUOPTIONS
28 #include <unotools/dynamicmenuoptions.hxx>
30 #include <cppuhelper/bootstrap.hxx>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/registry/XSimpleRegistry.hpp>
35 #include <cppuhelper/servicefactory.hxx>
36 #include <comphelper/processfactory.hxx>
37 #include <com/sun/star/uno/Reference.h>
38 #include <com/sun/star/uno/Sequence.h>
40 #ifndef _RTL_USTRING_
41 #include <rtl/ustring>
42 #endif
43 #include <rtl/ustrbuf.hxx>
44 #include <osl/diagnose.h>
45 #include <osl/mutex.hxx>
47 #include <vcl/event.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/wrkwin.hxx>
50 #include <vcl/msgbox.hxx>
51 #include <stdio.h>
53 using namespace ::rtl ;
54 using namespace ::osl ;
55 using namespace ::comphelper ;
56 using namespace ::com::sun::star::uno ;
57 using namespace ::com::sun::star::lang ;
58 using namespace ::com::sun::star::beans ;
59 using namespace ::com::sun::star::registry ;
61 class TestApplication : public Application
63 //*************************************************************************************************************
64 // interface
65 //*************************************************************************************************************
66 public:
67 void Main();
69 //*************************************************************************************************************
70 // test methods
71 //*************************************************************************************************************
72 private:
73 void impl_testDynamicMenuOptions();
75 //*************************************************************************************************************
76 // helper methods
77 //*************************************************************************************************************
78 private:
79 static Reference< XMultiServiceFactory > getUNOServiceManager();
81 //*************************************************************************************************************
82 // member
83 //*************************************************************************************************************
84 private:
86 }; // class TestApplication
88 //_________________________________________________________________________________________________________________
89 // global variables
90 //_________________________________________________________________________________________________________________
92 TestApplication aTestApplication ;
94 //_________________________________________________________________________________________________________________
95 // main
96 //_________________________________________________________________________________________________________________
98 void TestApplication::Main()
100 /**-***********************************************************************************************************
101 initialize program
102 **************************************************************************************************************/
104 // Init global servicemanager and set it for external services.
105 ::comphelper::setProcessServiceFactory( TestApplication::getUNOServiceManager() );
106 // Control success of operation.
107 OSL_ENSURE( !(::comphelper::getProcessServiceFactory()!=TestApplication::getUNOServiceManager()), "TestApplication::Main()\nGlobal servicemanager not right initialized.\n" );
109 /**-***********************************************************************************************************
110 test area
111 **************************************************************************************************************/
113 #ifdef TEST_DYNAMICMENUOPTIONS
114 impl_testDynamicMenuOptions();
115 #endif
117 // Execute();
118 OSL_FAIL( "Test was successful!\n" );
121 //*****************************************************************************************************************
122 // test configuration of dynamic menus "New" and "Wizard"
123 //*****************************************************************************************************************
124 void TestApplication::impl_testDynamicMenuOptions()
126 SvtDynamicMenuOptions aCFG;
128 // Test:
129 // read menus
130 // if( menus == empty )
131 // {
132 // fill it with samples
133 // read it again
134 // }
135 // output content
137 Sequence< Sequence< PropertyValue > > lNewMenu = aCFG.GetMenu( E_NEWMENU );
138 Sequence< Sequence< PropertyValue > > lWizardMenu = aCFG.GetMenu( E_WIZARDMENU );
140 if( lNewMenu.getLength() < 1 )
142 aCFG.AppendItem( E_NEWMENU, "private:factory/swriter", "new writer", "icon_writer", "_blank";
143 aCFG.AppendItem( E_NEWMENU, "private:factory/scalc", "new calc", "icon_calc", "_blank";
144 aCFG.AppendItem( E_NEWMENU, "private:factory/sdraw", "new draw", "icon_draw", "_blank";
146 lNewMenu = aCFG.GetMenu( E_NEWMENU );
149 if( lWizardMenu.getLength() < 1 )
151 aCFG.AppendItem( E_WIZARDMENU, "file://a", "system file", "icon_file", "_self";
152 aCFG.AppendItem( E_WIZARDMENU, "ftp://b", "ftp host", "icon_ftp", "_self";
153 aCFG.AppendItem( E_WIZARDMENU, "http://c", "www", "icon_www", "_self";
155 lWizardMenu = aCFG.GetMenu( E_WIZARDMENU );
158 sal_uInt32 nItemCount ;
159 sal_uInt32 nItem ;
160 sal_uInt32 nPropertyCount;
161 sal_uInt32 nProperty ;
162 OUString sPropertyValue;
163 OUStringBuffer sOut( 5000 ) ;
165 nItemCount = lNewMenu.getLength();
166 for( nItem=0; nItem<nItemCount; ++nItem )
168 nPropertyCount = lNewMenu[nItem].getLength();
169 for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
171 lNewMenu[nItem][nProperty].Value >>= sPropertyValue;
173 sOut.appendAscii ( "New/" );
174 sOut.append ( (sal_Int32)nItem );
175 sOut.appendAscii ( "/" );
176 sOut.append ( lNewMenu[nItem][nProperty].Name );
177 sOut.appendAscii ( " = " );
178 sOut.append ( sPropertyValue );
179 sOut.appendAscii ( "\n" );
183 sOut.appendAscii("\n--------------------------------------\n");
185 nItemCount = lWizardMenu.getLength();
186 for( nItem=0; nItem<nItemCount; ++nItem )
188 nPropertyCount = lNewMenu[nItem].getLength();
189 for( nProperty=0; nProperty<nPropertyCount; ++nProperty )
191 lWizardMenu[nItem][nProperty].Value >>= sPropertyValue;
193 sOut.appendAscii ( "Wizard/" );
194 sOut.append ( (sal_Int32)nItem );
195 sOut.appendAscii ( "/" );
196 sOut.append ( lNewMenu[nItem][nProperty].Name );
197 sOut.appendAscii ( " = " );
198 sOut.append ( sPropertyValue );
199 sOut.appendAscii ( "\n" );
203 OSL_FAIL( OUStringToOString( sOut.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr() );
206 //*****************************************************************************************************************
207 // create new uno servicemanager by using normall applicat.rdb and user.rdb of an office installation!
208 // Don't use this application at same time like the office!
209 //*****************************************************************************************************************
210 Reference< XMultiServiceFactory > TestApplication::getUNOServiceManager()
212 static Reference< XMultiServiceFactory > smgr;
213 if( ! smgr.is() )
215 Reference< XComponentContext > rCtx =
216 cppu::defaultBootstrap_InitialComponentContext();
217 smgr = Reference< XMultiServiceFactory > ( rCtx->getServiceManager() , UNO_QUERY );
219 return smgr;
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */