1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_testtools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "sal/config.h" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "multi.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include "rtl/string.hxx" 36*cdf0e10cSrcweir #include "rtl/textenc.h" 37*cdf0e10cSrcweir #include "rtl/ustring.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <sstream> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace css = com::sun::star; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir namespace { 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir struct CheckFailed { 46*cdf0e10cSrcweir explicit CheckFailed(rtl::OUString const & theMessage): message(theMessage) 47*cdf0e10cSrcweir {} 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir rtl::OUString message; 50*cdf0e10cSrcweir }; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir template< typename T > void checkEqual(T const & value, T const & argument) { 53*cdf0e10cSrcweir if (argument != value) { 54*cdf0e10cSrcweir std::ostringstream s; 55*cdf0e10cSrcweir s << value << " != " << argument; 56*cdf0e10cSrcweir throw CheckFailed( 57*cdf0e10cSrcweir rtl::OStringToOUString( 58*cdf0e10cSrcweir rtl::OString(s.str().c_str()), RTL_TEXTENCODING_UTF8)); 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir namespace testtools { namespace bridgetest { 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir rtl::OUString testMulti( 67*cdf0e10cSrcweir com::sun::star::uno::Reference< test::testtools::bridgetest::XMulti > 68*cdf0e10cSrcweir const & multi) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir try { 71*cdf0e10cSrcweir checkEqual( 72*cdf0e10cSrcweir 0.0, 73*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >( 74*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt1()); 75*cdf0e10cSrcweir checkEqual( 76*cdf0e10cSrcweir 0.0, 77*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase2 * >( 78*cdf0e10cSrcweir multi.get())->getatt1()); 79*cdf0e10cSrcweir checkEqual( 80*cdf0e10cSrcweir 0.0, 81*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >( 82*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt1()); 83*cdf0e10cSrcweir checkEqual( 84*cdf0e10cSrcweir 0.0, 85*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 86*cdf0e10cSrcweir multi.get())->getatt1()); 87*cdf0e10cSrcweir checkEqual( 88*cdf0e10cSrcweir 0.0, 89*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 90*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt1()); 91*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 92*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->setatt1(0.1); 93*cdf0e10cSrcweir checkEqual( 94*cdf0e10cSrcweir 0.1, 95*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >( 96*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt1()); 97*cdf0e10cSrcweir checkEqual( 98*cdf0e10cSrcweir 0.1, 99*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase2 * >( 100*cdf0e10cSrcweir multi.get())->getatt1()); 101*cdf0e10cSrcweir checkEqual( 102*cdf0e10cSrcweir 0.1, 103*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >( 104*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt1()); 105*cdf0e10cSrcweir checkEqual( 106*cdf0e10cSrcweir 0.1, 107*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 108*cdf0e10cSrcweir multi.get())->getatt1()); 109*cdf0e10cSrcweir checkEqual( 110*cdf0e10cSrcweir 0.1, 111*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 112*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt1()); 113*cdf0e10cSrcweir checkEqual< sal_Int32 >( 114*cdf0e10cSrcweir 11 * 1, 115*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >( 116*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn11(1)); 117*cdf0e10cSrcweir checkEqual< sal_Int32 >( 118*cdf0e10cSrcweir 11 * 1, 119*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase2 * >( 120*cdf0e10cSrcweir multi.get())->fn11(1)); 121*cdf0e10cSrcweir checkEqual< sal_Int32 >( 122*cdf0e10cSrcweir 11 * 2, 123*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >( 124*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn11(2)); 125*cdf0e10cSrcweir checkEqual< sal_Int32 >( 126*cdf0e10cSrcweir 11 * 1, 127*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 128*cdf0e10cSrcweir multi.get())->fn11(1)); 129*cdf0e10cSrcweir checkEqual< sal_Int32 >( 130*cdf0e10cSrcweir 11 * 5, 131*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 132*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn11(5)); 133*cdf0e10cSrcweir checkEqual( 134*cdf0e10cSrcweir rtl::OUString::createFromAscii("12" "abc"), 135*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase1 >( 136*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn12( 137*cdf0e10cSrcweir rtl::OUString::createFromAscii("abc"))); 138*cdf0e10cSrcweir checkEqual( 139*cdf0e10cSrcweir rtl::OUString::createFromAscii("12" "abc-2"), 140*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase2 * >( 141*cdf0e10cSrcweir multi.get())->fn12(rtl::OUString::createFromAscii("abc-2"))); 142*cdf0e10cSrcweir checkEqual( 143*cdf0e10cSrcweir rtl::OUString::createFromAscii("12" "abc-2"), 144*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase2 >( 145*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn12( 146*cdf0e10cSrcweir rtl::OUString::createFromAscii("abc-2"))); 147*cdf0e10cSrcweir checkEqual( 148*cdf0e10cSrcweir rtl::OUString::createFromAscii("12" "abc-5"), 149*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 150*cdf0e10cSrcweir multi.get())->fn12(rtl::OUString::createFromAscii("abc-5"))); 151*cdf0e10cSrcweir checkEqual( 152*cdf0e10cSrcweir rtl::OUString::createFromAscii("12" "abc-5"), 153*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 154*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn12( 155*cdf0e10cSrcweir rtl::OUString::createFromAscii("abc-5"))); 156*cdf0e10cSrcweir checkEqual< sal_Int32 >(21 * 2, multi->fn21(2)); 157*cdf0e10cSrcweir checkEqual( 158*cdf0e10cSrcweir rtl::OUString::createFromAscii("22" "de"), 159*cdf0e10cSrcweir multi->fn22(rtl::OUString::createFromAscii("de"))); 160*cdf0e10cSrcweir checkEqual< sal_Int32 >( 161*cdf0e10cSrcweir 31 * 3, 162*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >( 163*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn31(3)); 164*cdf0e10cSrcweir checkEqual< sal_Int32 >( 165*cdf0e10cSrcweir 31 * 5, 166*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 167*cdf0e10cSrcweir multi.get())->fn31(5)); 168*cdf0e10cSrcweir checkEqual< sal_Int32 >( 169*cdf0e10cSrcweir 31 * 5, 170*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 171*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn31(5)); 172*cdf0e10cSrcweir checkEqual( 173*cdf0e10cSrcweir 0.0, 174*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >( 175*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt3()); 176*cdf0e10cSrcweir checkEqual( 177*cdf0e10cSrcweir 0.0, 178*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 179*cdf0e10cSrcweir multi.get())->getatt3()); 180*cdf0e10cSrcweir checkEqual( 181*cdf0e10cSrcweir 0.0, 182*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 183*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt3()); 184*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >( 185*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->setatt3(0.3); 186*cdf0e10cSrcweir checkEqual( 187*cdf0e10cSrcweir 0.3, 188*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >( 189*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt3()); 190*cdf0e10cSrcweir checkEqual( 191*cdf0e10cSrcweir 0.3, 192*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 193*cdf0e10cSrcweir multi.get())->getatt3()); 194*cdf0e10cSrcweir checkEqual( 195*cdf0e10cSrcweir 0.3, 196*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 197*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->getatt3()); 198*cdf0e10cSrcweir checkEqual( 199*cdf0e10cSrcweir rtl::OUString::createFromAscii("32" "f"), 200*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >( 201*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn32( 202*cdf0e10cSrcweir rtl::OUString::createFromAscii("f"))); 203*cdf0e10cSrcweir checkEqual( 204*cdf0e10cSrcweir rtl::OUString::createFromAscii("32" "f-5"), 205*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 206*cdf0e10cSrcweir multi.get())->fn32(rtl::OUString::createFromAscii("f-5"))); 207*cdf0e10cSrcweir checkEqual( 208*cdf0e10cSrcweir rtl::OUString::createFromAscii("32" "f-5"), 209*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 210*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn32( 211*cdf0e10cSrcweir rtl::OUString::createFromAscii("f-5"))); 212*cdf0e10cSrcweir checkEqual< sal_Int32 >( 213*cdf0e10cSrcweir 33, 214*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase3 >( 215*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn33()); 216*cdf0e10cSrcweir checkEqual< sal_Int32 >( 217*cdf0e10cSrcweir 33, 218*cdf0e10cSrcweir static_cast< test::testtools::bridgetest::XMultiBase5 * >( 219*cdf0e10cSrcweir multi.get())->fn33()); 220*cdf0e10cSrcweir checkEqual< sal_Int32 >( 221*cdf0e10cSrcweir 33, 222*cdf0e10cSrcweir css::uno::Reference< test::testtools::bridgetest::XMultiBase5 >( 223*cdf0e10cSrcweir multi, css::uno::UNO_QUERY_THROW)->fn33()); 224*cdf0e10cSrcweir checkEqual< sal_Int32 >(41 * 4, multi->fn41(4)); 225*cdf0e10cSrcweir checkEqual< sal_Int32 >(61 * 6, multi->fn61(6)); 226*cdf0e10cSrcweir checkEqual( 227*cdf0e10cSrcweir rtl::OUString::createFromAscii("62" ""), 228*cdf0e10cSrcweir multi->fn62(rtl::OUString::createFromAscii(""))); 229*cdf0e10cSrcweir checkEqual< sal_Int32 >(71 * 7, multi->fn71(7)); 230*cdf0e10cSrcweir checkEqual( 231*cdf0e10cSrcweir rtl::OUString::createFromAscii("72" "g"), 232*cdf0e10cSrcweir multi->fn72(rtl::OUString::createFromAscii("g"))); 233*cdf0e10cSrcweir checkEqual< sal_Int32 >(73, multi->fn73()); 234*cdf0e10cSrcweir } catch (CheckFailed const & f) { 235*cdf0e10cSrcweir return f.message; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir return rtl::OUString(); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir } } 241