about summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorJacek Galowicz <jacek@galowicz.de>2019-11-05 15:59:29 +0100
committerJacek Galowicz <jacek@galowicz.de>2019-11-05 18:07:05 +0100
commit45b339b736380fe007721a460b2d2ac9791d8f5c (patch)
tree8ba20c328df5bb5259269af4fcfac3ca3ea2fd9b /nixos/lib
parentfdb72f68ad5179883af7d13d070a7bb36dab1603 (diff)
downloadnixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.tar
nixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.tar.gz
nixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.tar.bz2
nixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.tar.lz
nixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.tar.xz
nixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.tar.zst
nixlib-45b339b736380fe007721a460b2d2ac9791d8f5c.zip
nixos/tests: Implement python test-driver version of getWindowNames and waitForWindow
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/test-driver.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/nixos/lib/test-driver/test-driver.py b/nixos/lib/test-driver/test-driver.py
index 2c137ab38372..b1e2b9231856 100644
--- a/nixos/lib/test-driver/test-driver.py
+++ b/nixos/lib/test-driver/test-driver.py
@@ -655,6 +655,27 @@ class Machine:
                 if status == 0:
                     return
 
+    def get_window_names(self):
+        return self.succeed(
+            r"xwininfo -root -tree | sed 's/.*0x[0-9a-f]* \"\([^\"]*\)\".*/\1/; t; d'"
+        ).splitlines()
+
+    def wait_for_window(self, regexp):
+        pattern = re.compile(regexp)
+
+        def window_is_visible(last_try):
+            names = self.get_window_names()
+            if last_try:
+                self.log(
+                    "Last chance to match {} on the window list,".format(regexp)
+                    + " which currently contains: "
+                    + ", ".join(names)
+                )
+            return any(pattern.search(name) for name in names)
+
+        with self.nested("Waiting for a window to appear"):
+            retry(window_is_visible)
+
     def sleep(self, secs):
         time.sleep(secs)