12#include <rtl/string.hxx>
23 Timer(
"debug event injector")
24 , mnEventsLeft( nMaxEvents )
50 assert (pParent !=
nullptr);
52 std::vector< vcl::Window *> aChildren;
55 return aChildren[ aChildren.size() *
getRandom() ];
62 for (sal_uInt16
i = 0;
i < nItems;
i++)
65 rIds.emplace_back( pMenu->
GetItemId(
i ), pMenu );
99 std::vector< SalMenuEvent > aIds;
107 "Injected menu event " <<
aEvent.mpMenu
108 <<
" (" <<
aEvent.mnId <<
") '"
136 sal_uInt16 nCodeStart, nCodeEnd;
138 }
const nTextCodes[] = {
144 int offset =
int(
getRandom() * ( nTextCodes[
i].nCodeEnd - nTextCodes[
i].nCodeStart ) );
145 aKeyEvent.
mnCode = nTextCodes[
i].nCodeStart + offset;
146 aKeyEvent.
mnCharCode = nTextCodes[
i].aCharStart + offset;
157 "Injected key 0x" << std::hex <<
static_cast<int>(aKeyEvent.
mnCode) << std::dec
158 <<
" -> " << bHandled
159 <<
" win " << pWindow );
176 for (
int i = 0;
i < nEvents;
i++)
179 else if (nRand < 0.60)
181 else if (nRand < 0.95)
192 }
const nWeights[] = {
216 for (
auto & rWeight : nWeights)
222 nKey = rWeight.mnKey;
239 "Injected edit / move key 0x" << std::hex <<
static_cast<int>(aKeyEvent.
mnCode) << std::dec
240 <<
" -> " << bHandled
241 <<
" win " << pWindow );
261 const char *pEvents = getenv(
"VCL_EVENT_INJECTION");
static tools::Long GetTopWindowCount()
Return the number of top-level windows being used by the application.
static vcl::Window * GetTopWindow(tools::Long nIndex)
Get the nth top window.
static void Quit()
Quit the program.
static vcl::Window * GetFocusWindow()
Get the currently focused window.
static vcl::Window * GetActiveTopWindow()
Get the "active" top window.
DebugEventInjector(sal_uInt32 nMaxEvents)
static void InjectTextEvent()
virtual void Invoke() override
Calls the maInvokeHandler with the parameter this.
static void InjectMenuEvent()
static void InjectKeyNavEdit()
static vcl::Window * ChooseWindow()
static void InjectEvent()
static DebugEventInjector * getCreate()
MenuBar * GetMenuBar() const
void SetTimeout(sal_uInt64 nTimeoutMs)
virtual void Start(bool bStartTimer=true) override
Schedules the task for execution.
SAL_DLLPRIVATE void CollectChildren(::std::vector< vcl::Window * > &rAllChildren)
Add all children to rAllChildren recursively.
SystemWindow * GetSystemWindow() const
static void CollectMenuItemIds(Menu *pMenu, std::vector< SalMenuEvent > &rIds)
static void InitKeyEvent(SalKeyEvent &rKeyEvent)
static double getRandom()
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_0
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_CODE_MASK
constexpr sal_uInt16 KEY_MODIFIERS_MASK
constexpr sal_uInt16 KEY_9
constexpr sal_uInt16 KEY_Z
constexpr sal_uInt16 KEY_A
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_SPACE
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_INSERT
constexpr sal_uInt16 KEY_BACKSPACE
constexpr sal_uInt16 KEY_END
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
double uniform_real_distribution(double a=0.0, double b=1.0)
sal_uInt32 toUInt32(std::u16string_view str, sal_Int16 radix=10)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
bool ImplWindowFrameProc(vcl::Window *_pWindow, SalEvent nEvent, const void *pEvent)