uitest: speed up close_doc()

I used solenv/gbuild/Trace.mk to measure where the time is spent at the
end of an incremental 'make check'. The last 95 seconds in spent
executing UITest_demo_ui alone.

If that test is executed in isolation, it takes 135 seconds. Profiling
the test shows that some of that time is spent on waiting for an
OnViewClosed event to be emitted after .uno:CloseDoc is dispatched.

I'm not sure how this worked in the past, but seems that in case there
is a single view, then we currently only emit OnUnloaded, which means we
wait a minute for an event that does not arrive, then we silently move
on.

Fix the problem by closing the document via dispose(), the old code also
just discarded all changes to the file.

The new cost of UITest_demo_ui is 73 seconds (54% of baseline).

The overall 'make check' is 84 seconds faster with this, too.

Change-Id: I97e8e2af3ba355b8029920076e070d619b110b77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89984
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna 2020-03-04 17:10:13 +01:00
parent 9323307d67
commit d1a4f95def

View file

@ -162,21 +162,19 @@ class UITest(object):
raise DialogNotClosedException()
def close_doc(self):
with EventListener(self._xContext, ["DialogExecute", "OnViewClosed"] ) as event:
if not self._xUITest.executeDialog(".uno:CloseDoc"):
print(".uno:CloseDoc failed")
time_ = 0
while time_ < MAX_WAIT:
if event.hasExecuted("DialogExecute"):
xCloseDlg = self._xUITest.getTopFocusWindow()
xNoBtn = xCloseDlg.getChild("discard")
xNoBtn.executeAction("CLICK", tuple())
return
elif event.hasExecuted("OnViewClosed"):
return
time_ += DEFAULT_SLEEP
time.sleep(DEFAULT_SLEEP)
desktop = self.get_desktop()
active_frame = desktop.getActiveFrame()
if not active_frame:
print("close_doc: no active frame")
return
component = active_frame.getController().getModel()
if not component:
print("close_doc: active frame has no component")
return
component.dispose()
frames = desktop.getFrames()
if frames:
frames[0].activate()
def execute_blocking_action(self, action, dialog_element=None,
args=(), dialog_handler=None, printNames=False):