1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: autoregisterhelper.cxx,v $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_testshl2.hxx"
37 #include "testshl/autoregisterhelper.hxx"
39 #include <rtl/ustring.hxx>
41 #include <cppunit/autoregister/registerfunc.h>
42 #include <cppunit/autoregister/callbackstructure.h>
43 #include <cppunit/result/callbackfunc.h>
44 #include <cppunit/autoregister/testfunc.h>
45 #include "testshl/filehelper.hxx"
47 FunctionList m_Functions
;
48 // osl::Mutex m_Mutex;
50 extern "C" void SAL_CALL
registerFunc(FktPtr _pFunc
, const char*)
52 m_Functions
.push_back(_pFunc
);
55 // -----------------------------------------------------------------------------
56 AutomaticRegisterHelper::AutomaticRegisterHelper(rtl::OUString
const& _sDLLName
, GetOpt
& _aOptions
/*, JobList * _pJobList*/)
57 :DynamicLibraryHelper(_sDLLName
, _aOptions
),
58 m_bLoadLibraryOK(false)
60 // try to get the entry pointer
61 FktRegAllPtr pFunc
= (FktRegAllPtr
) m_pModule
->getFunctionSymbol(
62 rtl::OUString::createFromAscii( "registerAllTestFunction" ) );
66 m_bLoadLibraryOK
= true;
67 // FktRegFuncPtr pRegisterFunc = &DynamicLibraryHelper::registerFunc;
68 // pFunc(pRegisterFunc);
69 // osl::Guard aGuard(m_Mutex);
70 FktRegFuncPtr pRegisterFunc
= ®isterFunc
;
72 CallbackStructure aCallback
;
73 aCallback
.aRegisterFunction
= pRegisterFunc
;
75 aCallback
.aCallbackDispatch
= &CallbackDispatch
;
77 // special parameter for API testing
78 if (_aOptions
.hasOpt("-forward"))
80 aCallback
.psForward
= _aOptions
.getOpt("-forward").getStr();
83 // aCallback.pJobList = _pJobList;
85 //# aCallback.aStartTest = &TestResult_startTest;
86 //# aCallback.aAddFailure = &TestResult_addFailure;
87 //# aCallback.aAddError = &TestResult_addError;
88 //# aCallback.aEndTest = &TestResult_endTest;
89 //# aCallback.aShouldStop = &TestResult_shouldStop;
90 //# aCallback.aAddInfo = &TestResult_addInfo;
91 //# aCallback.aEnterNode = &TestResult_enterNode;
92 //# aCallback.aLeaveNode = &TestResult_leaveNode;
94 aCallback
.nBits
= FileHelper::createFlags(_aOptions
);
98 if (aCallback
.nMagic
== aCallback
.nMagic2
)
100 // ok internal simple test done.
101 m_aFunctionList
= m_Functions
;
105 // ERROR, the function seams not to be what we thing it's to be.
106 fprintf(stderr
, "error: Internal check failed. Structure inconsistent, Value Magic2 != Magic.\nPlease recompile your test libraries.");
112 fprintf(stderr
, "warning: Function 'registerAllTestFunction' not found.\n");
113 fprintf(stderr
, "If you think, you are right, build testshl2 completly new.\n");
117 void AutomaticRegisterHelper::CallAll(hTestResult _hResult
) const
119 // can't load the module, break the tests.
120 if (m_bLoadLibraryOK
== false)
125 for (FunctionList::const_iterator it
= m_aFunctionList
.begin();
126 it
!= m_aFunctionList
.end();
137 AutomaticRegisterHelper::~AutomaticRegisterHelper()
139 if (getOptions().hasOpt("-verbose"))
141 fprintf(stderr
, "Dtor AutomaticRegisterHelper.\n");