summaryrefslogtreecommitdiff
path: root/tests/anthycases.py
blob: 0f43b03a436dd2e191068c29bca53c2849165453 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# 'init' has one array which is [keysym, keycode, modifier] and to be run
# before the main tests. E.g.
# Ctrl-space to enable Hiragana mode
#
# 'tests' cases are the main test cases.
# 'preedit' case runs to create a preedit text.
# 'commit' case runs to commit the preedit text.
# 'result' case is the expected output.
# 'preedit' and 'commit' can choose the type of either 'string' or 'keys'
# 'string' type is a string sequence which does not need modifiers

from gi import require_version as gi_require_version
gi_require_version('IBus', '1.0')
from gi.repository import IBus

TestCases = {
    #'init': [ord(' '), 0, IBus.ModifierType.CONTROL_MASK]
    'init': [IBus.KEY_Escape, 0, IBus.ModifierType.MOD1_MASK],
    'tests': [
                { 'preedit': { 'string': 'watashinonamaeha,pendesu.' },
                  'conversion': { 'string': ' '  },
                  'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
                  'result': { 'string': '私の名前は、ペンです。' }
                },
                { 'preedit': { 'string': 'toukyou' },
                  'conversion': { 'string': ' '  },
                  'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
                  'result': { 'string': '東京' }
                },
                { 'preedit': { 'string': 'toukyo' },
                  'conversion': { 'keys': [[IBus.KEY_Tab, 0, 0],
                                           [IBus.KEY_Tab, 0, 0],
                                          ]
                                },
                  'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
                  'result': { 'string': '東京' }
                },
                { 'preedit': { 'string': 'myuutu-' },
                  'conversion': { 'keys': [[IBus.KEY_F7, 0, IBus.ModifierType.SHIFT_MASK]] },
                  'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
                  'result': { 'string': 'ミュウツー' }
                },
                { 'preedit': { 'string': 'myuutu-' },
                  'conversion': { 'keys': [[IBus.KEY_space, 0, 0],
                                           [IBus.KEY_Right, 0, IBus.ModifierType.SHIFT_MASK],
                                           [IBus.KEY_Right, 0, IBus.ModifierType.SHIFT_MASK],
                                           [IBus.KEY_Right, 0, IBus.ModifierType.SHIFT_MASK],
                                           [IBus.KEY_F7, 0, 0]
                                          ]
                                },
                  'commit': { 'keys': [[IBus.KEY_Return, 0, 0]] },
                  'result': { 'string': 'ミュウツー' }
                },
             ]

}