From 21edfcb82484be3e30e8e7f27f4cf68ec1cb8c4b Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Mon, 17 Sep 2012 02:11:02 +0200 Subject: test case for ScRangeList Change-Id: I371ac1b3236777a73e4f25f93d465041308e34b4 --- sc/CppunitTest_sc_rangelst_test.mk | 133 +++++++++++++++++++++++++++++++++++++ sc/Module_sc.mk | 1 + sc/inc/scdll.hxx | 4 +- sc/qa/unit/rangelst_test.cxx | 76 +++++++++++++++++++++ 4 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 sc/CppunitTest_sc_rangelst_test.mk create mode 100644 sc/qa/unit/rangelst_test.cxx diff --git a/sc/CppunitTest_sc_rangelst_test.mk b/sc/CppunitTest_sc_rangelst_test.mk new file mode 100644 index 000000000000..67762d9e0c80 --- /dev/null +++ b/sc/CppunitTest_sc_rangelst_test.mk @@ -0,0 +1,133 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# 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 or as specified alternatively below. 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. +# +# Major Contributor(s): +# Copyright (C) 2011 Red Hat, Inc., Caolán McNamara +# (initial developer) +# +# All Rights Reserved. +# +# For minor contributions see the git repository. +# +# 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. + +$(eval $(call gb_CppunitTest_CppunitTest,sc_rangelst_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_rangelst_test, \ + sc/qa/unit/rangelst_test \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_rangelst_test, \ + avmedia \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + fileacc \ + for \ + forui \ + i18nisolang1 \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_rangelst_test,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sc_rangelst_test,\ + offapi \ + oovbaapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sc_rangelst_test)) + +$(eval $(call gb_CppunitTest_use_components,sc_rangelst_test,\ + basic/util/sb \ + chart2/source/controller/chartcontroller \ + chart2/source/chartcore \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + embeddedobj/util/embobj \ + eventattacher/source/evtatt \ + fileaccess/source/fileacc \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sax/source/fastparser/fastsax \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sc/util/vbaobj \ + scaddins/source/analysis/analysis \ + scaddins/source/datefunc/date \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + svl/util/svl \ + svx/util/svx \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + xmloff/util/xo \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_rangelst_test)) + +$(eval $(call gb_CppunitTest_use_filter_configuration,sc_rangelst_test)) + +$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_rangelst_test)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index dc63ff7ddad3..c5c0449ca1c9 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -44,6 +44,7 @@ endif $(eval $(call gb_Module_add_check_targets,sc,\ CppunitTest_sc_ucalc \ CppunitTest_sc_filters_test \ + CppunitTest_sc_rangelst_test \ )) $(eval $(call gb_Module_add_slowcheck_targets,sc,\ diff --git a/sc/inc/scdll.hxx b/sc/inc/scdll.hxx index bd86e49f526b..983f91d628c8 100644 --- a/sc/inc/scdll.hxx +++ b/sc/inc/scdll.hxx @@ -36,6 +36,8 @@ class SfxFilter; #include #include +#include "scdllapi.h" + /** * This class is a wrapper for a Load-On-Demand-DLL. One instance per * SfxApplication will be created for the runtime of @@ -56,7 +58,7 @@ public: static void PreExit(); // muss vor LibExit gerufen werden // DLL-init/exit-code must be linked to the DLL only - static void Init(); // called directly after loading the DLL + static SC_DLLPUBLIC void Init(); // called directly after loading the DLL static sal_uLong DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter, SfxFilterFlags nMust, SfxFilterFlags nDont ); diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx new file mode 100644 index 000000000000..a65a0eb27010 --- /dev/null +++ b/sc/qa/unit/rangelst_test.cxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include "document.hxx" +#include "docsh.hxx" + +#include "rangelst.hxx" + +class Test : public test::BootstrapFixture { + +public: + virtual void setUp(); + virtual void tearDown(); + + void testDeleteArea_4Ranges(); + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testDeleteArea_4Ranges); + CPPUNIT_TEST_SUITE_END(); + + +private: + ScDocument *m_pDoc; + ScDocShellRef m_xDocShRef; +}; + + +void Test::setUp() +{ + BootstrapFixture::setUp(); + + ScDLL::Init(); + m_xDocShRef = new ScDocShell( + SFXMODEL_STANDARD | + SFXMODEL_DISABLE_EMBEDDED_SCRIPTS | + SFXMODEL_DISABLE_DOCUMENT_RECOVERY); + + m_pDoc = m_xDocShRef->GetDocument(); +} + +void Test::tearDown() +{ + m_xDocShRef.Clear(); + BootstrapFixture::tearDown(); +} + +void Test::testDeleteArea_4Ranges() +{ + ScRangeList aList(ScRange(0,0,0,5,5,0)); + aList.DeleteArea(2,2,0,3,3,0); + + CPPUNIT_ASSERT_EQUAL(aList.size(), static_cast(4)); + for(SCCOL nCol = 0; nCol <= 5; ++nCol) + { + for(SCROW nRow = 0; nRow <= 5; ++nRow) + { + if((nCol == 2 || nCol == 3) && ( nRow == 2 || nRow == 3)) + CPPUNIT_ASSERT(!aList.Intersects(ScRange(nCol, nRow, 0))); + else + CPPUNIT_ASSERT(aList.Intersects(ScRange(nCol, nRow, 0))); + } + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +CPPUNIT_PLUGIN_IMPLEMENT(); +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3