diff options
author | Ajay Mahato <ajjayymahato@gmail.com> | 2019-01-21 23:14:15 +0530 |
---|---|---|
committer | Jens Carl <j.carl43@gmx.de> | 2019-01-29 01:02:34 +0100 |
commit | ecc855aa1c86d88a99c3be06c70ed382180be688 (patch) | |
tree | d567859da94b60ff195d9b36c5d4af34b38d73fe | |
parent | 7cf66213a975d9c846990ed8b0c2eb0daae89aa2 (diff) |
tdf#45904 Move XSimpleText Java tests to C++
Change-Id: I6232615f15b52a1f004a13ed97fc0b8002a22269
Reviewed-on: https://gerrit.libreoffice.org/66694
Tested-by: Jenkins
Reviewed-by: Jens Carl <j.carl43@gmx.de>
-rw-r--r-- | include/test/text/xsimpletext.hxx | 36 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv | 4 | ||||
-rw-r--r-- | sc/qa/extras/sccellobj.cxx | 54 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/text/xsimpletext.cxx | 76 |
5 files changed, 145 insertions, 26 deletions
diff --git a/include/test/text/xsimpletext.hxx b/include/test/text/xsimpletext.hxx new file mode 100644 index 000000000000..fca6d24a0d6a --- /dev/null +++ b/include/test/text/xsimpletext.hxx @@ -0,0 +1,36 @@ +/* -*- 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: */ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv index 3be24423a38d..e31e938fe88b 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellObj.csv @@ -109,10 +109,6 @@ "ScCellObj";"com::sun::star::text::XTextRangeMover#optional";"moveTextRange()" "ScCellObj";"com::sun::star::text::XTextRangeCompare#optional";"compareRegionStarts()" "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";"queryEmptyCells()" "ScCellObj";"com::sun::star::sheet::XCellRangesQuery";"queryContentCells()" diff --git a/sc/qa/extras/sccellobj.cxx b/sc/qa/extras/sccellobj.cxx index cb1c5a1421fd..51d7b0ce22b1 100644 --- a/sc/qa/extras/sccellobj.cxx +++ b/sc/qa/extras/sccellobj.cxx @@ -10,11 +10,12 @@ #include <test/calc_unoapi_test.hxx> #include <test/container/xenumerationaccess.hxx> #include <test/sheet/sheetcell.hxx> -#include <test/table/xcell.hxx> #include <test/sheet/xcelladdressable.hxx> #include <test/sheet/xformulaquery.hxx> #include <test/sheet/xsheetannotationanchor.hxx> +#include <test/table/xcell.hxx> #include <test/table/xcolumnrowrange.hxx> +#include <test/text/xsimpletext.hxx> #include <test/util/xindent.hxx> #include <com/sun/star/lang/XComponent.hpp> @@ -25,27 +26,30 @@ #include <com/sun/star/sheet/XSpreadsheets.hpp> #include <com/sun/star/table/CellAddress.hpp> #include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/text/XSimpleText.hpp> #include <com/sun/star/uno/XInterface.hpp> using namespace css; using namespace css::uno; -namespace sc_apitest { - -class ScCellObj : public CalcUnoApiTest, public apitest::SheetCell, - public apitest::XCell, - public apitest::XCellAddressable, - public apitest::XColumnRowRange, - public apitest::XEnumerationAccess, - public apitest::XFormulaQuery, - public apitest::XIndent, - public apitest::XSheetAnnotationAnchor +namespace sc_apitest +{ +class ScCellObj : public CalcUnoApiTest, + public apitest::SheetCell, + public apitest::XCell, + public apitest::XCellAddressable, + public apitest::XColumnRowRange, + public apitest::XEnumerationAccess, + public apitest::XFormulaQuery, + public apitest::XIndent, + public apitest::XSheetAnnotationAnchor, + public apitest::XSimpleText { public: ScCellObj(); - virtual uno::Reference< uno::XInterface > init() override; - virtual uno::Reference< uno::XInterface > getXSpreadsheet() override; + virtual uno::Reference<uno::XInterface> init() override; + virtual uno::Reference<uno::XInterface> getXSpreadsheet() override; virtual void setUp() override; virtual void tearDown() override; @@ -81,23 +85,30 @@ public: // XSheetAnnotationAnchor CPPUNIT_TEST(testGetAnnotation); + // XSimpleText + CPPUNIT_TEST(testCreateTextCursor); + CPPUNIT_TEST(testCreateTextCursorByRange); + CPPUNIT_TEST(testInsertString); + CPPUNIT_TEST(testInsertControlCharacter); + CPPUNIT_TEST_SUITE_END(); private: - uno::Reference< lang::XComponent > mxComponent; + uno::Reference<lang::XComponent> mxComponent; }; ScCellObj::ScCellObj() - : CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XFormulaQuery(table::CellRangeAddress(0, 2, 3, 2, 3), table::CellRangeAddress(0, 0, 0, 3, 0), 0, 0) + : CalcUnoApiTest("/sc/qa/extras/testdocuments") + , 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<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW); @@ -111,9 +122,9 @@ uno::Reference< uno::XInterface > ScCellObj::init() 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<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW); @@ -134,7 +145,6 @@ void ScCellObj::tearDown() CalcUnoApiTest::tearDown(); } - CPPUNIT_TEST_SUITE_REGISTRATION(ScCellObj); } // end namespace diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index 1269f3771f81..d0ce3ad4dac0 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -164,6 +164,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/table/xtablechart \ test/source/table/xtablechartssupplier \ test/source/table/xtablerows \ + test/source/text/xsimpletext \ test/source/text/xtext \ test/source/text/xtextcontent \ test/source/text/xtextfield \ diff --git a/test/source/text/xsimpletext.cxx b/test/source/text/xsimpletext.cxx new file mode 100644 index 000000000000..edb61faa80ee --- /dev/null +++ b/test/source/text/xsimpletext.cxx @@ -0,0 +1,76 @@ +/* -*- 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: */ |