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: tstMgr.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_soltools.hxx"
34 #include <osl/module.hxx>
35 #include <rtl/tres.hxx>
37 #ifndef _SOLTOOLS_TESTSHL_TLOG_HXX_
41 #ifndef _SOLTOOLS_TESTSHL_TUTIL_HXX_
50 typedef void* ( tstFunc
)( TestResult
* );
51 void test_Entry_Impl( ::osl::Module
& oMod
, TestResult
* oRes
);
54 struct tstMgr::tstMgr_Impl
{
55 ::osl::Module m_tstmodule
;
60 // <method_initialize>
61 sal_Bool
tstMgr::initialize( sal_Char
* modName
, sal_Bool boom
) {
63 ::rtl::OUString
tstMod( ::rtl::OUString::createFromAscii( modName
) );
64 pImpl
= new tstMgr_Impl
;
66 return ( pImpl
->m_tstmodule
.load( tstMod
) );
67 } // <method_initialize>
69 // <method_test_Entries>
70 sal_Bool
tstMgr::test_Entries( vector
< sal_Char
* > entries
,
73 sal_Bool bOK
= sal_False
;
74 if ( ! entries
.empty() ) {
77 vector
< sal_Char
* >::iterator iter
= entries
.begin();
82 while ( iter
!= entries
.end() ) {
83 if ( *iter
[0] != '#' ) {
84 ::rtl::TestResult
oRes( *iter
, pImpl
->m_boom
);
85 test_Entry_Impl( pImpl
->m_tstmodule
, &oRes
);
86 bOK
&= oRes
.getState();
94 } // </method_test_Entries>
96 // <method_test_Entry>
97 sal_Bool
tstMgr::test_Entry( sal_Char
* entry
, sal_Char
* logName
) {
102 ::rtl::TestResult
oRes( entry
, pImpl
->m_boom
);
103 test_Entry_Impl( pImpl
->m_tstmodule
, &oRes
);
104 log
.writeRes( oRes
, sal_True
);
106 return ( oRes
.getState() );
107 } // </method_test_Entry>
109 // <method_test_EntriesFromFile>
110 sal_Bool
tstMgr::test_EntriesFromFile( sal_Char
* fName
, sal_Char
* logName
) {
112 sal_Bool bOK
= sal_False
;
113 vector
< sal_Char
* > entries
;
115 if ( getEntriesFromFile( fName
, entries
) ) {
116 sal_Bool bOK
= test_Entries( entries
, logName
);
118 vector
< sal_Char
* >::iterator iter
= entries
.begin();
119 while ( iter
!= entries
.end() ) {
127 bOK
= test_Entry( fName
);
131 } // </method_test_EntriesFromFile>
134 void tstMgr::cleanup() {
138 } // </method_cleanup>
141 // <function_test_Entry_Impl>
142 void test_Entry_Impl( ::osl::Module
& oMod
, ::rtl::TestResult
* oRes
) {
144 tstFunc
* pFunc
; // entry pointer
145 ::rtl::OString
entryName( "test_" ); // entryname prefix
148 entryName
+= oRes
->getName();
151 pFunc
= (tstFunc
*) oMod
.getSymbol(
152 ::rtl::OUString::createFromAscii( entryName
.getStr() ) );
160 oRes
->end("symbol not found");
165 } // </function_test_Entry_Impl>
167 } // </namespace_tstutl>