diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-02-21 15:10:38 +0100 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-02-22 08:15:30 +0100 |
commit | d0cb804f7a25274d725475418a97c293f55f30cf (patch) | |
tree | 92d7a26e0a6d849b359aa44ce96848d519753a62 /unotest | |
parent | a5ccdbbc457fb7aadca2d6a046ab891dedca5bb1 (diff) |
Framework for some UNOIDL to test the Embind UNO binding with
It is only built for --enable-dbgutil builds. Load
instdir/program/qt_soffice.html in a browser and see "Running embindtest" in its
console. For now, it only contains a Test singleton with an empty XTest
interface, which is meant to grow additional methods over time.
(The code needs to reside in the unotest rather than in the static module, or
else the wasm build would run into cyclic dependencies.)
Change-Id: I6f65f0c904648a4fd96fc6215c8d59a1544f48a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163693
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'unotest')
-rw-r--r-- | unotest/InternalUnoApi_embindtest.mk | 16 | ||||
-rw-r--r-- | unotest/Library_embindtest.mk | 26 | ||||
-rw-r--r-- | unotest/Module_unotest.mk | 7 | ||||
-rw-r--r-- | unotest/source/embindtest/embindtest.component | 20 | ||||
-rw-r--r-- | unotest/source/embindtest/embindtest.cxx | 38 | ||||
-rw-r--r-- | unotest/source/embindtest/embindtest.idl | 18 | ||||
-rw-r--r-- | unotest/source/embindtest/embindtest.js | 18 |
7 files changed, 143 insertions, 0 deletions
diff --git a/unotest/InternalUnoApi_embindtest.mk b/unotest/InternalUnoApi_embindtest.mk new file mode 100644 index 000000000000..ed96a209ce81 --- /dev/null +++ b/unotest/InternalUnoApi_embindtest.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_InternalUnoApi_InternalUnoApi,embindtest,unotest/source/embindtest/embindtest.idl)) + +$(eval $(call gb_InternalUnoApi_use_api,embindtest, \ + udkapi \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/unotest/Library_embindtest.mk b/unotest/Library_embindtest.mk new file mode 100644 index 000000000000..8c2d48bbfac9 --- /dev/null +++ b/unotest/Library_embindtest.mk @@ -0,0 +1,26 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,embindtest)) + +$(eval $(call gb_Library_add_exception_objects,embindtest, \ + unotest/source/embindtest/embindtest \ +)) + +$(eval $(call gb_Library_set_componentfile,embindtest,unotest/source/embindtest/embindtest,services)) + +$(eval $(call gb_Library_use_api,embindtest, \ + udkapi \ +)) + +$(eval $(call gb_Library_use_internal_api,embindtest, \ + embindtest \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/unotest/Module_unotest.mk b/unotest/Module_unotest.mk index bdffe8e8ac14..a12267817d27 100644 --- a/unotest/Module_unotest.mk +++ b/unotest/Module_unotest.mk @@ -30,6 +30,13 @@ $(eval $(call gb_Module_add_targets,unotest,\ )) endif endif + +ifeq ($(OS)-$(ENABLE_DBGUTIL),EMSCRIPTEN-TRUE) +$(eval $(call gb_Module_add_targets,unotest, \ + InternalUnoApi_embindtest \ + Library_embindtest \ +)) +endif endif # vim: set noet sw=4 ts=4: diff --git a/unotest/source/embindtest/embindtest.component b/unotest/source/embindtest/embindtest.component new file mode 100644 index 000000000000..57a89249e8c0 --- /dev/null +++ b/unotest/source/embindtest/embindtest.component @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * +--> + +<component + environment="@CPPU_ENV@" + loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation + constructor="org_libreoffice_comp_embindtest_Test_get_implementation" + name="org.libreoffice.comp.embindtest.Test"> + <singleton name="org.libreoffice.embindtest.Test"/> + </implementation> +</component> diff --git a/unotest/source/embindtest/embindtest.cxx b/unotest/source/embindtest/embindtest.cxx new file mode 100644 index 000000000000..bc8db7d5c9b4 --- /dev/null +++ b/unotest/source/embindtest/embindtest.cxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <sal/config.h> + +#include <com/sun/star/uno/Sequence.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weak.hxx> +#include <org/libreoffice/embindtest/XTest.hpp> +#include <sal/types.h> + +namespace com::sun::star::uno +{ +class Any; +class XComponentContext; +} + +namespace +{ +class Test : public cppu::WeakImplHelper<org::libreoffice::embindtest::XTest> +{ +}; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +org_libreoffice_comp_embindtest_Test_get_implementation(css::uno::XComponentContext*, + css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new Test); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/unotest/source/embindtest/embindtest.idl b/unotest/source/embindtest/embindtest.idl new file mode 100644 index 000000000000..553fe6ac38d3 --- /dev/null +++ b/unotest/source/embindtest/embindtest.idl @@ -0,0 +1,18 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +module org { module libreoffice { module embindtest { + +interface XTest {}; + +singleton Test: XTest; + +}; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js new file mode 100644 index 000000000000..ad5eeea29075 --- /dev/null +++ b/unotest/source/embindtest/embindtest.js @@ -0,0 +1,18 @@ +/* -*- Mode: JS; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +Module.addOnPostRun(function() { + console.log('Running embindtest'); + init_unoembind_uno(Module); + let test = new Module.unoembind_uno.org.libreoffice.embindtest.Test( + Module.getUnoComponentContext()); + console.assert(typeof test === 'object'); +}); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |