dbaccess/uitest: Wait for idle after selecting view mode

The .uno:DBViewTables and .uno:DBViewQueries commands are executed
asynchronously by posting an event to the main thread from
OApplicationController. This creates a race condition for the test where
the following call to .uno:SelectAll silently fails if the event is not
processed before the command is dispatched. After that the attempt to
open a new subcomponent fails, the OnLoad event is never sent and the
test gets stuck in an infinite loop until the kill-wrapper kills it.
This happens for example in the following build log:

https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/193243/console

I think I can artificially reproduce the problem locally by adding a
sleep in OApplicationController::OnSelectContainer and at least in that
case this patch appears to fix it. It just makes the tests wait until
the main thread is idle after issuing the commands to switch the view.

Change-Id: If8698114c30cf4219310a9c1b2a2bb365debea8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194376
Reviewed-by: Neil Roberts <bpeeluk@yahoo.co.uk>
Tested-by: Jenkins
This commit is contained in:
Neil Roberts
2025-11-23 08:09:42 +01:00
parent 02b0772b31
commit 9b004694bb
2 changed files with 8 additions and 0 deletions
@@ -23,6 +23,10 @@ class tdf75509(UITestCase):
xDbWindow = self.xUITest.getTopFocusWindow()
self.xUITest.executeCommand(".uno:DBViewTables")
# The above command is run asynchronously via an event on the main thread so we need to
# wait until it is dispatched before executing the next command
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
xToolkit.waitUntilAllIdlesDispatched()
# We just want to select the single table in the list of tables but it seems difficult
# to get access to the treeview window for it because there are multiple treeviews in a
@@ -24,6 +24,10 @@ class tdf99619(UITestCase):
xDbWindow = self.xUITest.getTopFocusWindow()
self.xUITest.executeCommand(".uno:DBViewQueries")
# The above command is run asynchronously via an event on the main thread so we need to
# wait until it is dispatched before executing the next command
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
xToolkit.waitUntilAllIdlesDispatched()
# We just want to select the single query in the list of queries but it seems difficult
# to get access to the treeview window for it because there are multiple treeviews in a