diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-30 16:47:51 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-04-30 16:48:55 -0400 |
commit | d55837cc6ab736dd78b965e13c96d41d59dca1b6 (patch) | |
tree | 09f40f118a93210518b2fd4c9326d191b7f0cb12 /test/source | |
parent | 4712cd34531f1f257238b5ededaa5f130db2abec (diff) |
Implemented test for XPropertySet::setPropertyValue().
Also cover all UNO primitive types in isPropertyValueChangeable().
Change-Id: I21a1809ed2a6b58f68ef82252f513991e0f012af
Diffstat (limited to 'test/source')
-rw-r--r-- | test/source/beans/xpropertyset.cxx | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/test/source/beans/xpropertyset.cxx b/test/source/beans/xpropertyset.cxx index ffa1a01cefff..96283d26fc22 100644 --- a/test/source/beans/xpropertyset.cxx +++ b/test/source/beans/xpropertyset.cxx @@ -69,9 +69,12 @@ void XPropertySet::testAddVetoableChangeListener() void XPropertySet::testSetPropertyValue() { testGetPropertySetInfo(); - uno::Reference<beans::XPropertySet> xPropSet(init(), UNO_QUERY_THROW); - // TODO: implement this. + for (size_t i = 0, n = maPropsToTest.normal.size(); i < n; ++i) + { + bool bSuccess = isPropertyValueChangeable(maPropsToTest.normal[i]); + CPPUNIT_ASSERT(bSuccess); + } } void XPropertySet::testGetPropertyValue() @@ -116,10 +119,48 @@ bool XPropertySet::isPropertyValueChangeable(const rtl::OUString& rName) // boolean type sal_Bool bOld = any.get<sal_Bool>(); xPropSet->setPropertyValue(rName, makeAny(!bOld)); - any = xPropSet->getPropertyValue(rName); - sal_Bool bNew = any.get<sal_Bool>(); - - return bOld != bNew; + } + else if (type == getCppuType<sal_Int8>()) + { + // 8-bit integer + sal_Int8 nOld = any.get<sal_Int8>(); + sal_Int8 nNew = nOld + 1; + xPropSet->setPropertyValue(rName, makeAny(nNew)); + } + else if (type == getCppuType<sal_Int16>()) + { + // 16-bit integer + sal_Int16 nOld = any.get<sal_Int16>(); + sal_Int16 nNew = nOld + 2; + xPropSet->setPropertyValue(rName, makeAny(nNew)); + } + else if (type == getCppuType<sal_Int32>()) + { + // 32-bit integer + sal_Int32 nOld = any.get<sal_Int32>(); + sal_Int32 nNew = nOld + 3; + xPropSet->setPropertyValue(rName, makeAny(nNew)); + } + else if (type == getCppuType<sal_Int64>()) + { + // 64-bit integer + sal_Int64 nOld = any.get<sal_Int64>(); + sal_Int64 nNew = nOld + 4; + xPropSet->setPropertyValue(rName, makeAny(nNew)); + } + else if (type == getCppuType<float>()) + { + // single precision + float fOld = any.get<float>(); + float fNew = fOld + 1.2; + xPropSet->setPropertyValue(rName, makeAny(fNew)); + } + else if (type == getCppuType<double>()) + { + // double precision + double fOld = any.get<double>(); + double fNew = fOld + 1.3; + xPropSet->setPropertyValue(rName, makeAny(fNew)); } else if (type == getCppuType<rtl::OUString>()) { @@ -127,16 +168,14 @@ bool XPropertySet::isPropertyValueChangeable(const rtl::OUString& rName) rtl::OUString aOld = any.get<rtl::OUString>(); rtl::OUString aNew = aOld + rtl::OUString("foo"); xPropSet->setPropertyValue(rName, makeAny(aNew)); - any = xPropSet->getPropertyValue(rName); - rtl::OUString aTest = any.get<rtl::OUString>(); - return aOld != aTest; + } + else + { + CPPUNIT_ASSERT_MESSAGE("XPropertySet::isChangeable: unknown type in Any tested.", false); } - // TODO: add more primitive types to cover. For specialized types, - // the client code should provide the test code to change their values - // by overwriting this method. - - CPPUNIT_ASSERT_MESSAGE("XPropertySet::isChangeable: unknown type in Any tested.", false); + uno::Any anyTest = xPropSet->getPropertyValue(rName); + return any != anyTest; } catch (const uno::Exception&) { |