Kaydet (Commit) ecc855aa authored tarafından Ajay Mahato's avatar Ajay Mahato Kaydeden (comit) Jens Carl

tdf#45904 Move XSimpleText Java tests to C++

Change-Id: I6232615f15b52a1f004a13ed97fc0b8002a22269
Reviewed-on: https://gerrit.libreoffice.org/66694
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 7cf66213
/* -*- 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_TEXT_XSIMPLETEXT_HXX
#define INCLUDED_TEST_TEXT_XSIMPLETEXT_HXX
#include <test/testdllapi.hxx>
#include <com/sun/star/text/XSimpleText.hpp>
namespace apitest
{
class OOO_DLLPUBLIC_TEST XSimpleText
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void testCreateTextCursor();
void testCreateTextCursorByRange();
void testInsertString();
void testInsertControlCharacter();
protected:
~XSimpleText() {}
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -109,10 +109,6 @@ ...@@ -109,10 +109,6 @@
"ScCellObj";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()" "ScCellObj";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()"
"ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()" "ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()"
"ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionEnds()" "ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionEnds()"
"ScCellObj";"com::sun::star::text::XSimpleText";"createTextCursor()"
"ScCellObj";"com::sun::star::text::XSimpleText";"createTextCursorByRange()"
"ScCellObj";"com::sun::star::text::XSimpleText";"insertString()"
"ScCellObj";"com::sun::star::text::XSimpleText";"insertControlCharacter()"
"ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryVisibleCells()" "ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryVisibleCells()"
"ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryEmptyCells()" "ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryEmptyCells()"
"ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryContentCells()" "ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryContentCells()"
......
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
#include <test/calc_unoapi_test.hxx> #include <test/calc_unoapi_test.hxx>
#include <test/container/xenumerationaccess.hxx> #include <test/container/xenumerationaccess.hxx>
#include <test/sheet/sheetcell.hxx> #include <test/sheet/sheetcell.hxx>
#include <test/table/xcell.hxx>
#include <test/sheet/xcelladdressable.hxx> #include <test/sheet/xcelladdressable.hxx>
#include <test/sheet/xformulaquery.hxx> #include <test/sheet/xformulaquery.hxx>
#include <test/sheet/xsheetannotationanchor.hxx> #include <test/sheet/xsheetannotationanchor.hxx>
#include <test/table/xcell.hxx>
#include <test/table/xcolumnrowrange.hxx> #include <test/table/xcolumnrowrange.hxx>
#include <test/text/xsimpletext.hxx>
#include <test/util/xindent.hxx> #include <test/util/xindent.hxx>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
...@@ -25,27 +26,30 @@ ...@@ -25,27 +26,30 @@
#include <com/sun/star/sheet/XSpreadsheets.hpp> #include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/text/XSimpleText.hpp>
#include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/XInterface.hpp>
using namespace css; using namespace css;
using namespace css::uno; using namespace css::uno;
namespace sc_apitest { namespace sc_apitest
{
class ScCellObj : public CalcUnoApiTest, public apitest::SheetCell, class ScCellObj : public CalcUnoApiTest,
public apitest::XCell, public apitest::SheetCell,
public apitest::XCellAddressable, public apitest::XCell,
public apitest::XColumnRowRange, public apitest::XCellAddressable,
public apitest::XEnumerationAccess, public apitest::XColumnRowRange,
public apitest::XFormulaQuery, public apitest::XEnumerationAccess,
public apitest::XIndent, public apitest::XFormulaQuery,
public apitest::XSheetAnnotationAnchor public apitest::XIndent,
public apitest::XSheetAnnotationAnchor,
public apitest::XSimpleText
{ {
public: public:
ScCellObj(); ScCellObj();
virtual uno::Reference< uno::XInterface > init() override; virtual uno::Reference<uno::XInterface> init() override;
virtual uno::Reference< uno::XInterface > getXSpreadsheet() override; virtual uno::Reference<uno::XInterface> getXSpreadsheet() override;
virtual void setUp() override; virtual void setUp() override;
virtual void tearDown() override; virtual void tearDown() override;
...@@ -81,23 +85,30 @@ public: ...@@ -81,23 +85,30 @@ public:
// XSheetAnnotationAnchor // XSheetAnnotationAnchor
CPPUNIT_TEST(testGetAnnotation); CPPUNIT_TEST(testGetAnnotation);
// XSimpleText
CPPUNIT_TEST(testCreateTextCursor);
CPPUNIT_TEST(testCreateTextCursorByRange);
CPPUNIT_TEST(testInsertString);
CPPUNIT_TEST(testInsertControlCharacter);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
uno::Reference< lang::XComponent > mxComponent; uno::Reference<lang::XComponent> mxComponent;
}; };
ScCellObj::ScCellObj() ScCellObj::ScCellObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments"), : CalcUnoApiTest("/sc/qa/extras/testdocuments")
apitest::XFormulaQuery(table::CellRangeAddress(0, 2, 3, 2, 3), table::CellRangeAddress(0, 0, 0, 3, 0), 0, 0) , apitest::XFormulaQuery(table::CellRangeAddress(0, 2, 3, 2, 3),
table::CellRangeAddress(0, 0, 0, 3, 0), 0, 0)
{ {
} }
uno::Reference< uno::XInterface > ScCellObj::init() uno::Reference<uno::XInterface> ScCellObj::init()
{ {
uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheetDocument> xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheets> xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheets> xSheets(xSheetDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW); uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
...@@ -111,9 +122,9 @@ uno::Reference< uno::XInterface > ScCellObj::init() ...@@ -111,9 +122,9 @@ uno::Reference< uno::XInterface > ScCellObj::init()
uno::Reference<uno::XInterface> ScCellObj::getXSpreadsheet() uno::Reference<uno::XInterface> ScCellObj::getXSpreadsheet()
{ {
uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheetDocument> xSheetDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheets> xSheets (xSheetDoc->getSheets(), UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheets> xSheets(xSheetDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW); uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW);
...@@ -134,7 +145,6 @@ void ScCellObj::tearDown() ...@@ -134,7 +145,6 @@ void ScCellObj::tearDown()
CalcUnoApiTest::tearDown(); CalcUnoApiTest::tearDown();
} }
CPPUNIT_TEST_SUITE_REGISTRATION(ScCellObj); CPPUNIT_TEST_SUITE_REGISTRATION(ScCellObj);
} // end namespace } // end namespace
......
...@@ -164,6 +164,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ ...@@ -164,6 +164,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/table/xtablechart \ test/source/table/xtablechart \
test/source/table/xtablechartssupplier \ test/source/table/xtablechartssupplier \
test/source/table/xtablerows \ test/source/table/xtablerows \
test/source/text/xsimpletext \
test/source/text/xtext \ test/source/text/xtext \
test/source/text/xtextcontent \ test/source/text/xtextcontent \
test/source/text/xtextfield \ test/source/text/xtextfield \
......
/* -*- 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/text/xsimpletext.hxx>
#include <com/sun/star/text/XTextCursor.hpp>
#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
using namespace css::uno;
namespace apitest
{
void XSimpleText::testCreateTextCursor()
{
uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xSimpleText->createTextCursor());
}
void XSimpleText::testCreateTextCursorByRange()
{
uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
uno::Reference<text::XTextCursor> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
xCursor->gotoStart(false);
CPPUNIT_ASSERT(xSimpleText->createTextCursorByRange(xCursor));
}
void XSimpleText::testInsertString()
{
uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
uno::Reference<text::XTextRange> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
::rtl::OUString sString = "TestString";
xSimpleText->insertString(xCursor, sString, false);
::rtl::OUString gString = xSimpleText->getText()->getString();
CPPUNIT_ASSERT(!gString.isEmpty());
CPPUNIT_ASSERT(gString.indexOf(sString) >= 0);
}
void XSimpleText::testInsertControlCharacter()
{
bool bOK = true;
uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
uno::Reference<text::XTextRange> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
try
{
xSimpleText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK,
false);
xSimpleText->insertControlCharacter(xCursor, text::ControlCharacter::LINE_BREAK, false);
xSimpleText->insertString(xSimpleText->createTextCursor(), "newLine", false);
}
catch (const lang::IllegalArgumentException&)
{
bOK = false;
}
OUString gString = xSimpleText->getString();
CPPUNIT_ASSERT(bOK);
CPPUNIT_ASSERT(gString.indexOf("\n") > -1);
}
}
/* 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