File: keymap.vala

package info (click to toggle)
libkkc 0.3.5-11
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,908 kB
  • sloc: ansic: 7,099; makefile: 917; cpp: 435; python: 231; sh: 124
file content (59 lines) | stat: -rw-r--r-- 1,647 bytes parent folder | download | duplicates (6)
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
class KeymapTests : Kkc.TestCase {
    public KeymapTests () {
        base ("Keymap");

        add_test ("creation", this.test_creation);
        add_test ("properties", this.test_properties);
        add_test ("lookup", this.test_lookup);
    }

    void test_creation () {
        Kkc.RuleMetadata? metadata;

        metadata = Kkc.RuleMetadata.find ("nonexistent");
        assert (metadata == null);

        metadata = Kkc.RuleMetadata.find ("kana");
        assert (metadata != null);
    }

    void test_properties () {
        var metadata = Kkc.RuleMetadata.find ("kana");
        var rule = new Kkc.Rule (metadata);
        var keymap = rule.get_keymap (Kkc.InputMode.HIRAGANA) as Object;
        Kkc.Keymap parent;
        keymap.get ("parent", out parent);
        keymap.set ("parent", parent);
    }

    void test_lookup () {
        var metadata = Kkc.RuleMetadata.find ("kana");
        var rule = new Kkc.Rule (metadata);
        var keymap = rule.get_keymap (Kkc.InputMode.HIRAGANA);

        string? command;
        command = keymap.lookup_key (new Kkc.KeyEvent.from_string ("(alt r)"));
        assert (command == "register");

        Kkc.KeyEvent? key;
        key = keymap.where_is ("register");
        assert (key.to_string () == "(alt r)");

        var commands = keymap.commands ();
        var entries = keymap.entries ();

        assert (keymap.get_command_label ("register") == "Register Word");
    }
}

int main (string[] args) {
    Test.init (ref args);
    Kkc.init ();

    TestSuite root = TestSuite.get_root ();
    root.add_suite (new KeymapTests ().get_suite ());

    Test.run ();

    return 0;
}