summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-02-22 10:25:32 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-02-22 12:57:35 +0100
commit29b109dfc0f836e34b61b2fbbe69d2b0728dc7b8 (patch)
tree5768af16053ad2b35cc01bb1301a8b1ecfeee80d
parent0690f3b7b981417a7b1f2fffd87c593a2a2a15d5 (diff)
A first cut at embindtest
(UNO boolean should arguably map to JS Boolean, not Number) Change-Id: I21847c558b14ead053aa5c5ea94a508a73aaf36b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163722 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
-rw-r--r--unotest/source/embindtest/embindtest.cxx56
-rw-r--r--unotest/source/embindtest/embindtest.idl33
-rw-r--r--unotest/source/embindtest/embindtest.js74
3 files changed, 162 insertions, 1 deletions
diff --git a/unotest/source/embindtest/embindtest.cxx b/unotest/source/embindtest/embindtest.cxx
index bc8db7d5c9b4..b1f819272931 100644
--- a/unotest/source/embindtest/embindtest.cxx
+++ b/unotest/source/embindtest/embindtest.cxx
@@ -12,7 +12,9 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/weak.hxx>
+#include <org/libreoffice/embindtest/Struct.hpp>
#include <org/libreoffice/embindtest/XTest.hpp>
+#include <rtl/ustring.hxx>
#include <sal/types.h>
namespace com::sun::star::uno
@@ -25,6 +27,60 @@ namespace
{
class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest>
{
+public:
+ sal_Bool SAL_CALL getBoolean() override { return true; }
+
+ sal_Bool SAL_CALL isBoolean(sal_Bool value) override { return value; }
+
+ sal_Int8 SAL_CALL getByte() override { return -12; }
+
+ sal_Bool SAL_CALL isByte(sal_Int8 value) override { return value == -12; }
+
+ sal_Int16 SAL_CALL getShort() override { return -1234; }
+
+ sal_Bool SAL_CALL isShort(sal_Int16 value) override { return value == -1234; }
+
+ sal_uInt16 SAL_CALL getUnsignedShort() override { return 54321; }
+
+ sal_Bool SAL_CALL isUnsignedShort(sal_uInt16 value) override { return value == 54321; }
+
+ sal_Int32 SAL_CALL getLong() override { return -123456; }
+
+ sal_Bool SAL_CALL isLong(sal_Int32 value) override { return value == -123456; }
+
+ sal_uInt32 SAL_CALL getUnsignedLong() override { return 3456789012; }
+
+ sal_Bool SAL_CALL isUnsignedLong(sal_uInt32 value) override { return value == 3456789012; }
+
+ sal_Int64 SAL_CALL getHyper() override { return -123456789; }
+
+ sal_Bool SAL_CALL isHyper(sal_Int64 value) override { return value == -123456789; }
+
+ sal_uInt64 SAL_CALL getUnsignedHyper() override { return 9876543210; }
+
+ sal_Bool SAL_CALL isUnsignedHyper(sal_uInt64 value) override { return value == 9876543210; }
+
+ float SAL_CALL getFloat() override { return -10.25; }
+
+ sal_Bool SAL_CALL isFloat(float value) override { return value == -10.25; }
+
+ double SAL_CALL getDouble() override { return 100.5; }
+
+ sal_Bool SAL_CALL isDouble(double value) override { return value == 100.5; }
+
+ OUString SAL_CALL getString() override { return u"hä"_ustr; }
+
+ sal_Bool SAL_CALL isString(OUString const& value) override { return value == u"hä"; }
+
+ org::libreoffice::embindtest::Struct SAL_CALL getStruct() override
+ {
+ return { -123456, 100.5, u"hä"_ustr };
+ }
+
+ sal_Bool SAL_CALL isStruct(org::libreoffice::embindtest::Struct const& value) override
+ {
+ return value.m1 == -123456 && value.m2 == 100.5 && value.m3 == u"hä";
+ }
};
}
diff --git a/unotest/source/embindtest/embindtest.idl b/unotest/source/embindtest/embindtest.idl
index 553fe6ac38d3..913cde39e12b 100644
--- a/unotest/source/embindtest/embindtest.idl
+++ b/unotest/source/embindtest/embindtest.idl
@@ -9,7 +9,38 @@
module org { module libreoffice { module embindtest {
-interface XTest {};
+struct Struct {
+ long m1;
+ double m2;
+ string m3;
+};
+
+interface XTest {
+ boolean getBoolean();
+ boolean isBoolean([in] boolean value);
+ byte getByte();
+ boolean isByte([in] byte value);
+ short getShort();
+ boolean isShort([in] short value);
+ unsigned short getUnsignedShort();
+ boolean isUnsignedShort([in] unsigned short value);
+ long getLong();
+ boolean isLong([in] long value);
+ unsigned long getUnsignedLong();
+ boolean isUnsignedLong([in] unsigned long value);
+ hyper getHyper();
+ boolean isHyper([in] hyper value);
+ unsigned hyper getUnsignedHyper();
+ boolean isUnsignedHyper([in] unsigned hyper value);
+ float getFloat();
+ boolean isFloat([in] float value);
+ double getDouble();
+ boolean isDouble([in] double value);
+ string getString();
+ boolean isString([in] string value);
+ Struct getStruct();
+ boolean isStruct([in] Struct value);
+};
singleton Test: XTest;
diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js
index ad5eeea29075..805dd16bfe99 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -13,6 +13,80 @@ Module.addOnPostRun(function() {
let test = new Module.unoembind_uno.org.libreoffice.embindtest.Test(
Module.getUnoComponentContext());
console.assert(typeof test === 'object');
+ {
+ let v = test.getBoolean();
+ console.log(v);
+ console.assert(v === 1); //TODO: true
+ console.assert(test.isBoolean(v));
+ }
+ {
+ let v = test.getByte();
+ console.log(v);
+ console.assert(v === -12);
+ console.assert(test.isByte(v));
+ }
+ {
+ let v = test.getShort();
+ console.log(v);
+ console.assert(v === -1234);
+ console.assert(test.isShort(v));
+ }
+ {
+ let v = test.getUnsignedShort();
+ console.log(v);
+ console.assert(v === 54321);
+ console.assert(test.isUnsignedShort(v));
+ }
+ {
+ let v = test.getLong();
+ console.log(v);
+ console.assert(v === -123456);
+ console.assert(test.isLong(v));
+ }
+ {
+ let v = test.getUnsignedLong();
+ console.log(v);
+ console.assert(v === 3456789012);
+ console.assert(test.isUnsignedLong(v));
+ }
+ {
+ let v = test.getHyper();
+ console.log(v);
+ console.assert(v === -123456789n);
+ console.assert(test.isHyper(v));
+ }
+ {
+ let v = test.getUnsignedHyper();
+ console.log(v);
+ console.assert(v === 9876543210n);
+ console.assert(test.isUnsignedHyper(v));
+ }
+ {
+ let v = test.getFloat();
+ console.log(v);
+ console.assert(v === -10.25);
+ console.assert(test.isFloat(v));
+ }
+ {
+ let v = test.getDouble();
+ console.log(v);
+ console.assert(v === 100.5);
+ console.assert(test.isDouble(v));
+ }
+ {
+ let v = test.getString();
+ console.log(v);
+ console.assert(v === 'hä');
+ console.assert(test.isString(v));
+ }
+ {
+ let v = test.getStruct();
+ console.log(v.m1 + ', ' + v.m2 + ', ' + v.m3);
+ console.assert(v.m1 === -123456);
+ console.assert(v.m2 === 100.5);
+ console.assert(v.m3 === 'hä');
+ console.assert(test.isStruct(v));
+ }
});
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */