1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_testtools.hxx"
31 #include "sal/config.h"
35 #include "rtl/string.hxx"
36 #include "rtl/textenc.h"
37 #include "rtl/ustring.hxx"
41 namespace css
= com::sun::star
;
46 explicit CheckFailed(rtl::OUString
const & theMessage
): message(theMessage
)
49 rtl::OUString message
;
52 template< typename T
> void checkEqual(T
const & value
, T
const & argument
) {
53 if (argument
!= value
) {
55 s
<< value
<< " != " << argument
;
57 rtl::OStringToOUString(
58 rtl::OString(s
.str().c_str()), RTL_TEXTENCODING_UTF8
));
64 namespace testtools
{ namespace bridgetest
{
66 rtl::OUString
testMulti(
67 com::sun::star::uno::Reference
< test::testtools::bridgetest::XMulti
>
73 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
74 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
77 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
78 multi
.get())->getatt1());
81 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
82 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
85 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
86 multi
.get())->getatt1());
89 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
90 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
91 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
92 multi
, css::uno::UNO_QUERY_THROW
)->setatt1(0.1);
95 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
96 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
99 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
100 multi
.get())->getatt1());
103 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
104 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
107 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
108 multi
.get())->getatt1());
111 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
112 multi
, css::uno::UNO_QUERY_THROW
)->getatt1());
113 checkEqual
< sal_Int32
>(
115 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
116 multi
, css::uno::UNO_QUERY_THROW
)->fn11(1));
117 checkEqual
< sal_Int32
>(
119 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
120 multi
.get())->fn11(1));
121 checkEqual
< sal_Int32
>(
123 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
124 multi
, css::uno::UNO_QUERY_THROW
)->fn11(2));
125 checkEqual
< sal_Int32
>(
127 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
128 multi
.get())->fn11(1));
129 checkEqual
< sal_Int32
>(
131 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
132 multi
, css::uno::UNO_QUERY_THROW
)->fn11(5));
134 rtl::OUString::createFromAscii("12" "abc"),
135 css::uno::Reference
< test::testtools::bridgetest::XMultiBase1
>(
136 multi
, css::uno::UNO_QUERY_THROW
)->fn12(
137 rtl::OUString::createFromAscii("abc")));
139 rtl::OUString::createFromAscii("12" "abc-2"),
140 static_cast< test::testtools::bridgetest::XMultiBase2
* >(
141 multi
.get())->fn12(rtl::OUString::createFromAscii("abc-2")));
143 rtl::OUString::createFromAscii("12" "abc-2"),
144 css::uno::Reference
< test::testtools::bridgetest::XMultiBase2
>(
145 multi
, css::uno::UNO_QUERY_THROW
)->fn12(
146 rtl::OUString::createFromAscii("abc-2")));
148 rtl::OUString::createFromAscii("12" "abc-5"),
149 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
150 multi
.get())->fn12(rtl::OUString::createFromAscii("abc-5")));
152 rtl::OUString::createFromAscii("12" "abc-5"),
153 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
154 multi
, css::uno::UNO_QUERY_THROW
)->fn12(
155 rtl::OUString::createFromAscii("abc-5")));
156 checkEqual
< sal_Int32
>(21 * 2, multi
->fn21(2));
158 rtl::OUString::createFromAscii("22" "de"),
159 multi
->fn22(rtl::OUString::createFromAscii("de")));
160 checkEqual
< sal_Int32
>(
162 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
163 multi
, css::uno::UNO_QUERY_THROW
)->fn31(3));
164 checkEqual
< sal_Int32
>(
166 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
167 multi
.get())->fn31(5));
168 checkEqual
< sal_Int32
>(
170 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
171 multi
, css::uno::UNO_QUERY_THROW
)->fn31(5));
174 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
175 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
178 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
179 multi
.get())->getatt3());
182 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
183 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
184 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
185 multi
, css::uno::UNO_QUERY_THROW
)->setatt3(0.3);
188 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
189 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
192 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
193 multi
.get())->getatt3());
196 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
197 multi
, css::uno::UNO_QUERY_THROW
)->getatt3());
199 rtl::OUString::createFromAscii("32" "f"),
200 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
201 multi
, css::uno::UNO_QUERY_THROW
)->fn32(
202 rtl::OUString::createFromAscii("f")));
204 rtl::OUString::createFromAscii("32" "f-5"),
205 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
206 multi
.get())->fn32(rtl::OUString::createFromAscii("f-5")));
208 rtl::OUString::createFromAscii("32" "f-5"),
209 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
210 multi
, css::uno::UNO_QUERY_THROW
)->fn32(
211 rtl::OUString::createFromAscii("f-5")));
212 checkEqual
< sal_Int32
>(
214 css::uno::Reference
< test::testtools::bridgetest::XMultiBase3
>(
215 multi
, css::uno::UNO_QUERY_THROW
)->fn33());
216 checkEqual
< sal_Int32
>(
218 static_cast< test::testtools::bridgetest::XMultiBase5
* >(
219 multi
.get())->fn33());
220 checkEqual
< sal_Int32
>(
222 css::uno::Reference
< test::testtools::bridgetest::XMultiBase5
>(
223 multi
, css::uno::UNO_QUERY_THROW
)->fn33());
224 checkEqual
< sal_Int32
>(41 * 4, multi
->fn41(4));
225 checkEqual
< sal_Int32
>(61 * 6, multi
->fn61(6));
227 rtl::OUString::createFromAscii("62" ""),
228 multi
->fn62(rtl::OUString::createFromAscii("")));
229 checkEqual
< sal_Int32
>(71 * 7, multi
->fn71(7));
231 rtl::OUString::createFromAscii("72" "g"),
232 multi
->fn72(rtl::OUString::createFromAscii("g")));
233 checkEqual
< sal_Int32
>(73, multi
->fn73());
234 } catch (CheckFailed
const & f
) {
237 return rtl::OUString();