Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2021-09-14 17:08:00 -0400
committerAlexander Kurtakov2021-09-15 05:13:02 -0400
commit478e788c73311b74fc75d1a477d889a32dd9473f (patch)
tree67eead3f75a2aa5b80a52958d4ca396ca8764453
parent4b4ffe7987a71e87a8154a5c3a8520b8535cc763 (diff)
downloadeclipse.platform.swt-478e788c73311b74fc75d1a477d889a32dd9473f.tar.gz
eclipse.platform.swt-478e788c73311b74fc75d1a477d889a32dd9473f.tar.xz
eclipse.platform.swt-478e788c73311b74fc75d1a477d889a32dd9473f.zip
Bug 575983 - Stop disposing colors in swtI20210915-0510
Handle tests. Not all dispose are removed as there explicit checks in multiple components to not allow disposed colors. Change-Id: I3036ff1ae616191ea470b4ce65f89b2d4a546c68 Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/185425 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java9
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java17
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Color.java157
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_GC.java6
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java20
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java7
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_DateTime.java2
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Link.java1
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java2
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java2
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/performance/Test_situational.java8
11 files changed, 40 insertions, 191 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java
index 66e49ff73e..1dedc9f3c0 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyleRange.java
@@ -27,7 +27,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -55,13 +54,6 @@ public void setUp() {
initializeColors();
}
-@After
-public void tearDown() {
- for (Color color : colors.values()) {
- color.dispose();
- }
-}
-
@Test
public void test_Constructor() {
StyleRange styleRange = new StyleRange();
@@ -126,7 +118,6 @@ public void test_hashCode() {
set.add(new StyleRange(0, 1, testColor, null));
set.add(new StyleRange(0, 1, testColor, testColor));
set.add(new StyleRange(0, 1, testColor, testColor, SWT.BOLD));
- testColor.dispose();
}
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
index 4cb946dccf..a745e998b8 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
@@ -75,7 +75,6 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.test.Screenshots;
-import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
@@ -118,16 +117,6 @@ public void setUp() {
setWidget(text);
}
-@Override
-@After
-public void tearDown() {
- for (Color color : colors.values()) {
- color.dispose();
- }
- super.tearDown();
-
-}
-
// this method must not be public so that the auto-gen tool keeps it
private StyleRange[] defaultStyles() {
return new StyleRange[] {
@@ -3513,12 +3502,6 @@ public void test_setEnabled(){
text.setForeground(null);
assertEquals(disabledBg, text.getBackground());
assertEquals(disabledFg, text.getForeground());
-
- // Dispose colors
- disabledBg.dispose();
- disabledFg.dispose();
- enabledBg.dispose();
- enabledFg.dispose();
}
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Color.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Color.java
index 4f6bd6a552..031167661e 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Color.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Color.java
@@ -95,49 +95,40 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DeviceIII() {
}
@Test
+@SuppressWarnings("unused")
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceIII_with_device() {
// Test new Color(Device device, int red, int green, int blue)
// IllegalArgumentException if the red, green or blue argument is not between 0 and 255
// valid color (black)
Color color = new Color(display, 0, 0, 0);
- color.dispose();
// valid color (black with alpha)
color = new Color(display, 0, 0, 0, 0);
- color.dispose();
// valid color (white)
color = new Color(display, 255, 255, 255);
- color.dispose();
// valid color (white with alpha)
color = new Color(display, 255, 255, 255, 0);
- color.dispose();
// valid color (random grey)
color = new Color(display, 20, 20, 20);
- color.dispose();
// valid color (random grey with alpha)
color = new Color(display, 20, 20, 20, 0);
- color.dispose();
// valid color (random)
color = new Color(display, 102, 255, 0);
- color.dispose();
// valid color (random with alpha)
color = new Color(display, 102, 255, 0, 0);
- color.dispose();
// device == null (valid)
color = new Color(null, 0, 0, 0);
- color.dispose();
// device == null (valid with alpha)
color = new Color(null, 0, 0, 0, 0);
- color.dispose();
// illegal argument, rgb < 0
assertThrows("No exception thrown for rgb < 0", IllegalArgumentException.class, () -> new Color(display, -10, -10, -10));
@@ -211,49 +202,40 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_gra
}
@Test
+@SuppressWarnings("unused")
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_graphics_RGB_with_device() {
// Test new Color(Device device, RGB rgb)
// IllegalArgumentException if the red, green or blue argument is not between 0 and 255; or rgb is null
// valid color (black)
Color color = new Color(display, new RGB(0, 0, 0));
- color.dispose();
// valid color (black with alpha)
color = new Color(display, new RGB(0, 0, 0), 0);
- color.dispose();
// valid color (white)
color = new Color(display, new RGB(255, 255, 255));
- color.dispose();
// valid color (white with alpha)
color = new Color(display, new RGB(255, 255, 255), 0);
- color.dispose();
// valid color (random grey)
color = new Color(display, new RGB(10, 10, 10));
- color.dispose();
// valid color (random grey with alpha)
color = new Color(display, new RGB(10, 10, 10), 0);
- color.dispose();
// valid color (random)
color = new Color(display, new RGB(102, 255, 0));
- color.dispose();
// valid color (random with alpha)
color = new Color(display, new RGB(102, 255, 0), 0);
- color.dispose();
// device == null (valid)
color = new Color(null, new RGB(0, 0, 0));
- color.dispose();
// device == null (valid with alpha)
color = new Color(null, new RGB(0, 0, 0), 0);
- color.dispose();
// illegal argument, rgb < 0
assertThrows("No exception thrown for rgb < 0", IllegalArgumentException.class, () -> new Color(display, new RGB(-10, -10, -10)));
@@ -324,49 +306,40 @@ public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_gra
}
@Test
+@SuppressWarnings("unused")
public void test_ConstructorLorg_eclipse_swt_graphics_DeviceLorg_eclipse_swt_graphics_RGBA_with_device() {
// Test new Color(Device device, RGBA rgba)
// IllegalArgumentException if the red, green, blue or alpha argument is not between 0 and 255; or rgba is null
// valid color (black)
Color color = new Color(display, new RGBA(0, 0, 0, 255));
- color.dispose();
// valid color (black with alpha)
color = new Color(display, new RGBA(0, 0, 0, 0));
- color.dispose();
// valid color (white)
color = new Color(display, new RGBA(255, 255, 255, 255));
- color.dispose();
// valid color (white with alpha)
color = new Color(display, new RGBA(255, 255, 255, 0));
- color.dispose();
// valid color (random grey)
color = new Color(display, new RGBA(10, 10, 10, 10));
- color.dispose();
// valid color (random grey with alpha)
color = new Color(display, new RGBA(10, 10, 10, 0));
- color.dispose();
// valid color (random)
color = new Color(display, new RGBA(102, 255, 0, 255));
- color.dispose();
// valid color (random with alpha)
color = new Color(display, new RGBA(102, 255, 0, 0));
- color.dispose();
// device == null (valid)
color = new Color(null, new RGBA(0, 0, 0, 255));
- color.dispose();
// device == null (valid with alpha)
color = new Color(null, new RGBA(0, 0, 0, 0));
- color.dispose();
// illegal argument, rgba < 0
assertThrows("No exception thrown for rgba < 0", IllegalArgumentException.class, () -> new Color(display, new RGBA(-10, -10, -10, -10)));
@@ -391,9 +364,7 @@ public void test_equalsLjava_lang_Object() {
Color sameColor2 = new Color(new RGB(1, 2, 3));
Color otherColor = new Color(5, 6, 7);
Color disposedColor = new Color(1, 2, 3);
- disposedColor.dispose();
Color disposedColor2 = new Color(5, 6, 7);
- disposedColor2.dispose();
// Test Color.equals(Object)
assertFalse("!color.equals((Object)null)", color.equals((Object)null));
@@ -433,44 +404,30 @@ public void test_equalsLjava_lang_Object_with_device() {
Color sameColor = new Color(display, 1, 2, 3);
Color sameColor2 = new Color(display, new RGB(1, 2, 3));
Color otherColor = new Color(display, 5, 6, 7);
- try {
- // Test Color.equals(Object)
- assertFalse("!color.equals((Object)null)", color.equals((Object)null));
-
- // Test Color.equals(Color)
- assertFalse("!color.equals((Color)null)", color.equals((Color)null));
- assertTrue("color.equals(color)", color.equals(color));
- assertTrue("color.equals(sameColor)", color.equals(sameColor));
- assertTrue("color.equals(sameColor2)", color.equals(sameColor2));
- assertFalse("!color.equals(otherColor)", color.equals(otherColor));
- } finally {
- color.dispose();
- sameColor.dispose();
- sameColor2.dispose();
- otherColor.dispose();
- }
+ // Test Color.equals(Object)
+ assertFalse("!color.equals((Object)null)", color.equals((Object)null));
+
+ // Test Color.equals(Color)
+ assertFalse("!color.equals((Color)null)", color.equals((Color)null));
+ assertTrue("color.equals(color)", color.equals(color));
+ assertTrue("color.equals(sameColor)", color.equals(sameColor));
+ assertTrue("color.equals(sameColor2)", color.equals(sameColor2));
+ assertFalse("!color.equals(otherColor)", color.equals(otherColor));
// With alpha
color = new Color(display, 1, 2, 3, 0);
sameColor = new Color(display, 1, 2, 3, 0);
sameColor2 = new Color(display, new RGB(1, 2, 3), 0);
otherColor = new Color(display, 5, 6, 7, 0);
- try {
- // Test Color.equals(Object)
- assertFalse("!color.equals((Object)null)", color.equals((Object)null));
-
- // Test Color.equals(Color)
- assertFalse("!color.equals((Color)null)", color.equals((Color)null));
- assertTrue("color.equals(color)", color.equals(color));
- assertTrue("color.equals(sameColor)", color.equals(sameColor));
- assertTrue("color.equals(sameColor2)", color.equals(sameColor2));
- assertFalse("!color.equals(otherColor)", color.equals(otherColor));
- } finally {
- color.dispose();
- sameColor.dispose();
- sameColor2.dispose();
- otherColor.dispose();
- }
+ // Test Color.equals(Object)
+ assertFalse("!color.equals((Object)null)", color.equals((Object)null));
+
+ // Test Color.equals(Color)
+ assertFalse("!color.equals((Color)null)", color.equals((Color)null));
+ assertTrue("color.equals(color)", color.equals(color));
+ assertTrue("color.equals(sameColor)", color.equals(sameColor));
+ assertTrue("color.equals(sameColor2)", color.equals(sameColor2));
+ assertFalse("!color.equals(otherColor)", color.equals(otherColor));
}
@Test
@@ -478,29 +435,21 @@ public void test_equalsLjava_lang_Object_mix() {
Color color = new Color(display, 1, 2, 3);
Color sameColorNoDevice = new Color(1, 2, 3);
Color otherColorNoDevice = new Color(5, 6, 7);
- try {
- // Test Color.equals(Color)
- assertTrue("color.equals(sameColor)", color.equals(sameColorNoDevice));
- assertFalse("!color.equals(otherColor)", color.equals(otherColorNoDevice));
- assertTrue("color.equals(sameColor)", sameColorNoDevice.equals(color));
- assertFalse("!color.equals(otherColor)", otherColorNoDevice.equals(color));
- } finally {
- color.dispose();
- }
+ // Test Color.equals(Color)
+ assertTrue("color.equals(sameColor)", color.equals(sameColorNoDevice));
+ assertFalse("!color.equals(otherColor)", color.equals(otherColorNoDevice));
+ assertTrue("color.equals(sameColor)", sameColorNoDevice.equals(color));
+ assertFalse("!color.equals(otherColor)", otherColorNoDevice.equals(color));
// With alpha
color = new Color(display, 1, 2, 3, 0);
sameColorNoDevice = new Color(1, 2, 3, 0);
otherColorNoDevice = new Color(5, 6, 7, 0);
- try {
- // Test Color.equals(Color)
- assertTrue("color.equals(sameColor)", color.equals(sameColorNoDevice));
- assertFalse("!color.equals(otherColor)", color.equals(otherColorNoDevice));
- assertTrue("color.equals(sameColor)", sameColorNoDevice.equals(color));
- assertFalse("!color.equals(otherColor)", otherColorNoDevice.equals(color));
- } finally {
- color.dispose();
- }
+ // Test Color.equals(Color)
+ assertTrue("color.equals(sameColor)", color.equals(sameColorNoDevice));
+ assertFalse("!color.equals(otherColor)", color.equals(otherColorNoDevice));
+ assertTrue("color.equals(sameColor)", sameColorNoDevice.equals(color));
+ assertFalse("!color.equals(otherColor)", otherColorNoDevice.equals(color));
}
@Test
@@ -514,12 +463,7 @@ public void test_getBlue() {
public void test_getBlue_with_device() {
// Test Color.getBlue()
Color color = new Color(display, 0, 0, 255);
- try {
- assertEquals("color.getBlue()", color.getBlue(), 255);
- } finally {
- color.dispose();
- }
-
+ assertEquals("color.getBlue()", color.getBlue(), 255);
}
@Test
@@ -533,11 +477,7 @@ public void test_getGreen() {
public void test_getGreen_with_device() {
// Test Color.getGreen()
Color color = new Color(display, 0, 255, 0);
- try {
- assertEquals("color.getGreen()", color.getGreen(), 255);
- } finally {
- color.dispose();
- }
+ assertEquals("color.getGreen()", color.getGreen(), 255);
}
@Test
@@ -552,7 +492,6 @@ public void test_getRGB_with_device() {
Color color = new Color(display, 255, 255, 255);
assertNotNull(color.getRGB());
assertEquals(new RGB(255, 255, 255), color.getRGB());
- color.dispose();
}
@Test
@@ -566,11 +505,7 @@ public void test_getRed() {
public void test_getRed_with_device() {
// Test Color.getRed()
Color color = new Color(display, 255, 0, 0);
- try {
- assertEquals("color.getRed()", color.getRed(), 255);
- } finally {
- color.dispose();
- }
+ assertEquals("color.getRed()", color.getRed(), 255);
}
@Test
@@ -584,11 +519,7 @@ public void test_getAlpha() {
public void test_getAlpha_with_device() {
// Test Color.getRed()
Color color = new Color(display, 255, 0, 0, 0);
- try {
- assertEquals("color.getAlpha()", color.getAlpha(), 0);
- } finally {
- color.dispose();
- }
+ assertEquals("color.getAlpha()", color.getAlpha(), 0);
}
@Test
@@ -607,8 +538,6 @@ public void test_hashCode_with_device() {
if (color.equals(otherColor)) {
assertEquals("Hash codes of equal objects should be equal", color.hashCode(), otherColor.hashCode());
}
- color.dispose();
- otherColor.dispose();
}
/**
@@ -646,13 +575,9 @@ public void test_toString() {
@Test
public void test_toString_with_device() {
Color color = new Color(display, 0, 0, 255, 255);
- try {
- assertNotNull(color.toString());
- assertFalse(color.toString().isEmpty());
- assertEquals("Color {0, 0, 255, 255}", color.toString());
- } finally {
- color.dispose();
- }
+ assertNotNull(color.toString());
+ assertFalse(color.toString().isEmpty());
+ assertEquals("Color {0, 0, 255, 255}", color.toString());
}
@Test
@@ -674,11 +599,7 @@ public void test_getDevice() {
@Test
public void test_getDevice_with_device() {
Color color = new Color(display, 0, 0, 255, 255);
- try {
- assertEquals("Color should return device as constructed", display, color.getDevice());
- } finally {
- color.dispose();
- }
+ assertEquals("Color should return device as constructed", display, color.getDevice());
SWTException e = assertThrows("No exception thrown for getDevice on disposed Color", SWTException.class, () -> {
Color color1 = new Color(0, 0, 255, 255);
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 b1711875fb..0246b425d3 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
@@ -250,9 +250,6 @@ public void test_drawImageLorg_eclipse_swt_graphics_ImageII() {
image.dispose();
imageTransparent.dispose();
imageAlpha.dispose();
- c1.dispose();
- c2.dispose();
- c3.dispose();
}
@Test
@@ -294,9 +291,6 @@ public void test_drawImageLorg_eclipse_swt_graphics_ImageIIIIIIII() {
image.dispose();
imageAlpha.dispose();
imageTransparent.dispose();
- c1.dispose();
- c2.dispose();
- c3.dispose();
}
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java
index e5f387ddae..e0d35c60fb 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Button.java
@@ -191,7 +191,6 @@ public void test_setBackgroundCheckButton() {
checkButton.setBackground(null);
assertTrue("getBackground unchanged after setBackground(null) for SWT.CHECK Button",
!checkButton.getBackground().equals(color));
- color.dispose();
color = new Color(255, 0, 0, 0);
checkButton.setBackground(color);
assertEquals("getBackground not equal after setBackground with 0 alpha for SWT.CHECK Button",
@@ -207,9 +206,7 @@ public void test_setBackgroundCheckButton() {
color, checkButton.getBackground());
assertEquals("Setting a foreground onto an SWT.CHECK Button with a background failed",
fg, checkButton.getForeground());
- fg.dispose();
}
- color.dispose();
checkButton.dispose();
}
@@ -222,8 +219,6 @@ public void test_setBackgroundAlphaCheckButton() {
Color fg = new Color(0, 255, 0, 0);
checkButton.setForeground(fg);
assertEquals(color, checkButton.getBackground());
- color.dispose();
- fg.dispose();
checkButton.dispose();
}
@@ -237,7 +232,6 @@ public void test_setBackgroundRadioButton() {
radioButton.setBackground(null);
assertFalse("getBackground unchanged after setBackground(null) for SWT.RADIO Button",
radioButton.getBackground().equals(color));
- color.dispose();
color = new Color(255, 0, 0, 0);
radioButton.setBackground(color);
assertEquals("getBackground not equal after setBackground with 0 alpha for SWT.RADIO Button",
@@ -253,9 +247,7 @@ public void test_setBackgroundRadioButton() {
color, radioButton.getBackground());
assertEquals("Setting a foreground onto an SWT.RADIO Button with a background failed",
fg, radioButton.getForeground());
- fg.dispose();
}
- color.dispose();
radioButton.dispose();
}
@@ -268,8 +260,6 @@ public void test_setBackgroundAlphaRadioButton() {
Color fg = new Color(0, 255, 0, 0);
radioButton.setForeground(fg);
assertEquals(color, radioButton.getBackground());
- color.dispose();
- fg.dispose();
radioButton.dispose();
}
@@ -296,10 +286,8 @@ public void test_setForegroundCheckButton() {
color, checkButton.getForeground());
assertEquals("Setting a background onto an SWT.CHECK Button with a foreground failed",
bg, checkButton.getBackground());
- bg.dispose();
}
- color.dispose();
- checkButton.dispose();
+ checkButton.dispose();
}
@Test
@@ -313,8 +301,6 @@ public void test_setForegroundAlphaCheckButton() {
Color bg = new Color(0, 255, 0, 0);
checkButton.setBackground(bg);
assertEquals(color, checkButton.getForeground());
- color.dispose();
- bg.dispose();
checkButton.dispose();
}
@@ -334,9 +320,7 @@ public void test_setForegroundRadioButton() {
color, radioButton.getForeground());
assertEquals("Setting a background onto an SWT.RADIO Button with a foreground failed",
bg, radioButton.getBackground());
- bg.dispose();
}
- color.dispose();
radioButton.dispose();
}
@@ -351,8 +335,6 @@ public void test_setForegroundAlphaRadiokButton() {
Color bg = new Color(0, 255, 0, 0);
radioButton.setBackground(bg);
assertEquals(color, radioButton.getForeground());
- color.dispose();
- bg.dispose();
radioButton.dispose();
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
index 652c434bf7..b540ceb1c4 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
@@ -613,7 +613,6 @@ public void test_setBackgroundLorg_eclipse_swt_graphics_Color() {
assertEquals("getBackground not equal color after setBackground(color) for " + control, color, control.getBackground());
control.setBackground(null);
assertTrue("getBackground unchanged after setBackground(null) for " + control, !control.getBackground().equals(color));
- color.dispose();
color = new Color(255, 0, 0, 0);
control.setBackground(color);
assertEquals("getBackground not equal color after setBackground(color) with 0 alpha for " + control + " " + control.getBackground(), color, control.getBackground());
@@ -628,7 +627,6 @@ public void test_setBackgroundLorg_eclipse_swt_graphics_Color() {
assertEquals("Setting a foreground onto a widget with a background failed for " + control,
fg, control.getForeground());
}
- color.dispose();
}
@Test
public void test_setBackgroundAlphaLorg_eclipse_swt_graphics_Color() {
@@ -638,8 +636,6 @@ public void test_setBackgroundAlphaLorg_eclipse_swt_graphics_Color() {
Color fg = new Color(0, 255, 0, 0);
control.setForeground(fg);
assertEquals(color, control.getBackground());
- color.dispose();
- fg.dispose();
}
@Test
public void test_setBackgroundDisposedColorLorg_eclipse_swt_graphics_Color() {
@@ -763,7 +759,6 @@ public void test_setForegroundLorg_eclipse_swt_graphics_Color() {
assertEquals("Setting a background onto a widget with a foreground failed for " + control,
bg, control.getBackground());
}
- color.dispose();
}
@Test
public void test_setForegroundAlphaLorg_eclipse_swt_graphics_Color() {
@@ -775,8 +770,6 @@ public void test_setForegroundAlphaLorg_eclipse_swt_graphics_Color() {
Color bg = new Color(0, 255, 0, 0);
control.setBackground(bg);
assertEquals(color, control.getForeground());
- color.dispose();
- bg.dispose();
}
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_DateTime.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_DateTime.java
index 0605b00e76..c02db49a44 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_DateTime.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_DateTime.java
@@ -221,8 +221,6 @@ public void test_setBackgroundAlphaTimeDateTime() {
Color fg = new Color(0, 255, 0, 0);
time.setForeground(fg);
assertEquals(color, time.getBackground());
- color.dispose();
- fg.dispose();
time.dispose();
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Link.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Link.java
index 0c567b58a5..ef7a6240f1 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Link.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Link.java
@@ -181,6 +181,5 @@ public void test_setLinkForegroundLorg_eclipse_swt_graphics_Color() {
assertEquals(color, link.getLinkForeground());
link.setLinkForeground(null);
assertFalse(link.getForeground().equals(color));
- color.dispose();
}
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java
index f7c34e922c..659d503c4d 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java
@@ -1407,7 +1407,6 @@ public void test_setHeaderBackgroundLorg_eclipse_swt_graphics_Color() {
assertEquals(color, table.getHeaderBackground());
table.setHeaderBackground(null);
assertFalse(table.getHeaderBackground().equals(color));
- color.dispose();
}
@Test
@@ -1418,7 +1417,6 @@ public void test_setHeaderForegroundLorg_eclipse_swt_graphics_Color() {
assertEquals(color, table.getHeaderForeground());
table.setHeaderForeground(null);
assertFalse(table.getHeaderForeground().equals(color));
- color.dispose();
}
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
index 917900106d..f077dc3e82 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
@@ -380,7 +380,6 @@ public void test_setHeaderBackgroundLorg_eclipse_swt_graphics_Color() {
assertEquals(color, tree.getHeaderBackground());
tree.setHeaderBackground(null);
assertFalse(tree.getHeaderBackground().equals(color));
- color.dispose();
}
@Test
@@ -391,7 +390,6 @@ public void test_setHeaderForegroundLorg_eclipse_swt_graphics_Color() {
assertEquals(color, tree.getHeaderForeground());
tree.setHeaderForeground(null);
assertFalse(tree.getHeaderForeground().equals(color));
- color.dispose();
}
@Test
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/performance/Test_situational.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/performance/Test_situational.java
index 0ff14c88d0..8a53c40eff 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/performance/Test_situational.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/performance/Test_situational.java
@@ -245,8 +245,6 @@ public void test_imageDrawing() {
gc.dispose();
meter.stop();
image.dispose();
- color1.dispose();
- color2.dispose();
while(display.readAndDispatch()){/*empty*/}
}
disposeMeter(meter);
@@ -296,8 +294,6 @@ public void test_windowDrawing() {
gc.dispose();
meter.stop();
shell.dispose();
- color1.dispose();
- color2.dispose();
while(display.readAndDispatch()){/*empty*/}
}
disposeMeter(meter);
@@ -343,8 +339,6 @@ public void test_stringDrawing() {
gc.dispose();
meter.stop();
shell.dispose();
- color1.dispose();
- color2.dispose();
font1.dispose();
font2.dispose();
while(display.readAndDispatch()){/*empty*/}
@@ -391,8 +385,6 @@ public void test_fastStringDrawing() {
gc.dispose();
meter.stop();
shell.dispose();
- color1.dispose();
- color2.dispose();
font1.dispose();
font2.dispose();
while(display.readAndDispatch()){/*empty*/}

Back to the top