ya2 · news · projects · code · about

more asserts
[pmachines.git] / ya2 / p3d / asserts.py
1 from logging import info, debug
2 import threading
3
4
5 def assert_render3d():
6 for child in render.children:
7 if child.name != 'camera':
8 raise Exception()
9
10 def assert_aspect2d():
11 for child in aspect2d.children:
12 preserve = [
13 'a2dBackground', 'a2dTopCenter', 'a2dTopCenterNS',
14 'a2dBottomCenter', 'a2dBottomCenterNS', 'a2dLeftCenter',
15 'a2dLeftCenterNS', 'a2dRightCenter', 'a2dRightCenterNS',
16 'a2dTopLeft', 'a2dTopLeftNS', 'a2dTopRight',
17 'a2dTopRightNS', 'a2dBottomLeft', 'a2dBottomLeftNS',
18 'a2dBottomRight', 'a2dBottomRightNS']
19 if child.name not in preserve and not child.has_python_tag('preserve'):
20 raise Exception()
21
22 def assert_render2d():
23 for child in render2d.children:
24 preserve = ['aspect2d', 'pixel2d', 'camera2d']
25 if child.name not in preserve and not child.has_python_tag('preserve'):
26 raise Exception()
27
28 def assert_events():
29 preserve = ['window-event', 'window-closed', 'async_loader_0',
30 'render-texture-targets-changed', 'aspectRatioChanged']
31 for evt in messenger.getEvents():
32 if evt not in preserve:
33 msg = 'unexpected event: %s' % evt
34 raise Exception(msg)
35
36 def assert_tasks():
37 preserve = [
38 'ivalLoop', 'garbageCollectStates', 'collisionLoop',
39 'igLoop', 'audioLoop', 'resetPrevTransform', 'dataLoop',
40 'eventManager', 'simplepbr update', 'on frame music']
41 for task in taskMgr.getTasks() + taskMgr.getDoLaters():
42 if task.name not in preserve and not hasattr(task, 'preserve'):
43 msg = 'unexpected task: %s' % task.name
44 raise Exception(msg)
45
46 def assert_buffers():
47 pass
48 #for buffer in RenderToTexture.buffers:
49 # raise Error()
50
51
52 def assert_threads():
53 thr_names = [thread.name for thread in threading.enumerate()]
54 preserve = ['MainThread']
55 for thr_name in thr_names:
56 if thr_name not in preserve:
57 msg = 'unexpected thread: %s' % thr_name
58 raise Exception(msg)