simplified daemon test

pull/14/head
sezanzeb 4 years ago
parent f84557cc80
commit 4019388264

@ -45,47 +45,26 @@ class TestDaemon(unittest.TestCase):
evdev.InputDevice.grab = self.grab
def test_daemon(self):
custom_mapping.change(9, 'a')
# one mapping that is unknown in the system_mapping on purpose
custom_mapping.change(10, 'b')
keycode_from = 9
keycode_to = 100
custom_mapping.change(keycode_from, 'a')
system_mapping.empty()
a_code = 100
system_mapping.change(a_code, 'a')
system_mapping.change(keycode_to, 'a')
custom_mapping.save('device 2', 'foo')
config.set_autoload_preset('device 2', 'foo')
pending_events['device 2'] = [
Event(evdev.events.EV_KEY, 1, 0),
Event(evdev.events.EV_KEY, 1, 1),
# ignored because unknown to the system
Event(evdev.events.EV_KEY, 2, 0),
Event(evdev.events.EV_KEY, 2, 1),
# just pass those over without modifying
Event(3124, 3564, 6542),
Event(evdev.events.EV_KEY, keycode_from - 8, 0)
]
self.daemon = Daemon()
time.sleep(0.5)
write_history = []
pipe = uinput_write_history_pipe[0]
while pipe.poll():
write_history.append(pipe.recv())
self.assertEqual(write_history[0].type, evdev.events.EV_KEY)
self.assertEqual(write_history[0].code, a_code - 8)
self.assertEqual(write_history[0].value, 0)
self.assertEqual(write_history[1].type, evdev.events.EV_KEY)
self.assertEqual(write_history[1].code, a_code - 8)
self.assertEqual(write_history[1].value, 1)
self.assertEqual(write_history[2].type, 3124)
self.assertEqual(write_history[2].code, 3564)
self.assertEqual(write_history[2].value, 6542)
event = uinput_write_history_pipe[0].recv()
self.assertEqual(event.type, evdev.events.EV_KEY)
self.assertEqual(event.code, keycode_to - 8)
self.assertEqual(event.value, 0)
if __name__ == "__main__":

@ -91,7 +91,6 @@ class TestInjector(unittest.TestCase):
@ensure_numlock
def wrapped():
toggle_numlock()
return 1234
wrapped() # should not change
self.assertEqual(not before, is_numlock_on())

Loading…
Cancel
Save