cppunittester: use a dedicated desktop on Windows
Since introduction of accessibility tests infrastructure in commit
0185ddd6d5
(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>
This commit is contained in:
parent
b16861f667
commit
1f24d35033
1 changed files with 19 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue