1import ../make-test-python.nix (
2 {
3 pkgs, ...
4 }:
5 # copy_from_host works only for store paths
6 rec {
7 name = "fcitx";
8 meta.broken = true; # takes hours to time out since October 2021
9 nodes.machine =
10 {
11 pkgs,
12 ...
13 }:
14 {
15
16 imports = [
17 ../common/user-account.nix
18 ];
19
20 environment.systemPackages = [
21 # To avoid clashing with xfce4-terminal
22 pkgs.alacritty
23 ];
24
25
26 services.xserver =
27 {
28 enable = true;
29
30 displayManager = {
31 lightdm.enable = true;
32 autoLogin = {
33 enable = true;
34 user = "alice";
35 };
36 };
37
38 desktopManager.xfce.enable = true;
39 };
40
41 i18n = {
42 inputMethod = {
43 enabled = "fcitx";
44 fcitx.engines = [
45 pkgs.fcitx-engines.m17n
46 pkgs.fcitx-engines.table-extra
47 ];
48 };
49 };
50 }
51 ;
52
53 testScript = { nodes, ... }:
54 let
55 user = nodes.machine.config.users.users.alice;
56 userName = user.name;
57 userHome = user.home;
58 xauth = "${userHome}/.Xauthority";
59 fcitx_confdir = "${userHome}/.config/fcitx";
60 in
61 ''
62 # We need config files before login session
63 # So copy first thing
64
65 # Point and click would be expensive,
66 # So configure using files
67 machine.copy_from_host(
68 "${./profile}",
69 "${fcitx_confdir}/profile",
70 )
71 machine.copy_from_host(
72 "${./config}",
73 "${fcitx_confdir}/config",
74 )
75
76 start_all()
77
78 machine.wait_for_file("${xauth}")
79 machine.succeed("xauth merge ${xauth}")
80
81 machine.sleep(5)
82
83 machine.succeed("su - ${userName} -c 'alacritty&'")
84 machine.succeed("su - ${userName} -c 'fcitx&'")
85 machine.sleep(10)
86
87 ### Type on terminal
88 machine.send_chars("echo ")
89 machine.sleep(1)
90
91 ### Start fcitx Unicode input
92 machine.send_key("ctrl-alt-shift-u")
93 machine.sleep(5)
94 machine.sleep(1)
95
96 ### Search for smiling face
97 machine.send_chars("smil")
98 machine.sleep(1)
99
100 ### Navigate to the second one
101 machine.send_key("tab")
102 machine.sleep(1)
103
104 ### Choose it
105 machine.send_key("\n")
106 machine.sleep(1)
107
108 ### Start fcitx language input
109 machine.send_key("ctrl-spc")
110 machine.sleep(1)
111
112 ### Default zhengma, enter 一下
113 machine.send_chars("a2")
114 machine.sleep(1)
115
116 ### Switch to Harvard Kyoto
117 machine.send_key("alt-shift")
118 machine.sleep(1)
119
120 ### Enter क
121 machine.send_chars("ka ")
122 machine.sleep(1)
123
124 machine.send_key("alt-shift")
125 machine.sleep(1)
126
127 ### Turn off Fcitx
128 machine.send_key("ctrl-spc")
129 machine.sleep(1)
130
131 ### Redirect typed characters to a file
132 machine.send_chars(" > fcitx_test.out\n")
133 machine.sleep(1)
134 machine.screenshot("terminal_chars")
135
136 ### Verify that file contents are as expected
137 file_content = machine.succeed("cat ${userHome}/fcitx_test.out")
138 assert file_content == "☺一下क\n"
139 ''
140 ;
141 }
142)