extend property tester - add optional variants and color
Change-Id: Iad72470b5f1fc5405673d2d7781bc59002a3a44a Reviewed-on: https://gerrit.libreoffice.org/53988 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
711c2e49dd
commit
2af7daa184
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
#include <com/sun/star/util/Color.hpp>
|
||||
|
||||
#include <sal/config.h>
|
||||
#include <test/testdllapi.hxx>
|
||||
@@ -26,6 +27,16 @@ namespace apitest
|
||||
void OOO_DLLPUBLIC_TEST testBooleanProperty(
|
||||
css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, const OUString& name);
|
||||
|
||||
/** @brief Tester for optional property type 'boolean' of a @see com::sun::star::beans::XPropertySet.
|
||||
*
|
||||
* Pass the test also if the property doesn't exists (throws a com::sun::star::beans::UnknownPropertyException)
|
||||
*
|
||||
* @param xPropertySet The property set, which contains the property to test against.
|
||||
* @param name Name of property to test.
|
||||
*/
|
||||
void OOO_DLLPUBLIC_TEST testBooleanOptionalProperty(
|
||||
css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, const OUString& name);
|
||||
|
||||
/** @brief Tester for read-only property type 'boolean' of a @see com::sun::star::beans::XPropertySet.
|
||||
*
|
||||
* @param xPropertySet The property set, which contains the property to test against.
|
||||
@@ -104,6 +115,18 @@ void OOO_DLLPUBLIC_TEST
|
||||
testStringProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& name, const OUString& rValue);
|
||||
|
||||
/** @brief Tester for optional property type 'string' of a @see com::sun::star::beans::XPropertySet.
|
||||
*
|
||||
* Pass the test also if the property doesn't exists (throws a com::sun::star::beans::UnknownPropertyException)
|
||||
*
|
||||
* @param xPropertySet The property set, which contains the property to test against.
|
||||
* @param name Name of property to test.
|
||||
* @param rValue Value to use when setting a new value.
|
||||
*/
|
||||
void OOO_DLLPUBLIC_TEST
|
||||
testStringOptionalProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& name, const OUString& rValue = OUString("StringValue"));
|
||||
|
||||
/** @brief Tester for read-only property type 'string' of a @see com::sun::star::beans::XPropertySet.
|
||||
*
|
||||
* @param xPropertySet The property set, which contains the property to test against.
|
||||
@@ -113,6 +136,17 @@ testStringProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropert
|
||||
void OOO_DLLPUBLIC_TEST
|
||||
testStringReadonlyProperty(css::uno::Reference<css::beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& name, const OUString& rValue);
|
||||
|
||||
/** @brief Tester for property type com::sun::star::util::Color of a @see com::sun::star::beans::XPropertySet.
|
||||
*
|
||||
* @param xPropertySet The property set, which contains the property to test against.
|
||||
* @param name Name of property to test.
|
||||
* @param rValue Value to use when setting a new value.
|
||||
*/
|
||||
void OOO_DLLPUBLIC_TEST testColorProperty(
|
||||
css::uno::Reference<css::beans::XPropertySet> const& xPropertySet, const OUString& name,
|
||||
const css::util::Color& rValue = css::util::Color(0x12345678));
|
||||
|
||||
} // namespace apitest
|
||||
#endif // INCLUDED_TEST_INC_UNOAPIPROPERTYTESTERS_HXX
|
||||
|
||||
|
@@ -9,10 +9,7 @@
|
||||
|
||||
#include <test/unoapi_property_testers.hxx>
|
||||
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/uno/Any.hxx>
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
using namespace css;
|
||||
@@ -39,6 +36,19 @@ void testBooleanProperty(uno::Reference<beans::XPropertySet> const& xPropertySet
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), !bPropertyGet, bPropertySet);
|
||||
}
|
||||
|
||||
void testBooleanOptionalProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& rName)
|
||||
{
|
||||
try
|
||||
{
|
||||
testBooleanProperty(xPropertySet, rName);
|
||||
}
|
||||
catch (css::beans::UnknownPropertyException /*ex*/)
|
||||
{
|
||||
// ignore if the property is unknown as it is optional
|
||||
}
|
||||
}
|
||||
|
||||
void testBooleanReadonlyProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& name)
|
||||
{
|
||||
@@ -175,6 +185,19 @@ void testShortReadonlyProperty(uno::Reference<beans::XPropertySet> const& xPrope
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), nPropertyGet, nPropertySet);
|
||||
}
|
||||
|
||||
void testStringOptionalProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& rName, const OUString& rValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
testStringProperty(xPropertySet, rName, rValue);
|
||||
}
|
||||
catch (css::beans::UnknownPropertyException /*ex*/)
|
||||
{
|
||||
// ignore if the property is unknown as it is optional
|
||||
}
|
||||
}
|
||||
|
||||
void testStringProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& name, const OUString& rValue)
|
||||
{
|
||||
@@ -213,6 +236,27 @@ void testStringReadonlyProperty(uno::Reference<beans::XPropertySet> const& xProp
|
||||
OString msgSet = "Able to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), sPropertyGet, sPropertySet);
|
||||
}
|
||||
|
||||
void testColorProperty(uno::Reference<beans::XPropertySet> const& xPropertySet,
|
||||
const OUString& name, const util::Color& rValue)
|
||||
{
|
||||
uno::Any aNewValue;
|
||||
|
||||
util::Color sPropertyGet;
|
||||
util::Color sPropertySet;
|
||||
|
||||
OString msgGet
|
||||
= "Unable to get PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8);
|
||||
CPPUNIT_ASSERT_MESSAGE(msgGet.getStr(), xPropertySet->getPropertyValue(name) >>= sPropertyGet);
|
||||
|
||||
aNewValue <<= rValue;
|
||||
xPropertySet->setPropertyValue(name, aNewValue);
|
||||
CPPUNIT_ASSERT(xPropertySet->getPropertyValue(name) >>= sPropertySet);
|
||||
OString msgSet
|
||||
= "Unable to set PropertyValue: " + OUStringToOString(name, RTL_TEXTENCODING_UTF8);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), rValue, sPropertySet);
|
||||
}
|
||||
|
||||
} // namespace apitest
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
Reference in New Issue
Block a user