[Libreoffice-commits] core.git: 2 commits - sw/qa
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 16 20:53:28 UTC 2019
sw/qa/uitest/writer_tests5/xwindow.py | 62 +++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 23 deletions(-)
New commits:
commit edeb858b57d5b45dbc20e04d323085cf9ce95f55
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu May 16 22:08:44 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu May 16 22:52:44 2019 +0200
Make xwindow.py test more robust
...by waiting for all events to be processed before the listeners are removed
Change-Id: I1aa4f6c43de97a567877a499c4c8fb51ef53eeea
Reviewed-on: https://gerrit.libreoffice.org/72432
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/qa/uitest/writer_tests5/xwindow.py b/sw/qa/uitest/writer_tests5/xwindow.py
index 7e561fe8de2f..29a89bb5809c 100644
--- a/sw/qa/uitest/writer_tests5/xwindow.py
+++ b/sw/qa/uitest/writer_tests5/xwindow.py
@@ -140,6 +140,10 @@ class XWindow(UITestCase):
xToolkitRobot.keyPress(xKeyEvent)
xToolkitRobot.keyRelease(xKeyEvent)
+ # Wait for async events to be processed
+ xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+ xToolkit.processEventsToIdle()
+
# remove mouse listener
xWindow.removeMouseListener(xMouseListener)
self.assertEqual(1, mouseListenerCount)
@@ -149,10 +153,6 @@ class XWindow(UITestCase):
xWindow.removeKeyListener(xKeyListener)
del xKeyListener
- # Wait for async events to be processed
- xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
- xToolkit.processEventsToIdle()
-
global keymousePressedEventsIntercepted
# Not expected any interceptions
self.assertEqual(0, keymousePressedEventsIntercepted)
commit 141c75847a0fc470915a16c83e80f8effb7a22b6
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu May 16 20:59:37 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu May 16 22:52:37 2019 +0200
More precisely count different event types in xwindow.py
Change-Id: I6872684292b4e7ef04f4c590012f1af25243f22f
Reviewed-on: https://gerrit.libreoffice.org/72426
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/qa/uitest/writer_tests5/xwindow.py b/sw/qa/uitest/writer_tests5/xwindow.py
index bdfbfecff17e..7e561fe8de2f 100644
--- a/sw/qa/uitest/writer_tests5/xwindow.py
+++ b/sw/qa/uitest/writer_tests5/xwindow.py
@@ -17,8 +17,12 @@ from com.sun.star.awt import XKeyListener
mouseListenerCount = 0
-mouseEventsIntercepted = 0
-keymouseEventsIntercepted = 0
+mousePressedEventsIntercepted = 0
+mouseReleasedEventsIntercepted = 0
+mouseEnteredEventsIntercepted = 0
+mouseExitedEventsIntercepted = 0
+keymousePressedEventsIntercepted = 0
+keymouseReleasedEventsIntercepted = 0
class XMouseListenerExtended(unohelper.Base, XMouseListener):
@@ -30,41 +34,41 @@ class XMouseListenerExtended(unohelper.Base, XMouseListener):
# is invoked when a mouse button has been pressed on a window.
@classmethod
def mousePressed(self, xMouseEvent):
- global mouseEventsIntercepted
- mouseEventsIntercepted += 1
+ global mousePressedEventsIntercepted
+ mousePressedEventsIntercepted += 1
# is invoked when a mouse button has been released on a window.
@classmethod
def mouseReleased(self, xMouseEvent):
- global mouseEventsIntercepted
- mouseEventsIntercepted += 1
+ global mouseReleasedEventsIntercepted
+ mouseReleasedEventsIntercepted += 1
# is invoked when the mouse enters a window.
@classmethod
def mouseEntered(self, xMouseEvent):
- global mouseEventsIntercepted
- mouseEventsIntercepted += 1
+ global mouseEnteredEventsIntercepted
+ mouseEnteredEventsIntercepted += 1
# is invoked when the mouse exits a window.
@classmethod
def mouseExited(self, xMouseEvent):
- global mouseEventsIntercepted
- mouseEventsIntercepted += 1
+ global mouseExitedEventsIntercepted
+ mouseExitedEventsIntercepted += 1
class XKeyListenerExtended(unohelper.Base, XKeyListener):
# is invoked when a key has been pressed
@classmethod
def keyPressed(self, xKeyEvent):
- global keymouseEventsIntercepted
- keymouseEventsIntercepted += 1
+ global keymousePressedEventsIntercepted
+ keymousePressedEventsIntercepted += 1
return super(XKeyListenerExtended, self).keyPressed(xKeyEvent)
# is invoked when a key has been released
@classmethod
def keyReleased(self, xKeyEvent):
- global keymouseEventsIntercepted
- keymouseEventsIntercepted += 1
+ global keymouseReleasedEventsIntercepted
+ keymouseReleasedEventsIntercepted += 1
return super(XKeyListenerExtended, self).keyReleased(xKeyEvent)
# Test that registered mouse/key listeners for top window receive mouse/key events
@@ -149,13 +153,25 @@ class XWindow(UITestCase):
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
xToolkit.processEventsToIdle()
- global keymouseEventsIntercepted
- # Not expected 2 interceptions
- self.assertEqual(0, keymouseEventsIntercepted)
+ global keymousePressedEventsIntercepted
+ # Not expected any interceptions
+ self.assertEqual(0, keymousePressedEventsIntercepted)
- global mouseEventsIntercepted
- # mousePressed (2x), mouseReleased (2x) and mouseEntered (1x) should be triggered
- self.assertEqual(5, mouseEventsIntercepted)
+ global keymouseReleasedEventsIntercepted
+ # Not expected any interceptions
+ self.assertEqual(0, keymouseReleasedEventsIntercepted)
+
+ global mousePressedEventsIntercepted
+ self.assertEqual(2, mousePressedEventsIntercepted)
+
+ global mouseReleasedEventsIntercepted
+ self.assertEqual(2, mouseReleasedEventsIntercepted)
+
+ global mouseEnteredEventsIntercepted
+ self.assertEqual(1, mouseEnteredEventsIntercepted)
+
+ global mouseExitedEventsIntercepted
+ self.assertEqual(0, mouseExitedEventsIntercepted)
# close document
self.ui_test.close_doc()
More information about the Libreoffice-commits
mailing list