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