Kaydet (Commit) ce6f47a4 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

move XGoalSeek api test to c++

Change-Id: I689be9776c4d1fe7d931446d62ea8b1fd733de92
üst edaa6ac1
# -*- 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:
......@@ -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:
/* -*- 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: */
......@@ -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 \
......
......@@ -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))
......
/* -*- 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: */
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment