git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #96371 from asdf8dfafjk/fcitx_commit

fcitx: Add test (Unicode input, table input, m17n)

commitc790ed8c4e91b031f5a991075446db94d3f816b3 authorRobert Hensing <roberth@users.noreply.github.com> dateThu 19 Nov 2020, 11:05 (6 years ago) parent3f2c5cf4c8a880
4 files changed+159
nixos/tests/all-tests.nix+1 nixos/tests/fcitx/config+12 nixos/tests/fcitx/default.nix+142 nixos/tests/fcitx/profile+4
nixos/tests/all-tests.nix+1
@@ -103,6 +103,7 @@ in
103103 etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {};
104104 etcd-cluster = handleTestOn ["x86_64-linux"] ./etcd-cluster.nix {};
105105 fancontrol = handleTest ./fancontrol.nix {};
106+ fcitx = handleTest ./fcitx {};
106107 ferm = handleTest ./ferm.nix {};
107108 firefox = handleTest ./firefox.nix {};
108109 firefox-esr = handleTest ./firefox.nix { esr = true; };
nixos/tests/fcitx/confignew file+12
@@ -0,0 +1,12 @@
1+[Hotkey]
2+SwitchKey=Disabled
3+IMSwitchHotkey=ALT_SHIFT
4+TimeInterval=240
5+
6+[Program]
7+DelayStart=5
8+
9+[Output]
10+
11+[Appearance]
12+
nixos/tests/fcitx/default.nixnew file+142
@@ -0,0 +1,142 @@
1+import ../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+ virtualisation.memorySize = 1024;
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+)
nixos/tests/fcitx/profilenew file+4
@@ -0,0 +1,4 @@
1+[Profile]
2+IMName=zhengma-large
3+EnabledIMList=fcitx-keyboard-us:True,zhengma-large:True,m17n_sa_harvard-kyoto:True
4+PreeditStringInClientWindow=False