summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-07-07 16:02:08 +0300
committerMichael Stahl <michael.stahl@allotropia.de>2023-07-10 19:38:58 +0200
commit236bf42fac81c074a07c193991e496d4c171e36e (patch)
treeee3c5312b657e11eca697fd277049aad42a3afef /sal
parentf11e83f29852de8c2ba6fe0c9abe547c92bb1063 (diff)
cppunittester: use a dedicated desktop on Windows
Since introduction of accessibility tests infrastructure in commit 0185ddd6d5f0324ba57b3fa36229103a6b27138e (Add infrastructure and basic tests including slight UI interaction, 2022-08-01) and the respective tests, running 'make check' on Windows produces pop-up dialogs, while these tests run. These dialogs distract, steal focus, swallow text that I type elsewhere, and may fail the tests if accidental user input interferes with what the tests check. This commit creates a dedicated system desktop for cppunittests, which would be isolated from the active desktop, yet allow creation of windows, thus not preventing accessibility testing. This way, it workarounds unavailability of svp vcl plugin on Windows. Change-Id: I83db54c82bfe98d14171355cc19cdd5767549fdb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154194 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 1f24d35033c2f02335ce254bbcf6ba89e1b7565e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154189 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sal')
-rw-r--r--sal/cppunittester/cppunittester.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index 6729903edd5d..50910fecfdd7 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -40,6 +40,7 @@
#include <string>
#include <sal/log.hxx>
#include <sal/types.h>
+#include <comphelper/scopeguard.hxx>
#include <cppunittester/protectorfactory.hxx>
#include <osl/module.h>
#include <osl/module.hxx>
@@ -404,6 +405,24 @@ static bool main2()
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG|_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif
+ // Create a desktop, to avoid popups interferring with active user session,
+ // because on Windows, we don't use svp vcl plugin for unit testing
+ HDESK hDesktop = nullptr;
+ comphelper::ScopeGuard desktopRestore(
+ [&hDesktop, hPrevDesktop = GetThreadDesktop(GetCurrentThreadId())]()
+ {
+ if (hDesktop)
+ {
+ SetThreadDesktop(hPrevDesktop);
+ CloseDesktop(hDesktop);
+ }
+ });
+ if (getenv("CPPUNIT_DEFAULT_DESKTOP") == nullptr)
+ {
+ hDesktop = CreateDesktopW(L"LO_CPPUNIT_DESKTOP", nullptr, nullptr, 0, GENERIC_ALL, nullptr);
+ if (hDesktop)
+ SetThreadDesktop(hDesktop);
+ }
#endif
std::vector<CppUnit::Protector *> protectors;