diff --git a/core/src/test/java/edu/umd/cs/piccolo/MemoryLeakTests.java b/core/src/test/java/edu/umd/cs/piccolo/MemoryLeakTests.java deleted file mode 100644 index c0b82e8..0000000 --- a/core/src/test/java/edu/umd/cs/piccolo/MemoryLeakTests.java +++ /dev/null @@ -1,33 +0,0 @@ -package edu.umd.cs.piccolo; - -import javax.swing.JPanel; - -import junit.framework.TestCase; -import edu.umd.cs.piccolo.PCanvas; - -public class MemoryLeakTests extends TestCase { - private int pCanvasFinalizerCount; - - public void setUp() { - pCanvasFinalizerCount = 0; - } - - public void testMemoryLeakWithPCanvas() throws InterruptedException { - JPanel panel = new JPanel(); - for (int i=0; i < 10; i++) { - PCanvas canvas = new PCanvas() { - public void finalize() { - pCanvasFinalizerCount ++; - } - }; - panel.add(canvas); - panel.remove(canvas); - canvas = null; - } - System.gc(); - System.runFinalization(); - - // Not sure why I need -1 here, but I do. If I create 10000 it'll always be 1 less - assertEquals(10-1, pCanvasFinalizerCount); - } -} diff --git a/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java b/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java index 3822845..01b89c3 100644 --- a/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java +++ b/core/src/test/java/edu/umd/cs/piccolo/PCanvasTest.java @@ -2,14 +2,18 @@ import java.awt.Cursor; +import javax.swing.JPanel; + import junit.framework.TestCase; import edu.umd.cs.piccolo.util.PBounds; import edu.umd.cs.piccolo.util.PPaintContext; public class PCanvasTest extends TestCase { private PCanvas canvas; - - public void setUp() { + private int pCanvasFinalizerCount; + + public void setUp() { + pCanvasFinalizerCount = 0; canvas = new PCanvas(); } @@ -86,6 +90,24 @@ canvas.setBounds(0, 0, 100, 100); assertEquals(new PBounds(0, 0, 100, 100), canvas.getCamera().getBounds()); } - + + public void testMemoryLeakWithPCanvas() throws InterruptedException { + JPanel panel = new JPanel(); + for (int i=0; i < 10; i++) { + PCanvas canvas = new PCanvas() { + public void finalize() { + pCanvasFinalizerCount ++; + } + }; + panel.add(canvas); + panel.remove(canvas); + canvas = null; + } + System.gc(); + System.runFinalization(); + + // Not sure why I need -1 here, but I do. If I create 10000 it'll always be 1 less + assertEquals(10-1, pCanvasFinalizerCount); + } }