Skip to content

Commit 72ec5a4

Browse files
committed
[test] TestLabelProvider: reduce font not disposed warnings
to a single "SWT Resource was not properly disposed" during LabelProviderTest (and fixed the font to be not bold)
1 parent b85d17e commit 72ec5a4

File tree

9 files changed

+4
-19
lines changed

9 files changed

+4
-19
lines changed

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/NavigatorTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ protected void checkItems(TreeItem[] rootItems, TestLabelProvider tlp, boolean a
402402
}
403403
assertEquals(tlp.backgroundColor, rootItem.getBackground(0));
404404
assertEquals(TestLabelProvider.toForegroundColor(tlp.backgroundColor), rootItem.getForeground(0));
405-
assertEquals(tlp.font, rootItem.getFont(0));
405+
assertEquals(TestLabelProvider.font, rootItem.getFont(0));
406406
assertEquals(tlp.image, rootItem.getImage(0));
407407
if (all) {
408408
checkItems(rootItem.getItems(), tlp, all, text);

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProvider.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class TestLabelProvider extends LabelProvider implements
4242

4343
public Image image;
4444

45-
public Font font;
45+
public static final Font font = new Font(Display.getDefault(), new FontData());
4646

4747
private Font boldFont;
4848

@@ -170,9 +170,8 @@ public void dispose() {
170170
_runnable.run();
171171
boldFont.dispose();
172172
boldFont = null;
173-
174-
// font.dispose();
175-
// font = null;
173+
// font can not disposed here because the TestLabelProviders are used by its
174+
// static instances
176175
}
177176

178177
}

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderBlank.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -32,7 +31,6 @@ public class TestLabelProviderBlank extends TestStyledLabelProvider {
3231
protected void initSubclass() {
3332
backgroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
3433
backgroundColorName = "Red";
35-
font = new Font(Display.getDefault(), boldFontData);
3634
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3735
ISharedImages.IMG_OBJ_ADD);
3836
instance = this;

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderBlue.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -32,7 +31,6 @@ protected void initSubclass() {
3231
backgroundColor = Display.getCurrent().getSystemColor(
3332
SWT.COLOR_BLUE);
3433
backgroundColorName = "Blue";
35-
font = new Font(Display.getDefault(), boldFontData);
3634
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3735
ISharedImages.IMG_ETOOL_SAVE_EDIT);
3836
instance = this;

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderCyan.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -32,7 +31,6 @@ protected void initSubclass() {
3231
backgroundColor = Display.getCurrent().getSystemColor(
3332
SWT.COLOR_CYAN);
3433
backgroundColorName = "Cyan";
35-
font = new Font(Display.getDefault(), boldFontData);
3634
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3735
ISharedImages.IMG_DEF_VIEW);
3836
instance = this;

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderPlainGreen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -31,7 +30,6 @@ protected void initSubclass() {
3130
backgroundColor = Display.getCurrent().getSystemColor(
3231
SWT.COLOR_GREEN);
3332
backgroundColorName = "Green";
34-
font = new Font(Display.getDefault(), boldFontData);
3533
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3634
ISharedImages.IMG_ELCL_COLLAPSEALL);
3735
instance = this;

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderPlainRed.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -31,7 +30,6 @@ protected void initSubclass() {
3130
backgroundColor = Display.getCurrent().getSystemColor(
3231
SWT.COLOR_RED);
3332
backgroundColorName = "Red";
34-
font = new Font(Display.getDefault(), boldFontData);
3533
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3634
ISharedImages.IMG_ELCL_REMOVE);
3735
instance = this;

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderStyledGreen.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -31,7 +30,6 @@ protected void initSubclass() {
3130
backgroundColor = Display.getCurrent().getSystemColor(
3231
SWT.COLOR_GREEN);
3332
backgroundColorName = "Green";
34-
font = new Font(Display.getDefault(), boldFontData);
3533
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3634
ISharedImages.IMG_ELCL_COLLAPSEALL);
3735
instance = this;

tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/extension/TestLabelProviderStyledRed.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.eclipse.ui.tests.navigator.extension;
1616

1717
import org.eclipse.swt.SWT;
18-
import org.eclipse.swt.graphics.Font;
1918
import org.eclipse.swt.widgets.Display;
2019
import org.eclipse.ui.ISharedImages;
2120
import org.eclipse.ui.PlatformUI;
@@ -31,7 +30,6 @@ protected void initSubclass() {
3130
backgroundColor = Display.getCurrent().getSystemColor(
3231
SWT.COLOR_RED);
3332
backgroundColorName = "Red";
34-
font = new Font(Display.getDefault(), boldFontData);
3533
image = PlatformUI.getWorkbench().getSharedImages().getImage(
3634
ISharedImages.IMG_ELCL_REMOVE);
3735
instance = this;

0 commit comments

Comments
 (0)