From 89a1622fa48e7dd7d9e7dea27db91f5d22e9faa8 Mon Sep 17 00:00:00 2001
From: Christos Tsolakis <christos.tsolakis@kitware.com>
Date: Mon, 31 Oct 2022 14:03:11 -0400
Subject: [PATCH] vtkWebApplication Add test to expose memory leak

---
 Web/Core/Testing/Python/CMakeLists.txt        |  1 +
 .../Python/TestWebApplicationMemory.py        | 33 +++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 Web/Core/Testing/Python/TestWebApplicationMemory.py

diff --git a/Web/Core/Testing/Python/CMakeLists.txt b/Web/Core/Testing/Python/CMakeLists.txt
index 17e827d3439..4856fd5dc0d 100644
--- a/Web/Core/Testing/Python/CMakeLists.txt
+++ b/Web/Core/Testing/Python/CMakeLists.txt
@@ -5,4 +5,5 @@ vtk_add_test_python(
 vtk_add_test_python(
   NO_DATA NO_VALID NO_OUTPUT
   TestObjectIdMap.py
+  TestWebApplicationMemory.py
   )
diff --git a/Web/Core/Testing/Python/TestWebApplicationMemory.py b/Web/Core/Testing/Python/TestWebApplicationMemory.py
new file mode 100644
index 00000000000..bafb6b6c025
--- /dev/null
+++ b/Web/Core/Testing/Python/TestWebApplicationMemory.py
@@ -0,0 +1,33 @@
+import vtk
+from vtk.test import Testing
+from vtk.vtkWebCore import vtkWebApplication
+
+class TestWebApplicationMemory(Testing.vtkTest):
+    def testWebApplicationMemory(self):
+        cylinder = vtk.vtkCylinderSource()
+        cylinder.SetResolution(8)
+
+        cylinderMapper = vtk.vtkPolyDataMapper()
+        cylinderMapper.SetInputConnection(cylinder.GetOutputPort())
+
+        cylinderActor = vtk.vtkActor()
+        cylinderActor.SetMapper(cylinderMapper)
+        cylinderActor.RotateX(30.0)
+        cylinderActor.RotateY(-45.0)
+
+        ren = vtk.vtkRenderer()
+        renWin = vtk.vtkRenderWindow()
+        renWin.AddRenderer(ren)
+        ren.AddActor(cylinderActor)
+        renWin.SetSize(200, 200)
+
+        ren.ResetCamera()
+        ren.GetActiveCamera().Zoom(1.5)
+        renWin.Render()
+
+        webApp = vtk.vtkWebApplication()
+        # no memory leaks sould be reported when compiling with VTK_DEBUG_LEAKS
+        webApp.StillRender(renWin)
+
+if __name__ == "__main__":
+    Testing.main([(TestWebApplicationMemory, 'test')])
-- 
GitLab