removed stuff from tests that was removed
parent
f18b013513
commit
3d3136ed8b
@ -1,4 +0,0 @@
|
||||
default
|
||||
xkb_symbols "basic" {
|
||||
name[Group1]="key-mapper/empty";
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
// keycodes configuration for key-mapper presets
|
||||
|
||||
default xkb_keycodes "basic" {{
|
||||
minimum = {minimum};
|
||||
maximum = {maximum};
|
||||
{xkb_keycodes}
|
||||
}};
|
@ -1,9 +0,0 @@
|
||||
// key-mapper symbols config file.
|
||||
|
||||
// the corresponding keycodes configuration is in
|
||||
// /usr/share/X11/xkb/keycodes/key-mapper
|
||||
|
||||
default xkb_symbols "basic" {{
|
||||
name[Group1] = "{name}";
|
||||
{xkb_symbols}
|
||||
}};
|
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# key-mapper - GUI for device specific keyboard mappings
|
||||
# Copyright (C) 2020 sezanzeb <proxima@hip70890b.de>
|
||||
#
|
||||
# This file is part of key-mapper.
|
||||
#
|
||||
# key-mapper is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# key-mapper is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with key-mapper. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from keymapper.cli import get_system_layout_locale
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
def test_get_system_layout_locale(self):
|
||||
layout = get_system_layout_locale()
|
||||
self.assertGreater(len(layout), 0)
|
||||
# should be all alphanumeric
|
||||
match = re.findall(r'\w+', layout)
|
||||
self.assertEqual(len(match), 1)
|
||||
self.assertEqual(match[0], layout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -1,144 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# key-mapper - GUI for device specific keyboard mappings
|
||||
# Copyright (C) 2020 sezanzeb <proxima@hip70890b.de>
|
||||
#
|
||||
# This file is part of key-mapper.
|
||||
#
|
||||
# key-mapper is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# key-mapper is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with key-mapper. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import shutil
|
||||
|
||||
from keymapper.archive.xkb import custom_mapping, generate_symbols, \
|
||||
create_identity_mapping, create_setxkbmap_config, \
|
||||
get_preset_name, create_default_symbols, parse_symbols_file, \
|
||||
get_usr_path, KEYCODES_PATH, USERS_SYMBOLS
|
||||
|
||||
from test import tmp
|
||||
|
||||
|
||||
class TestConfig(unittest.TestCase):
|
||||
def setUp(self):
|
||||
custom_mapping.empty()
|
||||
custom_mapping.change(None, 10, 'a')
|
||||
custom_mapping.change(None, 11, 'KP_1')
|
||||
custom_mapping.change(None, 12, 3)
|
||||
custom_mapping.change(None, 13, ['a', 'A', 'NoSymbol', 3])
|
||||
self.assertEqual(custom_mapping.get_character(12), '3')
|
||||
self.assertEqual(custom_mapping.get_character(13), 'a, A, NoSymbol, 3')
|
||||
if os.path.exists(tmp):
|
||||
shutil.rmtree(tmp)
|
||||
|
||||
def test_create_setxkbmap_config(self):
|
||||
create_setxkbmap_config('device a', 'preset b')
|
||||
|
||||
self.assertTrue(os.path.exists(os.path.join(
|
||||
USERS_SYMBOLS,
|
||||
'device_a',
|
||||
'preset_b'
|
||||
)))
|
||||
|
||||
self.assertTrue(os.path.exists(KEYCODES_PATH))
|
||||
|
||||
with open(get_usr_path('device_a', 'preset_b'), 'r') as f:
|
||||
content = f.read()
|
||||
self.assertIn('key <10> { [ a ] };', content)
|
||||
self.assertIn('key <11> { [ KP_1 ] };', content)
|
||||
self.assertIn('key <12> { [ 3 ] };', content)
|
||||
self.assertIn('key <13> { [ a, A, NoSymbol, 3 ] };', content)
|
||||
|
||||
self.assertIn('include "key-mapper/user/default"', content)
|
||||
self.assertIn(get_preset_name('device_a', 'preset_b'), content)
|
||||
|
||||
# it should be loaded correctly after saving
|
||||
parse_symbols_file('device_a', 'preset_b')
|
||||
self.assertIsNone(custom_mapping.get_character(9))
|
||||
self.assertEqual(custom_mapping.get_character(10), 'a')
|
||||
self.assertEqual(custom_mapping.get_character(11), 'KP_1')
|
||||
self.assertEqual(custom_mapping.get_character(12), '3')
|
||||
self.assertEqual(custom_mapping.get_character(13), 'a, A, NoSymbol, 3')
|
||||
self.assertIsNone(custom_mapping.get_character(14))
|
||||
|
||||
def test_default_symbols(self):
|
||||
# keycodes are missing
|
||||
self.assertRaises(
|
||||
FileNotFoundError,
|
||||
create_default_symbols
|
||||
)
|
||||
create_identity_mapping()
|
||||
create_default_symbols()
|
||||
|
||||
self.assertTrue(os.path.exists(get_usr_path('default')))
|
||||
|
||||
with open(get_usr_path('default'), 'r') as f:
|
||||
content = f.read()
|
||||
self.assertNotIn('include', content)
|
||||
# this is pretty much the same on every keyboard.
|
||||
# The default config should also contain the modified keys, but
|
||||
# since they are different in every country just check for the
|
||||
# comma.
|
||||
self.assertIn('key <10> { [ 1, ', content)
|
||||
self.assertIn('key <11> { [ 2, ', content)
|
||||
self.assertIn('key <12> { [ 3, ', content)
|
||||
self.assertIn('key <13> { [ 4, ', content)
|
||||
self.assertIn('key <65> { [ space, ', content)
|
||||
|
||||
def test_get_preset_name(self):
|
||||
self.assertEqual(get_preset_name('a', 'b'), 'key-mapper/user/a/b')
|
||||
self.assertEqual(get_preset_name('a'), 'key-mapper/user/a')
|
||||
|
||||
def test_generate_content(self):
|
||||
self.assertRaises(
|
||||
FileNotFoundError,
|
||||
generate_symbols,
|
||||
'device', 'preset'
|
||||
)
|
||||
|
||||
# create the identity mapping, because it is required for
|
||||
# generate_symbols
|
||||
create_identity_mapping()
|
||||
|
||||
content = generate_symbols('device/preset')
|
||||
self.assertIn('key <10> { [ a ] };', content)
|
||||
self.assertIn('key <11> { [ KP_1 ] };', content)
|
||||
self.assertIn('key <12> { [ 3 ] };', content)
|
||||
self.assertIn('key <13> { [ a, A, NoSymbol, 3 ] };', content)
|
||||
|
||||
def test_identity_mapping(self):
|
||||
create_identity_mapping()
|
||||
self.assertTrue(os.path.exists(KEYCODES_PATH))
|
||||
with open(KEYCODES_PATH, 'r') as f:
|
||||
content = f.read()
|
||||
self.assertIn('minimum = 8;', content)
|
||||
# whatever the maximum is, might change if mouse buttons
|
||||
# can be supported at some point as well (no idea how)
|
||||
self.assertIn('maximum =', content)
|
||||
self.assertIn('<8> = 8;', content)
|
||||
self.assertIn('<255> = 255;', content)
|
||||
# this is stuff that should only be found in symbol files
|
||||
self.assertNotIn('include', content)
|
||||
self.assertNotIn('name', content)
|
||||
# to make sure they are used together with format, which
|
||||
# changes {{ to {.
|
||||
self.assertNotIn('{{', content)
|
||||
self.assertNotIn('}}', content)
|
||||
self.assertIn('{', content)
|
||||
self.assertIn('}', content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Reference in New Issue