merge the formfield patch from ooo-build
[ooovba.git] / configmgr / qa / unit / common.hxx
blobf686a43aac408fad18bf48e5b2f335dc549da14b
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: common.hxx,v $
10 * $Revision: 1.3 $
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 #include "sal/config.h"
32 #include <cstdlib>
33 #include "com/sun/star/beans/NamedValue.hpp"
34 #include "com/sun/star/beans/XPropertySet.hpp"
35 #include "com/sun/star/beans/XPropertyState.hpp"
36 #include "com/sun/star/lang/XComponent.hpp"
37 #include "com/sun/star/lang/XMultiComponentFactory.hpp"
38 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
39 #include "com/sun/star/container/XNameReplace.hpp"
40 #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
41 #include "com/sun/star/util/XChangesBatch.hpp"
42 #include "com/sun/star/uno/Any.hxx"
43 #include "com/sun/star/uno/Reference.hxx"
44 #include "com/sun/star/uno/XComponentContext.hpp"
45 #include "cppuhelper/component_context.hxx"
46 #include "cppuhelper/servicefactory.hxx"
47 #include "cppunit/simpleheader.hxx"
48 #include "osl/file.hxx"
49 #include "osl/thread.h"
50 #include "osl/process.h"
51 #include "rtl/string.h"
52 #include "rtl/bootstrap.h"
53 #include "rtl/ustring.h"
54 #include "rtl/ustring.hxx"
55 #include "sal/types.h"
57 namespace css = com::sun::star;
59 #define CATCH_FAIL(msg) \
60 catch (const css::uno::Exception &e) { \
61 t_print ("msg '%s'\n", rtl::OUStringToOString (e.Message, RTL_TEXTENCODING_UTF8).getStr()); \
62 CPPUNIT_FAIL( msg ); \
63 throw; \
66 class Magic
68 rtl::OUString maTempDir;
69 public:
70 Magic();
71 ~Magic();
74 class Test: public CppUnit::TestFixture {
75 Magic *mpMagic;
76 public:
77 // init
78 virtual void setUp();
79 virtual void tearDown();
81 // helpers
82 void normalizePathKey (rtl::OString &rPath, rtl::OString &rKey);
83 css::uno::Reference< css::uno::XInterface > createView(const sal_Char *pNodepath, bool bUpdate);
84 css::uno::Any getKey (const sal_Char *pPath, rtl::OUString aName);
85 css::uno::Any getKey (const sal_Char *pPath, const sal_Char *pName)
86 { return getKey (pPath, rtl::OUString::createFromAscii (pName)); }
87 void setKey (const sal_Char *pPath, rtl::OUString aName, css::uno::Any a);
88 void resetKey (const sal_Char *pPath, rtl::OUString aName);
90 // tests
91 void keyFetch();
92 void keySet();
93 void keyReset();
94 void readCommands();
95 void threadTests();
96 void recursiveTests();
97 void eventTests();
99 CPPUNIT_TEST_SUITE(Test);
100 CPPUNIT_TEST(keyFetch);
101 CPPUNIT_TEST(keySet);
102 CPPUNIT_TEST(keyReset);
103 CPPUNIT_TEST(readCommands);
104 CPPUNIT_TEST(threadTests);
105 CPPUNIT_TEST(recursiveTests);
106 CPPUNIT_TEST(eventTests);
107 CPPUNIT_TEST_SUITE_END();
109 private:
110 css::uno::Reference< css::uno::XComponentContext > mxContext;
111 css::uno::Reference< css::lang::XMultiServiceFactory > mxProvider;
114 void disposeComponent (const css::uno::Reference<css::uno::XInterface> &xComp);