cppcheck: port thb's test over and get it to work again

This commit is contained in:
Caolán McNamara 2010-12-20 16:20:30 +00:00
parent 672be186c1
commit 25a8024703
2 changed files with 204 additions and 1 deletions

View file

@ -60,9 +60,98 @@ DEF1NAME =$(SHL1TARGET)
# DEF1EXPORTFILE= export.exp
SHL1VERSIONMAP = export.map
# 2nd test ------------------------------------------------------------------
SHL2OBJS=$(SLO)$/swdoc-test.obj
SHL2TARGET=swdoctest
SHL2STDLIBS+= \
$(LNGLIB) \
$(BASICLIB) \
$(SFXLIB) \
$(SVTOOLLIB) \
$(SVLLIB) \
$(SVXCORELIB) \
$(EDITENGLIB) \
$(SVXLIB) \
$(BASEGFXLIB) \
$(DRAWINGLAYERLIB) \
$(VCLLIB) \
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(COMPHELPERLIB) \
$(UCBHELPERLIB) \
$(TKLIB) \
$(VOSLIB) \
$(SALLIB) \
$(SALHELPERLIB) \
$(TOOLSLIB) \
$(I18NISOLANGLIB) \
$(UNOTOOLSLIB) \
$(SOTLIB) \
$(XMLOFFLIB) \
$(ICUUCLIB) \
$(I18NUTILLIB) \
$(AVMEDIALIB) \
$(CPPUNITLIB)
SHL2IMPLIB= i$(SHL2TARGET)
DEF2NAME =$(SHL2TARGET)
SHL2VERSIONMAP = export.map
# linking statically against sw parts
SHL2LIBS=\
$(SLB)$/swall.lib \
$(SLB)$/core1.lib \
$(SLB)$/core2.lib \
$(SLB)$/core3.lib \
$(SLB)$/core4.lib \
$(SLB)$/filter.lib \
$(SLB)$/ui1.lib \
$(SLB)$/ui2.lib
# END ------------------------------------------------------------------
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
.INCLUDE : _cppunit.mk
.IF "$(OS)" == "WNT"
my_file = file:///
.ELSE
my_file = file://
.END
ALLTAR: test
$(MISC)$/$(TARGET)$/types.rdb .ERRREMOVE : $(SOLARBINDIR)$/types.rdb
$(MKDIRHIER) $(@:d)
$(GNUCOPY) $? $@
$(MISC)/$(TARGET)/udkapi.rdb .ERRREMOVE : $(SOLARBINDIR)$/udkapi.rdb
$(MKDIRHIER) $(@:d)
$(GNUCOPY) $? $@
#Make a services.rdb with the services we know we need to get up and running
$(MISC)/$(TARGET)/services.rdb .ERRREMOVE : $(MISC)/$(TARGET)/udkapi.rdb makefile.mk
$(MKDIRHIER) $(@:d)
$(REGCOMP) -register -br $(MISC)/$(TARGET)/udkapi.rdb -r $@ -wop \
-c $(DLLPRE)fwk$(DLLPOSTFIX)$(DLLPOST)
#Tweak things so that we use the .res files in the solver
STAR_RESOURCEPATH:=$(PWD)/$(BIN)$(PATH_SEPERATOR)$(SOLARBINDIR)
.EXPORT : STAR_RESOURCEPATH
test .PHONY: $(SHL1TARGETN) $(SHL2TARGETN) $(MISC)/$(TARGET)/services.rdb $(MISC)$/$(TARGET)$/types.rdb $(MISC)/$(TARGET)/udkapi.rdb
@echo ----------------------------------------------------------
@echo - start unit test \#1 on library $(SHL1TARGETN)
@echo ----------------------------------------------------------
$(CPPUNITTESTER) $(SHL1TARGETN)
@echo ----------------------------------------------------------
@echo - start unit test \#2 on library $(SHL2TARGETN)
@echo ----------------------------------------------------------
$(CPPUNITTESTER) $(SHL2TARGETN) -headless -invisible \
-env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
-env:UNO_TYPES="$(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/udkapi.rdb" \
-env:OOO_BASE_DIR="$(my_file)$(PWD)/$(MISC)/$(TARGET)" \
-env:BRAND_BASE_DIR="$(my_file)$(PWD)/$(MISC)/$(TARGET)" \
-env:UNO_USER_PACKAGES_CACHE="$(my_file)$(PWD)/$(MISC)/$(TARGET)"

114
sw/qa/core/swdoc-test.cxx Normal file
View file

@ -0,0 +1,114 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Thorsten Behrens <tbehrens@novell.com>
*
* Contributor(s):
* Thorsten Behrens <tbehrens@novell.com>
* Caolán McNamara <caolanm@redhat.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include "precompiled_sw.hxx"
#include "preextstl.h"
#include <cppunit/TestSuite.h>
#include <cppunit/TestFixture.h>
#include <cppunit/TestCase.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <cppunit/extensions/HelperMacros.h>
#include "postextstl.h"
#include <osl/file.hxx>
#include <osl/process.h>
#include <cppuhelper/compbase1.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/basemutex.hxx>
#include <comphelper/processfactory.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/app.hxx>
#include "init.hxx"
#include "swtypes.hxx"
#include "doc.hxx"
using namespace ::com::sun::star;
/* Implementation of Swdoc-Test class */
class SwDocTest : public CppUnit::TestFixture
{
public:
SwDocTest();
~SwDocTest();
virtual void setUp();
virtual void tearDown();
void randomTest()
{
CPPUNIT_ASSERT_MESSAGE("SwDoc::IsRedlineOn()", !m_pDoc->IsRedlineOn());
}
CPPUNIT_TEST_SUITE(SwDocTest);
CPPUNIT_TEST(randomTest);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<uno::XComponentContext> m_xContext;
uno::Reference<lang::XMultiComponentFactory> m_xFactory;
SwDoc *m_pDoc;
};
SwDocTest::SwDocTest()
{
m_xContext = cppu::defaultBootstrap_InitialComponentContext();
m_xFactory = m_xContext->getServiceManager();
uno::Reference<lang::XMultiServiceFactory> xSM(m_xFactory, uno::UNO_QUERY_THROW);
//Without this we're crashing because callees are using
//getProcessServiceFactory. In general those should be removed in favour
//of retaining references to the root ServiceFactory as its passed around
comphelper::setProcessServiceFactory(xSM);
InitVCL(xSM);
SwDLL::Init();
}
void SwDocTest::setUp()
{
m_pDoc = new SwDoc;
}
SwDocTest::~SwDocTest()
{
}
void SwDocTest::tearDown()
{
delete m_pDoc;
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwDocTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */