Skip to content

Commit aabf009

Browse files
Mogurirdb
authored andcommitted
tests: Add test_window_basic
This test just makes sure that created windows match the default WindowProperties (with a few exceptions). This also adds the following fixtures: * graphics_engine - scope='session', GraphicsEngine * graphics_pipe - scope='session', default GraphicsPipe * window - scope='test', GraphicsWindow with default framebuffer and window properties
1 parent 9d7896c commit aabf009

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

tests/display/conftest.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pytest
2+
3+
@pytest.fixture
4+
def graphics_pipe(scope='session'):
5+
from panda3d.core import GraphicsPipeSelection
6+
7+
pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe()
8+
9+
if not pipe.is_valid():
10+
pytest.xfail("GraphicsPipe is invalid")
11+
12+
yield pipe
13+
14+
@pytest.fixture
15+
def graphics_engine(scope='session'):
16+
from panda3d.core import GraphicsEngine
17+
18+
engine = GraphicsEngine.get_global_ptr()
19+
yield engine
20+
21+
@pytest.fixture
22+
def window(graphics_pipe, graphics_engine):
23+
from panda3d.core import GraphicsPipe, FrameBufferProperties, WindowProperties
24+
25+
fbprops = FrameBufferProperties.get_default()
26+
winprops = WindowProperties.get_default()
27+
28+
win = graphics_engine.make_output(
29+
graphics_pipe,
30+
'window',
31+
0,
32+
fbprops,
33+
winprops,
34+
GraphicsPipe.BF_require_window
35+
)
36+
graphics_engine.open_windows()
37+
38+
assert win is not None
39+
yield win
40+
41+
if win is not None:
42+
graphics_engine.remove_window(win)

tests/display/test_window.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def test_window_basic(window):
2+
from panda3d.core import WindowProperties
3+
assert window is not None
4+
5+
current_props = window.get_properties()
6+
default_props = WindowProperties.get_default()
7+
8+
# Opening the window changes these from the defaults
9+
default_props.set_size(current_props.get_size())
10+
default_props.set_origin(current_props.get_origin())
11+
default_props.set_minimized(False)
12+
default_props.set_foreground(True)
13+
14+
# The rest should be the same
15+
assert current_props == default_props

0 commit comments

Comments
 (0)