sw/CppunitTest_sw_apitests.mk  |    1 
 sw/qa/api/SwXTableCellText.cxx |  103 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)

New commits:
commit b9e72b2577da2a0a61e95ff8a0a7f289f194c59b
Author:     anfanite396 <dipamt1...@gmail.com>
AuthorDate: Thu Jul 6 11:18:21 2023 +0530
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Aug 14 21:06:56 2023 +0200

    Move SwXTableCellText Java tests to C++
    
    Change-Id: Iea2113030bb82ee02bd84140f5def7040b4f4fcb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154087
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk
index fb500fa990c5..93bc9453113e 100644
--- a/sw/CppunitTest_sw_apitests.mk
+++ b/sw/CppunitTest_sw_apitests.mk
@@ -37,6 +37,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,sw_apitests, \
     sw/qa/api/SwXReferenceMark \
     sw/qa/api/SwXStyleFamilies \
     sw/qa/api/SwXReferenceMarks \
+    sw/qa/api/SwXTableCellText \
     sw/qa/api/SwXTextFrame \
     sw/qa/api/SwXTextField \
     sw/qa/api/SwXTextTable \
diff --git a/sw/qa/api/SwXTableCellText.cxx b/sw/qa/api/SwXTableCellText.cxx
new file mode 100644
index 000000000000..733ba36415fd
--- /dev/null
+++ b/sw/qa/api/SwXTableCellText.cxx
@@ -0,0 +1,103 @@
+/* -*- 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/unoapi_test.hxx>
+#include <test/container/xenumerationaccess.hxx>
+#include <test/container/xelementaccess.hxx>
+#include <test/text/xsimpletext.hxx>
+#include <test/text/xtextrange.hxx>
+#include <test/text/xtext.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/XSimpleText.hpp>
+
+using namespace css;
+using namespace css::uno;
+
+namespace
+{
+/**
+ * Initial tests for SwXTableCellText.
+ */
+class SwXTableCellText final : public UnoApiTest,
+                               public apitest::XEnumerationAccess,
+                               public apitest::XElementAccess,
+                               public apitest::XSimpleText,
+                               public apitest::XTextRange,
+                               public apitest::XText
+{
+public:
+    SwXTableCellText()
+        : UnoApiTest("")
+        , XElementAccess(cppu::UnoType<text::XTextRange>::get())
+    {
+    }
+
+    virtual void setUp() override
+    {
+        UnoApiTest::setUp();
+        mxDesktop.set(frame::Desktop::create(mxComponentContext));
+        mxComponent = loadFromDesktop("private:factory/swriter");
+        CPPUNIT_ASSERT(mxComponent.is());
+    }
+
+    Reference<XInterface> init() override
+    {
+        Reference<text::XTextDocument> xTextDocument(mxComponent, 
UNO_QUERY_THROW);
+        Reference<lang::XMultiServiceFactory> xMSF(mxComponent, 
UNO_QUERY_THROW);
+
+        Reference<text::XText> xText = xTextDocument->getText();
+        Reference<text::XTextCursor> xCursor = xText->createTextCursor();
+
+        Reference<text::XTextTable> 
xTable(xMSF->createInstance("com.sun.star.text.TextTable"),
+                                           UNO_QUERY_THROW);
+        xText->insertTextContent(xCursor, xTable, false);
+
+        Reference<table::XCell> xCell = xTable->getCellByName("A1");
+        Reference<text::XSimpleText> xCellText(xCell, UNO_QUERY_THROW);
+        xCellText->setString("SwXTableCellText");
+
+        mxTextContent = Reference<text::XTextContent>(
+            xMSF->createInstance("com.sun.star.text.TextTable"), 
UNO_QUERY_THROW);
+
+        return Reference<XInterface>(xCellText->getText(), UNO_QUERY_THROW);
+    }
+
+    Reference<text::XTextContent> getTextContent() override { return 
mxTextContent; };
+
+    CPPUNIT_TEST_SUITE(SwXTableCellText);
+    CPPUNIT_TEST(testCreateEnumeration);
+    CPPUNIT_TEST(testGetElementType);
+    CPPUNIT_TEST(testHasElements);
+    CPPUNIT_TEST(testCreateTextCursor);
+    CPPUNIT_TEST(testCreateTextCursorByRange);
+    CPPUNIT_TEST(testInsertString);
+    CPPUNIT_TEST(testInsertControlCharacter);
+    CPPUNIT_TEST(testGetEnd);
+    CPPUNIT_TEST(testGetSetString);
+    CPPUNIT_TEST(testGetStart);
+    CPPUNIT_TEST(testGetText);
+    CPPUNIT_TEST(testInsertRemoveTextContent);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    Reference<text::XTextContent> mxTextContent;
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXTableCellText);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to