1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <cppuhelper/shlib.hxx>
22 #include <cppuhelper/implbase1.hxx>
23 #include <cppu/EnvDcp.hxx>
25 #include "../testcmp/TestComponent.hxx"
31 # define SAL_DLLPREFIX ""
35 using namespace ::com::sun::star
;
38 class MyKey
: public cppu::WeakImplHelper1
<registry::XRegistryKey
>
42 virtual rtl::OUString SAL_CALL
getKeyName() throw (uno::RuntimeException
) { return rtl::OUString(); };
45 virtual sal_Bool SAL_CALL
isReadOnly( ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return sal_False
;};
46 virtual sal_Bool SAL_CALL
isValid( ) throw (uno::RuntimeException
) {return sal_False
;};
47 virtual registry::RegistryKeyType SAL_CALL
getKeyType( const rtl::OUString
& /*rKeyName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return registry::RegistryKeyType_KEY
;};
48 virtual registry::RegistryValueType SAL_CALL
getValueType( ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return registry::RegistryValueType_NOT_DEFINED
;};
49 virtual sal_Int32 SAL_CALL
getLongValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) {return 0;};
50 virtual void SAL_CALL
setLongValue( sal_Int32
/*value*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
51 virtual uno::Sequence
< sal_Int32
> SAL_CALL
getLongListValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) { return uno::Sequence
<sal_Int32
>(); };
52 virtual void SAL_CALL
setLongListValue( const uno::Sequence
< sal_Int32
>& /*seqValue*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
53 virtual rtl::OUString SAL_CALL
getAsciiValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) {return rtl::OUString();};
54 virtual void SAL_CALL
setAsciiValue( const rtl::OUString
& /*value*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
55 virtual uno::Sequence
< rtl::OUString
> SAL_CALL
getAsciiListValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) {return uno::Sequence
<rtl::OUString
>();};
56 virtual void SAL_CALL
setAsciiListValue( const uno::Sequence
< rtl::OUString
>& /*seqValue*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
57 virtual rtl::OUString SAL_CALL
getStringValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) {return rtl::OUString();};
58 virtual void SAL_CALL
setStringValue( const rtl::OUString
& /*value*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
59 virtual uno::Sequence
< rtl::OUString
> SAL_CALL
getStringListValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) {return uno::Sequence
<rtl::OUString
>();};
60 virtual void SAL_CALL
setStringListValue( const uno::Sequence
< rtl::OUString
>& /*seqValue*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
61 virtual uno::Sequence
< sal_Int8
> SAL_CALL
getBinaryValue( ) throw (registry::InvalidRegistryException
, registry::InvalidValueException
, uno::RuntimeException
) {return uno::Sequence
<sal_Int8
>();};
62 virtual void SAL_CALL
setBinaryValue( const uno::Sequence
< sal_Int8
>& /*value*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
63 virtual uno::Reference
< registry::XRegistryKey
> SAL_CALL
openKey( const rtl::OUString
& /*aKeyName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return uno::Reference
<registry::XRegistryKey
>();};
64 virtual uno::Reference
< registry::XRegistryKey
> SAL_CALL
createKey( const rtl::OUString
& /*aKeyName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return uno::Reference
<registry::XRegistryKey
>();};
65 virtual void SAL_CALL
closeKey( ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
66 virtual void SAL_CALL
deleteKey( const rtl::OUString
& /*rKeyName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
67 virtual uno::Sequence
< uno::Reference
< registry::XRegistryKey
> > SAL_CALL
openKeys( ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return uno::Sequence
<uno::Reference
<registry::XRegistryKey
> >();};
68 virtual uno::Sequence
< rtl::OUString
> SAL_CALL
getKeyNames( ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return uno::Sequence
<rtl::OUString
>();};
69 virtual sal_Bool SAL_CALL
createLink( const rtl::OUString
& /*aLinkName*/, const rtl::OUString
& /*aLinkTarget*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return sal_False
;};
70 virtual void SAL_CALL
deleteLink( const rtl::OUString
& /*rLinkName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {};
71 virtual rtl::OUString SAL_CALL
getLinkTarget( const rtl::OUString
& /*rLinkName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return rtl::OUString();};
72 virtual rtl::OUString SAL_CALL
getResolvedName( const rtl::OUString
& /*aKeyName*/ ) throw (registry::InvalidRegistryException
, uno::RuntimeException
) {return rtl::OUString();};
77 static rtl::OUString
s_test__cppu_loadSharedLibComponentFactory(char const * pServicePurpose
)
81 rtl::OUString servicePurpose
= rtl::OUString(pServicePurpose
,
82 rtl_str_getLength(pServicePurpose
),
83 RTL_TEXTENCODING_ASCII_US
);
85 result
+= rtl::OUString("\ts_test__cppu_loadSharedLibComponentFactory ");
86 result
+= rtl::OUString("(\"");
87 result
+= servicePurpose
;
88 result
+= rtl::OUString("\") - ");
91 uno::Reference
<uno::XInterface
> xObject(
92 cppu::loadSharedLibComponentFactory(
93 rtl::OUString(SAL_DLLPREFIX
"TestComponent.uno" SAL_DLLEXTENSION
),
95 rtl::OUString("impl.test.TestComponent") + servicePurpose
,
96 uno::Reference
<lang::XMultiServiceFactory
>(),
97 uno::Reference
<registry::XRegistryKey
>())
100 rtl::OUString
envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp
));
101 if (envDcp_purpose
== servicePurpose
)
102 result
+= rtl::OUString("passed\n");
106 result
+= rtl::OUString("FAILED - got: \"");
107 result
+= envDcp_purpose
;
108 result
+= rtl::OUString("\"\n");
111 catch(uno::Exception
& exception
) {
112 result
+= rtl::OUString("FAILED - got: \"");
113 result
+= exception
.Message
;
114 result
+= rtl::OUString("\"\n");
120 static rtl::OUString
s_test__cppu_writeSharedLibComponentInfo(char const * pServicePurpose
)
122 rtl::OUString result
;
124 rtl::OUString servicePurpose
= rtl::OUString(pServicePurpose
,
125 rtl_str_getLength(pServicePurpose
),
126 RTL_TEXTENCODING_ASCII_US
);
128 result
+= rtl::OUString("\ts_test__cppu_writeSharedLibComponentInfo ");
129 result
+= rtl::OUString("(\"");
130 result
+= servicePurpose
;
131 result
+= rtl::OUString("\") - ");
134 strcpy(buff
, "TestComponent.uno=");
135 strcat(buff
, pServicePurpose
);
140 cppu::writeSharedLibComponentInfo(
141 rtl::OUString(SAL_DLLPREFIX
"TestComponent.uno" SAL_DLLEXTENSION
),
143 uno::Reference
<lang::XMultiServiceFactory
>(),
144 uno::Reference
<registry::XRegistryKey
>(new MyKey
)
147 rtl::OUString
envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp
));
148 if (envDcp_purpose
== servicePurpose
)
149 result
+= rtl::OUString("passed\n");
153 result
+= rtl::OUString("FAILED - got: \"");
154 result
+= envDcp_purpose
;
155 result
+= rtl::OUString("\"\n");
158 catch(uno::Exception
& exception
) {
159 result
+= rtl::OUString("FAILED - got: \"");
160 result
+= exception
.Message
;
161 result
+= rtl::OUString("\"\n");
168 SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv
)
172 rtl::OUString message
;
174 message
+= rtl::OUString(argv
[0], rtl_str_getLength(argv
[0]), RTL_TEXTENCODING_ASCII_US
);
175 message
+= rtl::OUString("\n");
177 message
+= s_test__cppu_loadSharedLibComponentFactory(":unsafe");
178 message
+= s_test__cppu_loadSharedLibComponentFactory(":affine");
179 message
+= s_test__cppu_loadSharedLibComponentFactory("");
181 message
+= s_test__cppu_writeSharedLibComponentInfo(":unsafe");
182 message
+= s_test__cppu_writeSharedLibComponentInfo(":affine");
183 message
+= s_test__cppu_writeSharedLibComponentInfo("");
185 if (message
.indexOf("FAILED") == -1)
186 message
+= rtl::OUString("TESTS PASSED\n");
190 message
+= rtl::OUString("TESTS _NOT_ PASSED\n");
194 std::cout
<< rtl::OUStringToOString(message
, RTL_TEXTENCODING_ASCII_US
).getStr();
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */