[Libreoffice-commits] core.git: uitest/uitest
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Mar 4 20:36:49 UTC 2020
uitest/uitest/test.py | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
New commits:
commit d1a4f95def7d65165a992613784564c02b1c76bb
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Mar 4 17:10:13 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Mar 4 21:36:15 2020 +0100
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 at collabora.com>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Jenkins
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 72b2a810c380..b4ad24e5c31c 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -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):
More information about the Libreoffice-commits
mailing list