get a basic cppunit test for sc up and running
This commit is contained in:
parent
7bd538ec6d
commit
18641fdaac
3 changed files with 80 additions and 43 deletions
|
@ -48,3 +48,4 @@ sc sc\addin\datefunc nmake - all sc_addfu sc_add sc_sdi sc_inc NULL
|
|||
sc sc\addin\rot13 nmake - all sc_adrot sc_add sc_sdi sc_inc NULL
|
||||
sc sc\addin\util nmake - all sc_adutil sc_addfu sc_adrot sc_sdi sc_inc NULL
|
||||
sc sc\util nmake - all sc_util sc_addfu sc_adrot sc_adutil sc_app sc_attr sc_cctrl sc_cosrc sc_data sc_dbgui sc_dif sc_docsh sc_drfnc sc_excel sc_form sc_html sc_lotus sc_qpro sc_misc sc_name sc_nvipi sc_opt sc_page sc_rtf sc_scalc sc_style sc_tool sc_uisrc sc_undo sc_unobj sc_view sc_xcl97 sc_xml sc_acc sc_ftools sc_inc sc_vba NULL
|
||||
sc sc\qa\unit nmake - all sc_qa_cppunit.u sc_util NULL
|
||||
|
|
|
@ -33,15 +33,22 @@
|
|||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ := ..$/..
|
||||
PRJNAME := configmgr
|
||||
TARGET := qa_unit
|
||||
PRJ=..$/..
|
||||
PRJNAME=sc
|
||||
TARGET=qa_unit
|
||||
|
||||
ENABLE_EXCEPTIONS := TRUE
|
||||
ENABLE_EXCEPTIONS=TRUE
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
.INCLUDE : settings.mk
|
||||
|
||||
DLLPRE = # no leading "lib" on .so files
|
||||
#building with stlport, but cppunit was not built with stlport
|
||||
.IF "$(USE_SYSTEM_STL)"!="YES"
|
||||
.IF "$(SYSTEM_CPPUNIT)"=="YES"
|
||||
CFLAGSCXX+=-DADAPT_EXT_STL
|
||||
.ENDIF
|
||||
.ENDIF
|
||||
|
||||
CFLAGSCXX += $(CPPUNIT_CFLAGS)
|
||||
|
||||
SHL1TARGET = $(TARGET)
|
||||
SHL1OBJS = $(SLO)$/ucalc.obj
|
||||
|
@ -74,12 +81,37 @@ SHL1STDLIBS= \
|
|||
$(CPPUNITLIB)
|
||||
SHL1IMPLIB = i$(SHL1TARGET)
|
||||
SHL1LIBS=$(SLB)$/scalc3.lib $(SLB)$/scalc3c.lib
|
||||
# SHL1VERSIONMAP = export.map
|
||||
DEF1NAME = $(SHL1TARGET)
|
||||
|
||||
.INCLUDE: target.mk
|
||||
|
||||
.IF "$(OS)" == "WNT"
|
||||
my_file = file:///
|
||||
.ELSE
|
||||
my_file = file://
|
||||
.END
|
||||
|
||||
ALLTAR: test
|
||||
|
||||
test .PHONY: $(SHL1TARGETN)
|
||||
LD_LIBRARY_PATH=$(SOLARVER)$/$(INPATH)$/lib $(SOLARVER)$/$(INPATH)$/bin$/cppunittester $(PRJ)$/$(INPATH)$/lib$/$(TARGET)$(DLLPOST)
|
||||
#Make a services.rdb with the services we know we need to get up and running
|
||||
$(MISC)/$(TARGET)/services.rdb:
|
||||
$(MKDIRHIER) $(@:d)
|
||||
$(RM) $@
|
||||
$(REGCOMP) -register -r $@ -wop \
|
||||
-c configmgr.uno$(DLLPOST) \
|
||||
-c $(DLLPRE)fwk$(DLLPOSTFIX)$(DLLPOST)
|
||||
|
||||
#Tweak things to that we use the .res files in the solver
|
||||
STAR_RESOURCEPATH:=$(SOLARBINDIR)
|
||||
.EXPORT : STAR_RESOURCEPATH
|
||||
|
||||
test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb
|
||||
@echo ----------------------------------------------------------
|
||||
@echo - start unit test \#1 on library $(SHL1TARGETN)
|
||||
@echo ----------------------------------------------------------
|
||||
$(CPPUNITTESTER) $(SHL1TARGETN) \
|
||||
-env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \
|
||||
-env:UNO_TYPES="$(my_file)$(SOLARBINDIR)/types.rdb $(my_file)$(SOLARBINDIR)/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)"
|
||||
|
|
|
@ -1,48 +1,42 @@
|
|||
/*
|
||||
* Known problems:
|
||||
*
|
||||
* + We need to work out why cppuint can't run this
|
||||
* + can it run even the most trivial of tests ?
|
||||
* + what symbol is it prodding around for ? and do we export it ?
|
||||
* + cf. objdump -T on the generated .so
|
||||
* + build verbose=1 to find it ...
|
||||
* + We are chancing our arm here; this is unlikely to work without
|
||||
* UNO bootstrapping - which is quite 'exciting' ;-)
|
||||
* + We need to resurrect the ubootstrap.[ch]xx files from old versions
|
||||
* of patches/test/build-in-unit-testing-sc.diff
|
||||
* + We need to re-enable the exports.map with the right symbol
|
||||
*/
|
||||
|
||||
|
||||
// TODO ...
|
||||
// officecfg: can we move this into our skeleton ?
|
||||
// Solve the Setup.xcu problem pleasantly [ custom version ? ]
|
||||
// Remove: Foo killed exception ! ...
|
||||
// deliver.pl
|
||||
// don't call regcomp if we don't have it.
|
||||
// find & kill signalfile stuff (?)
|
||||
// Consider - where to dump this code ?
|
||||
// - surely there is some Uno module we can use... ?
|
||||
// - 'unohelper' ?
|
||||
// In an ideal world
|
||||
// a) scp2 goes away and logic moved into the deliver d.lst
|
||||
// b) install set gets built incrementally as the build progresses
|
||||
// c) the new .xml component registration stuff then removes
|
||||
// the need for manually calling regcomp and knowing what
|
||||
// services we need, and in what .so they are implemented
|
||||
|
||||
#include "sal/config.h"
|
||||
// #include "ubootstrap.hxx"
|
||||
#include "vcl/svapp.hxx"
|
||||
|
||||
#include <cppuhelper/bootstrap.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <scdll.hxx>
|
||||
#include <document.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"
|
||||
|
||||
#define CATCH_FAIL(msg) \
|
||||
catch (const css::uno::Exception &e) { \
|
||||
t_print ("msg '%s'\n", rtl::OUStringToOString (e.Message, RTL_TEXTENCODING_UTF8).getStr()); \
|
||||
CPPUNIT_FAIL( msg ); \
|
||||
throw; \
|
||||
}
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
class Test: public CppUnit::TestFixture {
|
||||
// UnitBootstrap *mpUnitBootstrap;
|
||||
namespace {
|
||||
|
||||
class Test : public CppUnit::TestFixture {
|
||||
public:
|
||||
// init
|
||||
virtual void setUp();
|
||||
|
@ -56,22 +50,29 @@ public:
|
|||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
private:
|
||||
uno::Reference< uno::XComponentContext > m_context;
|
||||
};
|
||||
|
||||
void Test::setUp()
|
||||
{
|
||||
// FIXME: we badly need to bootstrap UNO [!]
|
||||
// mpUnitBootstrap = new UnitBootstrap();
|
||||
// InitVCL (mpUnitBootstrap->getMSF());
|
||||
m_context = cppu::defaultBootstrap_InitialComponentContext();
|
||||
|
||||
uno::Reference<lang::XMultiComponentFactory> xFactory(m_context->getServiceManager());
|
||||
uno::Reference<lang::XMultiServiceFactory> xSM(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);
|
||||
|
||||
ScDLL::Init();
|
||||
}
|
||||
|
||||
void Test::tearDown()
|
||||
{
|
||||
DeInitVCL ();
|
||||
|
||||
// delete mpUnitBootstrap;
|
||||
uno::Reference< lang::XComponent >(m_context, uno::UNO_QUERY_THROW)->dispose();
|
||||
}
|
||||
|
||||
void Test::createDocument()
|
||||
|
@ -88,10 +89,13 @@ void Test::createDocument()
|
|||
doc->CalcAll();
|
||||
double result;
|
||||
doc->GetValue (0, 2, 0, result);
|
||||
fprintf (stderr, "one plus one = %g\n", result);
|
||||
CPPUNIT_ASSERT_MESSAGE ("calculation failed", result == 2.0);
|
||||
|
||||
delete doc;
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
|
||||
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
|
Loading…
Reference in a new issue