Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License or as specified alternatively below. You may obtain a copy of
8 : * the License at http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2011 Michael Meeks <michael.meeks@suse.com>
17 : * Caolán McNamara <caolanm@redhat.com>
18 : *
19 : * All Rights Reserved.
20 : *
21 : * For minor contributions see the git repository.
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
25 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
26 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
27 : * instead of those above.
28 : */
29 : #include <unotest/bootstrapfixturebase.hxx>
30 : #include <rtl/strbuf.hxx>
31 : #include <rtl/bootstrap.hxx>
32 : #include <cppuhelper/bootstrap.hxx>
33 : #include <comphelper/processfactory.hxx>
34 :
35 : #include <com/sun/star/lang/Locale.hpp>
36 : #include <com/sun/star/lang/XComponent.hpp>
37 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 :
39 : using namespace ::com::sun::star;
40 :
41 : // NB. this constructor is called before any tests are run, once for each
42 : // test function in a rather non-intuitive way. This is why all the 'real'
43 : // heavy lifting is deferred until setUp. setUp and tearDown are interleaved
44 : // between the tests as you might expect.
45 198 : test::BootstrapFixtureBase::BootstrapFixtureBase()
46 198 : : m_aSrcRootURL("file://"), m_aSolverRootURL( m_aSrcRootURL )
47 : {
48 : #ifndef ANDROID
49 198 : const char* pSrcRoot = getenv( "SRC_ROOT" );
50 198 : CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != NULL && pSrcRoot[0] != 0);
51 198 : const char* pSolverRoot = getenv( "OUTDIR_FOR_BUILD" );
52 198 : CPPUNIT_ASSERT_MESSAGE("$OUTDIR_FOR_BUILD env variable not set", pSolverRoot != NULL && pSolverRoot[0] != 0);
53 198 : const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" );
54 198 : CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != NULL && pWorkdirRoot[0] != 0);
55 : #ifdef WNT
56 : if (pSrcRoot[1] == ':')
57 : {
58 : m_aSrcRootURL += rtl::OUString::createFromAscii( "/" );
59 : }
60 : if (pSolverRoot[1] == ':')
61 : {
62 : m_aSolverRootURL += rtl::OUString::createFromAscii( "/" );
63 : }
64 : if (pWorkdirRoot[1] == ':')
65 : {
66 : m_aWorkdirRootURL += rtl::OUString::createFromAscii( "/" );
67 : }
68 : #endif
69 : #else
70 : const char* pSrcRoot = "/assets";
71 : const char* pSolverRoot = "/assets";
72 : const char* pWorkdirRoot = "/assets";
73 : #endif
74 198 : m_aSrcRootPath = rtl::OUString::createFromAscii( pSrcRoot );
75 198 : m_aSrcRootURL += m_aSrcRootPath;
76 :
77 198 : m_aSolverRootPath = rtl::OUString::createFromAscii( pSolverRoot );
78 198 : m_aSolverRootURL += m_aSolverRootPath;
79 :
80 198 : m_aWorkdirRootPath = rtl::OUString::createFromAscii( pWorkdirRoot );
81 198 : m_aWorkdirRootURL += m_aWorkdirRootPath;
82 :
83 198 : }
84 :
85 198 : test::BootstrapFixtureBase::~BootstrapFixtureBase()
86 : {
87 198 : }
88 :
89 218 : ::rtl::OUString test::BootstrapFixtureBase::getURLFromSrc( const char *pPath )
90 : {
91 218 : return m_aSrcRootURL + rtl::OUString::createFromAscii( pPath );
92 : }
93 :
94 14 : ::rtl::OUString test::BootstrapFixtureBase::getPathFromSrc( const char *pPath )
95 : {
96 14 : return m_aSrcRootPath + rtl::OUString::createFromAscii( pPath );
97 : }
98 :
99 :
100 0 : ::rtl::OUString test::BootstrapFixtureBase::getURLFromWorkdir( const char *pPath )
101 : {
102 0 : return m_aWorkdirRootURL + rtl::OUString::createFromAscii( pPath );
103 : }
104 :
105 0 : ::rtl::OUString test::BootstrapFixtureBase::getPathFromWorkdir( const char *pPath )
106 : {
107 0 : return m_aWorkdirRootPath + rtl::OUString::createFromAscii( pPath );
108 :
109 : }
110 :
111 198 : void test::BootstrapFixtureBase::setUp()
112 : {
113 : // set UserInstallation to user profile dir in test/user-template
114 198 : rtl::Bootstrap aDefaultVars;
115 198 : rtl::OUString sUserInstallURL = m_aSolverRootURL + rtl::OUString("/unittest");
116 198 : aDefaultVars.set(rtl::OUString("UserInstallation"), sUserInstallURL);
117 :
118 198 : m_xContext = comphelper::getProcessComponentContext();
119 198 : m_xFactory = m_xContext->getServiceManager();
120 198 : m_xSFactory = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW);
121 198 : }
122 :
123 198 : void test::BootstrapFixtureBase::tearDown()
124 : {
125 309 : }
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|