[Libreoffice-commits] core.git: uitest/uitest

2023-12-05 Thread Mike Kaganski (via logerrit)
 uitest/uitest/test.py |   48 +++-
 1 file changed, 19 insertions(+), 29 deletions(-)

New commits:
commit faefc434efdc38587ddad0a65618efde81431e38
Author: Mike Kaganski 
AuthorDate: Tue Dec 5 14:29:00 2023 +0100
Commit: Mike Kaganski 
CommitDate: Tue Dec 5 19:28:28 2023 +0100

Deduplicate execute_dialog_through_*

Use Python 3.3's 'yield from', which should be OK, because the
baseline rhel8 has Python 3.6. If needed, older Python could
use replacement like this:

for dialog in self.wait_and_yield_dialog(event, xDialogParent, 
close_button):
yield dialog

Change-Id: Ic70bdf19fed730e41b7ce2868990ec88423eab33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160352
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 08c9a89ef9f5..db2bc1828be1 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -124,6 +124,23 @@ class UITest(object):
 finally:
 self.close_doc()
 
+def wait_and_yield_dialog(self, event, parent, close_button):
+while not event.executed:
+time.sleep(DEFAULT_SLEEP)
+dialog = self._xUITest.getTopFocusWindow()
+if parent == dialog:
+raise Exception("executing the action did not open the dialog")
+try:
+yield dialog
+except:
+if not close_button:
+if 'cancel' in dialog.getChildren():
+self.close_dialog_through_button(dialog.getChild("cancel"))
+raise
+finally:
+if close_button:
+self.close_dialog_through_button(dialog.getChild(close_button))
+
 # Calls UITest.close_dialog_through_button at exit
 @contextmanager
 def execute_dialog_through_command(self, command, printNames=False, 
close_button = "ok", eventName = "DialogExecute"):
@@ -131,23 +148,7 @@ class UITest(object):
 xDialogParent = self._xUITest.getTopFocusWindow()
 if not self._xUITest.executeDialog(command):
 raise Exception("Dialog not executed for: " + command)
-while True:
-if event.executed:
-xDialog = self._xUITest.getTopFocusWindow()
-if xDialogParent == xDialog:
-raise Exception("executing the action did not open the 
dialog")
-try:
-yield xDialog
-except:
-if not close_button:
-if 'cancel' in xDialog.getChildren():
-
self.close_dialog_through_button(xDialog.getChild("cancel"))
-raise
-finally:
-if close_button:
-
self.close_dialog_through_button(xDialog.getChild(close_button))
-return
-time.sleep(DEFAULT_SLEEP)
+yield from self.wait_and_yield_dialog(event, xDialogParent, 
close_button)
 
 @contextmanager
 def execute_modeless_dialog_through_command(self, command, 
printNames=False, close_button = "ok"):
@@ -163,18 +164,7 @@ class UITest(object):
 xDialogParent = self._xUITest.getTopFocusWindow()
 with EventListener(self._xContext, event_name) as event:
 ui_object.executeAction(action, parameters)
-while True:
-if event.executed:
-xDialog = self._xUITest.getTopFocusWindow()
-if xDialogParent == xDialog:
-raise Exception("executing the action did not open the 
dialog")
-try:
-yield xDialog
-finally:
-if close_button:
-
self.close_dialog_through_button(xDialog.getChild(close_button))
-return
-time.sleep(DEFAULT_SLEEP)
+yield from self.wait_and_yield_dialog(event, xDialogParent, 
close_button)
 
 # Calls UITest.close_doc at exit
 @contextmanager


[Libreoffice-commits] core.git: uitest/uitest

2023-12-05 Thread Xisco Fauli (via logerrit)
 uitest/uitest/test.py |   17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

New commits:
commit 6b41d3f6778b91838c98d1648eb652de48b0511d
Author: Xisco Fauli 
AuthorDate: Mon Dec 4 20:41:06 2023 +0100
Commit: Xisco Fauli 
CommitDate: Tue Dec 5 09:24:59 2023 +0100

uitest: remove crash report handler

Unneded since a4a1f2ecee2e7b1d50e0065e25090e262863e1c4
"Disallow crash reporting in UITests"

Change-Id: I661b6111bd5142e67ee73a82c071e7651300
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160324
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index fcf9d3dee783..08c9a89ef9f5 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -176,17 +176,6 @@ class UITest(object):
 return
 time.sleep(DEFAULT_SLEEP)
 
-def _handle_crash_reporter(self):
-xCrashReportDlg = self._xUITest.getTopFocusWindow()
-state = get_state_as_dict(xCrashReportDlg)
-print(state)
-if state['ID'] != "CrashReportDialog":
-return False
-print("found a crash reporter")
-xCancelBtn = xCrashReportDlg.getChild("btn_cancel")
-self.close_dialog_through_button(xCancelBtn)
-return True
-
 # Calls UITest.close_doc at exit
 @contextmanager
 def create_doc_in_start_center(self, app):
@@ -194,11 +183,7 @@ class UITest(object):
 try:
 xBtn = xStartCenter.getChild(app + "_all")
 except RuntimeException:
-if self._handle_crash_reporter():
-xStartCenter = self._xUITest.getTopFocusWindow()
-xBtn = xStartCenter.getChild(app + "_all")
-else:
-raise
+raise
 
 with EventListener(self._xContext, "OnNew") as event:
 xBtn.executeAction("CLICK", tuple())


[Libreoffice-commits] core.git: uitest/uitest

2023-11-01 Thread Noel Grandin (via logerrit)
 uitest/uitest/test.py |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 9071fa5f5f103808234102dc7552266ccda7bb22
Author: Noel Grandin 
AuthorDate: Wed Nov 1 12:41:05 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Nov 2 06:22:04 2023 +0100

uitest: check that dialog really did open

to make it easier to debug cases where the event.executed flag is not
sufficient to indicate that the dialog has finished opening

Change-Id: Ibcbd089372e47908e3692d452f4064edbc7f788d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158751
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 602b03c2a9f7..fcf9d3dee783 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -128,11 +128,14 @@ class UITest(object):
 @contextmanager
 def execute_dialog_through_command(self, command, printNames=False, 
close_button = "ok", eventName = "DialogExecute"):
 with EventListener(self._xContext, eventName, printNames=printNames) 
as event:
+xDialogParent = self._xUITest.getTopFocusWindow()
 if not self._xUITest.executeDialog(command):
 raise Exception("Dialog not executed for: " + command)
 while True:
 if event.executed:
 xDialog = self._xUITest.getTopFocusWindow()
+if xDialogParent == xDialog:
+raise Exception("executing the action did not open the 
dialog")
 try:
 yield xDialog
 except:
@@ -157,11 +160,14 @@ class UITest(object):
 if parameters is None:
 parameters = tuple()
 
+xDialogParent = self._xUITest.getTopFocusWindow()
 with EventListener(self._xContext, event_name) as event:
 ui_object.executeAction(action, parameters)
 while True:
 if event.executed:
 xDialog = self._xUITest.getTopFocusWindow()
+if xDialogParent == xDialog:
+raise Exception("executing the action did not open the 
dialog")
 try:
 yield xDialog
 finally:


[Libreoffice-commits] core.git: uitest/uitest

2023-10-04 Thread Henry Castro (via logerrit)
 uitest/uitest/test.py |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 3d665f4ee60d994257a29d5fc607d6c88593aed7
Author: Henry Castro 
AuthorDate: Wed Sep 20 07:44:43 2023 -0400
Commit: Henry Castro 
CommitDate: Wed Oct 4 19:46:13 2023 +0200

uitest: add load properties parameters

Add the option to include the load properties
when invoked load_file function.

Signed-off-by: Henry Castro 
Change-Id: I27cb31e2470bc76bcc5b760661e50f00fc334d64
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157102
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157567
Tested-by: Jenkins

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 23ca7f39bc4e..d160b9564d0f 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -81,9 +81,9 @@ class UITest(object):
 return
 time.sleep(DEFAULT_SLEEP)
 
-def load_component_from_url(self, url, eventName="OnLoad"):
+def load_component_from_url(self, url, eventName="OnLoad", load_props=()):
 with EventListener(self._xContext, eventName) as event:
-component =  self.get_desktop().loadComponentFromURL(url, 
"_default", 0, tuple())
+component =  self.get_desktop().loadComponentFromURL(url, 
"_default", 0, load_props)
 while True:
 if event.executed:
 frames = self.get_frames()
@@ -94,9 +94,9 @@ class UITest(object):
 
 # Calls UITest.close_doc at exit
 @contextmanager
-def load_file(self, url):
+def load_file(self, url, load_props=()):
 try:
-yield self.load_component_from_url(url)
+yield self.load_component_from_url(url, "OnLoad", load_props)
 finally:
 self.close_doc()
 


[Libreoffice-commits] core.git: uitest/uitest

2022-02-24 Thread Xisco Fauli (via logerrit)
 uitest/uitest/test.py |   10 ++
 1 file changed, 10 insertions(+)

New commits:
commit 8e8236500ce862ce27acbbfc7bbeab545931798e
Author: Xisco Fauli 
AuthorDate: Thu Feb 24 18:34:27 2022 +0100
Commit: Xisco Fauli 
CommitDate: Thu Feb 24 19:47:47 2022 +0100

uitest: try harder to close the dialog when it fails ...

... and close_button is empty

This was introduced in

2021-06-29 15:35:55 - ff641dc9e4d2aff1d1cbe4425cd9c03a2edc847e
< uitest: try harder to close the dialog when it fails... >

and later reverted in

2021-07-02 20:41:50 - 4f8748fc973acdb67790ff048a247717afa9b9c7
< Revert "uitest: try harder to close the dialog when it fails..." >

Reintroduce it again and also fix the problem why it was reverted.
Without this fix, it will hang when an assert is triggered inside
a dialog when close_button is empty

Change-Id: If643caea61139f69f72c9b429aaad5b9d7d78c72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130506
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 3beee0d274f2..11cb15dab9c8 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -133,6 +133,11 @@ class UITest(object):
 xDialog = self._xUITest.getTopFocusWindow()
 try:
 yield xDialog
+except:
+if not close_button:
+if 'cancel' in xDialog.getChildren():
+
self.close_dialog_through_button(xDialog.getChild("cancel"))
+raise
 finally:
 if close_button:
 
self.close_dialog_through_button(xDialog.getChild(close_button))
@@ -259,6 +264,11 @@ class UITest(object):
 xDialog = self._xUITest.getTopFocusWindow()
 try:
 yield xDialog
+except:
+if not close_button:
+if 'cancel' in xDialog.getChildren():
+
self.close_dialog_through_button(xDialog.getChild("cancel"))
+raise
 finally:
 if close_button:
 
self.close_dialog_through_button(xDialog.getChild(close_button))


[Libreoffice-commits] core.git: uitest/uitest

2021-11-27 Thread Noel Grandin (via logerrit)
 uitest/uitest/uihelper/common.py |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 99d2ee15ad6fae7073a53f7df8868300328a36e7
Author: Noel Grandin 
AuthorDate: Sat Nov 27 14:07:30 2021 +0200
Commit: Noel Grandin 
CommitDate: Sat Nov 27 18:10:48 2021 +0100

blind fix for UITest_impress_demo failures

Change-Id: Ia26c5a15fa4487c68cf6d4bc2aee41a3ded7f6a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125941
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/uitest/uitest/uihelper/common.py b/uitest/uitest/uihelper/common.py
index 2c0cd67a2152..c1269038e523 100644
--- a/uitest/uitest/uihelper/common.py
+++ b/uitest/uitest/uihelper/common.py
@@ -57,4 +57,7 @@ def change_measurement_unit(UITestCase, unit):
 xApplyBtn.executeAction("CLICK", tuple())
 UITestCase.assertEqual(unit, 
get_state_as_dict(xUnit)['SelectEntryText'])
 
+xToolkit = 
UITestCase.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+xToolkit.processEventsToIdle()
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:


[Libreoffice-commits] core.git: uitest/uitest

2021-10-25 Thread Xisco Fauli (via logerrit)
 uitest/uitest/test.py |   26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

New commits:
commit 02bd6074b00c3e4420f67ad67566c217d9341c03
Author: Xisco Fauli 
AuthorDate: Mon Oct 25 16:17:43 2021 +0200
Commit: Xisco Fauli 
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 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 239038c4..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"):


[Libreoffice-commits] core.git: uitest/uitest

2021-07-02 Thread Xisco Fauli (via logerrit)
 uitest/uitest/test.py |8 
 1 file changed, 8 deletions(-)

New commits:
commit 4f8748fc973acdb67790ff048a247717afa9b9c7
Author: Xisco Fauli 
AuthorDate: Fri Jul 2 20:41:50 2021 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 2 21:45:04 2021 +0200

Revert "uitest: try harder to close the dialog when it fails..."

This reverts commit ff641dc9e4d2aff1d1cbe4425cd9c03a2edc847e.

Reason for revert: This patch is wrong, when close_button is set, the 
exceptions will be caught here so the test won't fail

Change-Id: Id884abe70ab5602f914742e91bb2ed644c23b041
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118303
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index c1688f84be96..fe06c1e65817 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -119,10 +119,6 @@ class UITest(object):
 xDialog = self._xUITest.getTopFocusWindow()
 try:
 yield xDialog
-except:
-if not close_button:
-if 'cancel' in xDialog.getChildren():
-
self.close_dialog_through_button(xDialog.getChild("cancel"))
 finally:
 if close_button:
 
self.close_dialog_through_button(xDialog.getChild(close_button))
@@ -257,10 +253,6 @@ class UITest(object):
 xDialog = self._xUITest.getTopFocusWindow()
 try:
 yield xDialog
-except:
-if not close_button:
-if 'cancel' in xDialog.getChildren():
-
self.close_dialog_through_button(xDialog.getChild("cancel"))
 finally:
 if close_button:
 
self.close_dialog_through_button(xDialog.getChild(close_button))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2021-06-29 Thread Xisco Fauli (via logerrit)
 uitest/uitest/test.py |8 
 1 file changed, 8 insertions(+)

New commits:
commit ff641dc9e4d2aff1d1cbe4425cd9c03a2edc847e
Author: Xisco Fauli 
AuthorDate: Tue Jun 29 15:35:55 2021 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jun 29 21:52:01 2021 +0200

uitest: try harder to close the dialog when it fails...

... and close_button is None.

Change-Id: I01318fd3eff5c9d8775443529ad1a7b18d537968
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118117
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 1e3ddc85747f..8b7b5a4c98f8 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -119,6 +119,10 @@ class UITest(object):
 xDialog = self._xUITest.getTopFocusWindow()
 try:
 yield xDialog
+except:
+if not close_button:
+if 'cancel' in xDialog.getChildren():
+
self.close_dialog_through_button(xDialog.getChild("cancel"))
 finally:
 if close_button:
 
self.close_dialog_through_button(xDialog.getChild(close_button))
@@ -248,6 +252,10 @@ class UITest(object):
 xDialog = self._xUITest.getTopFocusWindow()
 try:
 yield xDialog
+except:
+if not close_button:
+if 'cancel' in xDialog.getChildren():
+
self.close_dialog_through_button(xDialog.getChild("cancel"))
 finally:
 if close_button:
 
self.close_dialog_through_button(xDialog.getChild(close_button))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2021-06-25 Thread Xisco Fauli (via logerrit)
 uitest/uitest/test.py |   31 +--
 1 file changed, 13 insertions(+), 18 deletions(-)

New commits:
commit 66494118ec1ddad3af56a1ed708f0a59fe063e86
Author: Xisco Fauli 
AuthorDate: Thu Jun 24 14:28:22 2021 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jun 25 18:36:49 2021 +0200

uitest: raise exception if timeout is reached

Change-Id: Ibcde404456f5c71484d925c47eb2a0c20c601033
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117785
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 833f5a726049..e8238f790d6b 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -16,13 +16,6 @@ from com.sun.star.uno import RuntimeException
 
 from libreoffice.uno.eventlistener import EventListener
 
-class DialogNotExecutedException(Exception):
-def __init__(self, command):
-self.command = command
-
-def __str__(self):
-return "Dialog not executed for: " + self.command
-
 class UITest(object):
 
 def __init__(self, xUITest, xContext):
@@ -58,28 +51,28 @@ class UITest(object):
 
 def wait_until_child_is_available(self, childName):
 time_ = 0
-xChild = None
 
 while time_ < MAX_WAIT:
 xDialog = self._xUITest.getTopFocusWindow()
 if childName in xDialog.getChildren():
-xChild = xDialog.getChild(childName)
-break
+return xDialog.getChild(childName)
 else:
 time_ += DEFAULT_SLEEP
 time.sleep(DEFAULT_SLEEP)
 
-return xChild
+raise Exception("Child not found: " + childName)
 
 def wait_until_property_is_updated(self, element, propertyName, value):
 time_ = 0
 while time_ < MAX_WAIT:
 if get_state_as_dict(element)[propertyName] == value:
-break
+return
 else:
 time_ += DEFAULT_SLEEP
 time.sleep(DEFAULT_SLEEP)
 
+raise Exception("Property not updated: " + childName)
+
 @contextmanager
 def wait_until_component_loaded(self):
 with EventListener(self._xContext, "OnLoad") as event:
@@ -91,10 +84,12 @@ class UITest(object):
 if len(frames) == 1:
 self.get_desktop().setActiveFrame(frames[0])
 time.sleep(DEFAULT_SLEEP)
-break
+return
 time_ += DEFAULT_SLEEP
 time.sleep(DEFAULT_SLEEP)
 
+raise Exception("Component not loaded")
+
 # Calls UITest.close_doc at exit
 @contextmanager
 def load_file(self, url):
@@ -107,7 +102,7 @@ class UITest(object):
 def execute_dialog_through_command(self, command, printNames=False):
 with EventListener(self._xContext, "DialogExecute", 
printNames=printNames) as event:
 if not self._xUITest.executeDialog(command):
-raise DialogNotExecutedException(command)
+raise Exception("Dialog not executed for: " + command)
 while True:
 if event.executed:
 time.sleep(DEFAULT_SLEEP)
@@ -117,7 +112,7 @@ class UITest(object):
 def execute_modeless_dialog_through_command(self, command, 
printNames=False):
 with EventListener(self._xContext, "ModelessDialogVisible", printNames 
= printNames) as event:
 if not self._xUITest.executeCommand(command):
-raise DialogNotExecutedException(command)
+raise Exception("Dialog not executed for: " + command)
 time_ = 0
 while time_ < MAX_WAIT:
 if event.executed:
@@ -126,7 +121,7 @@ class UITest(object):
 time_ += DEFAULT_SLEEP
 time.sleep(DEFAULT_SLEEP)
 
-raise DialogNotExecutedException(command)
+raise Exception("Dialog not executed for: " + command)
 
 # Calls UITest.close_dialog_through_button at exit
 @contextmanager
@@ -147,7 +142,7 @@ class UITest(object):
 return
 time_ += DEFAULT_SLEEP
 time.sleep(DEFAULT_SLEEP)
-raise DialogNotExecutedException(action)
+raise Exception("Dialog not executed for: " + action)
 
 def _handle_crash_reporter(self):
 xCrashReportDlg = self._xUITest.getTopFocusWindow()
@@ -244,6 +239,6 @@ class UITest(object):
 return
 time_ += DEFAULT_SLEEP
 time.sleep(DEFAULT_SLEEP)
-raise DialogNotExecutedException("did not execute a dialog for a 
blocking action")
+raise Exception("Did not execute a dialog for a blocking action")
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2020-04-27 Thread Stephan Bergmann (via logerrit)
 uitest/uitest/test.py |   10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

New commits:
commit 19d3dba72fd744ab8dc1288b1c7c4c811b24ca28
Author: Stephan Bergmann 
AuthorDate: Mon Apr 27 08:32:25 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Mon Apr 27 10:09:58 2020 +0200

Do not time out close_dialog_through_button

If something goes wrong, better keep the testing Python and the tested 
soffice
process in a state in which the actual problem can (hopefully) be debugged
better.

I happened to run into a hung UITest_chart on Linux, where soffice.bin was 
still
at

> Thread 1 (Thread 0x7f2e2b280fc0 (LWP 1906251)):
> #0  futex_abstimed_wait_cancelable (private=0, abstime=0x7f2e27b59a80, 
clockid=, expected=0, futex_word=0x60e24e8c) at 
/usr/src/debug/glibc-2.31-17-gab029a2801/sysdeps/nptl/futex-internal.h:320
> #1  __pthread_cond_wait_common (abstime=0x7f2e27b59a80, 
clockid=, mutex=0x60e24e38, cond=0x60e24e60) at 
/usr/src/debug/glibc-2.31-17-gab029a2801/nptl/pthread_cond_wait.c:520
> #2  __pthread_cond_clockwait (abstime=0x7f2e27b59a80, clockid=, mutex=0x60e24e38, cond=0x60e24e60) at 
/usr/src/debug/glibc-2.31-17-gab029a2801/nptl/pthread_cond_wait.c:677
> #3  __pthread_cond_clockwait (cond=0x60e24e60, mutex=0x60e24e38, 
clockid=, abstime=0x7f2e27b59a80) at 
/usr/src/debug/glibc-2.31-17-gab029a2801/nptl/pthread_cond_wait.c:665
> #4  0x7f2e5fead808 in 
std::condition_variable::__wait_until_impl > >(std::unique_lock&, 
std::chrono::time_point > > const&) 
(this=0x60e24e60, __lock=..., __atime=...) at 
include/c++/10.0.1/condition_variable:210
> #5  0x7f2e5fead295 in 
std::condition_variable::wait_until > >(std::unique_lock&, 
std::chrono::time_point > > const&) 
(this=0x60e24e60, __lock=..., __atime=...) at 
include/c++/10.0.1/condition_variable:120
> #6  0x7f2e5fea8f05 in 
std::condition_variable::wait_until >, 
SvpSalInstance::DoYield(bool, bool)::$_2>(std::unique_lock&, 
std::chrono::time_point > > const&, 
SvpSalInstance::DoYield(bool, bool)::$_2) (this=0x60e24e60, __lock=..., 
__atime=..., __p=...) at include/c++/10.0.1/condition_variable:159
> #7  0x7f2e5fea6e60 in std::condition_variable::wait_for, SvpSalInstance::DoYield(bool, 
bool)::$_2>(std::unique_lock&, std::chrono::duration > const&, SvpSalInstance::DoYield(bool, bool)::$_2) 
(this=0x60e24e60, __lock=..., __rtime=..., __p=...) at 
include/c++/10.0.1/condition_variable:186
> #8  0x7f2e5fea5a8e in SvpSalInstance::DoYield(bool, bool) 
(this=0x61101bc0, bWait=true, bHandleAllCurrentEvents=false) at 
vcl/headless/svpinst.cxx:497
> #9  0x7f2e5f3a232d in ImplYield(bool, bool) (i_bWait=true, 
i_bAllEvents=false) at vcl/source/app/svapp.cxx:454
> #10 0x7f2e5f3a18e8 in Application::Yield() () at 
vcl/source/app/svapp.cxx:518
> #11 0x7f2e5bf32c2d in Dialog::Execute() (this=0x61a72080) at 
vcl/source/window/dialog.cxx:1032
> #12 0x7f2e5efdcd62 in SalInstanceDialog::run() (this=0x61991080) 
at vcl/source/app/salvtables.cxx:1480
> #13 0x7f2dc37421fd in weld::DialogController::run() 
(this=0x61200077c5c0) at include/vcl/weld.hxx:2227
> #14 0x7f2dc39672f2 in chart::CreationWizardUnoDlg::execute() 
(this=0x61168d40) at 
chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx:189
> #15 0x7f2df91f2507 in FuInsertChart::FuInsertChart(ScTabViewShell&, 
vcl::Window*, ScDrawView*, SdrModel*, SfxRequest&) (this=0x7f2e27f1a300, 
rViewSh=..., pWin=0x61a0001e8a80, pViewP=0x61d0001f6880, pDoc=0x61766a00, 
rReq=...) at sc/source/ui/drawfunc/fuins2.cxx:673
> #16 0x7f2dfaf9a379 in ScTabViewShell::ExecDrawIns(SfxRequest&) 
(this=0x61d0001eaa80, rReq=...) at sc/source/ui/view/tabvwshb.cxx:336
> #17 0x7f2dfaedf365 in SfxStubScTabViewShellExecDrawIns(SfxShell*, 
SfxRequest&) (pShell=0x61d0001eaa80, rReq=...) at 
workdir/SdiTarget/sc/sdi/scslots.hxx:1447
> #18 0x7f2e8031ded6 in SfxShell::CallExec(void (*)(SfxShell*, 
SfxRequest&), SfxRequest&) (this=0x61d0001eaa80, pFunc=0x7f2dfaedf240 
, rReq=...) at 
include/sfx2/shell.hxx:197
> #19 0x7f2e802a77ff in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot 
const&, SfxRequest&, bool) (this=0x6020002f3dd0, rShell=..., rSlot=..., 
rReq=..., bRecord=true) at sfx2/source/control/dispatch.cxx:251
> #20 0x7f2e802aacb6 in 
SfxDispatcher::PostMsgHandler(std::unique_ptr >) (this=0x6020002f3dd0, 
pReq=std::unique_ptr = {...}) at 
sfx2/source/control/dispatch.cxx:988
[...]

but the Python process was already at

> Traceback (most recent call first):
>   
>   File "instdir/program/python-core-3.7.7/lib/subprocess.py", line 1611, 
in _try_wait
> (pid, sts) = os.waitpid(self.pid, wait_flags)
>   File "instdir/program/python-core-3.7.7/lib/subprocess.py", line 1653, 
in _wait
> (pid, sts) = self._try_wait(0)
>   File 

[Libreoffice-commits] core.git: uitest/uitest

2020-03-04 Thread Miklos Vajna (via logerrit)
 uitest/uitest/test.py |   28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

New commits:
commit d1a4f95def7d65165a992613784564c02b1c76bb
Author: Miklos Vajna 
AuthorDate: Wed Mar 4 17:10:13 2020 +0100
Commit: Miklos Vajna 
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 
Reviewed-by: Noel Grandin 
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):
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2019-01-16 Thread Libreoffice Gerrit user
 uitest/uitest/test.py |   21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

New commits:
commit ba4a3e650531a4832795514cdbd7535281f408aa
Author: Noel Grandin 
AuthorDate: Wed Jan 16 08:25:51 2019 +0200
Commit: Noel Grandin 
CommitDate: Wed Jan 16 09:12:19 2019 +0100

eliminate some noise from uitest failure

re-arrange the logic so that when create_doc_in_start_center fails, we
only get one backtrace instead of two.

Change-Id: I736b56da8cfb11e8ef17b8422a19eafd70e3cd6f
Reviewed-on: https://gerrit.libreoffice.org/66415
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 1a72c76fb37b..0855a9d4efc5 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -115,22 +115,23 @@ class UITest(object):
 xCrashReportDlg = self._xUITest.getTopFocusWindow()
 state = get_state_as_dict(xCrashReportDlg)
 print(state)
-if state['ID'] == "CrashReportDialog":
-print("found a crash reporter")
-xCancelBtn = xCrashReportDlg.getChild("btn_cancel")
-self.close_dialog_through_button(xCancelBtn)
-else:
-raise RuntimeException("not a crashreporter")
+if state['ID'] != "CrashReportDialog":
+return False
+print("found a crash reporter")
+xCancelBtn = xCrashReportDlg.getChild("btn_cancel")
+self.close_dialog_through_button(xCancelBtn)
+return True
 
 def create_doc_in_start_center(self, app):
 xStartCenter = self._xUITest.getTopFocusWindow()
 try:
 xBtn = xStartCenter.getChild(app + "_all")
 except RuntimeException:
-print("Handled crash reporter")
-self._handle_crash_reporter()
-xStartCenter = self._xUITest.getTopFocusWindow()
-xBtn = xStartCenter.getChild(app + "_all")
+if self._handle_crash_reporter():
+xStartCenter = self._xUITest.getTopFocusWindow()
+xBtn = xStartCenter.getChild(app + "_all")
+else:
+raise
 
 with EventListener(self._xContext, "OnNew") as event:
 xBtn.executeAction("CLICK", tuple())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2018-02-21 Thread Stephan Bergmann
 uitest/uitest/test.py |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

New commits:
commit ef03e3a36f821e9d85f08cb06e72dc32fbbaade9
Author: Stephan Bergmann 
Date:   Wed Feb 21 09:39:50 2018 +0100

Revert "uitest: add timeout for blocking actions"

This reverts commit fb4d5885f3c8d00ae528ddf57b2abaa4aabfbcf3:

"For one, as Michael already responded, many builds (local, Gerrit/Jenkins,
other tinderboxes) now fail UITest_writerperfect_epubexport with what looks 
like
random 'raise DialogNotClosedException()'.  Gut feeling is that it's way 
more
than used to fail UITest_writerperfect_epubexport with a deadlock."

(
"Re: UITest_writerperfect_epubexport hang (only sometimes)")  For example,
 "tdf#115853: save current custom
property when adding line" Jenkins linux_clang_dbgutil_64 now failed twice 
in a
row with what looks like random "raise DialogNotClosedException()" failures 
in
UITest_writerperfect_epubexport.

And for another:  "As long as its unclear what the underlying problem is, 
what
benefit does it have to add a timeout failure path in the test?  Without the
added timeout, a local failed test will be ready to be inspected (and moggi 
now
gave suggestions what exactly to inspect in another mail in this thread).  
And
failed tests on the tinderboxes will eventually time out either way."

(
"Re: UITest_writerperfect_epubexport hang (only sometimes)")

Change-Id: I36db7526b68a1cf6be596aa82c57095e4067c150
Reviewed-on: https://gerrit.libreoffice.org/50080
Tested-by: Jenkins 
Reviewed-by: Stephan Bergmann 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index f179807c5b0f..0318dfa64d81 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -178,7 +178,7 @@ class UITest(object):
 time.sleep(DEFAULT_SLEEP)
 
 def execute_blocking_action(self, action, dialog_element=None,
-args=(), dialog_handler=None, dialog_timeout=30):
+args=(), dialog_handler=None):
 """Executes an action which blocks while a dialog is shown.
 
 Click a button or perform some other action on the dialog when it
@@ -192,8 +192,6 @@ class UITest(object):
 args(tuple, optional): The arguments to be passed to `action`
 dialog_handler(callable, optional): Will be called when the dialog
 is shown, with the dialog object passed as a parameter.
-timeout(optional): The maximum time the thread will wait for the
-dialog actions to happen. None means wait forever.
 """
 
 thread = threading.Thread(target=action, args=args)
@@ -209,9 +207,7 @@ class UITest(object):
 xUIElement.executeAction("CLICK", tuple())
 if dialog_handler:
 dialog_handler(xDlg)
-thread.join(dialog_timeout)
-if thread.isAlive():
-raise DialogNotClosedException()
+thread.join()
 return
 
 time_ += DEFAULT_SLEEP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2018-02-18 Thread Markus Mohrhard
 uitest/uitest/test.py |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit fb4d5885f3c8d00ae528ddf57b2abaa4aabfbcf3
Author: Markus Mohrhard 
Date:   Sun Feb 18 01:06:13 2018 +0100

uitest: add timeout for blocking actions

Change-Id: I796d4ea0034ddae0427418f0d53a00c3dfa66871
Reviewed-on: https://gerrit.libreoffice.org/49939
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 0318dfa64d81..f179807c5b0f 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -178,7 +178,7 @@ class UITest(object):
 time.sleep(DEFAULT_SLEEP)
 
 def execute_blocking_action(self, action, dialog_element=None,
-args=(), dialog_handler=None):
+args=(), dialog_handler=None, dialog_timeout=30):
 """Executes an action which blocks while a dialog is shown.
 
 Click a button or perform some other action on the dialog when it
@@ -192,6 +192,8 @@ class UITest(object):
 args(tuple, optional): The arguments to be passed to `action`
 dialog_handler(callable, optional): Will be called when the dialog
 is shown, with the dialog object passed as a parameter.
+timeout(optional): The maximum time the thread will wait for the
+dialog actions to happen. None means wait forever.
 """
 
 thread = threading.Thread(target=action, args=args)
@@ -207,7 +209,9 @@ class UITest(object):
 xUIElement.executeAction("CLICK", tuple())
 if dialog_handler:
 dialog_handler(xDlg)
-thread.join()
+thread.join(dialog_timeout)
+if thread.isAlive():
+raise DialogNotClosedException()
 return
 
 time_ += DEFAULT_SLEEP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-07-30 Thread Markus Mohrhard
 uitest/uitest/test.py |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 0163984ce76141665296969118791a9ffbf076eb
Author: Markus Mohrhard 
Date:   Mon Jul 31 01:17:28 2017 +0200

uitest: wait longer for the blocking action event

Blocking actions are normal actions plus a modal dialog. So we need
to wait quite some time before considering the action as failed.

Change-Id: I76360b15f54abb1f957a1cddf5314359dfae2d25

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 485fe5e4756f..58f4ec4e64b2 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -198,8 +198,8 @@ class UITest(object):
 with EventListener(self._xContext, ["DialogExecute", 
"ModelessDialogExecute"]) as event:
 thread.start()
 time_ = 0
-# wait twice as long as we are potentially executing a second 
action
-while time_ < 2*MAX_WAIT:
+# we are not necessarily opeinging a dialog, so wait much longer
+while time_ < 10 * MAX_WAIT:
 if event.executed:
 xDlg = self._xUITest.getTopFocusWindow()
 if dialog_element:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-07-23 Thread Markus Mohrhard
 uitest/uitest/test.py |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit fadf31b32566bc5e7b729de3e112addb93585be8
Author: Markus Mohrhard 
Date:   Sun Jul 23 06:41:34 2017 +0200

uitest: wait twice as long for blocking actions

Change-Id: Ib54a12e9bce3f0be9b31c57550d01754323832c6

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 122df519da4d..485fe5e4756f 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -198,7 +198,8 @@ class UITest(object):
 with EventListener(self._xContext, ["DialogExecute", 
"ModelessDialogExecute"]) as event:
 thread.start()
 time_ = 0
-while time_ < MAX_WAIT:
+# wait twice as long as we are potentially executing a second 
action
+while time_ < 2*MAX_WAIT:
 if event.executed:
 xDlg = self._xUITest.getTopFocusWindow()
 if dialog_element:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-06-20 Thread Stephan Bergmann
 uitest/uitest/config.py |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 32dd79ba451c949f764e73004795ec07f699cdd4
Author: Stephan Bergmann 
Date:   Tue Jun 20 14:15:26 2017 +0200

MAX_WAIT turns out to be too small

...at least for my ASan+UBSan build, causing spurious 'make check' failures

Change-Id: I6871e6fbc41790de1b38b1b7757b93d349154f47

diff --git a/uitest/uitest/config.py b/uitest/uitest/config.py
index 4ba4146a15a8..d9a86baae84b 100644
--- a/uitest/uitest/config.py
+++ b/uitest/uitest/config.py
@@ -9,6 +9,6 @@ use_sleep = False
 
 DEFAULT_SLEEP = 0.1
 
-MAX_WAIT = 30
+MAX_WAIT = 60
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-06-13 Thread Markus Mohrhard
 uitest/uitest/config.py |2 ++
 uitest/uitest/test.py   |   17 +
 2 files changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 144edb88d29d397604010734f2d6c2e9d7626d1c
Author: Markus Mohrhard 
Date:   Tue Jun 13 05:17:12 2017 +0200

uitest: extract the wait time for the dialogs

Change-Id: Ieb82b643de58523cef30f88363276874b6169021

diff --git a/uitest/uitest/config.py b/uitest/uitest/config.py
index 890d88475b94..4ba4146a15a8 100644
--- a/uitest/uitest/config.py
+++ b/uitest/uitest/config.py
@@ -9,4 +9,6 @@ use_sleep = False
 
 DEFAULT_SLEEP = 0.1
 
+MAX_WAIT = 30
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index e17149251c03..04168c48ae2a 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -8,6 +8,7 @@
 import time
 import threading
 from uitest.config import DEFAULT_SLEEP
+from uitest.config import MAX_WAIT
 from uitest.uihelper.common import get_state_as_dict
 
 from com.sun.star.uno import RuntimeException
@@ -57,7 +58,7 @@ class UITest(object):
 with EventListener(self._xContext, "OnLoad") as event:
 component = desktop.loadComponentFromURL(url, "_default", 0, 
tuple())
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 frames = self.get_frames()
 if len(frames) == 1:
@@ -71,7 +72,7 @@ class UITest(object):
 with EventListener(self._xContext, "DialogExecute") as event:
 self._xUITest.executeDialog(command)
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 time.sleep(DEFAULT_SLEEP)
 return
@@ -84,7 +85,7 @@ class UITest(object):
 with EventListener(self._xContext, "ModelessDialogVisible") as event:
 self._xUITest.executeCommand(command)
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 time.sleep(DEFAULT_SLEEP)
 return
@@ -100,7 +101,7 @@ class UITest(object):
 with EventListener(self._xContext, event_name) as event:
 ui_object.executeAction(action, parameters)
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 time.sleep(DEFAULT_SLEEP)
 return
@@ -132,7 +133,7 @@ class UITest(object):
 with EventListener(self._xContext, "OnNew") as event:
 xBtn.executeAction("CLICK", tuple())
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 frames = self.get_frames()
 self.get_desktop().setActiveFrame(frames[0])
@@ -149,7 +150,7 @@ class UITest(object):
 with EventListener(self._xContext, "DialogClosed" ) as event:
 button.executeAction("CLICK", tuple())
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 time.sleep(DEFAULT_SLEEP)
 return
@@ -161,7 +162,7 @@ class UITest(object):
 with EventListener(self._xContext, ["DialogExecute", "OnViewClosed"] ) 
as event:
 self._xUITest.executeDialog(".uno:CloseDoc")
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.hasExecuted("DialogExecute"):
 xCloseDlg = self._xUITest.getTopFocusWindow()
 xNoBtn = xCloseDlg.getChild("discard")
@@ -178,7 +179,7 @@ class UITest(object):
 with EventListener(self._xContext, ["DialogExecute", 
"ModelessDialogExecute"]) as event:
 thread.start()
 time_ = 0
-while time_ < 30:
+while time_ < MAX_WAIT:
 if event.executed:
 xDlg = self._xUITest.getTopFocusWindow()
 xUIElement = xDlg.getChild(dialog_element)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-03-25 Thread Markus Mohrhard
 uitest/uitest/bisecting.py |   16 
 1 file changed, 16 insertions(+)

New commits:
commit 646be83e93fc2e68fc419cf6893bd1d1c1322bf7
Author: Markus Mohrhard 
Date:   Sun Mar 26 01:50:01 2017 +0100

uitest: add a decorator to document required revision

This is the first step in allowing easy bisecting with the UI testing
framework. We now also need a script that can execute tests and a way to
get the revision information back into the bisecting script.

Change-Id: If59db62ba25162ae69360d5b8ae769a6d179c16c

diff --git a/uitest/uitest/bisecting.py b/uitest/uitest/bisecting.py
new file mode 100644
index ..7d2f074411df
--- /dev/null
+++ b/uitest/uitest/bisecting.py
@@ -0,0 +1,16 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from functools import wraps
+
+def requires(revision):
+def decorator(f):
+f.requires = revision
+return f
+return decorator
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-02-27 Thread Markus Mohrhard
 uitest/uitest/framework.py |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 08750abc64a7ad82cac96adeb7a0bcdce7ac704d
Author: Markus Mohrhard 
Date:   Mon Feb 27 16:25:22 2017 +0100

uitest: catch more exceptions during shutdown

Change-Id: Ie4bfc28c32b4b21c75ca92b95521c03a0683db32
Reviewed-on: https://gerrit.libreoffice.org/34692
Reviewed-by: Markus Mohrhard 
Tested-by: Markus Mohrhard 

diff --git a/uitest/uitest/framework.py b/uitest/uitest/framework.py
index f21d72b..7149132 100644
--- a/uitest/uitest/framework.py
+++ b/uitest/uitest/framework.py
@@ -35,13 +35,13 @@ class UITestCase(unittest.TestCase):
 t = time.time() - self.startTime
 print("Execution time for %s: %.3f" % (self.id(), t))
 if self.xContext is not None:
-desktop = self.ui_test.get_desktop()
-components = desktop.getComponents()
-for component in components:
-try:
-component.close(False)
-except Exception as e:
-print(e)
+try:
+desktop = self.ui_test.get_desktop()
+components = desktop.getComponents()
+for component in components:
+component.close(False)
+except Exception as e:
+print(e)
 
 self.connection.tearDown()
 finally:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-02-27 Thread Markus Mohrhard
 uitest/uitest/test.py |   23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 48c8675b030ec597f3f7430963841901dbececff
Author: Markus Mohrhard 
Date:   Mon Feb 27 04:07:01 2017 +0100

uitest: handle crash reporter dialog correctly during start-up

Change-Id: I1db54ad2ad38642ac84211fd6d6505e171fc4423
Reviewed-on: https://gerrit.libreoffice.org/34671
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 2de8b31..e171492 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -8,6 +8,9 @@
 import time
 import threading
 from uitest.config import DEFAULT_SLEEP
+from uitest.uihelper.common import get_state_as_dict
+
+from com.sun.star.uno import RuntimeException
 
 from libreoffice.uno.eventlistener import EventListener
 
@@ -105,9 +108,27 @@ class UITest(object):
 time.sleep(DEFAULT_SLEEP)
 raise DialogNotExecutedException(action)
 
+def _handle_crash_reporter(self):
+xCrashReportDlg = self._xUITest.getTopFocusWindow()
+state = get_state_as_dict(xCrashReportDlg)
+print(state)
+if state['ID'] == "CrashReportDialog":
+print("found a crash reporter")
+xCancelBtn = xCrashReportDlg.getChild("btn_cancel")
+self.close_dialog_through_button(xCancelBtn)
+else:
+raise RuntimeException("not a crashreporter")
+
 def create_doc_in_start_center(self, app):
 xStartCenter = self._xUITest.getTopFocusWindow()
-xBtn = xStartCenter.getChild(app + "_all")
+try:
+xBtn = xStartCenter.getChild(app + "_all")
+except RuntimeException:
+print("Handled crash reporter")
+self._handle_crash_reporter()
+xStartCenter = self._xUITest.getTopFocusWindow()
+xBtn = xStartCenter.getChild(app + "_all")
+
 with EventListener(self._xContext, "OnNew") as event:
 xBtn.executeAction("CLICK", tuple())
 time_ = 0
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2017-02-27 Thread Markus Mohrhard
 uitest/uitest/test.py |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit c9326537872e1f6b90a418ee2d7c7ffcf27b9c43
Author: Markus Mohrhard 
Date:   Mon Feb 27 04:05:59 2017 +0100

uitest: use the new dialog method in the python code

Change-Id: I252310bc453450236b5b7de0ef292cfbba7ea64a
Reviewed-on: https://gerrit.libreoffice.org/34670
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 3122329..2de8b31 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -66,7 +66,7 @@ class UITest(object):
 
 def execute_dialog_through_command(self, command):
 with EventListener(self._xContext, "DialogExecute") as event:
-self._xUITest.executeCommand(command)
+self._xUITest.executeDialog(command)
 time_ = 0
 while time_ < 30:
 if event.executed:
@@ -138,13 +138,13 @@ class UITest(object):
 
 def close_doc(self):
 with EventListener(self._xContext, ["DialogExecute", "OnViewClosed"] ) 
as event:
-self._xUITest.executeCommand(".uno:CloseDoc")
+self._xUITest.executeDialog(".uno:CloseDoc")
 time_ = 0
 while time_ < 30:
 if event.hasExecuted("DialogExecute"):
 xCloseDlg = self._xUITest.getTopFocusWindow()
 xNoBtn = xCloseDlg.getChild("discard")
-self.close_dialog_through_button(xNoBtn);
+xNoBtn.executeAction("CLICK", tuple())
 return
 elif event.hasExecuted("OnViewClosed"):
 return
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2016-12-01 Thread Markus Mohrhard
 uitest/uitest/framework.py |9 +
 1 file changed, 9 insertions(+)

New commits:
commit fa5af9196bf9fbebf194f7fff09b779cb5c3d0fb
Author: Markus Mohrhard 
Date:   Fri Dec 2 01:19:11 2016 +0100

uitest: prevent deadlock when the test fails

when the test fails it was possible that the terminate call was
trying to close all the  open windows which could show the query close
dialog. The new approach is to close all remaining documents in
tearDown.

Change-Id: I0078eaf1995c3085af0072f636b316003c02
Reviewed-on: https://gerrit.libreoffice.org/31515
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/uitest/uitest/framework.py b/uitest/uitest/framework.py
index be58b12..7d4a78d 100644
--- a/uitest/uitest/framework.py
+++ b/uitest/uitest/framework.py
@@ -31,6 +31,15 @@ class UITestCase(unittest.TestCase):
 def tearDown(self):
 t = time.time() - self.startTime
 print("Execution time for %s: %.3f" % (self.id(), t))
+if self.xContext is not None:
+desktop = self.ui_test.get_desktop()
+components = desktop.getComponents()
+for component in components:
+try:
+component.close(False)
+except Exception as e:
+print(e)
+
 self.connection.tearDown()
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2016-11-21 Thread Markus Mohrhard
 uitest/uitest/path.py |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 16982944a1800963ee01f6e429f5330cc82b5710
Author: Markus Mohrhard 
Date:   Mon Nov 21 11:40:05 2016 +0100

uitest: fix path to url conversion on windows

Our windows path is stored e.g. as D:/libo1 which os.path.path2url converts 
to D://libo1.
UNO does not recognize the URL as a valid file URL.

Change-Id: Iad4c4a3944d26312bb79bfeefaf55f697c0afd1c

diff --git a/uitest/uitest/path.py b/uitest/uitest/path.py
index 488520d..5a3aeff 100644
--- a/uitest/uitest/path.py
+++ b/uitest/uitest/path.py
@@ -14,7 +14,7 @@ def get_src_dir_fallback():
 return os.path.abspath(os.path.join(current_dir, "../../"))
 
 def path2url(path):
-return urljoin('file:', pathname2url(path))
+return urljoin('file:', pathname2url(os.path.normpath(path)))
 
 def get_workdir_url():
 workdir_path = os.environ.get('WORKDIR', 
os.path.join(get_src_dir_fallback(), 'workdir'))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: uitest/uitest

2016-09-29 Thread Markus Mohrhard
 uitest/uitest/test.py |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 462048b3502bdb79cb1171cc58d911666bc7d142
Author: Markus Mohrhard 
Date:   Wed Sep 28 04:03:04 2016 +0200

fix test failure

Change-Id: Ia963b3930b5d2d0ab612619e0165dadd058b3fda
Reviewed-on: https://gerrit.libreoffice.org/29372
Tested-by: Jenkins 
Reviewed-by: Markus Mohrhard 

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index c9c51f5..2860c02 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -22,10 +22,14 @@ class UITest(object):
 def __init__(self, xUITest, xContext):
 self._xUITest = xUITest
 self._xContext = xContext
+self._desktop = None
 
 def get_desktop(self):
-desktop = 
self._xContext.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",
 self._xContext)
-return desktop
+if self._desktop:
+return self._desktop
+
+self._desktop = 
self._xContext.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",
 self._xContext)
+return self._desktop
 
 def get_frames(self):
 desktop = self.get_desktop()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits