summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-10-25 16:17:43 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-10-25 17:54:39 +0200
commit02bd6074b00c3e4420f67ad67566c217d9341c03 (patch)
tree8cdc7baa616b62f2c11799e4743e7dd361f32cbf /uitest
parent5dc3bc1e951a5e1c485db8034d691bac4d42344a (diff)
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>
Diffstat (limited to 'uitest')
-rw-r--r--uitest/uitest/test.py26
1 files changed, 20 insertions, 6 deletions
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"):