summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/osx/service_entry.cxx10
-rw-r--r--vcl/unx/generic/dtrans/X11_service.cxx13
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx13
-rw-r--r--vcl/win/dtrans/WinClipboard.cxx22
4 files changed, 53 insertions, 5 deletions
diff --git a/vcl/osx/service_entry.cxx b/vcl/osx/service_entry.cxx
index eebb675ce9d2..4263735422e7 100644
--- a/vcl/osx/service_entry.cxx
+++ b/vcl/osx/service_entry.cxx
@@ -34,9 +34,13 @@ using namespace ::cppu;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::datatransfer::clipboard;
+// 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");
+
uno::Reference< XInterface > AquaSalInstance::CreateClipboard( const Sequence< Any >& i_rArguments )
{
- if ( Application::IsHeadlessModeEnabled() )
+ if ( Application::IsHeadlessModeEnabled() || bRunningUnitTest )
return SalInstance::CreateClipboard( i_rArguments );
SalData* pSalData = GetSalData();
@@ -47,7 +51,7 @@ uno::Reference< XInterface > AquaSalInstance::CreateClipboard( const Sequence< A
uno::Reference<XInterface> AquaSalInstance::CreateDragSource()
{
- if ( Application::IsHeadlessModeEnabled() )
+ if ( Application::IsHeadlessModeEnabled() || bRunningUnitTest )
return SalInstance::CreateDragSource();
return uno::Reference<XInterface>(static_cast< XInitialization* >(new DragSource()), UNO_QUERY);
@@ -55,7 +59,7 @@ uno::Reference<XInterface> AquaSalInstance::CreateDragSource()
uno::Reference<XInterface> AquaSalInstance::CreateDropTarget()
{
- if ( Application::IsHeadlessModeEnabled() )
+ if ( Application::IsHeadlessModeEnabled() || bRunningUnitTest )
return SalInstance::CreateDropTarget();
return uno::Reference<XInterface>(static_cast< XInitialization* >(new DropTarget()), UNO_QUERY);
diff --git a/vcl/unx/generic/dtrans/X11_service.cxx b/vcl/unx/generic/dtrans/X11_service.cxx
index 2b9c1299be45..3d8ef3382a46 100644
--- a/vcl/unx/generic/dtrans/X11_service.cxx
+++ b/vcl/unx/generic/dtrans/X11_service.cxx
@@ -44,8 +44,15 @@ Sequence< OUString > x11::Xdnd_dropTarget_getSupportedServiceNames()
return { "com.sun.star.datatransfer.dnd.X11DropTarget" };
}
+// We run unit tests in parallel, which is a problem when touching a shared resource
+// the system clipboard, so rather use the dummy GenericClipboard.
+const bool bRunningUnitTest = getenv("LO_TESTNAME");
+
css::uno::Reference< XInterface > X11SalInstance::CreateClipboard( const Sequence< Any >& arguments )
{
+ if ( bRunningUnitTest )
+ return SalInstance::CreateClipboard( arguments );
+
SelectionManager& rManager = SelectionManager::get();
css::uno::Sequence<css::uno::Any> mgrArgs(1);
mgrArgs[0] <<= Application::GetDisplayConnection();
@@ -73,11 +80,17 @@ css::uno::Reference< XInterface > X11SalInstance::CreateClipboard( const Sequenc
css::uno::Reference< XInterface > X11SalInstance::CreateDragSource()
{
+ if ( bRunningUnitTest )
+ return SalInstance::CreateDragSource();
+
return css::uno::Reference < XInterface >( static_cast<OWeakObject *>(new SelectionManagerHolder()) );
}
css::uno::Reference< XInterface > X11SalInstance::CreateDropTarget()
{
+ if ( bRunningUnitTest )
+ return SalInstance::CreateDropTarget();
+
return css::uno::Reference < XInterface >( static_cast<OWeakObject *>(new DropTarget()) );
}
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 9f1804a78791..1c9e284be0c3 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1145,8 +1145,15 @@ void VclGtkClipboard::removeClipboardListener( const Reference< datatransfer::cl
m_aListeners.erase(std::remove(m_aListeners.begin(), m_aListeners.end(), listener), m_aListeners.end());
}
+// We run unit tests in parallel, which is a problem when touching a shared resource
+// the system clipboard, so rather use the dummy GenericClipboard.
+const bool bRunningUnitTest = getenv("LO_TESTNAME");
+
Reference< XInterface > GtkInstance::CreateClipboard(const Sequence< Any >& arguments)
{
+ if ( bRunningUnitTest )
+ return SalInstance::CreateClipboard( arguments );
+
OUString sel;
if (!arguments.hasElements()) {
sel = "CLIPBOARD";
@@ -1312,6 +1319,9 @@ void GtkDropTarget::setDefaultActions(sal_Int8 nDefaultActions)
Reference< XInterface > GtkInstance::CreateDropTarget()
{
+ if ( bRunningUnitTest )
+ return SalInstance::CreateDropTarget();
+
return Reference<XInterface>(static_cast<cppu::OWeakObject*>(new GtkDropTarget));
}
@@ -1381,6 +1391,9 @@ css::uno::Sequence<OUString> SAL_CALL GtkDragSource::getSupportedServiceNames()
Reference< XInterface > GtkInstance::CreateDragSource()
{
+ if ( bRunningUnitTest )
+ return SalInstance::CreateDragSource();
+
return Reference< XInterface >( static_cast<cppu::OWeakObject *>(new GtkDragSource()) );
}
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)