forked from orbbec/pyorbbecsdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_context.py
54 lines (36 loc) · 1.7 KB
/
test_context.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import unittest
from pyorbbecsdk import *
def on_device_connected_callback(_: DeviceList):
print("on_device_connected_callback")
def on_device_disconnected_callback(_: DeviceList):
print("on_device_disconnected_callback")
def on_set_device_changed_callback(disconn_list: DeviceList, conn_list: DeviceList):
on_device_disconnected_callback(disconn_list)
on_device_connected_callback(conn_list)
class ContextTest(unittest.TestCase):
def setUp(self) -> None:
self.context = Context()
def tearDown(self) -> None:
self.context = None
def test_get_device_list(self):
device_list = self.context.query_devices()
self.assertIsNotNone(device_list)
self.assertGreater(device_list.get_count(), 0)
def test_setup_logger_level(self):
self.context.set_logger_level(OBLogLevel.DEBUG)
self.context.set_logger_level(OBLogLevel.INFO)
self.context.set_logger_level(OBLogLevel.WARNING)
self.context.set_logger_level(OBLogLevel.ERROR)
self.context.set_logger_level(OBLogLevel.FATAL)
self.context.set_logger_level(OBLogLevel.NONE)
def test_set_device_changed_callback(self):
self.context.set_device_changed_callback(on_set_device_changed_callback)
def test_enable_multi_device_sync(self):
self.context.enable_multi_device_sync(100)
def test_set_logger_to_console(self):
self.context.set_logger_to_console(OBLogLevel.DEBUG)
def test_set_logger_to_file(self):
self.context.set_logger_to_file(OBLogLevel.DEBUG, "test.log")
if __name__ == '__main__':
print("Start test Context interface, Please make sure you have connected a device to your computer.")
unittest.main()