testing the injector constructor

xkb
sezanzeb 4 years ago committed by sezanzeb
parent 4617d56506
commit 91f304991a

@ -104,6 +104,7 @@ def _start_injecting_worker(path, pipe):
device = _grab(path)
if device is None:
print('lakjdsflakdsjfa')
pipe.send(FAILED)
return

@ -23,6 +23,7 @@
import sys
import time
import unittest
import evdev
@ -145,6 +146,9 @@ def patch_evdev():
while len(pending_events[self.name]) > 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):
return fixtures[self.path]['capabilities']

@ -24,7 +24,8 @@ import unittest
import evdev
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.state import custom_mapping, system_mapping
@ -97,6 +98,17 @@ class TestInjector(unittest.TestCase):
toggle_numlock()
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):
device = get_devices()['device 2']

Loading…
Cancel
Save