uitest/uitest/test.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
New commits: commit 02bd6074b00c3e4420f67ad67566c217d9341c03 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Oct 25 16:17:43 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Oct 25 17:54:39 2021 +0200 uitest: execute setActiveFrame in load_file first In 4839b7ca3b5a730edf90ebebc749db145efec098 < Fix UITests that use File Open dialog to load documents > the order of execution of load_file method was changed, making the code after the yield keyword to be executed after the test code is run, which is not what the original code did. We need to execute that code before running the test code, specially setActiveFrame Change-Id: I4ba436cbdf4fe2261589527f8d38a916d47b94aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124154 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py index 2dddd39038c4..9a15671223b9 100644 --- a/uitest/uitest/test.py +++ b/uitest/uitest/test.py @@ -74,8 +74,8 @@ class UITest(object): raise Exception("Property not updated: " + childName) @contextmanager - def wait_until_component_loaded(self, eventName="OnLoad"): - with EventListener(self._xContext, eventName) as event: + def wait_until_component_loaded(self): + with EventListener(self._xContext, "OnLoad") as event: yield time_ = 0 while time_ < MAX_WAIT: @@ -90,12 +90,26 @@ class UITest(object): raise Exception("Component not loaded") + def load_component_from_url(self, url, eventName="OnLoad"): + with EventListener(self._xContext, eventName) as event: + component = self.get_desktop().loadComponentFromURL(url, "_default", 0, tuple()) + time_ = 0 + while time_ < MAX_WAIT: + if event.executed: + frames = self.get_frames() + #activate the newest frame + self.get_desktop().setActiveFrame(frames[-1]) + return component + time_ += DEFAULT_SLEEP + time.sleep(DEFAULT_SLEEP) + + raise Exception("Document not loaded") + # Calls UITest.close_doc at exit @contextmanager def load_file(self, url): try: - with self.wait_until_component_loaded(): - yield self.get_desktop().loadComponentFromURL(url, "_default", 0, tuple()) + yield self.load_component_from_url(url) finally: self.close_doc() @@ -103,11 +117,11 @@ class UITest(object): @contextmanager def load_empty_file(self, app): try: - with self.wait_until_component_loaded("OnNew"): - yield self.get_desktop().loadComponentFromURL("private:factory/s" + app, "_blank", 0, tuple()) + yield self.load_component_from_url("private:factory/s" + app, "OnNew") finally: self.close_doc() + # Calls UITest.close_dialog_through_button at exit @contextmanager def execute_dialog_through_command(self, command, printNames=False, close_button = "ok", eventName = "DialogExecute"):