tdf#45904 Move java XViewPane test to c++
Change-Id: I3c99fb4c611a3b45d31412731c548b59e95d7179 Reviewed-on: https://gerrit.libreoffice.org/24285 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
committed by
Markus Mohrhard
parent
72f89e0f0e
commit
e7f55f15cc
40
include/test/sheet/xviewpane.hxx
Normal file
40
include/test/sheet/xviewpane.hxx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* -*- 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_TEST_SHEET_XVIEWPANE_HXX
|
||||||
|
#define INCLUDED_TEST_SHEET_XVIEWPANE_HXX
|
||||||
|
|
||||||
|
#include <com/sun/star/uno/Reference.hxx>
|
||||||
|
#include <com/sun/star/uno/XInterface.hpp>
|
||||||
|
#include <test/testdllapi.hxx>
|
||||||
|
|
||||||
|
using namespace css;
|
||||||
|
using namespace css::uno;
|
||||||
|
|
||||||
|
namespace apitest {
|
||||||
|
|
||||||
|
class OOO_DLLPUBLIC_TEST XViewPane
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual uno::Reference< uno::XInterface > init() = 0;
|
||||||
|
|
||||||
|
void testFirstVisibleColumn();
|
||||||
|
void testFirstVisibleRow();
|
||||||
|
void testVisibleRange();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~XViewPane() {}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // INCLUDED_TEST_SHEET_XVIEWPANE_HXX
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
107
sc/CppunitTest_sc_viewpaneobj.mk
Normal file
107
sc/CppunitTest_sc_viewpaneobj.mk
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
#*************************************************************************
|
||||||
|
#
|
||||||
|
# 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/.
|
||||||
|
#
|
||||||
|
#*************************************************************************
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_CppunitTest,sc_viewpaneobj))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_external,sc_viewpaneobj,boost_headers))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_add_exception_objects,sc_viewpaneobj, \
|
||||||
|
sc/qa/extras/scviewpaneobj \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_libraries,sc_viewpaneobj, \
|
||||||
|
basegfx \
|
||||||
|
comphelper \
|
||||||
|
cppu \
|
||||||
|
cppuhelper \
|
||||||
|
drawinglayer \
|
||||||
|
editeng \
|
||||||
|
for \
|
||||||
|
forui \
|
||||||
|
i18nlangtag \
|
||||||
|
msfilter \
|
||||||
|
oox \
|
||||||
|
sal \
|
||||||
|
salhelper \
|
||||||
|
sax \
|
||||||
|
sb \
|
||||||
|
sc \
|
||||||
|
sfx \
|
||||||
|
sot \
|
||||||
|
subsequenttest \
|
||||||
|
svl \
|
||||||
|
svt \
|
||||||
|
svx \
|
||||||
|
svxcore \
|
||||||
|
test \
|
||||||
|
tk \
|
||||||
|
tl \
|
||||||
|
ucbhelper \
|
||||||
|
unotest \
|
||||||
|
utl \
|
||||||
|
vbahelper \
|
||||||
|
vcl \
|
||||||
|
xo \
|
||||||
|
$(gb_UWINAPI) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_set_include,sc_viewpaneobj,\
|
||||||
|
-I$(SRCDIR)/sc/source/ui/inc \
|
||||||
|
-I$(SRCDIR)/sc/inc \
|
||||||
|
$$(INCLUDE) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_api,sc_viewpaneobj,\
|
||||||
|
offapi \
|
||||||
|
udkapi \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_ure,sc_viewpaneobj))
|
||||||
|
$(eval $(call gb_CppunitTest_use_vcl,sc_viewpaneobj))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_components,sc_viewpaneobj,\
|
||||||
|
basic/util/sb \
|
||||||
|
comphelper/util/comphelp \
|
||||||
|
configmgr/source/configmgr \
|
||||||
|
dbaccess/util/dba \
|
||||||
|
filter/source/config/cache/filterconfig1 \
|
||||||
|
filter/source/storagefilterdetect/storagefd \
|
||||||
|
forms/util/frm \
|
||||||
|
framework/util/fwk \
|
||||||
|
i18npool/util/i18npool \
|
||||||
|
oox/util/oox \
|
||||||
|
package/source/xstor/xstor \
|
||||||
|
package/util/package2 \
|
||||||
|
sax/source/expatwrap/expwrap \
|
||||||
|
scripting/source/basprov/basprov \
|
||||||
|
scripting/util/scriptframe \
|
||||||
|
sc/util/sc \
|
||||||
|
sc/util/scd \
|
||||||
|
sc/util/scfilt \
|
||||||
|
$(call gb_Helper_optional,SCRIPTING, \
|
||||||
|
sc/util/vbaobj) \
|
||||||
|
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 \
|
||||||
|
xmloff/util/xo \
|
||||||
|
svtools/util/svt \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_configuration,sc_viewpaneobj))
|
||||||
|
|
||||||
|
# vim: set noet sw=4 ts=4:
|
@@ -94,6 +94,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
|
|||||||
CppunitTest_sc_check_xcell_ranges_query \
|
CppunitTest_sc_check_xcell_ranges_query \
|
||||||
CppunitTest_sc_check_data_pilot_field \
|
CppunitTest_sc_check_data_pilot_field \
|
||||||
CppunitTest_sc_check_data_pilot_table \
|
CppunitTest_sc_check_data_pilot_table \
|
||||||
|
CppunitTest_sc_viewpaneobj \
|
||||||
))
|
))
|
||||||
|
|
||||||
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
|
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
|
||||||
|
97
sc/qa/extras/scviewpaneobj.cxx
Normal file
97
sc/qa/extras/scviewpaneobj.cxx
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/* -*- 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/calc_unoapi_test.hxx>
|
||||||
|
#include <test/sheet/xviewpane.hxx>
|
||||||
|
|
||||||
|
#include <com/sun/star/container/XIndexAccess.hpp>
|
||||||
|
#include <com/sun/star/frame/XController.hpp>
|
||||||
|
#include <com/sun/star/frame/XModel.hpp>
|
||||||
|
#include <com/sun/star/lang/XComponent.hpp>
|
||||||
|
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
||||||
|
#include <com/sun/star/sheet/XViewPane.hpp>
|
||||||
|
#include <com/sun/star/uno/XInterface.hpp>
|
||||||
|
|
||||||
|
using namespace css;
|
||||||
|
using namespace css::uno;
|
||||||
|
|
||||||
|
namespace sc_apitest {
|
||||||
|
|
||||||
|
#define NUMBER_OF_TESTS 3
|
||||||
|
|
||||||
|
class ScViewPaneObj : public CalcUnoApiTest, public apitest::XViewPane
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScViewPaneObj();
|
||||||
|
|
||||||
|
virtual uno::Reference< uno::XInterface > init() override;
|
||||||
|
virtual void setUp() override;
|
||||||
|
virtual void tearDown() override;
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(ScViewPaneObj);
|
||||||
|
CPPUNIT_TEST(testFirstVisibleColumn);
|
||||||
|
CPPUNIT_TEST(testFirstVisibleRow);
|
||||||
|
CPPUNIT_TEST(testVisibleRange);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static sal_Int32 nTest;
|
||||||
|
static uno::Reference<lang::XComponent> mxComponent;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
sal_Int32 ScViewPaneObj::nTest = 0;
|
||||||
|
uno::Reference< lang::XComponent > ScViewPaneObj::mxComponent;
|
||||||
|
|
||||||
|
ScViewPaneObj::ScViewPaneObj()
|
||||||
|
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uno::Reference< uno::XInterface > ScViewPaneObj::init()
|
||||||
|
{
|
||||||
|
// create a calc document
|
||||||
|
if (!mxComponent.is())
|
||||||
|
mxComponent = loadFromDesktop("private:factory/scalc");
|
||||||
|
|
||||||
|
uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE("no calc document!", xSheetDoc.is());
|
||||||
|
|
||||||
|
uno::Reference< frame::XModel > xModel(xSheetDoc, uno::UNO_QUERY_THROW);
|
||||||
|
uno::Reference< frame::XController > xController = xModel->getCurrentController();
|
||||||
|
uno::Reference< container::XIndexAccess > xIndexAccess(xController, uno::UNO_QUERY_THROW);
|
||||||
|
uno::Reference< sheet::XViewPane > xViewPane (xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
|
||||||
|
return xViewPane;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScViewPaneObj::setUp()
|
||||||
|
{
|
||||||
|
nTest++;
|
||||||
|
CalcUnoApiTest::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScViewPaneObj::tearDown()
|
||||||
|
{
|
||||||
|
if (nTest == NUMBER_OF_TESTS)
|
||||||
|
{
|
||||||
|
closeDocument(mxComponent);
|
||||||
|
mxComponent.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
CalcUnoApiTest::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION(ScViewPaneObj);
|
||||||
|
|
||||||
|
} // End Namespace
|
||||||
|
|
||||||
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -63,6 +63,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
|
|||||||
test/source/sheet/xsheetannotations \
|
test/source/sheet/xsheetannotations \
|
||||||
test/source/sheet/xsheetoutline \
|
test/source/sheet/xsheetoutline \
|
||||||
test/source/sheet/xstyleloader \
|
test/source/sheet/xstyleloader \
|
||||||
|
test/source/sheet/xviewpane \
|
||||||
test/source/text/xtext \
|
test/source/text/xtext \
|
||||||
test/source/text/xtextfield \
|
test/source/text/xtextfield \
|
||||||
test/source/text/xtextcontent \
|
test/source/text/xtextcontent \
|
||||||
|
54
test/source/sheet/xviewpane.cxx
Normal file
54
test/source/sheet/xviewpane.cxx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/* -*- 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/xviewpane.hxx>
|
||||||
|
#include <com/sun/star/sheet/XViewPane.hpp>
|
||||||
|
#include <com/sun/star/table/CellRangeAddress.hpp>
|
||||||
|
|
||||||
|
#include "cppunit/TestAssert.h"
|
||||||
|
|
||||||
|
using namespace css;
|
||||||
|
using namespace css::uno;
|
||||||
|
|
||||||
|
namespace apitest {
|
||||||
|
|
||||||
|
void XViewPane::testFirstVisibleColumn()
|
||||||
|
{
|
||||||
|
sal_Int32 nCol = 5;
|
||||||
|
uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
|
||||||
|
xViewPane->setFirstVisibleColumn(nCol);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(xViewPane->getFirstVisibleColumn(), nCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void XViewPane::testFirstVisibleRow()
|
||||||
|
{
|
||||||
|
sal_Int32 nRow = 3;
|
||||||
|
uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
|
||||||
|
xViewPane->setFirstVisibleRow(nRow);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(xViewPane->getFirstVisibleRow(), nRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void XViewPane::testVisibleRange()
|
||||||
|
{
|
||||||
|
sal_Int16 nSheet = 0;
|
||||||
|
sal_Int32 nCol = 5;
|
||||||
|
sal_Int32 nRow = 3;
|
||||||
|
uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
|
||||||
|
xViewPane->setFirstVisibleColumn(nCol);
|
||||||
|
xViewPane->setFirstVisibleRow(nRow);
|
||||||
|
|
||||||
|
table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.Sheet, nSheet);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.StartRow, nRow);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(aCellRangeAddress.StartColumn, nCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Reference in New Issue
Block a user