diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-09-25 02:40:39 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-09-25 15:11:34 +0200 |
commit | ce6f47a4588e2c6e115fcc4980f575d3002ca603 (patch) | |
tree | adf81474d76c2b6aa180bb388da04b2d66d3c72f | |
parent | edaa6ac16800be64e86e1a022a6b4a9fff82649a (diff) |
move XGoalSeek api test to c++
Change-Id: I689be9776c4d1fe7d931446d62ea8b1fd733de92
-rw-r--r-- | sc/CppunitTest_sc_modelobj.mk | 127 | ||||
-rw-r--r-- | sc/Module_sc.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/scmodelobj.cxx | 69 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/ScModelObj.ods | bin | 0 -> 7599 bytes | |||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/Package_inc.mk | 1 | ||||
-rw-r--r-- | test/inc/test/sheet/xgoalseek.hxx | 31 | ||||
-rw-r--r-- | test/source/sheet/xgoalseek.cxx | 36 |
8 files changed, 266 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_modelobj.mk b/sc/CppunitTest_sc_modelobj.mk new file mode 100644 index 000000000000..44ac9f51af3c --- /dev/null +++ b/sc/CppunitTest_sc_modelobj.mk @@ -0,0 +1,127 @@ +# -*- 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. +# +# The Initial Developer of the Original Code is +# Markus Mohrhard <markus.mohrhard@googlemail.com> +# Portions created by the Initial Developer are Copyright (C) 2011 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# 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_modelobj)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_modelobj, \ + sc/qa/extras/scmodelobj \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sc_modelobj, \ + 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 \ + subsequenttest \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_modelobj,\ + -I$(SRCDIR)/sc/source/ui/inc \ + -I$(SRCDIR)/sc/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_api,sc_modelobj,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,sc_modelobj)) + +$(eval $(call gb_CppunitTest_use_components,sc_modelobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + 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 \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + 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 \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sc_modelobj)) + +$(eval $(call gb_CppunitTest_use_filter_configuration,sc_modelobj)) + +$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_modelobj)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index f0c42526eb37..e9ba88f78842 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -69,6 +69,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ CppunitTest_sc_tablesheetsobj \ CppunitTest_sc_editfieldobj_cell \ CppunitTest_sc_editfieldobj_header \ + CppunitTest_sc_modelobj \ )) # vim: set noet sw=4 ts=4: diff --git a/sc/qa/extras/scmodelobj.cxx b/sc/qa/extras/scmodelobj.cxx new file mode 100644 index 000000000000..93bb0ca1d442 --- /dev/null +++ b/sc/qa/extras/scmodelobj.cxx @@ -0,0 +1,69 @@ +/* -*- 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 <test/unoapi_test.hxx> +#include <test/sheet/xgoalseek.hxx> + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 1 + +class ScModelObj : public UnoApiTest, apitest::XGoalSeek +{ +public: + virtual void setUp(); + virtual void tearDown(); + + virtual uno::Reference< uno::XInterface > init(); + + CPPUNIT_TEST_SUITE(ScModelObj); + CPPUNIT_TEST(testSeekGoal); + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + + +sal_Int32 ScModelObj::nTest = 0; +uno::Reference< lang::XComponent > ScModelObj::mxComponent; + +uno::Reference< uno::XInterface > ScModelObj::init() +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScModelObj.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + + return mxComponent; +} + +void ScModelObj::setUp() +{ + nTest++; + UnoApiTest::setUp(); +} + +void ScModelObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + closeDocument(mxComponent); + + UnoApiTest::tearDown(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScModelObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/testdocuments/ScModelObj.ods b/sc/qa/extras/testdocuments/ScModelObj.ods Binary files differnew file mode 100644 index 000000000000..56a25329cb7c --- /dev/null +++ b/sc/qa/extras/testdocuments/ScModelObj.ods diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index ead6af3adad1..aad5ebac3fb9 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -69,6 +69,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xcellrangedata \ test/source/sheet/xcellrangereferrer \ test/source/sheet/xcellrangesquery \ + test/source/sheet/xgoalseek \ test/source/sheet/xdatabaserange \ test/source/sheet/xdatapilotdescriptor \ test/source/sheet/xdatapilotfieldgrouping \ diff --git a/test/Package_inc.mk b/test/Package_inc.mk index f217e989212b..3b4b7c332d17 100644 --- a/test/Package_inc.mk +++ b/test/Package_inc.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Package_add_file,test_inc,inc/test/unoapi_test.hxx,test/unoapi_ $(eval $(call gb_Package_add_file,test_inc,inc/test/beans/xpropertyset.hxx,test/beans/xpropertyset.hxx)) $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilotdescriptor.hxx,test/sheet/xdatapilotdescriptor.hxx)) $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xcellrangesquery.hxx,test/sheet/xcellrangesquery.hxx)) +$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xgoalseek.hxx,test/sheet/xgoalseek.hxx)) $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xnamedranges.hxx,test/sheet/xnamedranges.hxx)) $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xnamedrange.hxx,test/sheet/xnamedrange.hxx)) $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatabaserange.hxx,test/sheet/xdatabaserange.hxx)) diff --git a/test/inc/test/sheet/xgoalseek.hxx b/test/inc/test/sheet/xgoalseek.hxx new file mode 100644 index 000000000000..71fce12a356b --- /dev/null +++ b/test/inc/test/sheet/xgoalseek.hxx @@ -0,0 +1,31 @@ +/* -*- 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 <com/sun/star/uno/Reference.hxx> +#include <test/testdllapi.hxx> + +using namespace com::sun::star; + +namespace apitest { + +class OOO_DLLPUBLIC_TEST XGoalSeek +{ +public: + + virtual uno::Reference< uno::XInterface > init() = 0; + + void testSeekGoal(); + +protected: + virtual ~XGoalSeek() {} +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/source/sheet/xgoalseek.cxx b/test/source/sheet/xgoalseek.cxx new file mode 100644 index 000000000000..6bdcfbbc5c84 --- /dev/null +++ b/test/source/sheet/xgoalseek.cxx @@ -0,0 +1,36 @@ +/* -*- 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 "test/sheet/xgoalseek.hxx" +#include <com/sun/star/sheet/XGoalSeek.hpp> +#include <com/sun/star/sheet/GoalResult.hpp> +#include <com/sun/star/table/CellAddress.hpp> + +#include "cppunit/extensions/HelperMacros.h" + +using namespace com::sun::star::uno; + +namespace apitest { + +void XGoalSeek::testSeekGoal() +{ + uno::Reference< sheet::XGoalSeek > xGoalSeek(init(), UNO_QUERY_THROW); + + table::CellAddress aFormulaAddr(0,3,5); + table::CellAddress aVariableAddr(0,3,4); + sheet::GoalResult aResult = xGoalSeek->seekGoal(aFormulaAddr, aVariableAddr, "4"); + + double nDivergence = 0.01; + CPPUNIT_ASSERT( aResult.Divergence < nDivergence ); + CPPUNIT_ASSERT_DOUBLES_EQUAL(16, aResult.Result, nDivergence); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |