Add a test for quick key events
authorMatthias Clasen <mclasen@redhat.com>
Sat, 6 May 2023 00:47:38 +0000 (20:47 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 6 May 2023 13:09:13 +0000 (09:09 -0400)
testsuite/headless/headless-input-tests.py

index f291d723b8a7d9e95ce5d43f8bf0d68822b5b1fe..10c152399b325f240ae8d0eae74dadbcc51fb698 100644 (file)
@@ -38,6 +38,7 @@ def wait(millis):
 
 display = None
 window = None
+entry = None
 expected_change = None
 
 def key_pressed_cb (controller, keyval, keycode, state):
@@ -232,11 +233,44 @@ def launch_observer():
     # we need to wait out the map animation, or pointer coords will be off
     wait(1000)
 
+def launch_entry():
+    global display
+    global window
+    global entry
+
+    if verbose:
+        print('launch entry')
+
+    if display == None:
+        display = Gdk.Display.open(os.getenv('WAYLAND_DISPLAY'))
+
+    window = Gtk.Window.new()
+
+    entry = Gtk.Entry.new()
+
+    window.set_child(entry)
+
+    window.connect('notify::is-active', got_active)
+    window.maximize()
+    window.present()
+
+    wait(500)
+
+    assert window.is_active(), "Observer not active"
+    assert window.get_width() == 1024, "Window not maximized"
+    assert window.get_height() == 768, "Window not maximized"
+
+    # we need to wait out the map animation, or pointer coords will be off
+    wait(1000)
+
 def stop_observer():
     global window
     window.destroy()
     window = None
 
+def expect_entry_text(text):
+    assert text == entry.get_text(), 'Unexpected entry text: ' + entry.get_text()
+
 def key_press(keyval):
     if verbose:
         print(f'press key {keyval}')
@@ -298,6 +332,27 @@ def basic_keyboard_tests():
         print(f'Error in basic_keyboard_tests: {e}')
         terminate()
 
+def quick_typing_test():
+    try:
+        launch_entry()
+
+        key_press(Gdk.KEY_T)
+        key_release(Gdk.KEY_T)
+        key_press(Gdk.KEY_e)
+        key_release(Gdk.KEY_e)
+        key_press(Gdk.KEY_s)
+        key_release(Gdk.KEY_s)
+        key_press(Gdk.KEY_t)
+        key_release(Gdk.KEY_t)
+
+        wait(100)
+        expect_entry_text('Test')
+
+        stop_observer()
+    except AssertionError as e:
+        print(f'Error in quick_typing_test: {e}')
+        terminate()
+
 def basic_pointer_tests():
     try:
         if verbose:
@@ -490,6 +545,7 @@ def run_commands():
     basic_keyboard_tests()
     basic_pointer_tests()
     dnd_tests()
+    quick_typing_test()
 
 def mutter_appeared(name):
     global remote_desktop