This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/218/head
in repository enlightenment.
View the commit online.
commit b7fb2f19efcbb1f34cab2394ecda01ec116077e8
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 27 18:18:01 2026 -0600
tests - send keys through fcitx5 in an input method suite
The input method tests play both ends, the text field and the input
method, so E is only checked against clients written alongside it.
fcitx5 is what users run with zwp_input_method_v2 and
zwp_virtual_keyboard_v1, and ibus speaks neither. This runs it as the
input method of a window of the test with a text field. Its keyboard
layout engine takes each key from E's keyboard grab and hands it back
through the virtual keyboard, so a key the window gets went both ways:
the case a grab without a working way back breaks, by swallowing every
key. Breaking e_comp_wl_key_inject() makes the test fail.
The test waits for its field's first done event before it types. On
activation fcitx5 grabs the keyboard and then commits, and E passes the
commit on to the field; a key typed before that goes to the window
directly and proves nothing. Asking for the input method to see whether
fcitx5 holds the seat does not work: if fcitx5 asks at the same time, E
tells it the seat is taken and it never asks again.
fcitx5-run.sh gives fcitx5 a configuration of its own, a private D-Bus,
as it will not start twice on one bus, and no cloud pinyin, which asks
a web service. The new im suite is left out of a plain meson test, as
the browser one is, and a missing fcitx5 is a skip.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/tests/meson.build | 2 +-
src/tests/wayland/fcitx5-run.sh | 54 ++++++++++++
src/tests/wayland/meson.build | 17 ++++
src/tests/wayland/test_fcitx5.c | 176 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 248 insertions(+), 1 deletion(-)
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 4dbbaeef0..5c466dc94 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -24,4 +24,4 @@ endif
subdir('x11')
# The browser suite runs only when asked for: meson test --suite browser
-add_test_setup('default', exclude_suites: ['browser'], is_default: true)
+add_test_setup('default', exclude_suites: ['browser', 'im'], is_default: true)
diff --git a/src/tests/wayland/fcitx5-run.sh b/src/tests/wayland/fcitx5-run.sh
new file mode 100755
index 000000000..370c9bf88
--- /dev/null
+++ b/src/tests/wayland/fcitx5-run.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+# Run fcitx5 as run-nested.sh's E_TEST_APP, cut off from the user's own
+# session: a configuration of its own, a private D-Bus, as fcitx5 will not
+# start twice on one bus, and no network.
+#
+# fcitx5-run.sh [engine]
+# fcitx5-run.sh --find [engine] fails when not installed
+#
+# With no engine, fcitx5 uses its keyboard layout engine, which hands back
+# every key it is given. An engine, such as pinyin, comes first in the
+# profile: fcitx5 starts an input context on the first input method of the
+# group, and only goes to the default one when the user switches to it.
+
+set -eu
+
+if [ "${1:-}" = "--find" ]; then
+ BIN=$(command -v fcitx5)
+ [ -z "${2:-}" ] && exit
+ test -e "${BIN%/bin/fcitx5}/share/fcitx5/inputmethod/$2.conf"
+ exit
+fi
+
+export XDG_CONFIG_HOME="$E_TEST_RUNDIR/fcitx5-config"
+export XDG_DATA_HOME="$E_TEST_RUNDIR/fcitx5-data"
+mkdir -p "$XDG_CONFIG_HOME/fcitx5" "$XDG_DATA_HOME"
+
+if [ -n "${1:-}" ]; then
+ cat > "$XDG_CONFIG_HOME/fcitx5/profile" <<PROFILE
+[Groups/0]
+Name=Default
+Default Layout=us
+DefaultIM=$1
+
+[Groups/0/Items/0]
+Name=$1
+Layout=
+
+[Groups/0/Items/1]
+Name=keyboard-us
+Layout=
+
+[GroupOrder]
+0=Default
+PROFILE
+fi
+
+# There is no X server in the session, and cloud pinyin asks a web service
+# for candidates.
+set -- fcitx5 --disable=xcb,xim,cloudpinyin
+
+if command -v dbus-run-session >/dev/null 2>&1; then
+ exec env -u DISPLAY LC_ALL=C.UTF-8 dbus-run-session -- "$@"
+fi
+exec env -u DISPLAY LC_ALL=C.UTF-8 DBUS_SESSION_BUS_ADDRESS=unix:path=/nonexistent "$@"
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index d29117f72..fc6fed148 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -189,3 +189,20 @@ foreach b: ['firefox', 'chromium', 'brave']
timeout: 300,
)
endforeach
+
+fcitx5_run = meson.current_source_dir() / 'fcitx5-run.sh'
+test('fcitx5',
+ run_nested,
+ args: [executable('test_wl_fcitx5',
+ ['test_fcitx5.c', tk_src, test_proto_src],
+ dependencies: [dependency('wayland-client')],
+ )],
+ env: {
+ 'E_TEST_COMPOSITOR': e_test_compositor,
+ 'E_TEST_APP': fcitx5_run,
+ 'E_TEST_APP_CHECK': ' '.join([fcitx5_run, '--find']),
+ 'E_TEST_WAIT_SECONDS': '60',
+ },
+ suite: 'im',
+ timeout: 300,
+)
diff --git a/src/tests/wayland/test_fcitx5.c b/src/tests/wayland/test_fcitx5.c
new file mode 100644
index 000000000..5f1a30f04
--- /dev/null
+++ b/src/tests/wayland/test_fcitx5.c
@@ -0,0 +1,176 @@
+/* fcitx5, as fcitx5-run.sh started it, is the input method of a window
+ * of the test with a text field. Its keyboard layout engine takes each key
+ * from E's keyboard grab and hands it back through zwp_virtual_keyboard_v1,
+ * so a key the window gets once fcitx5 holds the grab went both ways. */
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <linux/input-event-codes.h>
+
+#include "e_wl_testkit.h"
+#include "text-input-unstable-v3-client-protocol.h"
+
+#define PROG "test-fcitx5"
+#define APP_ID "e.test.fcitx5"
+
+static const struct
+{
+ const char *name;
+ uint32_t code;
+} _keys[] =
+{
+ { "a", KEY_A },
+};
+
+static struct wl_test *tester;
+static uint32_t last_key;
+static int keys, dones;
+
+static void
+_keymap(void *data __attribute__((unused)), struct wl_keyboard *k __attribute__((unused)),
+ uint32_t format __attribute__((unused)), int32_t fd, uint32_t size __attribute__((unused)))
+{
+ close(fd);
+}
+
+static void
+_enter(void *data __attribute__((unused)), struct wl_keyboard *k __attribute__((unused)),
+ uint32_t serial __attribute__((unused)), struct wl_surface *s __attribute__((unused)),
+ struct wl_array *held __attribute__((unused)))
+{
+}
+
+static void
+_leave(void *data __attribute__((unused)), struct wl_keyboard *k __attribute__((unused)),
+ uint32_t serial __attribute__((unused)), struct wl_surface *s __attribute__((unused)))
+{
+}
+
+static void
+_key(void *data __attribute__((unused)), struct wl_keyboard *k __attribute__((unused)),
+ uint32_t serial __attribute__((unused)), uint32_t time __attribute__((unused)),
+ uint32_t key, uint32_t state __attribute__((unused)))
+{
+ last_key = key;
+ keys++;
+}
+
+static void
+_modifiers(void *data __attribute__((unused)), struct wl_keyboard *k __attribute__((unused)),
+ uint32_t serial __attribute__((unused)), uint32_t depressed __attribute__((unused)),
+ uint32_t latched __attribute__((unused)), uint32_t locked __attribute__((unused)),
+ uint32_t group __attribute__((unused)))
+{
+}
+
+static void
+_repeat_info(void *data __attribute__((unused)), struct wl_keyboard *k __attribute__((unused)),
+ int32_t rate __attribute__((unused)), int32_t delay __attribute__((unused)))
+{
+}
+
+static const struct wl_keyboard_listener _keyboard_listener =
+{
+ _keymap, _enter, _leave, _key, _modifiers, _repeat_info
+};
+
+static void
+_ti_surface(void *data __attribute__((unused)), struct zwp_text_input_v3 *ti __attribute__((unused)),
+ struct wl_surface *s __attribute__((unused)))
+{
+}
+
+static void
+_ti_preedit(void *data __attribute__((unused)), struct zwp_text_input_v3 *ti __attribute__((unused)),
+ const char *text __attribute__((unused)), int32_t begin __attribute__((unused)),
+ int32_t end __attribute__((unused)))
+{
+}
+
+static void
+_ti_commit(void *data __attribute__((unused)), struct zwp_text_input_v3 *ti __attribute__((unused)),
+ const char *text __attribute__((unused)))
+{
+}
+
+static void
+_ti_delete(void *data __attribute__((unused)), struct zwp_text_input_v3 *ti __attribute__((unused)),
+ uint32_t before __attribute__((unused)), uint32_t after __attribute__((unused)))
+{
+}
+
+static void
+_ti_done(void *data __attribute__((unused)), struct zwp_text_input_v3 *ti __attribute__((unused)),
+ uint32_t serial __attribute__((unused)))
+{
+ dones++;
+}
+
+static const struct zwp_text_input_v3_listener _ti_listener =
+{
+ _ti_surface, _ti_surface, _ti_preedit, _ti_commit, _ti_delete, _ti_done
+};
+
+/* Activated, fcitx5 grabs the keyboard and then commits, which E passes
+ * on to the field as a done. */
+static int
+_fcitx5_grabbed(const Tk_Client *c __attribute__((unused)), void *data __attribute__((unused)))
+{
+ return dones > 0;
+}
+
+static void
+_type(Tk *tk, const char *name)
+{
+ wl_test_key(tester, name, 1);
+ wl_test_key(tester, name, 0);
+ tk_settle(tk);
+}
+
+static int
+_keys_back(const Tk_Client *c __attribute__((unused)), void *data)
+{
+ return keys >= *(int *)data;
+}
+
+int
+main(void)
+{
+ struct zwp_text_input_manager_v3 *ti_manager;
+ struct zwp_text_input_v3 *ti;
+ struct wl_seat *seat;
+ Tk *tk;
+ unsigned int i;
+ int want;
+
+ tk = tk_connect(PROG);
+ tester = tk_bind(tk, &wl_test_interface, 1);
+ seat = tk_bind(tk, &wl_seat_interface, 1);
+ ti_manager = tk_bind(tk, &zwp_text_input_manager_v3_interface, 1);
+ if ((!tester) || (!seat) || (!ti_manager)) tk_fail(tk, "missing global");
+ wl_keyboard_add_listener(wl_seat_get_keyboard(seat), &_keyboard_listener, NULL);
+
+ tk_toplevel_new(tk, APP_ID, PROG, 300, 200);
+ tk_wait_states(tk, APP_ID, WL_TEST_CLIENT_STATE_FOCUSED,
+ WL_TEST_CLIENT_STATE_FOCUSED, "the window to take the focus");
+
+ /* fcitx5 may come after: E activates it then. */
+ ti = zwp_text_input_manager_v3_get_text_input(ti_manager, seat);
+ zwp_text_input_v3_add_listener(ti, &_ti_listener, NULL);
+ zwp_text_input_v3_enable(ti);
+ zwp_text_input_v3_commit(ti);
+ tk_wait(tk, APP_ID, _fcitx5_grabbed, NULL, "fcitx5 to grab the keyboard");
+
+ for (i = 0; i < sizeof(_keys) / sizeof(_keys[0]); i++)
+ {
+ want = keys + 2;
+ _type(tk, _keys[i].name);
+ tk_wait(tk, APP_ID, _keys_back, &want, "the key to come back from fcitx5");
+ if (last_key != _keys[i].code)
+ tk_fail(tk, "%s came back as %u, not %u", _keys[i].name, last_key, _keys[i].code);
+ }
+
+ printf(PROG ": ok\n");
+ tk_disconnect(tk);
+ return 0;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.