diff options
Diffstat (limited to 'test/source/drawing')
-rw-r--r-- | test/source/drawing/captionshape.cxx | 178 | ||||
-rw-r--r-- | test/source/drawing/xdrawpages.cxx | 50 | ||||
-rw-r--r-- | test/source/drawing/xgluepointssupplier.cxx | 32 | ||||
-rw-r--r-- | test/source/drawing/xshape.cxx | 56 | ||||
-rw-r--r-- | test/source/drawing/xshapedescriptor.cxx | 30 | ||||
-rw-r--r-- | test/source/drawing/xshapegrouper.cxx | 57 | ||||
-rw-r--r-- | test/source/drawing/xshapes.cxx | 38 |
7 files changed, 441 insertions, 0 deletions
diff --git a/test/source/drawing/captionshape.cxx b/test/source/drawing/captionshape.cxx new file mode 100644 index 000000000..66093e70d --- /dev/null +++ b/test/source/drawing/captionshape.cxx @@ -0,0 +1,178 @@ +/* -*- 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/cppunitasserthelper.hxx> +#include <test/drawing/captionshape.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/awt/Point.hpp> + +#include <cppunit/TestAssert.h> + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest +{ +void CaptionShape::testCaptionShapeProperties() +{ + uno::Reference<beans::XPropertySet> xCaptionShape(init(), UNO_QUERY_THROW); + OUString propName; + uno::Any aNewValue; + + propName = "CornerRadius"; + sal_Int32 nCornerRadiusGet = 5; + sal_Int32 nCornerRadiusSet = 0; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CornerRadius", + xCaptionShape->getPropertyValue(propName) >>= nCornerRadiusGet); + + aNewValue <<= nCornerRadiusGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= nCornerRadiusSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue CornerRadius", nCornerRadiusGet + 5, + nCornerRadiusSet); + + propName = "CaptionPoint"; + awt::Point aCaptionPointGet; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionPoint", + xCaptionShape->getPropertyValue(propName) >>= aCaptionPointGet); + + awt::Point aCaptionPointSet; + aNewValue <<= awt::Point(5, 5); + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= aCaptionPointSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue of CaptionPoint", aCaptionPointSet, + awt::Point(5, 5)); + + propName = "CaptionType"; + sal_Int16 captionTypeGet = 0; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionType", + xCaptionShape->getPropertyValue(propName) >>= captionTypeGet); + + sal_Int16 captionTypeSet = 0; + const sal_Int16 FIVE = 5; + aNewValue <<= FIVE; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionTypeSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionType", FIVE, + captionTypeSet); + + propName = "CaptionIsFixedAngle"; + bool captionIsFixedAngleGet = false; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionPointIsFixedAngle", + xCaptionShape->getPropertyValue(propName) >>= captionIsFixedAngleGet); + + bool captionIsFixedAngleSet = false; + aNewValue <<= !captionIsFixedAngleGet; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionIsFixedAngleSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionPointisFixedAngle", + captionIsFixedAngleSet, !captionIsFixedAngleGet); + + propName = "CaptionAngle"; + sal_Int32 captionAngleGet = {}; + CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionAngle", + xCaptionShape->getPropertyValue(propName) >>= captionAngleGet); + + sal_Int32 captionAngleSet = 0; + aNewValue <<= captionAngleGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionAngleSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionAngle", captionAngleSet, + captionAngleGet + 5); + + propName = "CaptionGap"; + sal_Int32 captionGapGet = {}; + CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionGap", + xCaptionShape->getPropertyValue(propName) >>= captionGapGet); + + sal_Int32 captionGapSet = 0; + aNewValue <<= captionGapGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionGapSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionGap", captionGapSet, + captionGapGet + 5); + + propName = "CaptionEscapeDirection"; + sal_Int32 captionEscapeDirectionGet = {}; + CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeDirection", + xCaptionShape->getPropertyValue(propName) >>= captionEscapeDirectionGet); + + sal_Int32 captionEscapeDirectionSet = 0; + aNewValue <<= captionEscapeDirectionGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionEscapeDirectionSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeDirection", + captionEscapeDirectionSet, captionEscapeDirectionGet + 5); + + propName = "CaptionIsEscapeRelative"; + bool captionIsEscapeRelativeGet = false; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionIsEscapeRelative", + xCaptionShape->getPropertyValue(propName) + >>= captionIsEscapeRelativeGet); + + bool captionIsEscapeRelativeSet = false; + aNewValue <<= !captionIsEscapeRelativeGet; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionIsEscapeRelativeSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionIsEscapeRelative", + captionIsEscapeRelativeSet, !captionIsEscapeRelativeGet); + + propName = "CaptionEscapeRelative"; + sal_Int32 captionEscapeRelativeGet = {}; + CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeRelative", + xCaptionShape->getPropertyValue(propName) >>= captionEscapeRelativeGet); + + sal_Int32 captionEscapeRelativeSet = 0; + aNewValue <<= captionEscapeRelativeGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionEscapeRelativeSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeRelative", + captionEscapeRelativeSet, captionEscapeRelativeGet + 5); + + propName = "CaptionEscapeAbsolute"; + sal_Int32 captionEscapeAbsoluteGet = {}; + CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionEscapeAbsolute", + xCaptionShape->getPropertyValue(propName) >>= captionEscapeAbsoluteGet); + + sal_Int32 captionEscapeAbsoluteSet = 0; + aNewValue <<= captionEscapeAbsoluteGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionEscapeAbsoluteSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeAbsolute", + captionEscapeAbsoluteSet, captionEscapeAbsoluteGet + 5); + + propName = "CaptionLineLength"; + sal_Int32 captionLineLengthGet = {}; + CPPUNIT_ASSERT_MESSAGE("Unable to get the PropertyValue of CaptionLineLength", + xCaptionShape->getPropertyValue(propName) >>= captionLineLengthGet); + + sal_Int32 captionLineLengthSet = 0; + aNewValue <<= captionLineLengthGet + 5; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionLineLengthSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionEscapeAbsolute", + captionLineLengthSet, captionLineLengthGet + 5); + + propName = "CaptionIsFitLineLength"; + bool captionIsFitLineLengthGet = false; + CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue of CaptionIsFitLineLength", + xCaptionShape->getPropertyValue(propName) >>= captionIsFitLineLengthGet); + + bool captionIsFitLineLengthSet = false; + aNewValue <<= !captionIsFitLineLengthGet; + xCaptionShape->setPropertyValue(propName, aNewValue); + CPPUNIT_ASSERT(xCaptionShape->getPropertyValue(propName) >>= captionIsFitLineLengthSet); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set the PropertyValue of CaptionIsFitLineLength", + captionIsFitLineLengthSet, !captionIsFitLineLengthGet); +} +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/drawing/xdrawpages.cxx b/test/source/drawing/xdrawpages.cxx new file mode 100644 index 000000000..be57c4852 --- /dev/null +++ b/test/source/drawing/xdrawpages.cxx @@ -0,0 +1,50 @@ +/* -*- 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/xdrawpages.hxx> + +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XDrawPages.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <sal/types.h> + +#include <cppunit/TestAssert.h> + +using namespace css; +using namespace css::uno; + +namespace apitest +{ +void XDrawPages::testInsertNewByIndex() +{ + uno::Reference<drawing::XDrawPages> xDrawPages(init(), uno::UNO_QUERY_THROW); + const sal_Int32 nCount = xDrawPages->getCount(); + + uno::Reference<drawing::XDrawPage> xDP(xDrawPages->insertNewByIndex(0), uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xDP.is()); + CPPUNIT_ASSERT_EQUAL(nCount + 1, xDrawPages->getCount()); +} + +void XDrawPages::testRemove() +{ + uno::Reference<drawing::XDrawPages> xDrawPages(init(), uno::UNO_QUERY_THROW); + const sal_Int32 nCount = xDrawPages->getCount(); + + uno::Reference<drawing::XDrawPage> xDP(xDrawPages->insertNewByIndex(0), uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xDP.is()); + + xDrawPages->remove(xDP); + CPPUNIT_ASSERT_EQUAL(nCount, xDrawPages->getCount()); +} + +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/drawing/xgluepointssupplier.cxx b/test/source/drawing/xgluepointssupplier.cxx new file mode 100644 index 000000000..186c18d71 --- /dev/null +++ b/test/source/drawing/xgluepointssupplier.cxx @@ -0,0 +1,32 @@ +/* -*- 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/xgluepointssupplier.hxx> + +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/drawing/XGluePointsSupplier.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/TestAssert.h> + +using namespace css; + +namespace apitest +{ +void XGluePointsSupplier::testGetGluePoints() +{ + uno::Reference<drawing::XGluePointsSupplier> xGPS(init(), uno::UNO_QUERY_THROW); + + uno::Reference<container::XIndexContainer> xIC = xGPS->getGluePoints(); + CPPUNIT_ASSERT(xIC->getCount()); +} +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/drawing/xshape.cxx b/test/source/drawing/xshape.cxx new file mode 100644 index 000000000..a63b89265 --- /dev/null +++ b/test/source/drawing/xshape.cxx @@ -0,0 +1,56 @@ +/* -*- 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/xshape.hxx> +#include <test/cppunitasserthelper.hxx> + +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/drawing/XShape.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/TestAssert.h> + +using namespace css; + +namespace apitest +{ +void XShape::testGetSetPosition() +{ + uno::Reference<drawing::XShape> xShape(init(), uno::UNO_QUERY_THROW); + if (m_bObjSupportsPosition) + { + awt::Point aOldPoint = xShape->getPosition(); + CPPUNIT_ASSERT_NO_THROW( + xShape->setPosition(awt::Point(aOldPoint.X + 100, aOldPoint.Y + 100))); + + awt::Point aNewPoint = xShape->getPosition(); + CPPUNIT_ASSERT_EQUAL(awt::Point(aOldPoint.X + 100, aOldPoint.Y + 100), aNewPoint); + } + CPPUNIT_ASSERT(true); +} + +void XShape::testGetSetSize() +{ + uno::Reference<drawing::XShape> xShape(init(), uno::UNO_QUERY_THROW); + + awt::Size aOldSize = xShape->getSize(); + + CPPUNIT_ASSERT_NO_THROW(xShape->setSize(awt::Size(aOldSize.Width + 10, aOldSize.Height + 10))); + + awt::Size aNewSize = xShape->getSize(); + const sal_Int16 aAcceptableLimit = 2; + CPPUNIT_ASSERT(aOldSize.Height - aNewSize.Height <= aAcceptableLimit); + CPPUNIT_ASSERT(aOldSize.Height - aNewSize.Height <= aAcceptableLimit); +} + +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/drawing/xshapedescriptor.cxx b/test/source/drawing/xshapedescriptor.cxx new file mode 100644 index 000000000..ff14513ef --- /dev/null +++ b/test/source/drawing/xshapedescriptor.cxx @@ -0,0 +1,30 @@ +/* -*- 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/xshapedescriptor.hxx> + +#include <com/sun/star/drawing/XShapeDescriptor.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/TestAssert.h> + +using namespace css; + +namespace apitest +{ +void XShapeDescriptor::testGetShapeType() +{ + uno::Reference<drawing::XShapeDescriptor> xSD(init(), uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT_EQUAL(m_aShapeType, xSD->getShapeType()); +} +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/drawing/xshapegrouper.cxx b/test/source/drawing/xshapegrouper.cxx new file mode 100644 index 000000000..353faa1e7 --- /dev/null +++ b/test/source/drawing/xshapegrouper.cxx @@ -0,0 +1,57 @@ +/* -*- 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/xshapegrouper.hxx> +#include <sal/types.h> + +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/XShapeGroup.hpp> +#include <com/sun/star/drawing/XShapeGrouper.hpp> +#include <com/sun/star/drawing/XShapes.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/TestAssert.h> + +using namespace css; + +namespace apitest +{ +void XShapeGrouper::testGroup() +{ + uno::Reference<drawing::XShapeGrouper> xSG(init(), uno::UNO_QUERY_THROW); + + uno::Reference<drawing::XShapes> xShapes(m_xDrawPage, uno::UNO_QUERY_THROW); + const sal_Int32 nCountBeforeGroup = xShapes->getCount(); + + uno::Reference<drawing::XShape> xShape(xSG->group(xShapes), uno::UNO_QUERY_THROW); + const sal_Int32 nCountAfterGroup = xShapes->getCount(); + + CPPUNIT_ASSERT(xShape.is()); + CPPUNIT_ASSERT(nCountAfterGroup < nCountBeforeGroup); +} + +void XShapeGrouper::testUngroup() +{ + uno::Reference<drawing::XShapeGrouper> xSG(init(), uno::UNO_QUERY_THROW); + + uno::Reference<drawing::XShapes> xShapes(m_xDrawPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xSG->group(xShapes), uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShapeGroup> xShapeGroup(xShape, uno::UNO_QUERY_THROW); + + const sal_Int32 nCountAfterGroup = xShapes->getCount(); + + xSG->ungroup(xShapeGroup); + const sal_Int32 nCountAfterUngroup = xShapes->getCount(); + + CPPUNIT_ASSERT(nCountAfterUngroup != nCountAfterGroup); +} +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/drawing/xshapes.cxx b/test/source/drawing/xshapes.cxx new file mode 100644 index 000000000..d836daf2b --- /dev/null +++ b/test/source/drawing/xshapes.cxx @@ -0,0 +1,38 @@ +/* -*- 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/TestAssert.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: */ |