offapi/org/libreoffice/embindtest/Struct.idl | 1 unotest/source/embindtest/embindtest.cxx | 34 ++++++++++++++++----------- unotest/source/embindtest/embindtest.js | 16 +++++++++++- 3 files changed, 37 insertions(+), 14 deletions(-)
New commits: commit 4d18fa7694bae0b3d4364aa3072216782b7a5f26 Author: Stephan Bergmann <stephan.bergm...@allotropia.de> AuthorDate: Fri Jul 26 17:36:59 2024 +0200 Commit: Stephan Bergmann <stephan.bergm...@allotropia.de> CommitDate: Sat Jul 27 18:33:59 2024 +0200 In embindtest, also test Any included in Struct Change-Id: Id268692c750873629c1ceaf232e1e61912164872 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171078 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de> diff --git a/offapi/org/libreoffice/embindtest/Struct.idl b/offapi/org/libreoffice/embindtest/Struct.idl index 6b9d36e40a1b..b62d917256c6 100644 --- a/offapi/org/libreoffice/embindtest/Struct.idl +++ b/offapi/org/libreoffice/embindtest/Struct.idl @@ -13,6 +13,7 @@ struct Struct { long m1; double m2; string m3; + any m4; }; }; }; }; diff --git a/unotest/source/embindtest/embindtest.cxx b/unotest/source/embindtest/embindtest.cxx index 01e18d0b42f4..166fa9650b8a 100644 --- a/unotest/source/embindtest/embindtest.cxx +++ b/unotest/source/embindtest/embindtest.cxx @@ -115,12 +115,14 @@ class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> org::libreoffice::embindtest::Struct SAL_CALL getStruct() override { - return { -123456, 100.5, u"hä"_ustr }; + return { -123456, 100.5, u"hä"_ustr, css::uno::Any(true) }; } sal_Bool SAL_CALL isStruct(org::libreoffice::embindtest::Struct const& value) override { - return value == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr }; + return value + == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr, + css::uno::Any(true) }; } org::libreoffice::embindtest::StructLong SAL_CALL getStructLong() override @@ -293,14 +295,16 @@ class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> css::uno::Any SAL_CALL getAnyStruct() override { - return css::uno::Any(org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr }); + return css::uno::Any(org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr, + css::uno::Any(true) }); } sal_Bool SAL_CALL isAnyStruct(css::uno::Any const& value) override { return value.getValueType() == cppu::UnoType<org::libreoffice::embindtest::Struct>::get() && *o3tl::forceAccess<org::libreoffice::embindtest::Struct>(value) - == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr }; + == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr, + css::uno::Any(true) }; } css::uno::Any SAL_CALL getAnyException() override @@ -517,9 +521,9 @@ class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> css::uno::Sequence<org::libreoffice::embindtest::Struct> SAL_CALL getSequenceStruct() override { - return { { -123456, -100.5, u"foo"_ustr }, - { 1, 1.25, u"barr"_ustr }, - { 123456, 100.75, u"bazzz"_ustr } }; + return { { -123456, -100.5, u"foo"_ustr, css::uno::Any() }, + { 1, 1.25, u"barr"_ustr, css::uno::Any(true) }, + { 123456, 100.75, u"bazzz"_ustr, css::uno::Any(u"buzzz"_ustr) } }; } sal_Bool SAL_CALL @@ -527,9 +531,9 @@ class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> { return value == css::uno::Sequence<org::libreoffice::embindtest::Struct>{ - { -123456, -100.5, u"foo"_ustr }, - { 1, 1.25, u"barr"_ustr }, - { 123456, 100.75, u"bazzz"_ustr } + { -123456, -100.5, u"foo"_ustr, css::uno::Any() }, + { 1, 1.25, u"barr"_ustr, css::uno::Any(true) }, + { 123456, 100.75, u"bazzz"_ustr, css::uno::Any(u"buzzz"_ustr) } }; } @@ -569,7 +573,7 @@ class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> value14 = css::uno::Any(sal_Int32(-123456)); value15 = { u"foo"_ustr, u"barr"_ustr, u"bazzz"_ustr }; value16 = org::libreoffice::embindtest::Enum_E_2; - value17 = { -123456, 100.5, u"hä"_ustr }; + value17 = { -123456, 100.5, u"hä"_ustr, css::uno::Any(true) }; value18 = this; } @@ -758,7 +762,9 @@ private: } { auto const val = ifcCpp->getStruct(); - assert((val == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr })); + assert((val + == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr, + css::uno::Any(true) })); auto const ok = ifcCpp->isStruct(val); assert(ok == css::uno::Any(true)); } @@ -831,7 +837,9 @@ private: assert((value15 == css::uno::Sequence<OUString>{ u"foo"_ustr, u"barr"_ustr, u"bazzz"_ustr })); assert(value16 == org::libreoffice::embindtest::Enum_E_2); - assert((value17 == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr })); + assert((value17 + == org::libreoffice::embindtest::Struct{ -123456, 100.5, u"hä"_ustr, + css::uno::Any(true) })); assert(value18 == ifcCpp); } try diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js index ba25b050ffb7..42da2ee51b4e 100644 --- a/unotest/source/embindtest/embindtest.js +++ b/unotest/source/embindtest/embindtest.js @@ -105,7 +105,9 @@ Module.uno_init.then(function() { console.assert(v.m1 === -123456); console.assert(v.m2 === 100.5); console.assert(v.m3 === 'hä'); + console.assert(v.m4.get() === true); console.assert(test.isStruct(v)); + v.m4.delete(); } { let v = test.getAnyVoid(); @@ -282,12 +284,16 @@ Module.uno_init.then(function() { console.assert(v.get().m1 === -123456); console.assert(v.get().m2 === 100.5); console.assert(v.get().m3 === 'hä'); + console.assert(v.get().m4.get() === true); console.assert(test.isAnyStruct(v)); + v.get().m4.delete(); v.delete(); + let m4 = new Module.uno_Any(Module.uno_Type.Boolean(), true); let a = new Module.uno_Any( Module.uno_Type.Struct('org.libreoffice.embindtest.Struct'), - {m1: -123456, m2: 100.5, m3: 'hä'}); + {m1: -123456, m2: 100.5, m3: 'hä', m4}); console.assert(test.isAnyStruct(a)); + m4.delete(); a.delete(); } { @@ -509,13 +515,19 @@ Module.uno_init.then(function() { console.assert(v.get(0).m1 === -123456); console.assert(v.get(0).m2 === -100.5); console.assert(v.get(0).m3 === 'foo'); + console.assert(v.get(0).m4.get() === undefined); console.assert(v.get(1).m1 === 1); console.assert(v.get(1).m2 === 1.25); console.assert(v.get(1).m3 === 'barr'); + console.assert(v.get(1).m4.get() === true); console.assert(v.get(2).m1 === 123456); console.assert(v.get(2).m2 === 100.75); console.assert(v.get(2).m3 === 'bazzz'); + console.assert(v.get(2).m4.get() === 'buzzz'); console.assert(test.isSequenceStruct(v)); + v.get(0).m4.delete(); + v.get(1).m4.delete(); + v.get(2).m4.delete(); v.delete(); } { @@ -590,6 +602,7 @@ Module.uno_init.then(function() { console.assert(v17.val.m1 === -123456); console.assert(v17.val.m2 === 100.5); console.assert(v17.val.m3 === 'hä'); + console.assert(v17.val.m4.get() === true); console.assert(Module.sameUnoObject(v18.val, test)); v1.delete(); v2.delete(); @@ -609,6 +622,7 @@ Module.uno_init.then(function() { v15.val.delete(); v15.delete(); v16.delete(); + v17.val.m4.delete(); v17.delete(); v18.delete(); }