Add UNO API property tester for double and read-only boolean.
Change-Id: I85ec413aa34bdc563294dc71520742515849fbca Reviewed-on: https://gerrit.libreoffice.org/51722 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
This commit is contained in:
@@ -26,6 +26,24 @@ namespace apitest
|
||||
void OOO_DLLPUBLIC_TEST testBooleanProperty(
|
||||
css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name);
|
||||
|
||||
/** @brief Tester for test 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.
|
||||
* @param name Name of property to test.
|
||||
*/
|
||||
void OOO_DLLPUBLIC_TEST testBooleanReadonlyProperty(
|
||||
css::uno::Reference<css::beans::XPropertySet>& xPropertySet, const OUString& name);
|
||||
|
||||
/** @brief Tester for test property type 'double' 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 nValue Value to use when setting a new value.
|
||||
*/
|
||||
void OOO_DLLPUBLIC_TEST
|
||||
testDoubleProperty(css::uno::Reference<css::beans::XPropertySet>& 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 xPropertySet The property set, which contains the property to test against.
|
||||
|
||||
@@ -39,6 +39,45 @@ void testBooleanProperty(uno::Reference<beans::XPropertySet>& xPropertySet, cons
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(msgSet.getStr(), !bPropertyGet, bPropertySet);
|
||||
}
|
||||
|
||||
void testBooleanReadonlyProperty(uno::Reference<beans::XPropertySet>& 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<beans::XPropertySet>& 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<beans::XPropertySet>& xPropertySet, const OUString& name,
|
||||
const sal_Int32& nValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user