diff options
author | Vonfry <mail@vonfry.name> | 2023-03-12 14:19:03 +0800 |
---|---|---|
committer | Vonfry <mail@vonfry.name> | 2023-03-13 18:50:05 +0800 |
commit | f95c20d77d5275a0fe4d2809bbb6e10d5492b93f (patch) | |
tree | 6d8211e8422f472197775c799023a6f3afe437d6 /nixos/tests | |
parent | 6d951523ad424c077d60bcd57e9a53bc9dd56e5d (diff) |
nixos/fcitx5: init tests
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/fcitx5/config | 11 | ||||
-rw-r--r-- | nixos/tests/fcitx5/default.nix | 127 | ||||
-rw-r--r-- | nixos/tests/fcitx5/profile | 15 |
4 files changed, 154 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7b2dce92da47c..c586e08df3d21 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -217,6 +217,7 @@ in { extra-python-packages = handleTest ./extra-python-packages.nix {}; evcc = handleTest ./evcc.nix {}; fancontrol = handleTest ./fancontrol.nix {}; + fcitx5 = handleTest ./fcitx5 {}; fenics = handleTest ./fenics.nix {}; ferm = handleTest ./ferm.nix {}; firefox = handleTest ./firefox.nix { firefoxPackage = pkgs.firefox; }; diff --git a/nixos/tests/fcitx5/config b/nixos/tests/fcitx5/config new file mode 100644 index 0000000000000..cf4334639f1c0 --- /dev/null +++ b/nixos/tests/fcitx5/config @@ -0,0 +1,11 @@ +[Hotkey] +EnumerateSkipFirst=False + +[Hotkey/TriggerKeys] +0=Control+space + +[Hotkey/EnumerateForwardKeys] +0=Alt+Shift_L + +[Hotkey/EnumerateBackwardKeys] +0=Alt+Shift_R diff --git a/nixos/tests/fcitx5/default.nix b/nixos/tests/fcitx5/default.nix new file mode 100644 index 0000000000000..261a5f1f45cac --- /dev/null +++ b/nixos/tests/fcitx5/default.nix @@ -0,0 +1,127 @@ +import ../make-test-python.nix ({ pkgs, ... }: +# copy_from_host works only for store paths +rec { + name = "fcitx5"; + nodes.machine = { pkgs, ... }: + { + imports = [ + ../common/user-account.nix + ]; + + environment.systemPackages = [ + # To avoid clashing with xfce4-terminal + pkgs.alacritty + ]; + + services.xserver = { + enable = true; + + displayManager = { + lightdm.enable = true; + autoLogin = { + enable = true; + user = "alice"; + }; + }; + + desktopManager.xfce.enable = true; + }; + + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = [ + pkgs.fcitx5-m17n + pkgs.fcitx5-chinese-addons + ]; + }; + }; + + testScript = { nodes, ... }: + let + user = nodes.machine.users.users.alice; + xauth = "${user.home}/.Xauthority"; + fcitx_confdir = "${user.home}/.config/fcitx5"; + in + '' + # We need config files before login session + # So copy first thing + + # Point and click would be expensive, + # So configure using files + machine.copy_from_host( + "${./profile}", + "${fcitx_confdir}/profile", + ) + machine.copy_from_host( + "${./config}", + "${fcitx_confdir}/config", + ) + + start_all() + + machine.wait_for_file("${xauth}}") + machine.succeed("xauth merge ${xauth}") + + machine.sleep(5) + + machine.succeed("su - ${user.name} -c 'alacritty&'") + machine.succeed("su - ${user.name} -c 'fcitx5&'") + machine.sleep(10) + + ### Type on terminal + machine.send_chars("echo ") + machine.sleep(1) + + ### Start fcitx Unicode input + machine.send_key("ctrl-alt-shift-u") + machine.sleep(5) + machine.sleep(1) + + ### Search for smiling face + machine.send_chars("smil") + machine.sleep(1) + + ### Navigate to the second one + machine.send_key("tab") + machine.sleep(1) + + ### Choose it + machine.send_key("\n") + machine.sleep(1) + + ### Start fcitx language input + machine.send_key("ctrl-spc") + machine.sleep(1) + + ### Default wubi, enter 一下 + machine.send_chars("gggh") + machine.sleep(1) + machine.send_key("\n") + machine.sleep(1) + + ### Switch to Harvard Kyoto + machine.send_key("alt-shift") + machine.sleep(1) + + ### Enter क + machine.send_chars("ka ") + machine.sleep(1) + + machine.send_key("alt-shift") + machine.sleep(1) + + ### Turn off Fcitx + machine.send_key("ctrl-spc") + machine.sleep(1) + + ### Redirect typed characters to a file + machine.send_chars(" > fcitx_test.out\n") + machine.sleep(1) + machine.screenshot("terminal_chars") + + ### Verify that file contents are as expected + file_content = machine.succeed("cat ${user.home}/fcitx_test.out") + assert file_content == "☺一下क\n" + '' + ; +}) diff --git a/nixos/tests/fcitx5/profile b/nixos/tests/fcitx5/profile new file mode 100644 index 0000000000000..55e7b7b459faf --- /dev/null +++ b/nixos/tests/fcitx5/profile @@ -0,0 +1,15 @@ +[Groups/0] +Name=NixOS_test +Default Layout=us +DefaultIM=wbx + +[Groups/0/Items/0] +Name=wbx +Layout=us + +[Groups/0/Items/1] +Name=m17n_sa_harvard-kyoto +Layout=us + +[GroupOrder] +0=NixOS_test |