-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Daniel McKnight <[email protected]>
- Loading branch information
1 parent
13cc44b
commit 5e38575
Showing
2 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import unittest | ||
from unittest import mock | ||
from unittest.mock import Mock | ||
|
||
|
||
class TestDeviceInput(unittest.TestCase): | ||
def test_input_device_helper(self): | ||
# TODO | ||
pass | ||
|
||
@mock.patch('distutils.spawn.find_executable') | ||
def test_can_use_touch_mouse(self, find_exec): | ||
from ovos_utils.device_input import InputDeviceHelper | ||
find_exec.return_value = True | ||
dev_input = InputDeviceHelper() | ||
|
||
dev_input._build_linput_devices_list = Mock() | ||
dev_input._build_xinput_devices_list = Mock() | ||
|
||
dev_input.libinput_devices_list = [{'Device': 'Mock', | ||
'Capabilities': ['mouse']}, | ||
{'Device': "Mock 1", | ||
'Capabilities': ['touch']} | ||
] | ||
self.assertTrue(dev_input.can_use_touch_mouse()) | ||
|
||
dev_input.libinput_devices_list.pop() | ||
self.assertTrue(dev_input.can_use_touch_mouse()) | ||
dev_input.libinput_devices_list.pop() | ||
self.assertFalse(dev_input.can_use_touch_mouse()) | ||
dev_input.xinput_devices_list = [{'Device': 'xinput', | ||
'Capabilities': ['tablet'] | ||
}] | ||
self.assertTrue(dev_input.can_use_touch_mouse()) | ||
dev_input.xinput_devices_list.pop() | ||
self.assertFalse(dev_input.can_use_touch_mouse()) | ||
|
||
@mock.patch('distutils.spawn.find_executable') | ||
def test_can_use_keyboard(self, find_exec): | ||
from ovos_utils.device_input import InputDeviceHelper | ||
find_exec.return_value = True | ||
dev_input = InputDeviceHelper() | ||
|
||
dev_input._build_linput_devices_list = Mock() | ||
dev_input._build_xinput_devices_list = Mock() | ||
|
||
dev_input.libinput_devices_list = [{'Device': 'Mock', | ||
'Capabilities': ['keyboard']}, | ||
{'Device': "Mock 1", | ||
'Capabilities': ['touch']} | ||
] | ||
self.assertTrue(dev_input.can_use_keyboard()) | ||
|
||
dev_input.libinput_devices_list.pop() | ||
self.assertTrue(dev_input.can_use_keyboard()) | ||
dev_input.libinput_devices_list.pop() | ||
self.assertFalse(dev_input.can_use_keyboard()) | ||
dev_input.xinput_devices_list = [{'Device': 'xinput', | ||
'Capabilities': ['keyboard'] | ||
}] | ||
self.assertTrue(dev_input.can_use_keyboard()) | ||
dev_input.xinput_devices_list.pop() | ||
self.assertFalse(dev_input.can_use_keyboard()) |