Example #1
0
 def test_make_current(self):
     mock_context = mock.MagicMock()
     with mock.patch(CONTEXT_PATH) as mock_glfw:
         mock_glfw.create_window.return_value = mock_context
         renderer = glfw_renderer.GLFWContext(MAX_WIDTH, MAX_HEIGHT)
         with renderer.make_current():
             pass
     mock_glfw.make_context_current.assert_called_once_with(mock_context)
Example #2
0
 def test_freeing(self):
     mock_context = mock.MagicMock()
     with mock.patch(CONTEXT_PATH) as mock_glfw:
         mock_glfw.create_window.return_value = mock_context
         renderer = glfw_renderer.GLFWContext(MAX_WIDTH, MAX_HEIGHT)
         renderer.free()
     mock_glfw.destroy_window.assert_called_once_with(mock_context)
     self.assertIsNone(renderer._context)
Example #3
0
 def test_repeatedly_create_and_destroy_context(self):
     renderer = glfw_renderer.GLFWContext(MAX_WIDTH, MAX_HEIGHT)
     wrapper.MjrContext(wrapper.MjModel.from_xml_string('<mujoco/>'),
                        renderer)
Example #4
0
 def test_init(self):
     mock_context = mock.MagicMock()
     with mock.patch(CONTEXT_PATH) as mock_glfw:
         mock_glfw.create_window.return_value = mock_context
         renderer = glfw_renderer.GLFWContext(MAX_WIDTH, MAX_HEIGHT)
     self.assertIs(renderer._context, mock_context)