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

tdf#45904 Move _XDDELink Java test to C++

Change-Id: Ic7a23088ee10f2d92d05354131e3066ec098a7b9
Reviewed-on: https://gerrit.libreoffice.org/51850Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 0869602f
/* -*- 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_XDDELINK_HXX
#define INCLUDED_TEST_SHEET_XDDELINK_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 XDDELink
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testGetApplication();
void testGetItem();
void testGetTopic();
protected:
~XDDELink() {}
};
} // namespace apitest
#endif // INCLUDED_TEST_SHEET_XDDELINK_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -575,7 +575,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement \
qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer \
qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \
qadevOOo/tests/java/ifc/sheet/_XDDELink \
qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \
qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster \
qadevOOo/tests/java/ifc/sheet/_XFormulaQuery \
......
"ScDDELinkObj";"com::sun::star::util::XRefreshable";"refresh()"
"ScDDELinkObj";"com::sun::star::util::XRefreshable";"addRefreshListener()"
"ScDDELinkObj";"com::sun::star::util::XRefreshable";"removeRefreshListener()"
"ScDDELinkObj";"com::sun::star::sheet::XDDELink";"getApplication()"
"ScDDELinkObj";"com::sun::star::sheet::XDDELink";"getTopic()"
"ScDDELinkObj";"com::sun::star::sheet::XDDELink";"getItem()"
"ScDDELinkObj";"com::sun::star::container::XNamed";"getName()"
"ScDDELinkObj";"com::sun::star::container::XNamed";"setName()"
/*
* 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.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.sheet.XDDELink;
/**
* Testing <code>com.sun.star.sheet.XDDELink</code>
* interface methods :
* <ul>
* <li><code> getApplication()</code></li>
* <li><code> getTopic()</code></li>
* <li><code> getItem()</code></li>
* </ul> <p>
* This test needs the following object relations :
* <ul>
* <li> <code>'APPLICATION'</code> (of type <code>String</code>):
* to have application name </li>
* <li> <code>'ITEM'</code> (of type <code>String</code>):
* to have DDE item </li>
* <li> <code>'TOPIC'</code> (of type <code>String</code>):
* to have DDE topic </li>
* <ul> <p>
* @see com.sun.star.sheet.XDDELink
*/
public class _XDDELink extends MultiMethodTest {
public XDDELink oObj = null;
/**
* Test calls the method and compares returned value to value obtained by
* relation <code>'APPLICATION'</code>. <p>
* Has <b> OK </b> status if values are equal. <p>
*/
public void _getApplication(){
log.println("testing getApplication()");
boolean bResult = false;
String oAppl = (String)tEnv.getObjRelation("APPLICATION");
if (oAppl == null) throw new StatusException(Status.failed
("Relation 'APPLICATION' not found"));
bResult = oAppl.equals(oObj.getApplication());
tRes.tested("getApplication()", bResult) ;
}
/**
* Test calls the method and compares returned value to value obtained by
* relation <code>'ITEM'</code>. <p>
* Has <b> OK </b> status if values are equal. <p>
*/
public void _getItem(){
log.println("testing getItem()");
boolean bResult = false;
String sItem = oObj.getItem();
String oItem = (String)tEnv.getObjRelation("ITEM");
if (oItem == null) throw new StatusException(Status.failed
("Relation 'ITEM' not found"));
bResult = oItem.equals(sItem);
tRes.tested("getItem()", bResult) ;
}
/**
* Test calls the method and compares returned value to value obtained by
* relation <code>'TOPIC'</code>. <p>
* Has <b> OK </b> status if values are equal. <p>
*/
public void _getTopic(){
log.println("testing getTopic()");
boolean bResult = false;
String sTopic = oObj.getTopic();
String oTopic = (String)tEnv.getObjRelation("TOPIC");
if (oTopic == null) throw new StatusException(Status.failed
("Relation 'TOPIC' not found"));
bResult = oTopic.equals(sTopic);
tRes.tested("getTopic()", bResult) ;
}
}
# -*- 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_ddelinkobj))
$(eval $(call gb_CppunitTest_use_external,sc_ddelinkobj,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_ddelinkobj, \
sc/qa/extras/scddelinkobj \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_ddelinkobj, \
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_ddelinkobj,\
-I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sc_ddelinkobj))
$(eval $(call gb_CppunitTest_use_ure,sc_ddelinkobj))
$(eval $(call gb_CppunitTest_use_vcl,sc_ddelinkobj))
$(eval $(call gb_CppunitTest_use_components,sc_ddelinkobj,\
$(sc_unoapi_common_components) \
))
$(eval $(call gb_CppunitTest_use_configuration,sc_ddelinkobj))
# vim: set noet sw=4 ts=4:
......@@ -157,6 +157,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
CppunitTest_sc_shapeobj \
CppunitTest_sc_sheetlinkobj \
CppunitTest_sc_spreadsheetsettingsobj \
CppunitTest_sc_ddelinkobj \
))
$(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/xddelink.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/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/sheet/XDDELink.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 ScDDELinkObj : public CalcUnoApiTest, public apitest::XDDELink
{
public:
ScDDELinkObj();
virtual uno::Reference<uno::XInterface> init() override;
virtual void setUp() override;
virtual void tearDown() override;
CPPUNIT_TEST_SUITE(ScDDELinkObj);
// XDDELink
CPPUNIT_TEST(testGetApplication);
CPPUNIT_TEST(testGetItem);
CPPUNIT_TEST(testGetTopic);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<lang::XComponent> mxComponent;
};
ScDDELinkObj::ScDDELinkObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
{
}
uno::Reference<uno::XInterface> ScDDELinkObj::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);
xSheet->getCellByPosition(5, 5)->setFormula(
"=DDE(\"soffice\";\"ScDDELinksObj.ods\";\"Sheet.A1\"");
xSheet->getCellByPosition(1, 4)->setFormula(
"=DDE(\"soffice\";\"ScDDELinksObj.ods\";\"Sheet.A1\"");
uno::Reference<beans::XPropertySet> xPropSet(xDoc, UNO_QUERY_THROW);
uno::Any aDDELinks = xPropSet->getPropertyValue("DDELinks");
uno::Reference<container::XNameAccess> xNA(aDDELinks, UNO_QUERY_THROW);
uno::Sequence<OUString> sLinkNames = xNA->getElementNames();
uno::Reference<sheet::XDDELink> xDDELink(xNA->getByName(sLinkNames[0]), UNO_QUERY_THROW);
return xDDELink;
}
void ScDDELinkObj::setUp()
{
CalcUnoApiTest::setUp();
// create a calc document
mxComponent = loadFromDesktop("private:factory/scalc");
}
void ScDDELinkObj::tearDown()
{
closeDocument(mxComponent);
CalcUnoApiTest::tearDown();
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScDDELinkObj);
} // namespace sc_apitest
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -89,6 +89,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xdatapilottable2 \
test/source/sheet/xdatapilottables \
test/source/sheet/xdatapilottablessupplier \
test/source/sheet/xddelink \
test/source/sheet/xfunctiondescriptions \
test/source/sheet/xheaderfootercontent \
test/source/sheet/xlabelrange \
......
/* -*- 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/xddelink.hxx>
#include <com/sun/star/sheet/XDDELink.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
using namespace css::uno;
namespace apitest
{
void XDDELink::testGetApplication()
{
uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getApplication()", OUString("soffice"),
xLink->getApplication());
}
void XDDELink::testGetItem()
{
uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getItem()", OUString("Sheet.A1"),
xLink->getItem());
}
void XDDELink::testGetTopic()
{
uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getTopic()", OUString("ScDDELinksObj.ods"),
xLink->getTopic());
}
} // namespace apitest
/* 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