summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-03-04 17:10:13 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-03-04 21:36:15 +0100
commitd1a4f95def7d65165a992613784564c02b1c76bb (patch)
tree5f78395647d6cd4eaaf95450b655cc9cfe12df6a /uitest
parent9323307d675b71c501534ee98872a2f00b465bc2 (diff)
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
Diffstat (limited to 'uitest')
-rw-r--r--uitest/uitest/test.py28
1 files changed, 13 insertions, 15 deletions
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):