merge the formfield patch from ooo-build
[ooovba.git] / testshl2 / workben / uno / unotest.cxx
blobe269f903938a5c1718d6c1069ff44945edbd89fb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unotest.cxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_testshl2.hxx"
34 #include "rtl/bootstrap.hxx"
35 #include <comphelper/processfactory.hxx>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <cppunit/simpleheader.hxx>
39 #include <cppuhelper/bootstrap.hxx>
40 #include <com/sun/star/xml/sax/XParser.hpp>
42 namespace css = com::sun::star;
43 namespace lang = css::lang;
44 namespace uno = css::uno;
45 namespace sax = css::xml::sax;
48 // StringHelper
49 inline void operator <<= (rtl::OString& _rAsciiString, const rtl::OUString& _rUnicodeString)
51 _rAsciiString = rtl::OUStringToOString(_rUnicodeString,RTL_TEXTENCODING_ASCII_US);
55 namespace unotest
57 //------------------------------------------------------------------------
58 // testing constructors
59 //------------------------------------------------------------------------
61 class ctor : public CppUnit::TestFixture
63 public:
64 void ctor_001()
66 uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
67 if (xFactory.is())
69 // sample, get a xParser instance
70 uno::Reference< sax::XParser > xParser;
71 xParser = uno::Reference< sax::XParser > (
72 xFactory->createInstance(
73 ::rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser")), uno::UNO_QUERY);
75 CPPUNIT_ASSERT_MESSAGE("can't get sax::Parser", xParser.is());
78 void ctor_002()
80 CPPUNIT_ASSERT_MESSAGE("Simple testshl2 test, MUST fail.", sal_False);
83 CPPUNIT_TEST_SUITE(ctor);
84 CPPUNIT_TEST(ctor_001);
85 CPPUNIT_TEST(ctor_002);
86 CPPUNIT_TEST_SUITE_END();
89 // -----------------------------------------------------------------------------
90 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(unotest::ctor, "unotest");
91 } // unotest
93 // -----------------------------------------------------------------------------
95 // this macro creates an empty function, which will called by the RegisterAllFunctions()
96 // to let the user the possibility to also register some functions by hand.
99 void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc)
101 (void) _pFunc;
102 uno::Reference<lang::XMultiServiceFactory> xMS;
106 uno::Reference< uno::XComponentContext > xComponentContext = cppu::defaultBootstrap_InitialComponentContext();
107 xMS.set(xComponentContext->getServiceManager(), uno::UNO_QUERY);
108 comphelper::setProcessServiceFactory(xMS);
110 catch (::com::sun::star::uno::Exception e )
112 rtl::OString aError;
113 aError <<= e.Message;
114 printf("Error: %s\n", aError.getStr());
117 // NOADDITIONAL;