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

tdf#45904 Move TextContent Java tests to C++

Move TextContent Java tests to C++ for ScEditFieldObj_Cell and
ScEditFieldObj_Header (formerly ScCellFieldObj).

Change-Id: Ieed5cdbc128490e66d1797c817d998a932317dd4
Reviewed-on: https://gerrit.libreoffice.org/70615
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 74288f5a
/* -*- 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/.
*/
#pragma once
#include <test/testdllapi.hxx>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST TextContent
{
public:
TextContent(const css::text::TextContentAnchorType aExpectedTCAT,
const css::text::TextContentAnchorType aNewTCAT,
const css::text::WrapTextMode aExpectedWTM, const css::text::WrapTextMode aNewWTM)
: m_aExpectedTCAT(aExpectedTCAT)
, m_aNewTCAT(aNewTCAT)
, m_aExpectedWTM(aExpectedWTM)
, m_aNewWTM(aNewWTM)
{
}
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testTextContentProperties();
protected:
~TextContent() {}
private:
css::text::TextContentAnchorType const m_aExpectedTCAT;
css::text::TextContentAnchorType const m_aNewTCAT;
css::text::WrapTextMode const m_aExpectedWTM;
css::text::WrapTextMode const m_aNewWTM;
};
} // namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
"ScCellFieldObj";"com::sun::star::lang::XComponent";"dispose()"
"ScCellFieldObj";"com::sun::star::lang::XComponent";"addEventListener()"
"ScCellFieldObj";"com::sun::star::lang::XComponent";"removeEventListener()"
"ScCellFieldObj";"com::sun::star::text::TextContent";"AnchorType#optional"
"ScCellFieldObj";"com::sun::star::text::TextContent";"AnchorTypes#optional"
"ScCellFieldObj";"com::sun::star::text::TextContent";"TextWrap#optional"
......@@ -9,15 +9,18 @@
#include <test/calc_unoapi_test.hxx>
#include <test/beans/xpropertyset.hxx>
#include <test/text/textcontent.hxx>
#include <test/text/xtextfield.hxx>
#include <test/text/xtextcontent.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
......@@ -33,6 +36,7 @@ using namespace css;
namespace sc_apitest
{
class ScEditFieldObj_Cell : public CalcUnoApiTest,
public apitest::TextContent,
public apitest::XPropertySet,
public apitest::XTextContent,
public apitest::XTextField
......@@ -51,6 +55,9 @@ public:
CPPUNIT_TEST_SUITE(ScEditFieldObj_Cell);
// TextContent
CPPUNIT_TEST(testTextContentProperties);
// XPropertySet
CPPUNIT_TEST(testGetPropertySetInfo);
CPPUNIT_TEST(testGetPropertyValue);
......@@ -79,6 +86,9 @@ uno::Reference<text::XTextField> ScEditFieldObj_Cell::mxField;
ScEditFieldObj_Cell::ScEditFieldObj_Cell()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
, TextContent(text::TextContentAnchorType_AS_CHARACTER,
text::TextContentAnchorType_AS_CHARACTER, text::WrapTextMode_NONE,
text::WrapTextMode_NONE)
{
}
......
......@@ -9,6 +9,7 @@
#include <test/calc_unoapi_test.hxx>
#include <test/beans/xpropertyset.hxx>
#include <test/text/textcontent.hxx>
#include <test/text/xtextcontent.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
......@@ -18,6 +19,8 @@
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextCursor.hpp>
......@@ -33,8 +36,9 @@ using namespace css;
namespace sc_apitest
{
class ScEditFieldObj_Header : public CalcUnoApiTest,
public apitest::XTextContent,
public apitest::XPropertySet
public apitest::TextContent,
public apitest::XPropertySet,
public apitest::XTextContent
{
public:
ScEditFieldObj_Header();
......@@ -48,6 +52,9 @@ public:
CPPUNIT_TEST_SUITE(ScEditFieldObj_Header);
// TextContent
CPPUNIT_TEST(testTextContentProperties);
// XPropertySet
CPPUNIT_TEST(testGetPropertySetInfo);
CPPUNIT_TEST(testGetPropertyValue);
......@@ -72,6 +79,9 @@ uno::Reference<text::XText> ScEditFieldObj_Header::mxRightText;
ScEditFieldObj_Header::ScEditFieldObj_Header()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
, TextContent(text::TextContentAnchorType_AS_CHARACTER,
text::TextContentAnchorType_AS_CHARACTER, text::WrapTextMode_NONE,
text::WrapTextMode_NONE)
{
}
......
......@@ -173,6 +173,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/table/xtablecolumns \
test/source/table/xtablerows \
test/source/text/baseindex \
test/source/text/textcontent \
test/source/text/xsimpletext \
test/source/text/xtext \
test/source/text/xtextcontent \
......
/* -*- 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/text/textcontent.hxx>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
namespace apitest
{
void TextContent::testTextContentProperties()
{
uno::Reference<beans::XPropertySet> xPS(init(), uno::UNO_QUERY_THROW);
text::TextContentAnchorType aExpectedTCAT;
CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorType") >>= aExpectedTCAT);
CPPUNIT_ASSERT_EQUAL(m_aExpectedTCAT, aExpectedTCAT);
try
{
xPS->setPropertyValue("AnchorType", uno::makeAny(m_aNewTCAT));
text::TextContentAnchorType aNewTCAT;
CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorType") >>= aNewTCAT);
CPPUNIT_ASSERT_EQUAL(m_aNewTCAT, aNewTCAT);
}
catch (const beans::UnknownPropertyException& /* ex */)
{
// ignore if property is optional
}
uno::Sequence<text::TextContentAnchorType> aAnchorTypes;
CPPUNIT_ASSERT(xPS->getPropertyValue("AnchorTypes") >>= aAnchorTypes);
CPPUNIT_ASSERT(aAnchorTypes.getLength());
text::WrapTextMode aExpectedWTM;
CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aExpectedWTM);
CPPUNIT_ASSERT_EQUAL(m_aExpectedWTM, aExpectedWTM);
try
{
xPS->setPropertyValue("TextWrap", uno::makeAny(m_aNewWTM));
text::WrapTextMode aNewWTM;
CPPUNIT_ASSERT(xPS->getPropertyValue("TextWrap") >>= aNewWTM);
CPPUNIT_ASSERT_EQUAL(m_aNewWTM, aNewWTM);
}
catch (const beans::UnknownPropertyException& /* ex */)
{
// ignore if property is optional
}
}
} // 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