summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-02-24 19:31:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-26 10:00:44 +0100
commit043c67e0f7358753a2007b7c2bb6cc68aeea7ecb (patch)
tree8a86daf82dfdce20090ff4ddc6d88eafe2af49a0 /vcl/win
parent9c1ec551524a75c20c1468a6fc0101eb2480e8e3 (diff)
dummy clipboard for unit tests
Change-Id: I285b36536dd38e41a199e8b6fd654666d125d906 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111498 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/dtrans/WinClipboard.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/vcl/win/dtrans/WinClipboard.cxx b/vcl/win/dtrans/WinClipboard.cxx
index f50c1810f4ea..6ed9e967d7e5 100644
--- a/vcl/win/dtrans/WinClipboard.cxx
+++ b/vcl/win/dtrans/WinClipboard.cxx
@@ -27,6 +27,9 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
+#include <vcl/svapp.hxx>
+#include <svdata.hxx>
+#include <salinst.hxx>
#include <com/sun/star/datatransfer/clipboard/RenderingCapabilities.hpp>
#include "XNotifyingDataObject.hxx"
@@ -299,11 +302,26 @@ uno::Sequence<OUString> SAL_CALL CWinClipboard::getSupportedServiceNames()
return { "com.sun.star.datatransfer.clipboard.SystemClipboard" };
}
+// We run unit tests in parallel, which is a problem when touching a shared resource
+// the system clipboard, so rather use the dummy GenericClipboard.
+static const bool bRunningUnitTest = getenv("LO_TESTNAME");
+
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
dtrans_CWinClipboard_get_implementation(css::uno::XComponentContext* context,
- css::uno::Sequence<css::uno::Any> const&)
+ css::uno::Sequence<css::uno::Any> const& args)
{
- return cppu::acquire(static_cast<cppu::OWeakObject*>(new CWinClipboard(context, "")));
+ if (bRunningUnitTest)
+ {
+ SolarMutexGuard aGuard;
+ auto xClipboard = ImplGetSVData()->mpDefInst->CreateClipboard(args);
+ if (xClipboard.is())
+ xClipboard->acquire();
+ return xClipboard.get();
+ }
+ else
+ {
+ return cppu::acquire(static_cast<cppu::OWeakObject*>(new CWinClipboard(context, "")));
+ }
}
void CWinClipboard::onReleaseDataObject(CXNotifyingDataObject* theCaller)