diff options
author | Thorsten Behrens <tbehrens@novell.com> | 2011-02-06 22:53:06 +0100 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-02-08 11:48:08 +0100 |
commit | a3d18de4e588b88da4f6a8cbb5d5160beaf4e65b (patch) | |
tree | 5c3e9df61dc2c00f7fd7dd33e28d831e057e91a6 /sd/qa | |
parent | a445d8c0472965bcf8d0d1bfbd469616b7fc325c (diff) |
Initial unit test framework for Impress
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/export.map | 7 | ||||
-rw-r--r-- | sd/qa/unit/makefile.mk | 117 | ||||
-rw-r--r-- | sd/qa/unit/uimpress.cxx | 137 | ||||
-rw-r--r-- | sd/qa/unit/version.map | 34 |
4 files changed, 295 insertions, 0 deletions
diff --git a/sd/qa/unit/export.map b/sd/qa/unit/export.map new file mode 100644 index 000000000000..4ca70fa85463 --- /dev/null +++ b/sd/qa/unit/export.map @@ -0,0 +1,7 @@ +UDK_3.0 { + global: + registerAllTestFunction; + + local: + *; +}; diff --git a/sd/qa/unit/makefile.mk b/sd/qa/unit/makefile.mk new file mode 100644 index 000000000000..0814a354797f --- /dev/null +++ b/sd/qa/unit/makefile.mk @@ -0,0 +1,117 @@ +# -*- 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 +# Novell, Inc. +# Portions created by the Initial Developer are Copyright (C) 2010 the +# Initial Developer. All Rights Reserved. +# +# Contributor(s): Michael Meeks <michael.meeks@novell.com> +# Caolan 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. +# + +PRJ=..$/.. +PRJNAME=sd +TARGET=qa_unit + +ENABLE_EXCEPTIONS=TRUE + +.INCLUDE : settings.mk + +#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)$/uimpress.obj +SHL1STDLIBS= \ + $(BASICLIB) \ + $(SFXLIB) \ + $(SVTOOLLIB) \ + $(SVLLIB) \ + $(SVXCORELIB) \ + $(EDITENGLIB) \ + $(SVXLIB) \ + $(BASEGFXLIB) \ + $(DRAWINGLAYERLIB) \ + $(I18NISOLANGLIB) \ + $(VCLLIB) \ + $(CPPULIB) \ + $(CPPCANVASLIB) \ + $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ + $(UCBHELPERLIB) \ + $(SALLIB) \ + $(SALHELPERLIB) \ + $(TOOLSLIB) \ + $(TKLIB) \ + $(SOTLIB) \ + $(UNOTOOLSLIB) \ + $(XMLOFFLIB) \ + $(AVMEDIALIB) \ + $(CPPUNITLIB) +SHL1IMPLIB = i$(SHL1TARGET) +SHL1LIBS=$(SLB)$/sdraw3.lib $(SLB)$/sdraw3_2.lib $(SLB)$/sdraw3_3.lib +DEF1NAME = $(SHL1TARGET) +SHL1VERSIONMAP=version.map + +.INCLUDE: target.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) $(MISC)/$(TARGET)/services.rdb $(MISC)$/$(TARGET)$/types.rdb $(MISC)/$(TARGET)/udkapi.rdb + @echo ---------------------------------------------------------- + @echo - start unit test \#1 on library $(SHL1TARGETN) + @echo ---------------------------------------------------------- + $(CPPUNITTESTER) $(SHL1TARGETN) -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)" diff --git a/sd/qa/unit/uimpress.cxx b/sd/qa/unit/uimpress.cxx new file mode 100644 index 000000000000..9956db3c9035 --- /dev/null +++ b/sd/qa/unit/uimpress.cxx @@ -0,0 +1,137 @@ +/* -*- 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 + * Novell, Inc. + * Portions created by the Initial Developer are Copyright (C) 2010 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Thorsten Behrens <tbehrens@novell.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_sd.hxx" + +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <sal/config.h> + +#include <cppuhelper/bootstrap.hxx> +#include <comphelper/processfactory.hxx> + +#include <vcl/svapp.hxx> +#include <sddll.hxx> +#include <drawdoc.hxx> + +#include <iostream> +#include <vector> + +using namespace ::com::sun::star; + +namespace { + +class Test : public CppUnit::TestFixture { +public: + Test(); + ~Test(); + + virtual void setUp(); + virtual void tearDown(); + + void testAddPage(); + void testCustomShow(); + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testAddPage); + CPPUNIT_TEST(testCustomShow); + CPPUNIT_TEST_SUITE_END(); + +private: + uno::Reference< uno::XComponentContext > m_xContext; + SdDrawDocument* m_pDoc; +}; + +Test::Test() + : m_pDoc(0) +{ + m_xContext = cppu::defaultBootstrap_InitialComponentContext(); + + uno::Reference<lang::XMultiComponentFactory> xFactory(m_xContext->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); + + SdDLL::Init(); +} + +void Test::setUp() +{ + m_pDoc = new SdDrawDocument(DOCUMENT_TYPE_IMPRESS, NULL); +} + +void Test::tearDown() +{ + delete m_pDoc; +} + +Test::~Test() +{ + uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose(); +} + +void Test::testAddPage() +{ + SdrPage* pPage = m_pDoc->AllocPage(false); + m_pDoc->InsertPage(pPage); + CPPUNIT_ASSERT_MESSAGE("added one page to model", + m_pDoc->GetPageCount()==1); + m_pDoc->DeletePage(0); + CPPUNIT_ASSERT_MESSAGE("removed one page to model", + m_pDoc->GetPageCount()==0); + + SdrPage* pMasterPage = m_pDoc->AllocPage(true); + m_pDoc->InsertMasterPage(pMasterPage); + CPPUNIT_ASSERT_MESSAGE("added one master page to model", + m_pDoc->GetMasterPageCount()==1); + m_pDoc->DeleteMasterPage(0); + CPPUNIT_ASSERT_MESSAGE("removed one master page to model", + m_pDoc->GetMasterPageCount()==0); +} + +void Test::testCustomShow() +{ + CPPUNIT_ASSERT_MESSAGE("test generation of custom show list!", + m_pDoc->GetCustomShowList(TRUE)); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/version.map b/sd/qa/unit/version.map new file mode 100644 index 000000000000..3308588ef6f8 --- /dev/null +++ b/sd/qa/unit/version.map @@ -0,0 +1,34 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +UDK_3_0_0 { + global: + cppunitTestPlugIn; + + local: + *; +}; |