ooo-build r11643 - in trunk: . patches/test



Author: michael
Date: Wed Feb 20 14:41:27 2008
New Revision: 11643
URL: http://svn.gnome.org/viewvc/ooo-build?rev=11643&view=rev

Log:
2008-02-20  Michael Meeks  <michael meeks novell com>

        * patches/test/built-in-unit-test-sc.diff: trivial (but working)
        calc unit test, needs serious re-factoring love.



Added:
   trunk/patches/test/built-in-unit-test-sc.diff
Modified:
   trunk/ChangeLog

Added: trunk/patches/test/built-in-unit-test-sc.diff
==============================================================================
--- (empty file)
+++ trunk/patches/test/built-in-unit-test-sc.diff	Wed Feb 20 14:41:27 2008
@@ -0,0 +1,514 @@
+--- /dev/null	2007-09-21 22:50:58.000000000 +0100
++++ sc/qa/unit/makefile.mk	2008-02-20 12:10:50.000000000 +0000
+@@ -0,0 +1,87 @@
++#*************************************************************************
++#
++#   OpenOffice.org - a multi-platform office productivity suite
++#
++#   $RCSfile: makefile.mk,v $
++#
++#   $Revision: 1.2 $
++#
++#   last change: $Author: ihi $ $Date: 2007/11/23 13:58:12 $
++#
++#   The Contents of this file are made available subject to
++#   the terms of GNU Lesser General Public License Version 2.1.
++#
++#
++#     GNU Lesser General Public License Version 2.1
++#     =============================================
++#     Copyright 2007 by Sun Microsystems, Inc.
++#     901 San Antonio Road, Palo Alto, CA 94303, USA
++#
++#     This library is free software; you can redistribute it and/or
++#     modify it under the terms of the GNU Lesser General Public
++#     License version 2.1, as published by the Free Software Foundation.
++#
++#     This library is distributed in the hope that it will be useful,
++#     but WITHOUT ANY WARRANTY; without even the implied warranty of
++#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++#     Lesser General Public License for more details.
++#
++#     You should have received a copy of the GNU Lesser General Public
++#     License along with this library; if not, write to the Free Software
++#     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++#     MA  02111-1307  USA
++#
++#*************************************************************************
++
++PRJ := ..$/..
++PRJNAME := configmgr
++TARGET := qa_unit
++
++ENABLE_EXCEPTIONS := TRUE
++
++.INCLUDE: settings.mk
++
++DLLPRE = # no leading "lib" on .so files
++
++SHL1TARGET = $(TARGET)
++SHL1OBJS = $(SLO)$/ucalc.obj $(SLO)$/ubootstrap.obj
++SHL1STDLIBS=       \
++	$(BASICLIB)	\
++	$(SFXLIB)		\
++	$(SVTOOLLIB)	\
++	$(SVLLIB)		\
++	$(SVXLIB)		\
++	$(GOODIESLIB)	\
++    $(BASEGFXLIB) \
++	$(VCLLIB)		\
++	$(CPPULIB)		\
++	$(CPPUHELPERLIB)	\
++	$(COMPHELPERLIB)	\
++	$(UCBHELPERLIB)	\
++	$(TKLIB)		\
++	$(VOSLIB)		\
++	$(SALLIB)		\
++	$(TOOLSLIB)	\
++	$(I18NUTILLIB) \
++	$(I18NISOLANGLIB) \
++	$(UNOTOOLSLIB) \
++	$(SOTLIB)		\
++	$(XMLOFFLIB)	\
++	$(DBTOOLSLIB)	\
++	$(AVMEDIALIB)	\
++	$(CPPUNITLIB)
++SHL1IMPLIB = i$(SHL1TARGET)
++SHL1LIBS=$(SLB)$/scalc3.lib $(SLB)$/scalc3c.lib 
++SHL1VERSIONMAP = export.map
++DEF1NAME = $(SHL1TARGET)
++
++.INCLUDE: target.mk
++
++ALLTAR: test
++
++$(MISC)$/$(TARGET).rdb .ERRREMOVE:
++    $(COPY) $(SOLARBINDIR)$/types.rdb $@
++    regmerge $@ / $(SOLARLIBDIR)$/services.rdb
++
++test .PHONY: $(SHL1TARGETN) $(MISC)$/$(TARGET).rdb
++    testshl2 $(SHL1TARGETN) -forward "$(MISC)$/$(TARGET).rdb#$(PWD)$/$(MISC)$/$(TARGET).registry"
+--- /dev/null	2007-09-21 22:50:58.000000000 +0100
++++ sc/qa/unit/ubootstrap.cxx	2008-02-20 14:43:28.000000000 +0000
+@@ -0,0 +1,115 @@
++#include "common.hxx"
++#include <osl/file.hxx>
++
++// Do all those evil things to make the tests actually work ...
++Magic::Magic()
++{
++    rtl_uString *curWd = NULL;
++    osl_getProcessWorkingDir( &curWd );
++
++    rtl::OUString aKey;
++    rtl::OUString aValue( curWd );
++
++    // Unless you do this, obviously you don't want your paths to be correct 
++    // or file access to work properly
++    aKey = rtl::OUString::createFromAscii( "BaseInstallation" );
++    rtl_bootstrap_set( aKey.pData, aValue.pData );
++    // Unless you do this, obviously you don't deserve to have anything work
++    aKey = rtl::OUString::createFromAscii( "CFG_INIFILE" );
++    aValue += rtl::OUString::createFromAscii( "/configmgrrc" );
++    rtl_bootstrap_set( aKey.pData, aValue.pData );
++
++    // FIXME: Create a safe /tmp directory - unfotunately that
++    // either requires dependencies we don't have, or some cut &
++    // paste action of unotools/source/ucbhelper/tempfile.cxx
++    if (osl::File::getTempDirURL(maTempDir) != osl::FileBase::E_None) {
++        t_print ("no tmp dir");
++        CPPUNIT_FAIL ("no tmp dir");
++    }
++    maTempDir += rtl::OUString::createFromAscii("/unittstconfig");
++    osl::FileBase::RC err = osl::Directory::create (maTempDir);
++                            
++    if (err != osl::FileBase::E_None) {
++        t_print ("tmp dir '%s' already exists\n",
++                 rtl::OUStringToOString (maTempDir, RTL_TEXTENCODING_UTF8).getStr());
++//        CPPUNIT_FAIL ("tmp user config dir already exists!");
++    }
++
++    aKey = rtl::OUString::createFromAscii( "UserInstallation" );
++    rtl_bootstrap_set( aKey.pData, maTempDir.pData );
++
++    {
++        rtl::OUString aTmp, aSolver;
++        
++        aTmp = (rtl::OUString::createFromAscii(getenv("SOLARVER")) +
++                rtl::OUString::createFromAscii("/") +
++                rtl::OUString::createFromAscii(getenv("INPATH")));
++        
++        if (osl::FileBase::getFileURLFromSystemPath(aTmp, aSolver) != osl::FileBase::E_None)
++            std::abort();
++
++        fprintf (stderr, "set SOLVER to '%s'\n",
++                 rtl::OUStringToOString (aSolver, RTL_TEXTENCODING_UTF8).getStr());
++
++        aKey = rtl::OUString::createFromAscii( "SOLVER" );
++        rtl_bootstrap_set( aKey.pData, aSolver.pData );
++    }
++
++    // Force vcl to be headless on Unix
++    fprintf (stderr, "Clobber display\n");
++    putenv ("SAL_USE_VCLPLUGIN=svp");
++    putenv ("OOO_FORCE_DESKTOP=none");
++}
++
++void removeRecursive (const rtl::OUString& aPath)
++{
++	sal_Int32 nMask = FileStatusMask_Type | FileStatusMask_FileURL;
++
++//    fprintf (stderr, "Remove recursive '%s'\n", rtl::OUStringToOString (aPath, RTL_TEXTENCODING_UTF8).getStr());
++    
++	osl::DirectoryItem aItem;
++	osl::FileStatus aStatus( nMask );
++	osl::FileBase::RC nError;
++
++    nError = osl::DirectoryItem::get( aPath, aItem );
++    CPPUNIT_ASSERT_MESSAGE ("invalid path", nError == osl::FileBase::E_None);
++
++    nError = aItem.getFileStatus( aStatus );
++    CPPUNIT_ASSERT_MESSAGE ("invalid file", nError == osl::FileBase::E_None);
++
++    if (aStatus.getFileType() == osl::FileStatus::Regular ||
++        aStatus.getFileType() == osl::FileStatus::Link )
++    {
++		nError = osl::File::remove( aPath );
++//        fprintf (stderr, "Remove file '%s'\n", rtl::OUStringToOString (aPath, RTL_TEXTENCODING_UTF8).getStr());
++        CPPUNIT_ASSERT_MESSAGE ("removing file", nError == osl::FileBase::E_None);
++    }
++    else if (aStatus.getFileType() == osl::FileStatus::Directory)
++    {
++		osl::Directory aDirectory (aPath);
++		nError = aDirectory.open();
++        CPPUNIT_ASSERT_MESSAGE ("opening dir", nError == osl::FileBase::E_None);
++
++		rtl::OUString name;
++
++        while (true) {
++            nError = aDirectory.getNextItem( aItem );
++            if ( nError != osl::FileBase::E_None )
++                break;
++  			nError = aItem.getFileStatus( aStatus );
++            CPPUNIT_ASSERT_MESSAGE ("getting status", nError == osl::FileBase::E_None);
++            removeRecursive (aStatus.getFileURL());
++		}
++  		aDirectory.close();
++
++		nError = osl::Directory::remove( aPath );
++//        fprintf (stderr, "Remove dir '%s'\n", rtl::OUStringToOString (aPath, RTL_TEXTENCODING_UTF8).getStr());
++
++        CPPUNIT_ASSERT_MESSAGE ("removing directory", nError == osl::FileBase::E_None);
++    }
++}
++
++Magic::~Magic()
++{
++//    removeRecursive (maTempDir);
++}
+--- /dev/null	2007-09-21 22:50:58.000000000 +0100
++++ sc/qa/unit/common.hxx	2008-02-20 14:17:38.000000000 +0000
+@@ -0,0 +1,105 @@
++/*************************************************************************
++ *
++ *  OpenOffice.org - a multi-platform office productivity suite
++ *
++ *  $RCSfile: common.hxx,v $
++ *
++ *  $Revision: 1.2 $
++ *
++ *  last change: $Author: ihi $ $Date: 2007/11/23 13:57:16 $
++ *
++ *  The Contents of this file are made available subject to
++ *  the terms of GNU Lesser General Public License Version 2.1.
++ *
++ *
++ *    GNU Lesser General Public License Version 2.1
++ *    =============================================
++ *    Copyright 2007 by Sun Microsystems, Inc.
++ *    901 San Antonio Road, Palo Alto, CA 94303, USA
++ *
++ *    This library is free software; you can redistribute it and/or
++ *    modify it under the terms of the GNU Lesser General Public
++ *    License version 2.1, as published by the Free Software Foundation.
++ *
++ *    This library is distributed in the hope that it will be useful,
++ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++ *    Lesser General Public License for more details.
++ *
++ *    You should have received a copy of the GNU Lesser General Public
++ *    License along with this library; if not, write to the Free Software
++ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ *    MA  02111-1307  USA
++ *
++ ************************************************************************/
++
++#include "sal/config.h"
++#include <cstdlib>
++#include "com/sun/star/beans/NamedValue.hpp"
++#include "com/sun/star/beans/XPropertySet.hpp"
++#include "com/sun/star/beans/XPropertyState.hpp"
++#include "com/sun/star/lang/XComponent.hpp"
++#include "com/sun/star/lang/XMultiComponentFactory.hpp"
++#include "com/sun/star/lang/XMultiServiceFactory.hpp"
++#include "com/sun/star/container/XNameReplace.hpp"
++#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
++#include "com/sun/star/util/XChangesBatch.hpp"
++#include "com/sun/star/uno/Any.hxx"
++#include "com/sun/star/uno/Reference.hxx"
++#include "com/sun/star/uno/XComponentContext.hpp"
++#include "cppuhelper/component_context.hxx"
++#include "cppuhelper/servicefactory.hxx"
++#include "cppunit/simpleheader.hxx"
++#include "osl/file.hxx"
++#include "osl/thread.h"
++#include "osl/process.h"
++#include "rtl/string.h"
++#include "rtl/bootstrap.h"
++#include "rtl/ustring.h"
++#include "rtl/ustring.hxx"
++#include "sal/types.h"
++
++namespace css = com::sun::star;
++
++#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; \
++    }
++
++class Magic
++{
++    rtl::OUString maTempDir;
++  public:
++    Magic();
++    ~Magic();
++};
++
++class Test: public CppUnit::TestFixture {
++    Magic *mpMagic;
++public:
++    // init
++    virtual void setUp();
++    virtual void tearDown();
++    
++    // helpers
++    void normalizePathKey (rtl::OString &rPath, rtl::OString &rKey);
++    css::uno::Reference< css::uno::XInterface > createView(const sal_Char *pNodepath, bool bUpdate);
++    css::uno::Any getKey (const sal_Char *pPath, rtl::OUString aName);
++    css::uno::Any getKey (const sal_Char *pPath, const sal_Char *pName)
++        { return getKey (pPath, rtl::OUString::createFromAscii (pName)); }
++
++    // tests
++    void createDocument();
++
++    CPPUNIT_TEST_SUITE(Test);
++    CPPUNIT_TEST(createDocument);
++    CPPUNIT_TEST_SUITE_END();
++
++private:
++    css::uno::Reference< css::uno::XComponentContext > mxContext;
++    css::uno::Reference< css::lang::XMultiServiceFactory > mxProvider;
++};
++
++void disposeComponent (const css::uno::Reference<css::uno::XInterface> &xComp);
+--- /dev/null	2007-09-21 22:50:58.000000000 +0100
++++ sc/qa/unit/ucalc.cxx	2008-02-20 14:44:22.000000000 +0000
+@@ -0,0 +1,170 @@
++// To debug me use:
++// $ export ENVCFGFLAGS='-me -ti -tw -tp -td'
++#include "common.hxx"
++
++// TODO ...
++//    re-factor
++//    don't call regcomp if we don't have it.
++//    Solve the Setup.xcu problem pleasantly [ custom version ? ]
++//    dung out the local configuration tree
++//    [etc.]
++
++#include "comphelper/processfactory.hxx"
++#include "vcl/svapp.hxx"
++
++// calc bits
++#include <scdll.hxx>
++#include <document.hxx>
++
++using namespace css;
++
++void Test::setUp()
++{
++    mpMagic = new Magic();
++
++    char const * f = getForwardString();
++    rtl::OUString args(
++        f, rtl_str_getLength(f), osl_getThreadTextEncoding());
++        //TODO: handle conversion failure
++    sal_Int32 i = args.indexOf('#');
++    if (i < 0)
++        std::abort();
++
++    rtl::OUString rdb(args.copy(0, i));
++    rtl::OUString regpath(args.copy(i + 1));
++    rtl::OUString regurl;
++    if (osl::FileBase::getFileURLFromSystemPath(regpath, regurl) !=
++        osl::FileBase::E_None)
++        std::abort();
++
++    css::uno::Reference< css::beans::XPropertySet > factory(
++        cppu::createRegistryServiceFactory(rdb), css::uno::UNO_QUERY_THROW);
++    css::uno::Reference< css::uno::XComponentContext > context(
++        factory->getPropertyValue(
++            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))),
++        css::uno::UNO_QUERY_THROW);
++    cppu::ContextEntry_Init entry(
++        rtl::OUString(
++            RTL_CONSTASCII_USTRINGPARAM(
++                "/modules/com.sun.star.configuration/bootstrap/Strata")),
++        css::uno::makeAny(
++            rtl::OUString(
++                RTL_CONSTASCII_USTRINGPARAM(
++                    "com.sun.star.comp.configuration.backend.LocalStratum:"))
++            + regurl));
++    mxContext = cppu::createComponentContext(&entry, 1, context);
++
++    CPPUNIT_ASSERT_MESSAGE ("component context is valid", mxContext.is());
++
++    try {
++        mxProvider = css::uno::Reference< css::lang::XMultiServiceFactory >(
++            (css::uno::Reference< css::lang::XMultiComponentFactory >(
++                mxContext->getServiceManager(), css::uno::UNO_QUERY_THROW)->
++             createInstanceWithContext(
++                 rtl::OUString(
++                     RTL_CONSTASCII_USTRINGPARAM(
++                         "com.sun.star.configuration.ConfigurationProvider")),
++                 mxContext)),
++            css::uno::UNO_QUERY_THROW);
++        
++    } catch (css::uno::Exception&e) {
++        CPPUNIT_FAIL( "exception creating provider" );
++        throw;
++    }
++
++    css::uno::Reference< css::lang::XMultiServiceFactory > xMSF ( context->getServiceManager(), css::uno::UNO_QUERY );
++    comphelper::setProcessServiceFactory( xMSF );
++    InitVCL (xMSF);
++
++    ScDLL::Init();
++}
++
++css::uno::Reference< css::uno::XInterface >
++Test::createView(const sal_Char *pNodepath, bool bUpdate)
++{
++    rtl::OUString aNodePath = rtl::OUString::createFromAscii(pNodepath);
++    static const rtl::OUString kInfoViewService( 
++        RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")) ;
++    static const rtl::OUString kUpdateViewService( 
++        RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")) ;
++    static const rtl::OUString kNodepath(RTL_CONSTASCII_USTRINGPARAM("nodepath")) ;
++    static const rtl::OUString kAsync(RTL_CONSTASCII_USTRINGPARAM("EnableAsync")) ;
++    
++    const rtl::OUString & kViewService = bUpdate ? kUpdateViewService : kInfoViewService;
++    css::uno::Sequence< css::uno::Any > aViewArgs(2);
++    aViewArgs[0] <<= css::beans::NamedValue( kNodepath, css::uno::makeAny(aNodePath) );
++    aViewArgs[1] <<= css::beans::NamedValue( kAsync, css::uno::makeAny(sal_False) );
++
++    css::uno::Reference< css::uno::XInterface > xView(
++        mxProvider->createInstanceWithArguments( kViewService, aViewArgs ) );
++    return xView;
++}
++
++void disposeComponent (const css::uno::Reference<css::uno::XInterface> &xComp)
++{
++    css::uno::Reference< css::lang::XComponent >(
++        xComp, css::uno::UNO_QUERY_THROW)->dispose();
++}
++
++void Test::tearDown()
++{
++    DeInitVCL ();
++
++    disposeComponent (mxProvider);
++    disposeComponent (mxContext);
++
++    delete mpMagic;
++}
++
++void Test::normalizePathKey (rtl::OString &rPath, rtl::OString &rKey)
++{
++    sal_Int32 idx = rKey.lastIndexOf("/");
++    if (idx > 0) {
++        rPath += "/";
++        rPath += rKey.copy (0, idx);
++        rKey = rKey.copy (idx + 1);
++//        t_print ("write to '%s' '%s'\n", (const sal_Char *)rPath,
++//                 (const sal_Char *)rKey);
++    }
++}
++
++uno::Any Test::getKey (const sal_Char *pPath, rtl::OUString aName)
++{
++    uno::Reference< container::XHierarchicalNameAccess > xNameAccess( 
++        createView(pPath, false), css::uno::UNO_QUERY_THROW);
++    uno::Any aVal;
++    aVal = xNameAccess->getByHierarchicalName (aName);
++    disposeComponent (xNameAccess);
++    return aVal;
++}
++
++void Test::createDocument()
++{
++    // Poke the config database just to make sure ...
++    try {
++        rtl::OUString aStr;
++        if (!(getKey ("/org.openoffice.Setup", "L10N/ooLocale") >>= aStr))
++            CPPUNIT_FAIL("to fetch key");
++    } CATCH_FAIL ("fetching key")
++
++    ScDocument *doc = new ScDocument();
++    
++    rtl::OUString aTabName = rtl::OUString::createFromAscii ("foo");
++    CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
++                            doc->InsertTab (0, aTabName));
++    double val = 1;
++    doc->SetValue (0, 0, 0, val);
++    doc->SetValue (0, 1, 0, val);
++    doc->SetString (0, 2, 0, rtl::OUString::createFromAscii ("=SUM(A1:A2)"));
++    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");
++
++NOADDITIONAL;
+--- /dev/null	2007-09-21 22:50:58.000000000 +0100
++++ sc/qa/unit/configmgrrc	2008-02-20 11:02:31.000000000 +0000
+@@ -0,0 +1,22 @@
++[Bootstrap]
++CFG_ServerType=uno
++BootstrapFile=$ORIGIN/bootstraprc
++VersionFile=$ORIGIN/versionrc
++UnoFile=$ORIGIN/unorc
++BaseInstallation=${$BootstrapFile:BaseInstallation}
++UserInstallation=${$BootstrapFile:UserInstallation}
++CFG_SchemaVersion=${$VersionFile:buildid}
++CFG_SchemaDataUrl=$SOLVER/xml/registry/schema
++CFG_DefaultLayerUrls=$SOLVER/xml/registry
++CFG_CacheDisposeDelay=900
++CFG_CacheDisposeInterval=60
++CFG_CacheWriteInterval=2
++CFG_UserLayerUrl=$UserInstallation
++CFG_CacheUrl=$UserInstallation/cache
++CFG_DefaultLayerUrl=$SOLVER/xml/registry
++CFG_BackendService=com.sun.star.comp.configuration.backend.MultiStratumBackend
++CFG_SchemaSupplier=com.sun.star.comp.configuration.backend.LocalSchemaSupplier
++CFG_LocalDataSvc=com.sun.star.comp.configuration.backend.LocalStratum
++CFG_LocalModuleDataSvc=com.sun.star.comp.configuration.backend.LocalMultiStratum
++# CFG_Strata=${CFG_LocalDataSvc}:$CFG_DefaultLayerUrl;?com.sun.star.comp.configuration.backend.SystemIntegration:;?com.sun.star.comp.configuration.backend.PolicyLayerBackend:;${CFG_LocalDataSvc}:$CFG_UserLayerUrl
++CFG_Strata=${CFG_LocalDataSvc}:$CFG_DefaultLayerUrl;${CFG_LocalDataSvc}:$CFG_UserLayerUrl



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]