mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-04 12:00:16 +00:00
testing the injector constructor
This commit is contained in:
parent
6def1dcc54
commit
3fcc5af310
@ -104,6 +104,7 @@ def _start_injecting_worker(path, pipe):
|
|||||||
device = _grab(path)
|
device = _grab(path)
|
||||||
|
|
||||||
if device is None:
|
if device is None:
|
||||||
|
print('lakjdsflakdsjfa')
|
||||||
pipe.send(FAILED)
|
pipe.send(FAILED)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import evdev
|
import evdev
|
||||||
@ -145,6 +146,9 @@ def patch_evdev():
|
|||||||
|
|
||||||
while len(pending_events[self.name]) > 0:
|
while len(pending_events[self.name]) > 0:
|
||||||
yield pending_events[self.name].pop(0)
|
yield pending_events[self.name].pop(0)
|
||||||
|
# give tests some time to test stuff while the process
|
||||||
|
# is still running
|
||||||
|
time.sleep(0.01)
|
||||||
|
|
||||||
def capabilities(self, absinfo=True):
|
def capabilities(self, absinfo=True):
|
||||||
return fixtures[self.path]['capabilities']
|
return fixtures[self.path]['capabilities']
|
||||||
|
@ -24,7 +24,8 @@ import unittest
|
|||||||
import evdev
|
import evdev
|
||||||
|
|
||||||
from keymapper.injector import _start_injecting_worker, _grab, \
|
from keymapper.injector import _start_injecting_worker, _grab, \
|
||||||
is_numlock_on, toggle_numlock, ensure_numlock, _modify_capabilities
|
is_numlock_on, toggle_numlock, ensure_numlock, _modify_capabilities, \
|
||||||
|
KeycodeInjector
|
||||||
from keymapper.getdevices import get_devices
|
from keymapper.getdevices import get_devices
|
||||||
from keymapper.state import custom_mapping, system_mapping
|
from keymapper.state import custom_mapping, system_mapping
|
||||||
|
|
||||||
@ -97,6 +98,17 @@ class TestInjector(unittest.TestCase):
|
|||||||
toggle_numlock()
|
toggle_numlock()
|
||||||
self.assertEqual(before, is_numlock_on())
|
self.assertEqual(before, is_numlock_on())
|
||||||
|
|
||||||
|
def test_injector_constructor(self):
|
||||||
|
global pending_events
|
||||||
|
# this buys some time to test if the process is alive. 2 (20ms) would
|
||||||
|
# already be enough
|
||||||
|
pending_events['device 2'] = [Event(1, 1, 1)] * 10
|
||||||
|
|
||||||
|
injector2 = KeycodeInjector('device 2')
|
||||||
|
self.assertEqual(len(injector2.processes), 1)
|
||||||
|
self.assertEqual(injector2.processes[0].is_alive(), True)
|
||||||
|
injector2.processes[0].join()
|
||||||
|
|
||||||
def test_injector(self):
|
def test_injector(self):
|
||||||
device = get_devices()['device 2']
|
device = get_devices()['device 2']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user