summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2022-02-27 00:00:17 -0800
committerJens Carl <j.carl43@gmx.de>2022-02-28 06:27:21 +0100
commita1877ab81b396c742c58a13d3830b4637db924c0 (patch)
tree6025a515733fb3f5adba94d5f5902aa0c74ff25b /sc
parent694d031fe470683a2f8e0fd3ae443fc829b6e26d (diff)
tdf#45904 Move XElementAccess Java test to C++
Move XElementAccess Java test to C++ for ScHeaderFieldsObj. Change-Id: I1bc29be9f17d117edecfd889b4f9784ffbd74d71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130660 Tested-by: Jenkins Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/extras/scheaderfieldsobj.cxx22
-rw-r--r--sc/qa/unoapi/sc_4.sce1
2 files changed, 19 insertions, 4 deletions
diff --git a/sc/qa/extras/scheaderfieldsobj.cxx b/sc/qa/extras/scheaderfieldsobj.cxx
index 2265fb795d83..a03e00329104 100644
--- a/sc/qa/extras/scheaderfieldsobj.cxx
+++ b/sc/qa/extras/scheaderfieldsobj.cxx
@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
+#include <test/container/xelementaccess.hxx>
#include <test/container/xenumerationaccess.hxx>
#include <test/util/xrefreshable.hxx>
@@ -21,6 +22,7 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/uno/XInterface.hpp>
@@ -31,6 +33,7 @@ using namespace css;
namespace sc_apitest
{
class ScHeaderFieldsObj : public CalcUnoApiTest,
+ public apitest::XElementAccess,
public apitest::XEnumerationAccess,
public apitest::XRefreshable
{
@@ -43,6 +46,10 @@ public:
CPPUNIT_TEST_SUITE(ScHeaderFieldsObj);
+ // XElementAccess
+ CPPUNIT_TEST(testGetElementType);
+ CPPUNIT_TEST(testHasElements);
+
// XEnumerationAccess
CPPUNIT_TEST(testCreateEnumeration);
@@ -53,10 +60,17 @@ public:
private:
uno::Reference<lang::XComponent> m_xComponent;
+ // We need a long living reference to css::text::XText to make the
+ // XElementAccess::hasElements() test work as ScHeaderFooterEditSource holds
+ // only (weak) references and they sometimes are gone.
+ static uno::Reference<text::XText> m_xText;
};
+uno::Reference<text::XText> ScHeaderFieldsObj::m_xText;
+
ScHeaderFieldsObj::ScHeaderFieldsObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
+ , ::apitest::XElementAccess(cppu::UnoType<text::XTextField>::get())
{
}
@@ -72,15 +86,15 @@ uno::Reference<uno::XInterface> ScHeaderFieldsObj::init()
uno::Reference<beans::XPropertySet> xPropertySet(xStyle, uno::UNO_QUERY_THROW);
uno::Reference<sheet::XHeaderFooterContent> xHFC(
xPropertySet->getPropertyValue("RightPageHeaderContent"), uno::UNO_QUERY_THROW);
- uno::Reference<text::XText> xText(xHFC->getLeftText(), uno::UNO_SET_THROW);
+ m_xText = xHFC->getLeftText();
uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, uno::UNO_QUERY_THROW);
uno::Reference<text::XTextContent> xTC(xMSF->createInstance("com.sun.star.text.TextField.Time"),
uno::UNO_QUERY_THROW);
- xText->insertTextContent(xText->createTextCursor(), xTC, false);
+ m_xText->insertTextContent(m_xText->createTextCursor(), xTC, false);
xPropertySet->setPropertyValue("RightPageHeaderContent", uno::makeAny(xHFC));
- uno::Reference<text::XTextFieldsSupplier> xTFS(xText, uno::UNO_QUERY_THROW);
+ uno::Reference<text::XTextFieldsSupplier> xTFS(m_xText, uno::UNO_QUERY_THROW);
return xTFS->getTextFields();
}
@@ -93,6 +107,8 @@ void ScHeaderFieldsObj::setUp()
void ScHeaderFieldsObj::tearDown()
{
+ m_xText.clear();
+
closeDocument(m_xComponent);
CalcUnoApiTest::tearDown();
}
diff --git a/sc/qa/unoapi/sc_4.sce b/sc/qa/unoapi/sc_4.sce
index 50727b8425fa..2d221d1bad3a 100644
--- a/sc/qa/unoapi/sc_4.sce
+++ b/sc/qa/unoapi/sc_4.sce
@@ -19,7 +19,6 @@
-o sc.ScDatabaseRangeObj
-o sc.ScDocumentConfiguration
# ported to cppunit -o sc.ScHeaderFieldObj
--o sc.ScHeaderFieldsObj
# The two HeaderFooter tests seem to fail randomly
# -o sc.ScHeaderFooterTextCursor
# SHF_TextObj is composed of SHF_TextData, which has a weak reference to