[gnome-photos/gnome-3-22] tests: Wait for the UI to be drawn completely



commit 07d95304fd94222db90bc7d5493d3603a8c3137e
Author: Iain Lane <iain orangesquash org uk>
Date:   Mon Jan 9 17:58:50 2017 +0000

    tests: Wait for the UI to be drawn completely
    
    The tests sometimes fail with:
      ValueError: Attempting to generate a mouse event at negative
        coordinates: (-2147483647.5,-2147483647.5)
    
    This is because the UI isn't drawn when we try to interact with it.
    This is a race condition. We should wait until the x or y coordinate
    is valid before going on with the test.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777053

 tests/basic.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/tests/basic.py b/tests/basic.py
index ea10ece..1dfa17f 100755
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -4,7 +4,7 @@ from testutil import *
 
 from gi.repository import Gio, GLib
 
-import os, sys
+import os, time, sys
 import pyatspi
 from dogtail import tree
 from dogtail import utils
@@ -15,6 +15,10 @@ try:
     app = start()
 
     albums_button = app.child('Albums')
+    x = y = -1
+    while x < 0 and y < 0:
+        (x, y) = albums_button.position
+        time.sleep(0.1)
     albums_button.click()
     photos_button = app.child('Photos')
     photos_button.click()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]