2023-05-19 20:21:02 +00:00
|
|
|
import ../make-test-python.nix ({ lib, ... }:
|
2023-03-12 06:19:03 +00:00
|
|
|
rec {
|
|
|
|
name = "fcitx5";
|
2023-05-19 20:21:02 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ nevivurn ];
|
|
|
|
|
2023-03-12 06:19:03 +00:00
|
|
|
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-chinese-addons
|
2023-05-19 20:21:02 +00:00
|
|
|
pkgs.fcitx5-hangul
|
|
|
|
pkgs.fcitx5-m17n
|
|
|
|
pkgs.fcitx5-mozc
|
2023-03-12 06:19:03 +00:00
|
|
|
];
|
2023-08-15 00:36:07 +00:00
|
|
|
fcitx5.settings = {
|
|
|
|
globalOptions = {
|
|
|
|
"Hotkey"."EnumerateSkipFirst" = "False";
|
|
|
|
"Hotkey/TriggerKeys"."0" = "Control+space";
|
|
|
|
"Hotkey/EnumerateForwardKeys"."0" = "Alt+Shift_L";
|
|
|
|
"Hotkey/EnumerateBackwardKeys"."0" = "Alt+Shift_R";
|
|
|
|
};
|
|
|
|
inputMethod = {
|
|
|
|
"GroupOrder" = {
|
|
|
|
"0" = "NixOS_test";
|
|
|
|
};
|
|
|
|
"Groups/0" = {
|
|
|
|
"Default Layout" = "us";
|
|
|
|
"DefaultIM" = "wbx";
|
|
|
|
"Name" = "NixOS_test";
|
|
|
|
};
|
|
|
|
"Groups/0/Items/0" = {
|
|
|
|
"Name" = "keyboard-us";
|
|
|
|
};
|
|
|
|
"Groups/0/Items/1" = {
|
|
|
|
"Layout" = "us";
|
|
|
|
"Name" = "wbx";
|
|
|
|
};
|
|
|
|
"Groups/0/Items/2" = {
|
|
|
|
"Layout" = "us";
|
|
|
|
"Name" = "hangul";
|
|
|
|
};
|
|
|
|
"Groups/0/Items/3" = {
|
|
|
|
"Layout" = "us";
|
|
|
|
"Name" = "m17n_sa_harvard-kyoto";
|
|
|
|
};
|
|
|
|
"Groups/0/Items/4" = {
|
|
|
|
"Layout" = "us";
|
|
|
|
"Name" = "mozc";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-03-12 06:19:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = { nodes, ... }:
|
|
|
|
let
|
|
|
|
user = nodes.machine.users.users.alice;
|
|
|
|
xauth = "${user.home}/.Xauthority";
|
|
|
|
in
|
|
|
|
''
|
2023-05-19 20:21:02 +00:00
|
|
|
start_all()
|
|
|
|
|
|
|
|
machine.wait_for_x()
|
|
|
|
machine.wait_for_file("${xauth}")
|
|
|
|
machine.succeed("xauth merge ${xauth}")
|
|
|
|
machine.sleep(5)
|
|
|
|
|
|
|
|
machine.succeed("su - ${user.name} -c 'kill $(pgrep fcitx5)'")
|
|
|
|
machine.sleep(1)
|
2023-03-12 06:19:03 +00:00
|
|
|
|
2023-05-19 20:21:02 +00:00
|
|
|
machine.succeed("su - ${user.name} -c 'alacritty >&2 &'")
|
|
|
|
machine.succeed("su - ${user.name} -c 'fcitx5 >&2 &'")
|
2023-03-12 06:19:03 +00:00
|
|
|
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(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 一下
|
2023-05-19 20:21:02 +00:00
|
|
|
machine.send_chars("gggh ")
|
2023-03-12 06:19:03 +00:00
|
|
|
machine.sleep(1)
|
2023-05-19 20:21:02 +00:00
|
|
|
|
|
|
|
### Switch to Hangul
|
|
|
|
machine.send_key("alt-shift")
|
|
|
|
machine.sleep(1)
|
|
|
|
|
|
|
|
### Enter 한
|
|
|
|
machine.send_chars("gks")
|
2023-03-12 06:19:03 +00:00
|
|
|
machine.sleep(1)
|
|
|
|
|
|
|
|
### Switch to Harvard Kyoto
|
|
|
|
machine.send_key("alt-shift")
|
|
|
|
machine.sleep(1)
|
|
|
|
|
|
|
|
### Enter क
|
2023-05-19 20:21:02 +00:00
|
|
|
machine.send_chars("ka")
|
2023-03-12 06:19:03 +00:00
|
|
|
machine.sleep(1)
|
|
|
|
|
2023-05-19 20:21:02 +00:00
|
|
|
### Switch to Mozc
|
2023-03-12 06:19:03 +00:00
|
|
|
machine.send_key("alt-shift")
|
|
|
|
machine.sleep(1)
|
|
|
|
|
2023-05-19 20:21:02 +00:00
|
|
|
### Enter か
|
|
|
|
machine.send_chars("ka\n")
|
|
|
|
machine.sleep(1)
|
|
|
|
|
2023-03-12 06:19:03 +00:00
|
|
|
### 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")
|
2023-05-19 20:21:02 +00:00
|
|
|
assert file_content == "☺一下한कか\n"
|
|
|
|
''
|
2023-03-12 06:19:03 +00:00
|
|
|
;
|
|
|
|
})
|