summaryrefslogtreecommitdiffstats
path: root/tests/org.eclipse.swt.tests
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2009-03-26 21:07:16 +0000
committerSilenio Quarti <silenio>2009-03-26 21:07:16 +0000
commit5d9f96bf8d13acdfa258518b395628fadfb41dd6 (patch)
tree7e2574217f38f366d70a3773df0b15266699fe09 /tests/org.eclipse.swt.tests
parenteb295d298f5a6bd34315c1f3f14f0f5c05d242c9 (diff)
downloadeclipse.platform.swt-5d9f96bf8d13acdfa258518b395628fadfb41dd6.tar.gz
eclipse.platform.swt-5d9f96bf8d13acdfa258518b395628fadfb41dd6.tar.xz
eclipse.platform.swt-5d9f96bf8d13acdfa258518b395628fadfb41dd6.zip
leaking
Diffstat (limited to 'tests/org.eclipse.swt.tests')
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java32
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java3
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java4
3 files changed, 26 insertions, 13 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
index 05af4cd369..ff103e2a57 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java
@@ -55,17 +55,20 @@ public void test_ConstructorLorg_eclipse_swt_graphics_Drawable() {
} catch (IllegalArgumentException e) {
assertEquals("Incorrect exception thrown for drawable == null", SWT.ERROR_NULL_ARGUMENT, e);
}
-
+
+ Image image = null;
+ GC gc1 = null, gc2 = null;
try {
- Image image = new Image(display, 10, 10);
- GC gc1 = new GC(image);
- GC gc2 = new GC(image);
- gc1.dispose();
- gc2.dispose();
- image.dispose();
+ image = new Image(display, 10, 10);
+ gc1 = new GC(image);
+ gc2 = new GC(image);
fail("No exception thrown for more than one GC on one image");
} catch (IllegalArgumentException e) {
assertEquals("Incorrect exception thrown for more than one GC on one image", SWT.ERROR_INVALID_ARGUMENT, e);
+ } finally {
+ if (image != null) image.dispose();
+ if (gc1 != null) gc1.dispose();
+ if (gc2 != null) gc2.dispose();
}
}
@@ -78,16 +81,19 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DrawableI() {
assertEquals("Incorrect exception thrown for drawable == null", SWT.ERROR_NULL_ARGUMENT, e);
}
+ Image image = null;
+ GC gc1 = null, gc2 = null;
try {
- Image image = new Image(display, 10, 10);
- GC gc1 = new GC(image, SWT.RIGHT_TO_LEFT);
- GC gc2 = new GC(image, SWT.LEFT_TO_RIGHT);
- gc1.dispose();
- gc2.dispose();
- image.dispose();
+ image = new Image(display, 10, 10);
+ gc1 = new GC(image, SWT.RIGHT_TO_LEFT);
+ gc2 = new GC(image, SWT.LEFT_TO_RIGHT);
fail("No exception thrown for more than one GC on one image");
} catch (IllegalArgumentException e) {
assertEquals("Incorrect exception thrown for more than one GC on one image", SWT.ERROR_INVALID_ARGUMENT, e);
+ } finally {
+ if (image != null) image.dispose();
+ if (gc1 != null) gc1.dispose();
+ if (gc2 != null) gc2.dispose();
}
Canvas canvas = new Canvas(shell, SWT.NULL);
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java
index 0e5f7197f7..e66bc653dd 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_ImageData.java
@@ -717,6 +717,7 @@ public void test_getTransparencyMask() {
imageData = image.getImageData();
ImageData maskData = imageData.getTransparencyMask();
assertNotNull(":b:", maskData);
+ image.dispose();
// Bug 71472 - transparency mask should be null
/* image = new Image(Display.getDefault(), getClass().getResourceAsStream(imageFilenames[0] + '.' + imageFormats[imageFormats.length-1]));
@@ -736,6 +737,7 @@ public void test_getTransparencyType() {
} catch (IOException e) {}
imageData = image.getImageData();
assertFalse(":b:", SWT.TRANSPARENCY_NONE == imageData.getTransparencyType());
+ image.dispose();
stream = getClass().getResourceAsStream(imageFilenames[0] + '.' + imageFormats[imageFormats.length-1]);
image = new Image(Display.getDefault(), stream);
@@ -744,6 +746,7 @@ public void test_getTransparencyType() {
} catch (IOException e) {}
imageData = image.getImageData();
assertEquals(":c:", SWT.TRANSPARENCY_NONE, imageData.getTransparencyType());
+ image.dispose();
}
public void test_internal_newIIILorg_eclipse_swt_graphics_PaletteDataI$BI$B$BIIIIIII() {
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
index c7bfb120f3..586db4fcb3 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Region.java
@@ -131,6 +131,7 @@ public void test_addLorg_eclipse_swt_graphics_Region() {
Region reg2 = new Region(display);
reg2.add(new Rectangle(40, 50, 10, 20));
reg1.add(reg2);
+ reg2.dispose();
try {
reg1.add((Region)null);
@@ -158,6 +159,8 @@ public void test_addLorg_eclipse_swt_graphics_Region() {
fail("no exception thrown for adding a Region to a Region which got disposed");
}
catch (SWTException e) {
+ } finally {
+ if (reg2 != null) reg2.dispose();
}
}
@@ -518,6 +521,7 @@ public void test_intersectLorg_eclipse_swt_graphics_Region() {
reg.dispose();
reg1.dispose();
reg4.dispose();
+ reg5.dispose();
}
public void test_intersectsIIII() {