tdf#45904 Move XComponent Java tests to C++
Move XComponent Java tests to C++ for ScShapeObj.
Change-Id: Ib692827729dbe38eaceb76aa042d76e14d9614f8
Reviewed-on: https://gerrit.libreoffice.org/71787
Tested-by: Jenkins
Reviewed-by: Jens Carl <[email protected]>
diff --git a/include/test/lang/xcomponent.hxx b/include/test/lang/xcomponent.hxx
index 347a36e..fdbeccc 100644
--- a/include/test/lang/xcomponent.hxx
+++ b/include/test/lang/xcomponent.hxx
@@ -26,6 +26,7 @@ public:
void testAddEventListener();
void testRemoveEventListener();
void testDispose();
void testDisposedByDesktopTerminate();
protected:
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv
index e7385e4..47138b4 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScShapeObj.csv
@@ -1,6 +1,3 @@
"ScShapeObj";"com::sun::star::lang::XComponent";"dispose()"
"ScShapeObj";"com::sun::star::lang::XComponent";"addEventListener()"
"ScShapeObj";"com::sun::star::lang::XComponent";"removeEventListener()"
"ScShapeObj";"com::sun::star::drawing::Shape";"ZOrder#optional"
"ScShapeObj";"com::sun::star::drawing::Shape";"LayerID#optional"
"ScShapeObj";"com::sun::star::drawing::Shape";"LayerName#optional"
diff --git a/sc/qa/extras/scshapeobj.cxx b/sc/qa/extras/scshapeobj.cxx
index 279b07d..2a1be66 100644
--- a/sc/qa/extras/scshapeobj.cxx
+++ b/sc/qa/extras/scshapeobj.cxx
@@ -8,6 +8,7 @@
*/
#include <test/calc_unoapi_test.hxx>
#include <test/lang/xcomponent.hxx>
#include <test/sheet/shape.hxx>
#include <com/sun/star/awt/Point.hpp>
@@ -25,17 +26,17 @@
#include <com/sun/star/uno/Reference.hxx>
using namespace css;
using namespace css::uno;
namespace sc_apitest
{
class ScShapeObj : public CalcUnoApiTest, public apitest::Shape
class ScShapeObj : public CalcUnoApiTest, public apitest::Shape, public apitest::XComponent
{
public:
ScShapeObj();
virtual uno::Reference<uno::XInterface> init() override;
virtual uno::Reference<uno::XInterface> getXSheetDocument() override;
virtual void triggerDesktopTerminate() override{};
virtual void setUp() override;
virtual void tearDown() override;
@@ -45,6 +46,11 @@ public:
CPPUNIT_TEST(testShapePropertiesAnchor);
CPPUNIT_TEST(testShapePropertiesPosition);
// XComponent
CPPUNIT_TEST(testAddEventListener);
CPPUNIT_TEST(testDispose);
CPPUNIT_TEST(testRemoveEventListener);
CPPUNIT_TEST_SUITE_END();
private:
@@ -58,18 +64,18 @@ ScShapeObj::ScShapeObj()
uno::Reference<uno::XInterface> ScShapeObj::init()
{
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, uno::UNO_QUERY_THROW);
uno::Reference<drawing::XShape> xShape(
xMSF->createInstance("com.sun.star.drawing.RectangleShape"), UNO_QUERY_THROW);
xMSF->createInstance("com.sun.star.drawing.RectangleShape"), uno::UNO_QUERY_THROW);
xShape->setPosition(awt::Point(5000, 3500));
xShape->setSize(awt::Size(7500, 5000));
uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDoc, UNO_QUERY_THROW);
uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDoc, uno::UNO_QUERY_THROW);
uno::Reference<drawing::XDrawPages> xDrawPages = xDPS->getDrawPages();
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), UNO_QUERY_THROW);
uno::Reference<drawing::XShapes> xShapes(xDrawPage, UNO_QUERY_THROW);
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
uno::Reference<drawing::XShapes> xShapes(xDrawPage, uno::UNO_QUERY_THROW);
xShapes->add(xShape);
for (auto i = 0; i < 10; i++)
@@ -84,7 +90,7 @@ uno::Reference<uno::XInterface> ScShapeObj::init()
uno::Reference<uno::XInterface> ScShapeObj::getXSheetDocument()
{
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW);
return xDoc;
}
@@ -103,7 +109,7 @@ void ScShapeObj::tearDown()
CPPUNIT_TEST_SUITE_REGISTRATION(ScShapeObj);
} // end namespace
} // namespace sc_apitest
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/test/source/lang/xcomponent.cxx b/test/source/lang/xcomponent.cxx
index 386fa45..ef0049d 100644
--- a/test/source/lang/xcomponent.cxx
+++ b/test/source/lang/xcomponent.cxx
@@ -57,6 +57,16 @@ void XComponent::testRemoveEventListener()
CPPUNIT_ASSERT_EQUAL(false, pListenerAddedAndRemoved->m_hasDisposingCalled);
}
void XComponent::testDispose()
{
Reference<lang::XComponent> xComponent(init(), uno::UNO_QUERY_THROW);
auto pListenerAdded(new TestEventListener());
Reference<lang::XEventListener> xListenerAdded(pListenerAdded);
xComponent->addEventListener(xListenerAdded);
xComponent->dispose();
CPPUNIT_ASSERT_EQUAL(true, pListenerAdded->m_hasDisposingCalled);
}
void XComponent::testDisposedByDesktopTerminate()
{
Reference<lang::XComponent> xComponent(init(), uno::UNO_QUERY_THROW);