sw/CppunitTest_sw_apitests.mk |    1 
 sw/qa/api/SwXBodyText.cxx     |  100 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+)

New commits:
commit ed78d54f7caf1d556ed16f8c78437845541377be
Author:     anfanite396 <[email protected]>
AuthorDate: Fri Jun 23 16:58:15 2023 +0530
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Mon Jun 26 14:38:50 2023 +0200

    Move SwXBodyText Java tests to C++
    
    Change-Id: I5d2807125fb374d8d05718d8bf5415d30f1a992a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153503
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/sw/CppunitTest_sw_apitests.mk b/sw/CppunitTest_sw_apitests.mk
index 716607dbe404..e71270e4d4db 100644
--- a/sw/CppunitTest_sw_apitests.mk
+++ b/sw/CppunitTest_sw_apitests.mk
@@ -16,6 +16,7 @@ $(eval $(call 
gb_CppunitTest_use_external,sw_apitests,boost_headers))
 $(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_apitests))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sw_apitests, \
+    sw/qa/api/SwXBodyText \
     sw/qa/api/SwXDocumentIndex \
     sw/qa/api/SwXDocumentSettings \
        sw/qa/api/SwXTextFrame \
diff --git a/sw/qa/api/SwXBodyText.cxx b/sw/qa/api/SwXBodyText.cxx
new file mode 100644
index 000000000000..d364ba3a8aa0
--- /dev/null
+++ b/sw/qa/api/SwXBodyText.cxx
@@ -0,0 +1,100 @@
+/* -*- 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/bootstrapfixture.hxx>
+#include <test/text/xsimpletext.hxx>
+#include <test/container/xelementaccess.hxx>
+#include <test/text/xtextrange.hxx>
+#include <test/container/xenumerationaccess.hxx>
+#include <unotest/macros_test.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 <comphelper/processfactory.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace
+{
+/**
+ * Initial tests for SwXBodyText.
+ */
+class SwXBodyText final : public test::BootstrapFixture,
+                          public unotest::MacrosTest,
+                          public apitest::XElementAccess,
+                          public apitest::XTextRange,
+                          public apitest::XSimpleText,
+                          public apitest::XEnumerationAccess
+{
+public:
+    SwXBodyText();
+    virtual void setUp() override;
+    void tearDown() override;
+
+    Reference<XInterface> init() override;
+
+    CPPUNIT_TEST_SUITE(SwXBodyText);
+    CPPUNIT_TEST(testCreateTextCursor);
+    CPPUNIT_TEST(testCreateTextCursorByRange);
+    CPPUNIT_TEST(testInsertString);
+    CPPUNIT_TEST(testInsertControlCharacter);
+    CPPUNIT_TEST(testGetElementType);
+    CPPUNIT_TEST(testHasElements);
+    CPPUNIT_TEST(testGetText);
+    CPPUNIT_TEST(testGetStart);
+    CPPUNIT_TEST(testGetEnd);
+    CPPUNIT_TEST(testGetSetString);
+    CPPUNIT_TEST(testCreateEnumeration);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<lang::XComponent> component_;
+};
+
+SwXBodyText::SwXBodyText()
+    : XElementAccess(cppu::UnoType<text::XTextRange>::get())
+{
+}
+
+void SwXBodyText::setUp()
+{
+    test::BootstrapFixture::setUp();
+    mxDesktop.set(
+        
frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+}
+
+void SwXBodyText::tearDown()
+{
+    if (component_.is())
+        component_->dispose();
+
+    test::BootstrapFixture::tearDown();
+}
+
+Reference<XInterface> SwXBodyText::init()
+{
+    component_ = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+    Reference<text::XTextDocument> xTextDocument(component_, UNO_QUERY_THROW);
+    Reference<lang::XMultiServiceFactory> xMSF(component_, UNO_QUERY_THROW);
+
+    Reference<text::XText> xText = xTextDocument->getText();
+
+    return Reference<XInterface>(xText, UNO_QUERY_THROW);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SwXBodyText);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to