diff options
author | Colomban Wendling <cwendling@hypra.fr> | 2023-01-24 18:07:52 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-03-03 09:58:06 +0000 |
commit | ab0681dadc15b569027c5ce637441ea95eae1631 (patch) | |
tree | 73cbeeb862378160a99f1f217f2d58148d676358 /test | |
parent | 70d0281bbd36c25b5251f4e1c99507084659db90 (diff) |
test: Fail earlier if we don't get WindowActivate events
Instead of waiting for the CI itself to timeout after 45 minutes, or
for an interactive caller to kill us sometime, don't wait more than 60
seconds for a WindowActivate event to show up.
This should not happen in the working code paths, but can help when
something's going wrong. Currently, this could help macos jobs to fail
sooner.
Change-Id: Iabce82b31440c14fd16478f1e574ce376027441c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146099
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/a11y/accessibletestbase.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/source/a11y/accessibletestbase.cxx b/test/source/a11y/accessibletestbase.cxx index 47a77e864932..857df519f136 100644 --- a/test/source/a11y/accessibletestbase.cxx +++ b/test/source/a11y/accessibletestbase.cxx @@ -283,12 +283,14 @@ test::AccessibleTestBase::awaitDialog(const std::u16string_view name, std::u16string_view msName; std::function<void(Dialog&)> mCallback; bool mbAutoClose; + Timer maTimeoutTimer; public: virtual ~ListenerHelper() { Application::SetDialogCancelMode(miPreviousDialogCancelMode); Application::RemoveEventListener(mLink); + maTimeoutTimer.Stop(); } ListenerHelper(const std::u16string_view& name, std::function<void(Dialog&)> callback, @@ -297,16 +299,39 @@ test::AccessibleTestBase::awaitDialog(const std::u16string_view name, , msName(name) , mCallback(callback) , mbAutoClose(bAutoClose) + , maTimeoutTimer("workaround timer if we don't catch WindowActivate") { mLink = LINK(this, ListenerHelper, eventListener); Application::AddEventListener(mLink); + maTimeoutTimer.SetInvokeHandler(LINK(this, ListenerHelper, timeoutTimerHandler)); + maTimeoutTimer.SetTimeout(60000); + maTimeoutTimer.Start(); + miPreviousDialogCancelMode = Application::GetDialogCancelMode(); Application::SetDialogCancelMode(DialogCancelMode::Off); } private: // mimic IMPL_LINK inline + static void LinkStubtimeoutTimerHandler(void* instance, Timer* timer) + { + static_cast<ListenerHelper*>(instance)->timeoutTimerHandler(timer); + } + + void timeoutTimerHandler(Timer*) + { + std::cerr << "timeout waiting for dialog '" << OUString(msName) << "' to show up" + << std::endl; + + assert(mbWaitingForDialog); + + // This is not very nice, but it should help fail earlier if we never catch the dialog + // yet we're in a sub-loop and waitEndDialog() didn't have a chance to run yet. + throw new css::uno::RuntimeException("Timeout waiting for dialog"); + } + + // mimic IMPL_LINK inline static void LinkStubeventListener(void* instance, VclSimpleEvent& event) { static_cast<ListenerHelper*>(instance)->eventListener(event); @@ -328,6 +353,8 @@ test::AccessibleTestBase::awaitDialog(const std::u16string_view name, // remove ourselves, we don't want to run again Application::RemoveEventListener(mLink); + maTimeoutTimer.ClearInvokeHandler(); + maTimeoutTimer.Stop(); /* bind the dialog before checking its name so auto-close can kick in if anything * fails/throws */ |