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 <xiscofauli@libreoffice.org>
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 2dddd39..9a15671 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"):