[Libreoffice-commits] core.git: test/inc test/source
test/inc/helper/form.hxx| 17 - test/source/helper/form.cxx | 25 +++-- test/source/view/xcontrolaccess.cxx |5 +++-- 3 files changed, 30 insertions(+), 17 deletions(-) New commits: commit 1e2868296730d3548574f61a3c6e323aa5c0598a Author: Jens Carl AuthorDate: Wed Mar 27 19:34:16 2019 + Commit: Jens Carl CommitDate: Thu Mar 28 19:55:35 2019 +0100 Be consistent with namespaces and parameter order for UNO Api helpers Have this file the same namespaces as the new introduced helpers in include/test/helper/shape.hxx and also change the order of the parameter be the same to avoid confusion. Change-Id: I5614e9a79dff3ee9aca96ff2e50ddfafa83de539 Reviewed-on: https://gerrit.libreoffice.org/69870 Tested-by: Jenkins Reviewed-by: Jens Carl diff --git a/test/inc/helper/form.hxx b/test/inc/helper/form.hxx index 173306b118c8..271f06be0b7e 100644 --- a/test/inc/helper/form.hxx +++ b/test/inc/helper/form.hxx @@ -22,19 +22,26 @@ namespace apitest { +namespace helper +{ +namespace form +{ /** @brief Create a XControlShape * * @param r_xComponent The document. - * @param nHeight The height of the shape. - * @param nWidthThe width of the shape. + * @param r_aKind The kind of the shape. * @param nXThe x-position of the shape. * @param nYThe y-position of the shape. - * @param r_aKind The kind of the shape. + * @param nHeight The height of the shape. + * @param nWidthThe width of the shape. + * @return The create XControlShape. */ css::uno::Reference OOO_DLLPUBLIC_TEST createControlShape( -const css::uno::Reference& r_xComponent, const sal_Int32 nHeight, -const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY, const OUString& r_aKind); +const css::uno::Reference& r_xComponent, const OUString& r_aKind, +const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth); +} // namespace form +} // namespace helper } // namespace apitest #endif // INCLUDED_TEST_INC_HELPER_FORM_HXX diff --git a/test/source/helper/form.cxx b/test/source/helper/form.cxx index 47da3565f79d..610bd43f1a51 100644 --- a/test/source/helper/form.cxx +++ b/test/source/helper/form.cxx @@ -8,6 +8,8 @@ */ #include +#include +#include #include #include @@ -16,19 +18,20 @@ #include #include +#include #include -#include -#include - using namespace css; namespace apitest { -uno::Reference -createControlShape(const uno::Reference& r_xComponent, const sal_Int32 nHeight, - const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY, - const OUString& r_aKind) +namespace helper +{ +namespace form +{ +uno::Reference OOO_DLLPUBLIC_TEST createControlShape( +const uno::Reference& r_xComponent, const OUString& r_aKind, +const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth) { uno::Reference xMSF(r_xComponent, uno::UNO_QUERY_THROW); @@ -38,9 +41,8 @@ createControlShape(const uno::Reference& r_xComponent, const s uno::Reference aComponent( xMSF->createInstance("com.sun.star.form.component." + r_aKind), uno::UNO_QUERY_THROW); uno::Reference xPropertySet(aComponent, uno::UNO_QUERY_THROW); -uno::Any aValue; -aValue <<= "com.sun.star.form.control." + r_aKind; -xPropertySet->setPropertyValue("DefaultControl", aValue); +xPropertySet->setPropertyValue("DefaultControl", + uno::makeAny("com.sun.star.form.control." + r_aKind)); uno::Reference xControlModel(aComponent, uno::UNO_QUERY_THROW); xControlShape->setSize(awt::Size(nHeight, nWidth)); @@ -50,6 +52,9 @@ createControlShape(const uno::Reference& r_xComponent, const s return xControlShape; } + +} // namespace form +} // namespace helper } // namespace apitest /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/view/xcontrolaccess.cxx b/test/source/view/xcontrolaccess.cxx index 29ca1fa339aa..5f00e88a5f63 100644 --- a/test/source/view/xcontrolaccess.cxx +++ b/test/source/view/xcontrolaccess.cxx @@ -21,10 +21,11 @@ #include #include +#include + #include using namespace css; -using namespace css::uno; namespace apitest { @@ -39,7 +40,7 @@ void XControlAccess::testGetControl() uno::Reference xShapes(xDP, uno::UNO_QUERY_THROW); uno::Reference xShape( -createControlShape(xComponent, 100, 100, 1, 5, "CommandButton"), +helper::form::createControlShape(xComponent, "CommandButton", 1, 5, 100, 100), uno::UNO_QUERY_THROW); xShapes->add(xShape); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commi
[Libreoffice-commits] core.git: test/inc test/Library_test.mk test/source
test/Library_test.mk|2 + test/inc/helper/form.hxx| 42 + test/source/helper/form.cxx | 55 3 files changed, 99 insertions(+) New commits: commit 04ca6792748eb410e997e8c6a5d4a18c9e9c531a Author: Jens Carl AuthorDate: Wed Dec 5 04:56:57 2018 + Commit: Jens Carl CommitDate: Wed Dec 5 10:47:09 2018 +0100 Make helper to create XControlShape. Change-Id: I74dc16cde0acdbc995a8808b8e8005c66c300823 Reviewed-on: https://gerrit.libreoffice.org/64584 Tested-by: Jenkins Reviewed-by: Jens Carl diff --git a/test/Library_test.mk b/test/Library_test.mk index 92097613eb4d..1e4a013e1e4b 100644 --- a/test/Library_test.mk +++ b/test/Library_test.mk @@ -10,6 +10,7 @@ $(eval $(call gb_Library_Library,test)) $(eval $(call gb_Library_set_include,test,\ + -I$(SRCDIR)/test/inc \ $$(INCLUDE) \ )) @@ -52,6 +53,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\ test/source/primitive2dxmldump \ test/source/screenshot_test \ test/source/unoapi_property_testers \ + test/source/helper/form \ )) # vim: set noet sw=4 ts=4: diff --git a/test/inc/helper/form.hxx b/test/inc/helper/form.hxx new file mode 100644 index ..173306b118c8 --- /dev/null +++ b/test/inc/helper/form.hxx @@ -0,0 +1,42 @@ +/* -*- 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_INC_HELPER_FORM_HXX +#define INCLUDED_TEST_INC_HELPER_FORM_HXX + +#include +#include + +#include + +#include +#include +#include +#include + +namespace apitest +{ +/** @brief Create a XControlShape + * + * @param r_xComponent The document. + * @param nHeight The height of the shape. + * @param nWidthThe width of the shape. + * @param nXThe x-position of the shape. + * @param nYThe y-position of the shape. + * @param r_aKind The kind of the shape. + */ +css::uno::Reference OOO_DLLPUBLIC_TEST createControlShape( +const css::uno::Reference& r_xComponent, const sal_Int32 nHeight, +const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY, const OUString& r_aKind); + +} // namespace apitest + +#endif // INCLUDED_TEST_INC_HELPER_FORM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/helper/form.cxx b/test/source/helper/form.cxx new file mode 100644 index ..47da3565f79d --- /dev/null +++ b/test/source/helper/form.cxx @@ -0,0 +1,55 @@ +/* -*- 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 + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +using namespace css; + +namespace apitest +{ +uno::Reference +createControlShape(const uno::Reference& r_xComponent, const sal_Int32 nHeight, + const sal_Int32 nWidth, const sal_Int32 nX, const sal_Int32 nY, + const OUString& r_aKind) +{ +uno::Reference xMSF(r_xComponent, uno::UNO_QUERY_THROW); + +uno::Reference xControlShape( +xMSF->createInstance("com.sun.star.drawing.ControlShape"), uno::UNO_QUERY_THROW); + +uno::Reference aComponent( +xMSF->createInstance("com.sun.star.form.component." + r_aKind), uno::UNO_QUERY_THROW); +uno::Reference xPropertySet(aComponent, uno::UNO_QUERY_THROW); +uno::Any aValue; +aValue <<= "com.sun.star.form.control." + r_aKind; +xPropertySet->setPropertyValue("DefaultControl", aValue); +uno::Reference xControlModel(aComponent, uno::UNO_QUERY_THROW); + +xControlShape->setSize(awt::Size(nHeight, nWidth)); +xControlShape->setPosition(awt::Point(nX, nY)); + +xControlShape->setControl(xControlModel); + +return xControlShape; +} +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: test/inc test/source
test/inc/unoapi_property_testers.hxx| 42 +++ test/source/unoapi_property_testers.cxx | 87 ++-- 2 files changed, 123 insertions(+), 6 deletions(-) New commits: commit 940f90f3da170b62379e9d1d33d4e6d690997026 Author: Jens Carl Date: Thu Mar 29 06:24:58 2018 + Add UNO API property tester for common read-only properties. Add UNO API property tester for read-only properties 'double', 'long', 'short' and 'string'. Change-Id: I7177e133972058b0272a3cf8493521fbfbcade32 Reviewed-on: https://gerrit.libreoffice.org/52142 Tested-by: Jenkins Reviewed-by: Jens Carl diff --git a/test/inc/unoapi_property_testers.hxx b/test/inc/unoapi_property_testers.hxx index 43e0f506c18f..616ab3bc0cb5 100644 --- a/test/inc/unoapi_property_testers.hxx +++ b/test/inc/unoapi_property_testers.hxx @@ -44,6 +44,16 @@ void OOO_DLLPUBLIC_TEST testDoubleProperty(css::uno::Reference& xPropertySet, const OUString& name, const double& dValue = 42.0); +/** @brief Tester for read-only property type 'double' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySetThe property set, which contains the property to test against. + * @param nameName of property to test. + * @param nValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testDoubleReadonlyProperty(css::uno::Reference& xPropertySet, + const OUString& name, const double& dValue = 42.0); + /** @brief Tester for property type 'long' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. @@ -54,6 +64,16 @@ void OOO_DLLPUBLIC_TEST testLongProperty(css::uno::Reference& xPropertySet, const OUString& name, const sal_Int32& nValue = 42); +/** @brief Tester for read-only property type 'long' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySetThe property set, which contains the property to test against. + * @param nameName of property to test. + * @param nValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testLongReadonlyProperty(css::uno::Reference& xPropertySet, + const OUString& name, const sal_Int32& nValue = 42); + /** @brief Tester for property type 'short' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. @@ -64,6 +84,16 @@ void OOO_DLLPUBLIC_TEST testShortProperty(css::uno::Reference& xPropertySet, const OUString& name, const sal_Int16& nValue = 42); +/** @brief Tester for read-only property type 'short' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySetThe property set, which contains the property to test against. + * @param nameName of property to test. + * @param nValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testShortReadonlyProperty(css::uno::Reference& xPropertySet, + const OUString& name, const sal_Int16& nValue = 42); + /** @brief Tester for property type 'string' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. @@ -73,7 +103,17 @@ testShortProperty(css::uno::Reference& xPropertySet, c void OOO_DLLPUBLIC_TEST testStringProperty(css::uno::Reference& xPropertySet, const OUString& name, const OUString& rValue); -} + +/** @brief Tester for read-only property type 'string' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySetThe property set, which contains the property to test against. + * @param nameName of property to test. + * @param rValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testStringReadonlyProperty(css::uno::Reference& xPropertySet, + const OUString& name, const OUString& rValue); +} // namespace apitest #endif // INCLUDED_TEST_INC_UNOAPIPROPERTYTESTERS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/test/source/unoapi_property_testers.cxx b/test/source/unoapi_property_testers.cxx index 14f4b3103e47..67589367ad99 100644 --- a/test/source/unoapi_property_testers.cxx +++ b/test/source/unoapi_property_testers.cxx @@ -63,19 +63,38 @@ void testDoubleProperty(uno::Reference& xPropertySet, const { uno::Any aNewValue; -double nPropertyGet; -double nPropertySet; +double dPropertyGet; +double dPropertySet; OString msgGet = "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); -CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= nPropert
[Libreoffice-commits] core.git: test/inc
test/inc/unoapi_property_testers.hxx |8 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit 4887640bad16bee68d36cdeca013525b8c095d4d Author: Jens Carl Date: Thu Mar 29 06:07:04 2018 + Improve documentation Change-Id: I1c8daa5544806e7d646d7e2c9bbf57d78b7091fb Reviewed-on: https://gerrit.libreoffice.org/52141 Reviewed-by: Jens Carl Tested-by: Jens Carl diff --git a/test/inc/unoapi_property_testers.hxx b/test/inc/unoapi_property_testers.hxx index 67f2fc6b5f18..43e0f506c18f 100644 --- a/test/inc/unoapi_property_testers.hxx +++ b/test/inc/unoapi_property_testers.hxx @@ -18,7 +18,7 @@ namespace apitest { -/** @brief Tester for test property type 'boolean' of a @see com::sun::star::beans::XPropertySet. +/** @brief Tester for property type 'boolean' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. * @param nameName of property to test. @@ -26,7 +26,7 @@ namespace apitest void OOO_DLLPUBLIC_TEST testBooleanProperty( css::uno::Reference& xPropertySet, const OUString& name); -/** @brief Tester for test read-only property type 'boolean' of a @see com::sun::star::beans::XPropertySet. +/** @brief Tester for read-only property type 'boolean' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. * @param nameName of property to test. @@ -34,7 +34,7 @@ void OOO_DLLPUBLIC_TEST testBooleanProperty( void OOO_DLLPUBLIC_TEST testBooleanReadonlyProperty( css::uno::Reference& xPropertySet, const OUString& name); -/** @brief Tester for test property type 'double' of a @see com::sun::star::beans::XPropertySet. +/** @brief Tester for property type 'double' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. * @param nameName of property to test. @@ -44,7 +44,7 @@ void OOO_DLLPUBLIC_TEST testDoubleProperty(css::uno::Reference& xPropertySet, const OUString& name, const double& dValue = 42.0); -/** @brief Tester for test property type 'long' of a @see com::sun::star::beans::XPropertySet. +/** @brief Tester for property type 'long' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. * @param nameName of property to test. ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: test/inc test/source
test/inc/unoapi_property_testers.hxx| 18 ++ test/source/unoapi_property_testers.cxx | 39 2 files changed, 57 insertions(+) New commits: commit 3228251663fa866c3cc84bc19d64f77f13e99eef Author: Jens Carl Date: Thu Mar 22 04:15:34 2018 + Add UNO API property tester for double and read-only boolean. Change-Id: I85ec413aa34bdc563294dc71520742515849fbca Reviewed-on: https://gerrit.libreoffice.org/51722 Tested-by: Jenkins Reviewed-by: Jens Carl diff --git a/test/inc/unoapi_property_testers.hxx b/test/inc/unoapi_property_testers.hxx index 1449df16b719..67f2fc6b5f18 100644 --- a/test/inc/unoapi_property_testers.hxx +++ b/test/inc/unoapi_property_testers.hxx @@ -26,6 +26,24 @@ namespace apitest void OOO_DLLPUBLIC_TEST testBooleanProperty( css::uno::Reference& xPropertySet, const OUString& name); +/** @brief Tester for test read-only property type 'boolean' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySetThe property set, which contains the property to test against. + * @param nameName of property to test. + */ +void OOO_DLLPUBLIC_TEST testBooleanReadonlyProperty( +css::uno::Reference& xPropertySet, const OUString& name); + +/** @brief Tester for test property type 'double' of a @see com::sun::star::beans::XPropertySet. + * + * @param xPropertySetThe property set, which contains the property to test against. + * @param nameName of property to test. + * @param nValue Value to use when setting a new value. + */ +void OOO_DLLPUBLIC_TEST +testDoubleProperty(css::uno::Reference& xPropertySet, + const OUString& name, const double& dValue = 42.0); + /** @brief Tester for test property type 'long' of a @see com::sun::star::beans::XPropertySet. * * @param xPropertySetThe property set, which contains the property to test against. diff --git a/test/source/unoapi_property_testers.cxx b/test/source/unoapi_property_testers.cxx index 756321a7e317..14f4b3103e47 100644 --- a/test/source/unoapi_property_testers.cxx +++ b/test/source/unoapi_property_testers.cxx @@ -39,6 +39,45 @@ void testBooleanProperty(uno::Reference& xPropertySet, cons CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), !bPropertyGet, bPropertySet); } +void testBooleanReadonlyProperty(uno::Reference& xPropertySet, + const OUString& name) +{ +uno::Any aNewValue; + +bool bPropertyGet = false; +bool bPropertySet = false; + +OString msgGet += "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); +CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= bPropertyGet); + +aNewValue <<= !bPropertyGet; +xPropertySet->setPropertyValue(name, aNewValue); +CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= bPropertySet); +OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); +CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), bPropertyGet, bPropertySet); +} + +void testDoubleProperty(uno::Reference& xPropertySet, const OUString& name, +const double& dValue) +{ +uno::Any aNewValue; + +double nPropertyGet; +double nPropertySet; + +OString msgGet += "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); +CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= nPropertyGet); + +aNewValue <<= dValue; +xPropertySet->setPropertyValue(name, aNewValue); +CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= nPropertySet); +OString msgSet += "Unable to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8); +CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(msgSet.getStr(), dValue, nPropertySet, 0.5); +} + void testLongProperty(uno::Reference& xPropertySet, const OUString& name, const sal_Int32& nValue) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits