[mutter/wip/3v1n0/run-tests-in-ci: 3/14] tests: Add accept_focus command to client and runner



commit 984d27f050e43f8f3e47dba985e92b16e6d27207
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Mon Nov 12 20:43:57 2018 -0600

    tests: Add accept_focus command to client and runner
    
    Under the hood, calls gtk_window_set_accept_focus in the client

 src/tests/test-client.c | 18 ++++++++++++++++++
 src/tests/test-runner.c | 19 +++++++++++++++++++
 2 files changed, 37 insertions(+)
---
diff --git a/src/tests/test-client.c b/src/tests/test-client.c
index 59915743a..ab1efe205 100644
--- a/src/tests/test-client.c
+++ b/src/tests/test-client.c
@@ -196,6 +196,24 @@ process_line (const char *line)
                                              NULL))
         g_print ("Fail to export handle for window id %s", argv[2]);
     }
+  else if (strcmp (argv[0], "accept_focus") == 0)
+    {
+      if (argc != 3)
+        {
+          g_print ("usage: %s <window-id> [true|false]", argv[0]);
+          goto out;
+        }
+
+      GtkWidget *window = lookup_window (argv[1]);
+      if (!window)
+        {
+          g_print ("unknown window %s", argv[1]);
+          goto out;
+        }
+
+      gboolean enabled = g_ascii_strcasecmp (argv[2], "true") == 0;
+      gtk_window_set_accept_focus (GTK_WINDOW (window), enabled);
+    }
   else if (strcmp (argv[0], "show") == 0)
     {
       if (argc != 2)
diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c
index 84a06ba88..18ea6f117 100644
--- a/src/tests/test-runner.c
+++ b/src/tests/test-runner.c
@@ -398,6 +398,25 @@ test_case_do (TestCase *test,
       if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
         return FALSE;
 
+      if (!test_client_do (client, error,
+                           argv[0], window_id,
+                           argv[2],
+                           NULL))
+        return FALSE;
+    }
+  else if (strcmp (argv[0], "accept_focus") == 0)
+    {
+      if (argc != 3 ||
+          (g_ascii_strcasecmp (argv[2], "true") != 0 &&
+           g_ascii_strcasecmp (argv[2], "false") != 0))
+        BAD_COMMAND("usage: %s <client-id>/<window-id> [true|false]",
+                    argv[0]);
+
+      TestClient *client;
+      const char *window_id;
+      if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
+        return FALSE;
+
       if (!test_client_do (client, error,
                            argv[0], window_id,
                            argv[2],


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