Kaydet (Commit) 0bf01669 authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Markus Mohrhard

sc test for XSheetAnnotation

Change-Id: I1fa77c874c6307ff71ea0aeee653acf1305f2646
Reviewed-on: https://gerrit.libreoffice.org/1736Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 3ceff214
# -*- 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
# Copyright (C) 2013 Laurent Godard <lgodard.libre@laposte.net> (initial developer)
# 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_annotationobj))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_annotationobj, \
sc/qa/extras/scannotationobj \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_annotationobj, \
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_UWINAPI) \
))
$(eval $(call gb_CppunitTest_set_include,sc_annotationobj,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sc_annotationobj,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_use_ure,sc_annotationobj))
$(eval $(call gb_CppunitTest_use_components,sc_annotationobj,\
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 \
linguistic/source/lng \
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 \
$(if $(filter TRUE,$(DISABLE_SCRIPTING)),, \
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_annotationobj))
$(eval $(call gb_CppunitTest_use_filter_configuration,sc_annotationobj))
$(eval $(call gb_CppunitTest_use_unittest_configuration,sc_annotationobj))
# vim: set noet sw=4 ts=4:
......@@ -61,6 +61,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sc, \
$(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
JunitTest_sc_complex \
JunitTest_sc_unoapi \
CppunitTest_sc_annotationobj \
CppunitTest_sc_cellrangeobj \
$(if $(filter-out $(OS),IOS), \
CppunitTest_sc_databaserangeobj) \
......
/* -*- 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 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) 2013 Laurent Godard <lgodard.libre@laposte.net> (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.
*/
#include <test/unoapi_test.hxx>
#include <test/sheet/xsheetannotation.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
namespace sc_apitest {
#define NUMBER_OF_TESTS 5
class ScAnnontationObj : public UnoApiTest, apitest::XSheetAnnotation
{
public:
ScAnnontationObj();
virtual void setUp();
virtual void tearDown();
virtual uno::Reference< uno::XInterface > init();
virtual uno::Reference< sheet::XSheetAnnotation> getAnnotation(table::CellAddress&);
CPPUNIT_TEST_SUITE(ScAnnontationObj);
CPPUNIT_TEST(testGetPosition);
CPPUNIT_TEST(testGetAuthor);
CPPUNIT_TEST(testGetDate);
CPPUNIT_TEST(testGetIsVisible);
CPPUNIT_TEST(testSetIsVisible);
CPPUNIT_TEST_SUITE_END();
private:
static sal_Int32 nTest;
static uno::Reference< lang::XComponent > mxComponent;
};
sal_Int32 ScAnnontationObj::nTest = 0;
uno::Reference< lang::XComponent > ScAnnontationObj::mxComponent;
ScAnnontationObj::ScAnnontationObj()
{
}
uno::Reference< sheet::XSheetAnnotation> ScAnnontationObj::getAnnotation(table::CellAddress& xCellAddress)
{
// get the sheet
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(xCellAddress.Sheet), UNO_QUERY_THROW);
// get the cell
uno::Reference< table::XCell > xCell( xSheet->getCellByPosition(xCellAddress.Column, xCellAddress.Row), UNO_QUERY_THROW);
// get the annotation from cell
uno::Reference< sheet::XSheetAnnotationAnchor > xAnnotationAnchor(xCell, UNO_QUERY_THROW);
uno::Reference< sheet::XSheetAnnotation > xSheetAnnotation( xAnnotationAnchor->getAnnotation(), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xSheetAnnotation.is());
return xSheetAnnotation;
}
uno::Reference< uno::XInterface > ScAnnontationObj::init()
{
// get the test file
rtl::OUString aFileURL;
createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAnnotationObj.ods")), aFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL);
CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
// tested annotation is in sheet 0 cell C2
table::CellAddress xCellAddress;
xCellAddress.Sheet = 0;
xCellAddress.Row = 1;
xCellAddress.Column = 2;
return getAnnotation(xCellAddress);
}
void ScAnnontationObj::setUp()
{
nTest++;
UnoApiTest::setUp();
}
void ScAnnontationObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
closeDocument(mxComponent);
UnoApiTest::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationObj);
CPPUNIT_PLUGIN_IMPLEMENT();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -80,6 +80,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xprintareas \
test/source/sheet/xspreadsheetdocument \
test/source/sheet/xspreadsheets2 \
test/source/sheet/xsheetannotation \
test/source/text/xtext \
test/source/text/xtextfield \
test/source/text/xtextcontent \
......
......@@ -52,6 +52,7 @@ $(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/datapilotfield.hxx,tes
$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xprintareas.hxx,test/sheet/xprintareas.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheetdocument.hxx,test/sheet/xspreadsheetdocument.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheets2.hxx,test/sheet/xspreadsheets2.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xsheetannotation.hxx,test/sheet/xsheetannotation.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/text/xtext.hxx,test/text/xtext.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/text/xtextfield.hxx,test/text/xtextfield.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/text/xtextcontent.hxx,test/text/xtextcontent.hxx))
......
/* -*- 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 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) 2013 Laurent Godard lgodard.libre@laposte.net (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.
*/
#include <rtl/ustring.hxx>
#include <com/sun/star/sheet/XSheetAnnotation.hpp>
#include <test/testdllapi.hxx>
#include <com/sun/star/table/CellAddress.hpp>
using namespace com::sun::star;
namespace apitest {
class OOO_DLLPUBLIC_TEST XSheetAnnotation
{
public:
virtual uno::Reference< uno::XInterface > init() = 0;
// XSheetAnnotation
void testGetPosition();
void testGetAuthor();
void testGetDate();
void testGetIsVisible();
void testSetIsVisible();
protected:
~XSheetAnnotation() {}
virtual uno::Reference< sheet::XSheetAnnotation> getAnnotation(table::CellAddress&) = 0;
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 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 Laurent Godard lgodard.libre@laposte.net (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.
*/
#include <test/sheet/xsheetannotation.hxx>
#include <com/sun/star/table/CellAddress.hpp>
#include "cppunit/extensions/HelperMacros.h"
#include <rtl/ustring.hxx>
using namespace com::sun::star::uno;
namespace apitest {
void XSheetAnnotation::testGetPosition()
{
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
table::CellAddress xResultCellAddress = aSheetAnnotation->getPosition();
//expected result
table::CellAddress xExpectedCellAddress;
xExpectedCellAddress.Sheet = 0;
xExpectedCellAddress.Row = 1;
xExpectedCellAddress.Column = 2;
CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xResultCellAddress.Sheet == xExpectedCellAddress.Sheet);
CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xResultCellAddress.Column == xExpectedCellAddress.Column);
CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xResultCellAddress.Row == xExpectedCellAddress.Row);
}
void XSheetAnnotation::testGetAuthor()
{
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
rtl::OUString aAuthor = aSheetAnnotation->getAuthor();
CPPUNIT_ASSERT_MESSAGE("Wrong author", aAuthor.equals("LG"));
}
void XSheetAnnotation::testGetDate()
{
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
rtl::OUString aDate = aSheetAnnotation->getDate();
CPPUNIT_ASSERT_MESSAGE("Wrong date", aDate.equals("01/17/2013"));
}
void XSheetAnnotation::testGetIsVisible()
{
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
bool isVisible = aSheetAnnotation->getIsVisible();
CPPUNIT_ASSERT_MESSAGE("Wrong visible state", isVisible == true);
}
void XSheetAnnotation::testSetIsVisible()
{
uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
aSheetAnnotation->setIsVisible(false);
bool isVisible = aSheetAnnotation->getIsVisible();
CPPUNIT_ASSERT_MESSAGE("Visible state not changed", isVisible == false);
}
}
/* 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