diff options
| author | Jules Aguillon | 2025-04-15 00:05:52 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2025-04-15 00:05:52 +0200 |
| commit | 460e5214a20a381af9b18273372477389927f3fc (patch) | |
| tree | 184aeaaecba4794a6e1df5700131f8ae397f9e65 /test | |
| parent | 5ae3ec05e7dbf5ad023e5121a5f12900d14098a0 (diff) | |
| download | unexpected-keyboard-460e5214a20a381af9b18273372477389927f3fc.tar.gz unexpected-keyboard-460e5214a20a381af9b18273372477389927f3fc.zip | |
Add class Modmap and test KeyModifier
Diffstat (limited to 'test')
| -rw-r--r-- | test/juloo.keyboard2/ModmapTest.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/juloo.keyboard2/ModmapTest.java b/test/juloo.keyboard2/ModmapTest.java new file mode 100644 index 0000000..3457c3b --- /dev/null +++ b/test/juloo.keyboard2/ModmapTest.java @@ -0,0 +1,47 @@ +package juloo.keyboard2; + +import android.view.KeyEvent; +import juloo.keyboard2.*; +import org.junit.Test; +import static org.junit.Assert.*; + +public class ModmapTest +{ + public ModmapTest() {} + + @Test + public void test() + { + Modmap mm = new Modmap(); + mm.add(Modmap.M.Shift, KeyValue.getKeyByName("a"), KeyValue.getKeyByName("b")); + mm.add(Modmap.M.Fn, KeyValue.getKeyByName("c"), KeyValue.getKeyByName("d")); + Utils.apply(mm, "a", KeyValue.Modifier.SHIFT, "b"); + Utils.apply(mm, "a", KeyValue.Modifier.FN, "æ"); + Utils.apply(mm, "c", KeyValue.Modifier.FN, "d"); + } + + @Test + public void keyevent_mappings() + { + Modmap mm = new Modmap(); + mm.add(Modmap.M.Ctrl, KeyValue.getKeyByName("љ"), KeyValue.getKeyByName("љ:q")); + Utils.apply(mm, "a", KeyValue.Modifier.CTRL, KeyValue.getKeyByName("a").withKeyevent(29)); + Utils.apply(mm, "љ", KeyValue.Modifier.CTRL, KeyValue.getKeyByName("љ").withKeyevent(45)); + } + + static class Utils + { + static void apply(Modmap mm, String a, KeyValue.Modifier mod, String expected) + { + apply(mm, a, mod, KeyValue.getKeyByName(expected)); + } + + static void apply(Modmap mm, String a, KeyValue.Modifier mod, KeyValue expected) + { + KeyModifier.set_modmap(mm); + KeyValue b = KeyModifier.modify(KeyValue.getKeyByName(a), mod); + KeyModifier.set_modmap(null); + assertEquals(b, expected); + } + } +} |
