diff options
author | Simeon Andreev | 2018-11-05 17:34:51 +0000 |
---|---|---|
committer | Simeon Andreev | 2018-11-05 18:36:15 +0000 |
commit | 4d89403a72c43b535e3cee44a63a52ac58799144 (patch) | |
tree | 95e6e813065dc891367168df1212373399019cc7 /tests | |
parent | 6ebcb89907ca02f035b4773c6409ad79aabc4b72 (diff) | |
download | eclipse.platform.swt-4d89403a72c43b535e3cee44a63a52ac58799144.tar.gz eclipse.platform.swt-4d89403a72c43b535e3cee44a63a52ac58799144.tar.xz eclipse.platform.swt-4d89403a72c43b535e3cee44a63a52ac58799144.zip |
Bug 540789 - Control.setForeground(Color) accepts disposed color
Among other code, the commits for bug 530841 removed checks from
Control.setForeground(Color) and Control.setBackground(Color) which
validate against a disposed color argument.
As a result, passing a disposed color object to those methods causes the
widget to use the default foreground resp. background color. This is
sub-optimal API behavior.
This change re-adds the missing dispose checks.
Change-Id: I4e4b76f09560dcd4d87b4eb2d79853a02b484369
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java | 22 |
1 files changed, 22 insertions, 0 deletions
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 1c9064983f..ecc6ef3e91 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 @@ -630,6 +630,17 @@ public void test_setBackgroundAlphaLorg_eclipse_swt_graphics_Color() { fg.dispose(); } @Test +public void test_setBackgroundDisposedColorLorg_eclipse_swt_graphics_Color() { + Color color = new Color(control.getDisplay(), 255, 0, 0); + color.dispose(); + try { + control.setBackground(color); + fail("setting a disposed color object with Control.setBackground(Color) should throw an exception"); + } catch (IllegalArgumentException e) { + // expected, since the color is disposed + } +} +@Test public void test_setBoundsIIII() { control.setBounds(10, 20, 30, 40); assertEquals(new Rectangle(10, 20, 30, 40), control.getBounds()); @@ -757,6 +768,17 @@ public void test_setForegroundAlphaLorg_eclipse_swt_graphics_Color() { } @Test +public void test_setForegroundDisposedColorLorg_eclipse_swt_graphics_Color() { + Color color = new Color(control.getDisplay(), 255, 0, 0); + color.dispose(); + try { + control.setForeground(color); + fail("setting a disposed color object with Control.setForeground(Color) should throw an exception"); + } catch (IllegalArgumentException e) { + // expected, since the color is disposed + } +} +@Test public void test_setLayoutDataLjava_lang_Object() { control.setLayoutData(this); assertEquals(this, control.getLayoutData()); |