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: multi.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_testtools.hxx"
34 #include "sal/config.h"
38 #include "rtl/string.hxx"
39 #include "rtl/textenc.h"
40 #include "rtl/ustring.hxx"
44 namespace css
= com::sun::star
;
49 explicit CheckFailed(rtl::OUString
const & theMessage
): message(theMessage
)
52 rtl::OUString message
;
55 template< typename T
> void checkEqual(T
const & value
, T
const & argument
) {
56 if (argument
!= value
) {
58 s
<< value
<< " != " << argument
;
60 rtl::OStringToOUString(
61 rtl::OString(s
.str().c_str()), RTL_TEXTENCODING_UTF8
));
67 namespace testtools
{ namespace bridgetest
{
69 rtl::OUString
testMulti(
70 com::sun::star::uno::Reference
< test::testtools::bridgetest::XMulti
>
76 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
77 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
80 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
81 multi
.get())->getatt1());
84 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
85 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
88 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
89 multi
.get())->getatt1());
92 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
93 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
94 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
95 multi
, css::uno::UNO_QUERY_THROW
)->setatt1(0.1);
98 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
99 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
102 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
103 multi
.get())->getatt1());
106 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
107 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
110 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
111 multi
.get())->getatt1());
114 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
115 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
116 checkEqual
< sal_Int32
>(
118 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
119 multi
, css::uno::UNO_QUERY_THROW
)->fn11(1));
120 checkEqual
< sal_Int32
>(
122 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
123 multi
.get())->fn11(1));
124 checkEqual
< sal_Int32
>(
126 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
127 multi
, css::uno::UNO_QUERY_THROW
)->fn11(2));
128 checkEqual
< sal_Int32
>(
130 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
131 multi
.get())->fn11(1));
132 checkEqual
< sal_Int32
>(
134 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
135 multi
, css::uno::UNO_QUERY_THROW
)->fn11(5));
137 rtl::OUString::createFromAscii("12" "abc"),
138 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
139 multi
, css::uno::UNO_QUERY_THROW
)->fn12(
140 rtl::OUString::createFromAscii("abc")));
142 rtl::OUString::createFromAscii("12" "abc-2"),
143 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
144 multi
.get())->fn12(rtl::OUString::createFromAscii("abc-2")));
146 rtl::OUString::createFromAscii("12" "abc-2"),
147 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
148 multi
, css::uno::UNO_QUERY_THROW
)->fn12(
149 rtl::OUString::createFromAscii("abc-2")));
151 rtl::OUString::createFromAscii("12" "abc-5"),
152 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
153 multi
.get())->fn12(rtl::OUString::createFromAscii("abc-5")));
155 rtl::OUString::createFromAscii("12" "abc-5"),
156 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
157 multi
, css::uno::UNO_QUERY_THROW
)->fn12(
158 rtl::OUString::createFromAscii("abc-5")));
159 checkEqual
< sal_Int32
>(21 * 2, multi
->fn21(2));
161 rtl::OUString::createFromAscii("22" "de"),
162 multi
->fn22(rtl::OUString::createFromAscii("de")));
163 checkEqual
< sal_Int32
>(
165 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
166 multi
, css::uno::UNO_QUERY_THROW
)->fn31(3));
167 checkEqual
< sal_Int32
>(
169 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
170 multi
.get())->fn31(5));
171 checkEqual
< sal_Int32
>(
173 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
174 multi
, css::uno::UNO_QUERY_THROW
)->fn31(5));
177 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
178 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
181 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
182 multi
.get())->getatt3());
185 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
186 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
187 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
188 multi
, css::uno::UNO_QUERY_THROW
)->setatt3(0.3);
191 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
192 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
195 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
196 multi
.get())->getatt3());
199 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
200 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
202 rtl::OUString::createFromAscii("32" "f"),
203 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
204 multi
, css::uno::UNO_QUERY_THROW
)->fn32(
205 rtl::OUString::createFromAscii("f")));
207 rtl::OUString::createFromAscii("32" "f-5"),
208 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
209 multi
.get())->fn32(rtl::OUString::createFromAscii("f-5")));
211 rtl::OUString::createFromAscii("32" "f-5"),
212 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
213 multi
, css::uno::UNO_QUERY_THROW
)->fn32(
214 rtl::OUString::createFromAscii("f-5")));
215 checkEqual
< sal_Int32
>(
217 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
218 multi
, css::uno::UNO_QUERY_THROW
)->fn33());
219 checkEqual
< sal_Int32
>(
221 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
222 multi
.get())->fn33());
223 checkEqual
< sal_Int32
>(
225 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
226 multi
, css::uno::UNO_QUERY_THROW
)->fn33());
227 checkEqual
< sal_Int32
>(41 * 4, multi
->fn41(4));
228 checkEqual
< sal_Int32
>(61 * 6, multi
->fn61(6));
230 rtl::OUString::createFromAscii("62" ""),
231 multi
->fn62(rtl::OUString::createFromAscii("")));
232 checkEqual
< sal_Int32
>(71 * 7, multi
->fn71(7));
234 rtl::OUString::createFromAscii("72" "g"),
235 multi
->fn72(rtl::OUString::createFromAscii("g")));
236 checkEqual
< sal_Int32
>(73, multi
->fn73());
237 } catch (CheckFailed
const & f
) {
240 return rtl::OUString();