Kaydet (Commit) b8563d46 authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move _SheetLink Java tests to C++

Change-Id: I33813be65bcb44c11a35bc97d963057418a28d9e
Reviewed-on: https://gerrit.libreoffice.org/50984Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 7a644e36
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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_SHEETLINK_HXX
#define INCLUDED_TEST_SHEET_SHEETLINK_HXX
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST SheetLink
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testSheetLinkProperties();
protected:
~SheetLink() {}
};
}
#endif // INCLUDED_TEST_SHEET_SHEETLINK_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -564,7 +564,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sdb/_XSingleSelectQueryComposer \
qadevOOo/tests/java/ifc/sdb/_XSQLErrorBroadcaster \
qadevOOo/tests/java/ifc/sheet/_FunctionDescription \
qadevOOo/tests/java/ifc/sheet/_SheetLink \
qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor \
qadevOOo/tests/java/ifc/sheet/_Spreadsheet \
qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \
......
"ScSheetLinkObj";"com::sun::star::util::XRefreshable";"refresh()"
"ScSheetLinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
"ScSheetLinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
"ScSheetLinkObj";"com::sun::star::sheet::SheetLink";"Url"
"ScSheetLinkObj";"com::sun::star::sheet::SheetLink";"Filter"
"ScSheetLinkObj";"com::sun::star::sheet::SheetLink";"FilterOptions"
"ScSheetLinkObj";"com::sun::star::container::XNamed";"getName()"
"ScSheetLinkObj";"com::sun::star::container::XNamed";"setName()"
"ScSheetLinkObj";"com::sun::star::beans::XPropertySet";"getPropertySetInfo()"
......
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package ifc.sheet;
import lib.MultiPropertyTest;
import util.ValueChanger;
/**
* Testing <code>com.sun.star.sheet.SheetLink</code>
* service properties :
* <ul>
* <li><code> Url</code></li>
* <li><code> Filter</code></li>
* <li><code> FilterOptions</code></li>
* </ul> <p>
* Properties testing is automated by <code>lib.MultiPropertyTest</code>.
* @see com.sun.star.sheet.SheetLink
*/
public class _SheetLink extends MultiPropertyTest {
/**
*This class is destined to custom test of property <code>Url</code>.
*/
protected PropertyTester UrlTester = new PropertyTester() {
@Override
protected Object getNewValue(String propName, Object oldValue) {
String newValue = (String) ValueChanger.changePValue(oldValue);
if ( !newValue.startsWith("file://") ) {
newValue = "file://" + newValue;
}
return newValue;
}
};
/**
* Test property <code>Url</code> using custom <code>PropertyTest</code>.
*/
public void _Url() {
testProperty("Url", UrlTester);
}
/**
*This class is destined to custom test of property <code>Filter</code>.
*/
protected PropertyTester FilterTester = new PropertyTester() {
@Override
protected Object getNewValue(String propName, Object oldValue) {
return "StarCalc 4.0";
}
};
/**
* Test property <code>Filter</code> using custom <code>PropertyTest</code>.
*/
public void _Filter() {
testProperty("Filter", FilterTester);
}
}
# -*- 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_sheetlinkobj))
$(eval $(call gb_CppunitTest_use_external,sc_sheetlinkobj,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_sheetlinkobj, \
sc/qa/extras/scsheetlinkobj \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_sheetlinkobj, \
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 \
))
$(eval $(call gb_CppunitTest_set_include,sc_sheetlinkobj,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sc_sheetlinkobj))
$(eval $(call gb_CppunitTest_use_ure,sc_sheetlinkobj))
$(eval $(call gb_CppunitTest_use_vcl,sc_sheetlinkobj))
$(eval $(call gb_CppunitTest_use_components,sc_sheetlinkobj,\
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 \
linguistic/source/lng \
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 \
uui/util/uui \
xmloff/util/xo \
svtools/util/svt \
))
$(eval $(call gb_CppunitTest_use_configuration,sc_sheetlinkobj))
# vim: set noet sw=4 ts=4:
......@@ -153,6 +153,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_documentconfigurationobj \
CppunitTest_sc_spreadsheetsettingsobj \
CppunitTest_sc_shapeobj \
CppunitTest_sc_sheetlinkobj \
))
$(eval $(call gb_Module_add_perfcheck_targets,sc,\
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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/sheetlink.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/sheet/SheetLinkMode.hpp>
#include <com/sun/star/sheet/XSheetLinkable.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
using namespace css;
using namespace css::uno;
using namespace com::sun::star;
namespace sc_apitest
{
class ScSheetLinkObj : public CalcUnoApiTest, public apitest::SheetLink
{
public:
ScSheetLinkObj();
virtual uno::Reference<uno::XInterface> init() override;
virtual void setUp() override;
virtual void tearDown() override;
CPPUNIT_TEST_SUITE(ScSheetLinkObj);
// SheetLink
CPPUNIT_TEST(testSheetLinkProperties);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<lang::XComponent> mxComponent;
OUString maUrl;
};
ScSheetLinkObj::ScSheetLinkObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
{
}
uno::Reference<uno::XInterface> ScSheetLinkObj::init()
{
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
uno::Reference<sheet::XSheetLinkable> xSL(xSheet, UNO_QUERY_THROW);
OUString aFileURL;
createFileURL("ScSheetLinkObj.ods", aFileURL);
xSL->link(aFileURL, "Sheet1", "", "", sheet::SheetLinkMode_VALUE);
uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW);
uno::Reference<container::XNameAccess> sheetLinks;
CPPUNIT_ASSERT(xPropSet->getPropertyValue("SheetLinks") >>= sheetLinks);
CPPUNIT_ASSERT(sheetLinks.is());
uno::Any aAny = sheetLinks->getByName(sheetLinks->getElementNames()[0]);
uno::Reference<beans::XPropertySet> sheetLink;
aAny >>= sheetLink;
return sheetLink;
}
void ScSheetLinkObj::setUp()
{
CalcUnoApiTest::setUp();
// create a calc document
mxComponent = loadFromDesktop("private:factory/scalc");
}
void ScSheetLinkObj::tearDown()
{
closeDocument(mxComponent);
CalcUnoApiTest::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScSheetLinkObj);
} // end namespace
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -58,6 +58,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/sheetcellrange \
test/source/sheet/sheetcellranges \
test/source/sheet/sheetfilterdescriptor \
test/source/sheet/sheetlink \
test/source/sheet/tableautoformat \
test/source/sheet/tablevalidation \
test/source/sheet/xarealink \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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/sheetlink.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace com::sun::star;
using namespace com::sun::star::uno;
namespace apitest
{
void SheetLink::testSheetLinkProperties()
{
uno::Reference<beans::XPropertySet> xSheetLink(init(), UNO_QUERY_THROW);
OUString propName;
uno::Any aNewValue;
propName = "Url";
OUString aUrlGet;
OUString aUrlSet;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Url",
xSheetLink->getPropertyValue(propName) >>= aUrlGet);
aNewValue <<= OUString("file:///tmp/ScSheetLinkObj.ods");
xSheetLink->setPropertyValue(propName, aNewValue);
CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aUrlSet);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Url",
OUString("file:///tmp/ScSheetLinkObj.ods"), aUrlSet);
propName = "Filter";
OUString aFilterGet;
OUString aFilterSet;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Filter",
xSheetLink->getPropertyValue(propName) >>= aFilterGet);
aNewValue <<= OUString("Text - txt - csv (StarCalc)");
xSheetLink->setPropertyValue(propName, aNewValue);
CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterSet);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Filter",
OUString("Text - txt - csv (StarCalc)"), aFilterSet);
propName = "FilterOptions";
OUString aFilterOptionsGet;
OUString aFilterOptionsSet;
CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FilterOptions",
xSheetLink->getPropertyValue(propName) >>= aFilterOptionsGet);
aNewValue <<= OUString("NewValue");
xSheetLink->setPropertyValue(propName, aNewValue);
CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterOptionsSet);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FilterOptions", OUString("NewValue"),
aFilterOptionsSet);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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