step 3: add widget shell sizing and frame pump
This commit is contained in:
30
tests/test_renderer.py
Normal file
30
tests/test_renderer.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dpg_map.commands import CommandKind, MapCommand
|
||||
from dpg_map.renderer import drain_renderer_commands
|
||||
from dpg_map.state import DirtyFlags, create_map_state
|
||||
|
||||
|
||||
def test_renderer_command_drain_preserves_structural_order_and_coalesces() -> None:
|
||||
state = create_map_state(tag="renderer-drain")
|
||||
state.dirty = DirtyFlags.NONE
|
||||
|
||||
state.command_queue.put(MapCommand(CommandKind.ADD_OVERLAY, state.tag, {"tag": "a"}))
|
||||
state.command_queue.put(MapCommand(CommandKind.SET_VIEW, state.tag, {"zoom": 3}))
|
||||
state.command_queue.put(MapCommand(CommandKind.SET_VIEW, state.tag, {"zoom": 4}))
|
||||
state.command_queue.put(MapCommand(CommandKind.UPDATE_OVERLAY, state.tag, {"tag": "a", "v": 1}))
|
||||
state.command_queue.put(MapCommand(CommandKind.UPDATE_OVERLAY, state.tag, {"tag": "a", "v": 2}))
|
||||
state.command_queue.put(MapCommand(CommandKind.DELETE_OVERLAY, state.tag, {"tag": "a"}))
|
||||
|
||||
commands = drain_renderer_commands(state)
|
||||
|
||||
assert [command.kind for command in commands] == [
|
||||
CommandKind.ADD_OVERLAY,
|
||||
CommandKind.SET_VIEW,
|
||||
CommandKind.UPDATE_OVERLAY,
|
||||
CommandKind.DELETE_OVERLAY,
|
||||
]
|
||||
assert commands[1].payload == {"zoom": 4}
|
||||
assert commands[2].payload == {"tag": "a", "v": 2}
|
||||
assert state.dirty & DirtyFlags.VIEW
|
||||
assert state.dirty & DirtyFlags.OVERLAYS
|
||||
Reference in New Issue
Block a user