offapi/org/libreoffice/embindtest/Test.idl     |    2 +-
 unotest/source/embindtest/embindtest.component |    2 +-
 unotest/source/embindtest/embindtest.cxx       |   12 +++++++-----
 unotest/source/embindtest/embindtest.js        |   18 +++++++++++-------
 4 files changed, 20 insertions(+), 14 deletions(-)

New commits:
commit a0f3225984f865b9604c420543a5951a21185ba6
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Fri Jul 12 17:08:58 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Fri Jul 12 19:36:46 2024 +0200

    Turn org.libreoffice.embindtest.Test from singleton to service
    
    ...so that testing its StringAttribute stars out with a known state.  And 
which
    revealed that the test code in unotest/source/embindtest/embindtest.js was
    actually wrong in assuming that that UNO attribute would be represented by 
a JS
    accessor property, when actually it is represented by a pair of
    get-/setStringAttribute member functions.
    
    Change-Id: I1a6e7c9f26e9a08cd089b7972a23f4c608c6b1bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170414
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/offapi/org/libreoffice/embindtest/Test.idl 
b/offapi/org/libreoffice/embindtest/Test.idl
index ac7a1ece34f3..ac945e60c5b8 100644
--- a/offapi/org/libreoffice/embindtest/Test.idl
+++ b/offapi/org/libreoffice/embindtest/Test.idl
@@ -9,7 +9,7 @@
 
 module org { module libreoffice { module embindtest {
 
-singleton Test: XTest;
+service Test: XTest;
 
 }; }; };
 
diff --git a/unotest/source/embindtest/embindtest.component 
b/unotest/source/embindtest/embindtest.component
index f1106d3bc96a..9391811ce2d0 100644
--- a/unotest/source/embindtest/embindtest.component
+++ b/unotest/source/embindtest/embindtest.component
@@ -20,6 +20,6 @@
     <implementation
             
constructor="org_libreoffice_comp_embindtest_Test_get_implementation"
             name="org.libreoffice.comp.embindtest.Test">
-        <singleton name="org.libreoffice.embindtest.Test"/>
+        <service name="org.libreoffice.embindtest.Test"/>
     </implementation>
 </component>
diff --git a/unotest/source/embindtest/embindtest.cxx 
b/unotest/source/embindtest/embindtest.cxx
index 81ede0e9cf93..bea60633dd3e 100644
--- a/unotest/source/embindtest/embindtest.cxx
+++ b/unotest/source/embindtest/embindtest.cxx
@@ -608,7 +608,7 @@ class Test : public 
cppu::WeakImplHelper<org::libreoffice::embindtest::XTest>
 
     void SAL_CALL setStringAttribute(OUString const& value) override { 
stringAttribute_ = value; }
 
-    OUString stringAttribute_;
+    OUString stringAttribute_ = u"hä"_ustr;
 };
 
 class BridgeTest : public cppu::WeakImplHelper<css::task::XJob>
@@ -647,7 +647,7 @@ private:
         }
         css::uno::UnoInterfaceReference ifcUno;
         cpp2uno.mapInterface(reinterpret_cast<void**>(&ifcUno.m_pUnoI),
-                             
org::libreoffice::embindtest::Test::get(context_).get(),
+                             
org::libreoffice::embindtest::Test::create(context_).get(),
                              
cppu::UnoType<org::libreoffice::embindtest::XTest>::get());
         if (!ifcUno.is())
         {
@@ -832,9 +832,11 @@ private:
             assert(e.Message.startsWith("test"));
         }
         {
-            ifcCpp->setStringAttribute(u"hä"_ustr);
-            auto const val = ifcCpp->getStringAttribute();
-            assert(val == u"hä"_ustr);
+            auto const val1 = ifcCpp->getStringAttribute();
+            assert(val1 == u"hä"_ustr);
+            ifcCpp->setStringAttribute(u"foo"_ustr);
+            auto const val2 = ifcCpp->getStringAttribute();
+            assert(val2 == u"foo"_ustr);
         }
         return css::uno::Any(true);
     }
diff --git a/unotest/source/embindtest/embindtest.js 
b/unotest/source/embindtest/embindtest.js
index 5c2451377550..9482643ce9ec 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -13,7 +13,7 @@ Module.addOnPostRun(function() {
     console.log('Running embindtest');
     Module.initUno();
     let css = Module.uno.com.sun.star;
-    let test = 
Module.uno.org.libreoffice.embindtest.Test(Module.getUnoComponentContext());
+    let test = 
Module.uno.org.libreoffice.embindtest.Test.create(Module.getUnoComponentContext());
     console.assert(typeof test === 'object');
     {
         let v = test.getBoolean();
@@ -676,8 +676,9 @@ Module.addOnPostRun(function() {
     test.passJob(css.task.XJob.query(obj));
     test.passJobExecutor(css.task.XJobExecutor.query(obj));
     test.passInterface(obj);
-    test.StringAttribute = 'hä';
-    console.assert(test.StringAttribute === 'hä');
+    console.assert(test.getStringAttribute() === 'hä');
+    test.setStringAttribute('foo');
+    console.assert(test.getStringAttribute() === 'foo');
 
     const args = new Module.uno_Sequence_any(
         [new 
Module.uno_Any(Module.uno_Type.Interface('com.sun.star.uno.XInterface'), 
test)]);
@@ -1100,12 +1101,15 @@ Module.addOnPostRun(function() {
         outparam.delete();
     }
     {
-        let a = new Module.uno_Any(Module.uno_Type.String(), 'hä');
+        const ret1 = invoke.getValue('StringAttribute');
+        console.assert(ret1.get() === 'foo');
+        ret1.delete();
+        let a = new Module.uno_Any(Module.uno_Type.String(), 'bar');
         invoke.setValue('StringAttribute', a);
         a.delete();
-        const ret = invoke.getValue('StringAttribute');
-        console.assert(ret.get() === 'hä');
-        ret.delete();
+        const ret2 = invoke.getValue('StringAttribute');
+        console.assert(ret2.get() === 'bar');
+        ret2.delete();
     }
     {
         const args = new Module.uno_Sequence_com$sun$star$beans$NamedValue(

Reply via email to