Skip to content

Refactor Image(Display, int, int) in Tests #3024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jface.tests.databinding
Bundle-Version: 1.12.600.qualifier
Bundle-Version: 1.12.700.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.databinding;bundle-version="[1.3.0,2.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static String takeScreenshot(Class<?> testClass, String name, PrintStream
GC gc = new GC(display);
Rectangle displayBounds= display.getBounds();
out.println("Display @ " + displayBounds);
final Image image = new Image(display, displayBounds.width, displayBounds.height);
final Image image = new Image(display, (iGc, width, height) -> {}, displayBounds.width, displayBounds.height);
gc.copyArea(image, 0, 0);
gc.dispose();

Expand Down
2 changes: 1 addition & 1 deletion tests/org.eclipse.jface.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.jface.tests
Bundle-Version: 1.4.900.qualifier
Bundle-Version: 1.4.1000.qualifier
Automatic-Module-Name: org.eclipse.jface.tests
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.junit;bundle-version="4.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class LabelProviderTest {

private static final Car HORCH = new Car("Horch");

private static Image horchImage = new Image(Display.getDefault(), 50, 10);
private static Image defaultImage = new Image(Display.getDefault(), 1, 1);
private static Image horchImage = new Image(Display.getDefault(), (gc, width, height) -> {}, 50, 10);
private static Image defaultImage = new Image(Display.getDefault(), (gc, width, height) -> {}, 1, 1);

private final Function<Object, String> textFunction = o -> o instanceof Car ? ((Car) o).getMake() : "unknown";
private final Function<Object, Image> imageFunction = o -> o instanceof Car ? horchImage : defaultImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.jface.tests.widgets;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageGcDrawer;
import org.eclipse.swt.widgets.Shell;
import org.junit.After;
import org.junit.AfterClass;
Expand All @@ -26,7 +27,8 @@ public class AbstractFactoryTest {

@BeforeClass
public static void classSetup() {
image = new Image(null, 1, 1);
final ImageGcDrawer noOp = (gc, width, height) -> {};
image = new Image(null, noOp, 1, 1);
}

@Before
Expand Down
2 changes: 1 addition & 1 deletion tests/org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jface.text.tests
Bundle-Version: 3.13.900.qualifier
Bundle-Version: 3.13.1000.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private static boolean hasCodeMiningPrintedBelowLine(ITextViewer viewer, int lin
starty= lineBounds.y;
}

Image image= new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
Image image= new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
try {
GC gc= new GC(widget);
gc.copyArea(image, 0, 0);
Expand Down Expand Up @@ -555,7 +555,7 @@ private static boolean hasCodeMiningPrintedAfterTextOnLine(ITextViewer viewer, i
} else {
secondLineBounds= widget.getTextBounds(lineOffset, lineOffset + lineLength);
}
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
GC gc = new GC(widget);
gc.copyArea(image, 0, 0);
gc.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected boolean condition() {
}

public int getMostRightPaintedPixel(StyledText widget) {
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
GC gc = new GC(widget);
gc.copyArea(image, 0, 0);
gc.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private static boolean existsPixelWithNonBackgroundColorAtLine(ITextViewer viewe
int lineOffset = document.getLineOffset(line);
Rectangle lineBounds = widget.getTextBounds(lineOffset, lineOffset + lineLength);
String lineStr = document.get(lineOffset, lineLength);
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
try {
GC gc = new GC(widget);
gc.copyArea(image, 0, 0);
Expand Down Expand Up @@ -306,7 +306,7 @@ private static boolean existsPixelWithNonBackgroundColorAtEndOfLine(ITextViewer
String lineStr = document.get(lineOffset,
document.getLineLength(line) - document.getLineDelimiter(line).length());
Rectangle lineBounds = widget.getTextBounds(lineOffset, lineOffset);
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
try {
GC gc = new GC(widget);
gc.copyArea(image, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion tests/org.eclipse.ui.tests.forms/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Forms Test
Bundle-SymbolicName: org.eclipse.ui.tests.forms;singleton:=true
Bundle-Version: 3.10.400.qualifier
Bundle-Version: 3.10.500.qualifier
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.test.performance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void testToolkitColors() throws Exception {
@Test
public void testDisposeUnknown() throws Exception {
Display display = Display.getCurrent();
Image image = new Image(display, 10, 10);
Image image = new Image(display, (gc, width, height) -> {}, 10, 10);
getFormImagesInstance().markFinished(image, display);
assertTrue("markFinished(...) did not dispose of an unknown image", image.isDisposed());
assertNull("descriptors map", getDescriptors(getFormImagesInstance()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.workbench.texteditor.tests
Bundle-Version: 3.14.800.qualifier
Bundle-Version: 3.14.900.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static String takeScreenshot(Class<?> testClass, String name, PrintStream
GC gc = new GC(display);
Rectangle displayBounds= display.getBounds();
out.println("Display @ " + displayBounds);
final Image image= new Image(display, displayBounds.width, displayBounds.height);
final Image image= new Image(display, (iGc, width, height) -> {}, displayBounds.width, displayBounds.height);
gc.copyArea(image, 0, 0);
gc.dispose();

Expand Down
Loading