forked from 20tab/UnrealEnginePython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_console_manager.py
38 lines (30 loc) · 1.8 KB
/
test_console_manager.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
import unittest
import unreal_engine as ue
from unreal_engine import IConsoleManager
class TestConsoleManager(unittest.TestCase):
def setUp(self):
if IConsoleManager.is_name_registered('uep_test_001'):
IConsoleManager.unregister_object('uep_test_001')
def test_history(self):
history = IConsoleManager.get_history()
IConsoleManager.add_history_entry('FooBar')
self.assertEqual(IConsoleManager.get_history()[-1], 'FooBar')
def test_variable_string_register(self):
IConsoleManager.register_variable_string('uep_test_001', 'test help string 001', 'xyz')
self.assertEqual(IConsoleManager.get_string('uep_test_001'), 'xyz')
self.assertEqual(IConsoleManager.get_help('uep_test_001'), 'test help string 001')
def test_variable_string_set_help(self):
IConsoleManager.register_variable_string('uep_test_001', 'test help string 001', 'xyz')
self.assertEqual(IConsoleManager.get_help('uep_test_001'), 'test help string 001')
IConsoleManager.set_help('uep_test_001', 'test help string 002')
self.assertEqual(IConsoleManager.get_help('uep_test_001'), 'test help string 002')
def test_variable_int_register(self):
IConsoleManager.register_variable_int('uep_test_001', 'test help string 001', 17)
self.assertEqual(IConsoleManager.get_int('uep_test_001'), 17)
self.assertEqual(IConsoleManager.get_help('uep_test_001'), 'test help string 001')
def test_variable_float_register(self):
IConsoleManager.register_variable_float('uep_test_001', 'test help string 001', 17.22)
self.assertTrue((17.22 - IConsoleManager.get_float('uep_test_001')) < 0.1)
self.assertEqual(IConsoleManager.get_help('uep_test_001'), 'test help string 001')
if __name__ == '__main__':
unittest.main(exit=False)