Kaydet (Commit) 4200896e authored tarafından Jens Carl's avatar Jens Carl Kaydeden (comit) Markus Mohrhard

tdf#45904: Move Java _XSheetLinkable tests to C++

Change-Id: I0f99c3b4a74748d7f1c73ef584170ae84b08cd9a
Reviewed-on: https://gerrit.libreoffice.org/43582Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst a0b7cd13
/* -*- 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_XSHEETLINKABLE_HXX
#define INCLUDED_TEST_SHEET_XSHEETLINKABLE_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 XSheetLinkable
{
public:
virtual css::uno::Reference< css::uno::XInterface > init() =0;
virtual OUString getFileURL() =0;
void testSheetLinkable();
protected:
~XSheetLinkable() {}
private:
OUString maFileName;
};
}
#endif // INCLUDED_TEST_SHEET_XSHEETLINKABLE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -627,7 +627,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/ifc/sheet/_XSheetFilterable \
qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \
qadevOOo/tests/java/ifc/sheet/_XSheetFilterDescriptor \
qadevOOo/tests/java/ifc/sheet/_XSheetLinkable \
qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView \
qadevOOo/tests/java/ifc/style/_CharacterProperties \
qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
......
......@@ -172,13 +172,6 @@
"ScTableSheetObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"setPropertyValuesTolerant()"
"ScTableSheetObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"getPropertyValuesTolerant()"
"ScTableSheetObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"getDirectPropertyValuesTolerant()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"getLinkMode()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"setLinkMode()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"getLinkUrl()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"setLinkUrl()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"getLinkSheetName()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"setLinkSheetName()"
"ScTableSheetObj";"com::sun::star::sheet::XSheetLinkable";"link()"
"ScTableSheetObj";"com::sun::star::container::XNamed";"getName()"
"ScTableSheetObj";"com::sun::star::container::XNamed";"setName()"
"ScTableSheetObj";"com::sun::star::sheet::XCellRangeMovement";"insertCells()"
......
/*
* 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 com.sun.star.sheet.SheetLinkMode;
import com.sun.star.sheet.XSheetLinkable;
import lib.MultiMethodTest;
import util.utils;
/**
*
*/
public class _XSheetLinkable extends MultiMethodTest {
public XSheetLinkable oObj = null;
SheetLinkMode slm = null;
String linkSheetName = null;
String linkUrl = null;
String linkUrl2 = null;
@Override
public void before() {
// get a document for linking.
linkUrl = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet");
linkUrl = utils.getFullTestURL(linkUrl);
// get a second sheet for changing the link url: if it's not set,
// this part of the test is omitted.
linkUrl2 = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet2");
if (linkUrl2 != null)
linkUrl = utils.getFullTestURL(linkUrl);
// set a name for the sheet.
linkSheetName = "Sheet1";
}
public void _getLinkMode() {
requiredMethod("link()");
slm = oObj.getLinkMode();
tRes.tested("getLinkMode()", slm == SheetLinkMode.VALUE);
}
public void _getLinkSheetName() {
requiredMethod("link()");
String lSheetName = oObj.getLinkSheetName();
tRes.tested("getLinkSheetName()", linkSheetName.equals(lSheetName));
}
public void _getLinkUrl() {
requiredMethod("link()");
String lUrl = oObj.getLinkUrl();
System.out.println("URL: " + lUrl);
tRes.tested("getLinkUrl()", lUrl.equals(linkUrl));
}
public void _link() {
oObj.link(linkUrl, linkSheetName, "", "", SheetLinkMode.VALUE);
tRes.tested("link()", true);
}
public void _setLinkMode() {
requiredMethod("getLinkMode()");
oObj.setLinkMode(SheetLinkMode.NONE);
slm = oObj.getLinkMode();
tRes.tested("setLinkMode()", slm == SheetLinkMode.NONE);
}
public void _setLinkSheetName() {
requiredMethod("getLinkSheetName()");
oObj.setLinkSheetName("Sheet2");
linkSheetName = oObj.getLinkSheetName();
tRes.tested("setLinkSheetName()", linkSheetName.equals("Sheet2"));
}
public void _setLinkUrl() {
requiredMethod("getLinkUrl()");
boolean result = false;
if (linkUrl2 == null) {
// set back to the original value
oObj.setLinkUrl(linkUrl);
result = true;
}
else {
oObj.setLinkUrl(linkUrl2);
linkUrl = oObj.getLinkUrl();
result = linkUrl.equals(linkUrl2);
}
tRes.tested("setLinkUrl()", result);
}
}
......@@ -10,6 +10,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/sheet/xcellseries.hxx>
#include <test/sheet/xprintareas.hxx>
#include <test/sheet/xsheetlinkable.hxx>
#include <test/sheet/xsheetoperation.hxx>
#include <test/sheet/xsheetpagebreak.hxx>
#include <test/sheet/xspreadsheet.hxx>
......@@ -27,12 +28,13 @@ using namespace css::uno;
namespace sc_apitest
{
#define NUMBER_OF_TESTS 19
#define NUMBER_OF_TESTS 20
class ScTableSheetObj : public CalcUnoApiTest, public apitest::XCellSeries,
public apitest::XPrintAreas,
public apitest::XReplaceable,
public apitest::XSearchable,
public apitest::XSheetLinkable,
public apitest::XSheetOperation,
public apitest::XSheetPageBreak,
public apitest::XSpreadsheet,
......@@ -45,27 +47,32 @@ public:
virtual void setUp() override;
virtual void tearDown() override;
virtual OUString getFileURL() override;
virtual uno::Reference< uno::XInterface > init() override;
virtual uno::Reference< uno::XInterface > getXSpreadsheet() override;
CPPUNIT_TEST_SUITE(ScTableSheetObj);
// XSearchable
CPPUNIT_TEST(testFindAll);
CPPUNIT_TEST(testFindNext);
CPPUNIT_TEST(testFindFirst);
// XCellSeries
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
// XPrintAreas
CPPUNIT_TEST(testSetAndGetPrintTitleColumns);
CPPUNIT_TEST(testSetAndGetPrintTitleRows);
// XReplaceable
CPPUNIT_TEST(testReplaceAll);
CPPUNIT_TEST(testCreateReplaceDescriptor);
// XPrintAreas
CPPUNIT_TEST(testSetAndGetPrintTitleColumns);
CPPUNIT_TEST(testSetAndGetPrintTitleRows);
// XSearchable
CPPUNIT_TEST(testFindAll);
CPPUNIT_TEST(testFindNext);
CPPUNIT_TEST(testFindFirst);
// XCellSeries
CPPUNIT_TEST(testFillAuto);
CPPUNIT_TEST(testFillSeries);
// XSheetLinkable
CPPUNIT_TEST(testSheetLinkable);
// XSheetOperation
CPPUNIT_TEST(testComputeFunction);
......@@ -76,9 +83,6 @@ public:
CPPUNIT_TEST(testGetRowPageBreaks);
CPPUNIT_TEST(testRemoveAllManualPageBreaks);
// XUniqueCellFormatRangesSupplier
CPPUNIT_TEST(testGetUniqueCellFormatRanges);
// XSpreadsheet
CPPUNIT_TEST(testCreateCursor);
CPPUNIT_TEST(testCreateCursorByRange);
......@@ -87,9 +91,13 @@ public:
CPPUNIT_TEST(testCreateSubTotalDescriptor);
CPPUNIT_TEST(testApplyRemoveSubTotals);
// XUniqueCellFormatRangesSupplier
CPPUNIT_TEST(testGetUniqueCellFormatRanges);
CPPUNIT_TEST_SUITE_END();
private:
OUString maFileURL;
static sal_Int32 nTest;
static uno::Reference< lang::XComponent > mxComponent;
};
......@@ -107,10 +115,10 @@ ScTableSheetObj::ScTableSheetObj():
uno::Reference< uno::XInterface > ScTableSheetObj::init()
{
OUString aFileURL;
createFileURL("ScTableSheetObj.ods", aFileURL);
//OUString aFileURL;
createFileURL("ScTableSheetObj.ods", maFileURL);
if(!mxComponent.is())
mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
mxComponent = loadFromDesktop(maFileURL, "com.sun.star.sheet.SpreadsheetDocument");
CPPUNIT_ASSERT(mxComponent.is());
uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
......@@ -135,6 +143,11 @@ uno::Reference< uno::XInterface > ScTableSheetObj::getXSpreadsheet()
return xSheet;
}
OUString ScTableSheetObj::getFileURL()
{
return maFileURL;
}
void ScTableSheetObj::setUp()
{
nTest++;
......
......@@ -71,6 +71,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xsheetannotations \
test/source/sheet/xsheetannotationshapesupplier \
test/source/sheet/xsheetoutline \
test/source/sheet/xsheetlinkable \
test/source/sheet/xsheetoperation \
test/source/sheet/xsheetpagebreak \
test/source/sheet/xstyleloader \
......
/* -*- 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/xsheetlinkable.hxx>
#include <com/sun/star/sheet/SheetLinkMode.hpp>
#include <com/sun/star/sheet/XSheetLinkable.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
using namespace css::uno;
namespace apitest {
void XSheetLinkable::testSheetLinkable()
{
uno::Reference< sheet::XSheetLinkable > xSheetLinkable(init(), UNO_QUERY_THROW);
xSheetLinkable->link(getFileURL(), "Sheet1", "", "", sheet::SheetLinkMode_VALUE);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get link mode",
sheet::SheetLinkMode_VALUE, xSheetLinkable->getLinkMode());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get link URL",
getFileURL(), xSheetLinkable->getLinkUrl());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get sheet name",
OUString("Sheet1"), xSheetLinkable->getLinkSheetName());
xSheetLinkable->setLinkMode(sheet::SheetLinkMode_NONE);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set link mode",
sheet::SheetLinkMode_NONE, xSheetLinkable->getLinkMode());
xSheetLinkable->setLinkSheetName("Sheet2");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set sheet name",
OUString("Sheet2"), xSheetLinkable->getLinkSheetName());
xSheetLinkable->setLinkUrl(getFileURL());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set link URL",
getFileURL(), xSheetLinkable->getLinkUrl());
}
}
/* 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