From aabf009ff0468bf30e1d81dfd3f14768c6fa0f98 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 31 Oct 2017 20:57:10 -0700 Subject: [PATCH] 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 --- tests/display/conftest.py | 42 ++++++++++++++++++++++++++++++++++++ tests/display/test_window.py | 15 +++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/display/conftest.py create mode 100644 tests/display/test_window.py diff --git a/tests/display/conftest.py b/tests/display/conftest.py new file mode 100644 index 0000000000..821b06af80 --- /dev/null +++ b/tests/display/conftest.py @@ -0,0 +1,42 @@ +import pytest + +@pytest.fixture +def graphics_pipe(scope='session'): + from panda3d.core import GraphicsPipeSelection + + pipe = GraphicsPipeSelection.get_global_ptr().make_default_pipe() + + if not pipe.is_valid(): + pytest.xfail("GraphicsPipe is invalid") + + yield pipe + +@pytest.fixture +def graphics_engine(scope='session'): + from panda3d.core import GraphicsEngine + + engine = GraphicsEngine.get_global_ptr() + yield engine + +@pytest.fixture +def window(graphics_pipe, graphics_engine): + from panda3d.core import GraphicsPipe, FrameBufferProperties, WindowProperties + + fbprops = FrameBufferProperties.get_default() + winprops = WindowProperties.get_default() + + win = graphics_engine.make_output( + graphics_pipe, + 'window', + 0, + fbprops, + winprops, + GraphicsPipe.BF_require_window + ) + graphics_engine.open_windows() + + assert win is not None + yield win + + if win is not None: + graphics_engine.remove_window(win) diff --git a/tests/display/test_window.py b/tests/display/test_window.py new file mode 100644 index 0000000000..d193fe92dd --- /dev/null +++ b/tests/display/test_window.py @@ -0,0 +1,15 @@ +def test_window_basic(window): + from panda3d.core import WindowProperties + assert window is not None + + current_props = window.get_properties() + default_props = WindowProperties.get_default() + + # Opening the window changes these from the defaults + default_props.set_size(current_props.get_size()) + default_props.set_origin(current_props.get_origin()) + default_props.set_minimized(False) + default_props.set_foreground(True) + + # The rest should be the same + assert current_props == default_props