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

tdf#45904 Move XShapes Java tests to C++

Move XShapes Java tests to C++ for ScDrawPageObj.

Change-Id: I1b65e8ad685c3d387a5023e8e8e9b9e06627af11
Reviewed-on: https://gerrit.libreoffice.org/69904
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst edcbe8c4
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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/.
*/
#ifndef INCLUDED_TEST_DRAWING_XSHAPES_HXX
#define INCLUDED_TEST_DRAWING_XSHAPES_HXX
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <test/testdllapi.hxx>
namespace apitest
{
class OOO_DLLPUBLIC_TEST XShapes
{
public:
virtual css::uno::Reference<css::uno::XInterface> init() = 0;
void setShape(const css::uno::Reference<css::drawing::XShape>& r_xShape)
{
m_xShape = r_xShape;
}
void testAddRemove();
protected:
~XShapes() {}
private:
css::uno::Reference<css::drawing::XShape> m_xShape;
};
} // namespace apitest
#endif // INCLUDED_TEST_DRAWING_XSHAPES_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
......@@ -961,7 +961,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj \
qadevOOo/tests/java/mod/_sc/ScDataPilotItemObj \
qadevOOo/tests/java/mod/_sc/ScDocumentConfiguration \
qadevOOo/tests/java/mod/_sc/ScDrawPageObj \
qadevOOo/tests/java/mod/_sc/ScHeaderFieldObj \
qadevOOo/tests/java/mod/_sc/ScHeaderFieldsObj \
qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor \
......
"ScDrawPageObj";"com::sun::star::drawing::XShapes";"add()"
"ScDrawPageObj";"com::sun::star::drawing::XShapes";"remove()"
/*
* 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package mod._sc;
import java.io.PrintWriter;
import lib.TestCase;
import lib.TestEnvironment;
import lib.TestParameters;
import util.DrawTools;
import util.InstCreator;
import util.SOfficeFactory;
import util.ShapeDsc;
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XDrawPages;
import com.sun.star.drawing.XDrawPagesSupplier;
import com.sun.star.drawing.XShape;
import com.sun.star.lang.XComponent;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
public class ScDrawPageObj extends TestCase {
private XSpreadsheetDocument xDoc = null;
/**
* Creates a new Draw document.
*/
@Override
protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
// get a soffice factory object
SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
log.println( "creating a sheetdocument" );
xDoc = SOF.createCalcDoc(null);
}
/**
* Disposes the Draw document created before
*/
@Override
protected void cleanup( TestParameters tParam, PrintWriter log ) {
log.println( " disposing xSheetDoc " );
XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xDoc);
util.DesktopTools.closeDoc(xComp);
}
/**
* Creating a TestEnvironment for the interfaces to be tested.
* From the Calc document created a collection of its draw
* pages is obtained. Two new pages are inserted. And one
* page is obtained as a testing component. A shape is added
* to this page. <p>
*
* Object relations created :
* <ul>
* <li> <code>'DrawPage'</code> for
* {@link ifc.drawing._XShapeGrouper} :
* the draw page tested. </li>
* <li> <code>'Shape'</code> for
* {@link ifc.drawing._XShapes} :
* the creator which can create instances of
* <code>com.sun.star.drawing.Line</code> service </li>
* </ul>
*/
@Override
protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
XInterface oObj = null;
XShape oShape = null ;
XDrawPages oDP = null;
XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xDoc);
// creation of testobject here
// first we write what we are intend to do to log file
log.println( "creating a test environment" );
log.println( "getting Drawpages" );
XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xDoc);
oDP = oDPS.getDrawPages();
oDP.insertNewByIndex(1);
oDP.insertNewByIndex(2);
oObj = (XDrawPage) AnyConverter.toObject(
new Type(XDrawPage.class),oDP.getByIndex(0));
SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
oShape = SOF.createShape(xComp,5000,3500,7500,5000,"Rectangle");
DrawTools.getShapes((XDrawPage) oObj).add(oShape);
XShape oShape1 = SOF.createShape(xComp,
5000,5500,5000,5000,"Rectangle");
DrawTools.getShapes((XDrawPage) oObj).add(oShape1);
// create test environment here
TestEnvironment tEnv = new TestEnvironment( oObj );
// relation for XShapes interface
ShapeDsc sDsc = new ShapeDsc(5000,3500,7500,10000,"Line");
tEnv.addObjRelation("Shape", new InstCreator(xDoc, sDsc)) ;
log.println("ImplementationName: "+util.utils.getImplName(oObj));
// adding relation for XShapeGrouper
tEnv.addObjRelation("DrawPage", oObj);
return tEnv;
} // finish method getTestEnvironment
}
......@@ -12,6 +12,7 @@
#include <test/container/xelementaccess.hxx>
#include <test/container/xindexaccess.hxx>
#include <test/drawing/xshapegrouper.hxx>
#include <test/drawing/xshapes.hxx>
#include <test/lang/xserviceinfo.hxx>
#include <cppu/unotype.hxx>
......@@ -34,7 +35,8 @@ class ScDrawPageObj : public CalcUnoApiTest,
public apitest::XElementAccess,
public apitest::XIndexAccess,
public apitest::XServiceInfo,
public apitest::XShapeGrouper
public apitest::XShapeGrouper,
public apitest::XShapes
{
public:
ScDrawPageObj();
......@@ -62,6 +64,9 @@ public:
CPPUNIT_TEST(testGroup);
CPPUNIT_TEST(testUngroup);
// XShapes
CPPUNIT_TEST(testAddRemove);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -98,6 +103,8 @@ uno::Reference<uno::XInterface> ScDrawPageObj::init()
// needed for XShapeGrouper tests
setDrawPage(xDrawPage);
// needed for XShapes tests
setShape(apitest::helper::shape::createLine(m_xComponent, 7500, 10000, 5000, 3500));
return xDrawPage;
}
......
......@@ -18,7 +18,6 @@
-o sc.ScDataPilotItemObj
-o sc.ScDatabaseRangeObj
-o sc.ScDocumentConfiguration
-o sc.ScDrawPageObj
# ported to cppunit -o sc.ScHeaderFieldObj
-o sc.ScHeaderFieldsObj
# The two HeaderFooter tests seem to fail randomly
......
......@@ -57,6 +57,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/drawing/captionshape \
test/source/drawing/xdrawpages \
test/source/drawing/xshapegrouper \
test/source/drawing/xshapes \
test/source/lang/xserviceinfo \
test/source/lang/xcomponent \
test/source/sheet/cellarealink \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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/drawing/xshapes.hxx>
#include <sal/types.h>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <cppunit/extensions/HelperMacros.h>
using namespace css;
namespace apitest
{
void XShapes::testAddRemove()
{
uno::Reference<drawing::XShapes> xShapes(init(), uno::UNO_QUERY_THROW);
const sal_Int32 nCountBeforeAdd = xShapes->getCount();
xShapes->add(m_xShape);
const sal_Int32 nCountAfterAdd = xShapes->getCount();
CPPUNIT_ASSERT_EQUAL(nCountBeforeAdd + 1, nCountAfterAdd);
xShapes->remove(m_xShape);
const sal_Int32 nCountAfterRemove = xShapes->getCount();
CPPUNIT_ASSERT_EQUAL(nCountBeforeAdd, nCountAfterRemove);
}
} // namespace apitest
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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