uitest: add an optional way to print all received event names

Change-Id: I8180d131c2f4dbc9759ca1166192970bc06231c0
Reviewed-on: https://gerrit.libreoffice.org/32280
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
This commit is contained in:
Markus Mohrhard
2016-12-21 14:34:42 +01:00
parent 996af54669
commit d19307846e

View File

@@ -18,12 +18,13 @@ except ImportError:
class EventListener(XDocumentEventListener,unohelper.Base):
def __init__(self, xContext, eventNames):
def __init__(self, xContext, eventNames, **kwargs):
self.xGEB = xContext.ServiceManager.createInstanceWithContext(
"com.sun.star.frame.GlobalEventBroadcaster", xContext)
self.xContext = xContext
self.executed = False
self.eventExecuted = []
self.printEvents = kwargs.get('printNames', False)
if isinstance(eventNames, str):
self.eventNames = [eventNames]
elif isinstance(eventNames, list):
@@ -37,6 +38,9 @@ class EventListener(XDocumentEventListener,unohelper.Base):
self.xGEB.removeDocumentEventListener(self)
def documentEventOccured(self, event):
if self.printEvents is True:
print(event.EventName)
if event.EventName in self.eventNames:
self.executed = True
self.eventExecuted.append(event.EventName)