diff options
author | Noel Grandin <noel@peralex.com> | 2021-09-01 10:58:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-09-01 20:42:40 +0200 |
commit | e25ba7dc57229d1cb9794abd1ca23c0d87ebecb3 (patch) | |
tree | 8c95e0c81e003410526cb4ad8357eab3a2db0f44 /vcl/osx/service_entry.cxx | |
parent | 86576cef2c77c8dc78e374aadaadf018610ed6f4 (diff) |
use a dummy clipboard when running unit tests
so the multiple unit tests don't stomp on each other.
This fixes a couple of things in my earlier attempt
(*) actually set the env variable on Windows
(*) don't use a global variable to test the env var, because that
variable might be initialised BEFORE the env var is actually set
Change-Id: Id43a1dd2fbd324691e0b6578c9026b8a523012e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121436
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/osx/service_entry.cxx')
-rw-r--r-- | vcl/osx/service_entry.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/vcl/osx/service_entry.cxx b/vcl/osx/service_entry.cxx index 22b28a2c4a1a..73fd2aa9c958 100644 --- a/vcl/osx/service_entry.cxx +++ b/vcl/osx/service_entry.cxx @@ -36,11 +36,12 @@ 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. -const bool bRunningUnitTest = getenv("LO_TESTNAME"); +// Note, cannot make this a global variable, because it might be initialised BEFORE the putenv() call in cppunittester. +static bool IsRunningUnitTest() { return getenv("LO_TESTNAME") != nullptr; } uno::Reference< XInterface > AquaSalInstance::CreateClipboard( const Sequence< Any >& i_rArguments ) { - if ( Application::IsHeadlessModeEnabled() || bRunningUnitTest ) + if ( Application::IsHeadlessModeEnabled() || IsRunningUnitTest() ) return SalInstance::CreateClipboard( i_rArguments ); SalData* pSalData = GetSalData(); @@ -51,7 +52,7 @@ uno::Reference< XInterface > AquaSalInstance::CreateClipboard( const Sequence< A uno::Reference<XInterface> AquaSalInstance::CreateDragSource() { - if ( Application::IsHeadlessModeEnabled() || bRunningUnitTest ) + if ( Application::IsHeadlessModeEnabled() || IsRunningUnitTest() ) return SalInstance::CreateDragSource(); return uno::Reference<XInterface>(static_cast< XInitialization* >(new DragSource()), UNO_QUERY); @@ -59,7 +60,7 @@ uno::Reference<XInterface> AquaSalInstance::CreateDragSource() uno::Reference<XInterface> AquaSalInstance::CreateDropTarget() { - if ( Application::IsHeadlessModeEnabled() || bRunningUnitTest ) + if ( Application::IsHeadlessModeEnabled() || IsRunningUnitTest() ) return SalInstance::CreateDropTarget(); return uno::Reference<XInterface>(static_cast< XInitialization* >(new DropTarget()), UNO_QUERY); |