Kaydet (Commit) 35608a19 authored tarafından Jens Carl's avatar Jens Carl

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: 's avatarJens Carl <j.carl43@gmx.de>
üst 2ddc66e6
......@@ -26,6 +26,7 @@ public:
void testAddEventListener();
void testRemoveEventListener();
void testDispose();
void testDisposedByDesktopTerminate();
protected:
......
"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"
......
......@@ -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();
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment