Skip to content

Commit

Permalink
[test] TestLabelProvider: reduce font not disposed warnings
Browse files Browse the repository at this point in the history
to a single "SWT Resource was not properly disposed"
during LabelProviderTest

(and fixed the font to be not bold)
  • Loading branch information
EcljpseB0T authored and jukzi committed Oct 9, 2024
1 parent b85d17e commit 72ec5a4
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ protected void checkItems(TreeItem[] rootItems, TestLabelProvider tlp, boolean a
}
assertEquals(tlp.backgroundColor, rootItem.getBackground(0));
assertEquals(TestLabelProvider.toForegroundColor(tlp.backgroundColor), rootItem.getForeground(0));
assertEquals(tlp.font, rootItem.getFont(0));
assertEquals(TestLabelProvider.font, rootItem.getFont(0));
assertEquals(tlp.image, rootItem.getImage(0));
if (all) {
checkItems(rootItem.getItems(), tlp, all, text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class TestLabelProvider extends LabelProvider implements

public Image image;

public Font font;
public static final Font font = new Font(Display.getDefault(), new FontData());

private Font boldFont;

Expand Down Expand Up @@ -170,9 +170,8 @@ public void dispose() {
_runnable.run();
boldFont.dispose();
boldFont = null;

// font.dispose();
// font = null;
// font can not disposed here because the TestLabelProviders are used by its
// static instances
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -32,7 +31,6 @@ public class TestLabelProviderBlank extends TestStyledLabelProvider {
protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
backgroundColorName = "Red";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_OBJ_ADD);
instance = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -32,7 +31,6 @@ protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(
SWT.COLOR_BLUE);
backgroundColorName = "Blue";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_ETOOL_SAVE_EDIT);
instance = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -32,7 +31,6 @@ protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(
SWT.COLOR_CYAN);
backgroundColorName = "Cyan";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_DEF_VIEW);
instance = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -31,7 +30,6 @@ protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(
SWT.COLOR_GREEN);
backgroundColorName = "Green";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_ELCL_COLLAPSEALL);
instance = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -31,7 +30,6 @@ protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(
SWT.COLOR_RED);
backgroundColorName = "Red";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_ELCL_REMOVE);
instance = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -31,7 +30,6 @@ protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(
SWT.COLOR_GREEN);
backgroundColorName = "Green";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_ELCL_COLLAPSEALL);
instance = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.ui.tests.navigator.extension;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
Expand All @@ -31,7 +30,6 @@ protected void initSubclass() {
backgroundColor = Display.getCurrent().getSystemColor(
SWT.COLOR_RED);
backgroundColorName = "Red";
font = new Font(Display.getDefault(), boldFontData);
image = PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_ELCL_REMOVE);
instance = this;
Expand Down

0 comments on commit 72ec5a4

Please sign in to comment.