Skip to content

Commit b7e5a53

Browse files
committed
Context test
1 parent 3b55fb5 commit b7e5a53

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_context.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import moderngl
2+
3+
from demosys.test import DemosysTestCase
4+
from demosys import geometry
5+
6+
7+
class ContextTestCase(DemosysTestCase):
8+
"""Test the headless context/window"""
9+
10+
def test_properties(self):
11+
self.assertEqual(type(self.window.ctx), moderngl.Context)
12+
# We don't have a default framebuffer in headless mode
13+
self.assertIsNone(self.ctx.screen)
14+
self.assertIsNotNone(self.window.fbo)
15+
16+
def test_basic_render(self):
17+
"""Ensure we actually draw something to the screen"""
18+
vao = geometry.quad_fs()
19+
shader = self.create_shader(path='vf_pos_color.glsl')
20+
shader.uniform("color", (1.0, 1.0, 1.0, 1.0))
21+
vao.draw(shader)
22+
23+
data = self.window.fbo.read()
24+
self.assertEqual(data[:10], b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')

0 commit comments

Comments
 (0)