2020-11-07 23:54:19 +00:00
|
|
|
#!/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 unittest
|
|
|
|
|
2020-12-26 15:46:01 +00:00
|
|
|
import evdev
|
|
|
|
from evdev.ecodes import EV_ABS, EV_KEY
|
|
|
|
|
2020-11-17 22:40:39 +00:00
|
|
|
from keymapper.getdevices import get_devices
|
2020-11-07 23:54:19 +00:00
|
|
|
|
2020-12-26 15:46:01 +00:00
|
|
|
from tests.test import InputDevice, cleanup, fixtures
|
|
|
|
|
2020-11-07 23:54:19 +00:00
|
|
|
|
|
|
|
class TestTest(unittest.TestCase):
|
|
|
|
def test_stubs(self):
|
|
|
|
self.assertIn('device 1', get_devices())
|
|
|
|
|
2020-12-26 15:46:01 +00:00
|
|
|
def test_fake_capabilities(self):
|
|
|
|
device = InputDevice('/dev/input/event30')
|
|
|
|
capabilities = device.capabilities(absinfo=False)
|
|
|
|
self.assertIsInstance(capabilities, dict)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS], list)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS][0], int)
|
|
|
|
|
|
|
|
capabilities = device.capabilities()
|
|
|
|
self.assertIsInstance(capabilities, dict)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS], list)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS][0], tuple)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS][0][0], int)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS][0][1], evdev.AbsInfo)
|
|
|
|
self.assertIsInstance(capabilities[EV_ABS][0][1].max, int)
|
|
|
|
self.assertIsInstance(capabilities, dict)
|
|
|
|
self.assertIsInstance(capabilities[EV_KEY], list)
|
|
|
|
self.assertIsInstance(capabilities[EV_KEY][0], int)
|
|
|
|
|
|
|
|
def test_restore_fixtures(self):
|
|
|
|
fixtures[1] = [1234]
|
|
|
|
del fixtures['/dev/input/event11']
|
|
|
|
cleanup()
|
|
|
|
self.assertIsNone(fixtures.get(1))
|
|
|
|
self.assertIsNotNone(fixtures.get('/dev/input/event11'))
|
|
|
|
|
2020-11-07 23:54:19 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|