Skip to content

Commit 5631d60

Browse files
ShahzaibIbrahimfedejeanne
authored andcommitted
Refactor Image(Display, int, int) in Tests
Replacing Image(Display, int, int) with Image(Display, ImageGcDrawer, int, int) in Tests
1 parent 1d70552 commit 5631d60

File tree

8 files changed

+13
-11
lines changed

8 files changed

+13
-11
lines changed

tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/swt/Screenshots.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static String takeScreenshot(Class<?> testClass, String name, PrintStream
8989
GC gc = new GC(display);
9090
Rectangle displayBounds= display.getBounds();
9191
out.println("Display @ " + displayBounds);
92-
final Image image = new Image(display, displayBounds.width, displayBounds.height);
92+
final Image image = new Image(display, (iGc, width, height) -> {}, displayBounds.width, displayBounds.height);
9393
gc.copyArea(image, 0, 0);
9494
gc.dispose();
9595

tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/labelProviders/LabelProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class LabelProviderTest {
1515

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

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

2121
private final Function<Object, String> textFunction = o -> o instanceof Car ? ((Car) o).getMake() : "unknown";
2222
private final Function<Object, Image> imageFunction = o -> o instanceof Car ? horchImage : defaultImage;

tests/org.eclipse.jface.tests/src/org/eclipse/jface/tests/widgets/AbstractFactoryTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.eclipse.jface.tests.widgets;
1515

1616
import org.eclipse.swt.graphics.Image;
17+
import org.eclipse.swt.graphics.ImageGcDrawer;
1718
import org.eclipse.swt.widgets.Shell;
1819
import org.junit.After;
1920
import org.junit.AfterClass;
@@ -26,7 +27,8 @@ public class AbstractFactoryTest {
2627

2728
@BeforeClass
2829
public static void classSetup() {
29-
image = new Image(null, 1, 1);
30+
final ImageGcDrawer noOp = (gc, width, height) -> {};
31+
image = new Image(null, noOp, 1, 1);
3032
}
3133

3234
@Before

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ private static boolean hasCodeMiningPrintedBelowLine(ITextViewer viewer, int lin
515515
starty= lineBounds.y;
516516
}
517517

518-
Image image= new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
518+
Image image= new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
519519
try {
520520
GC gc= new GC(widget);
521521
gc.copyArea(image, 0, 0);
@@ -555,7 +555,7 @@ private static boolean hasCodeMiningPrintedAfterTextOnLine(ITextViewer viewer, i
555555
} else {
556556
secondLineBounds= widget.getTextBounds(lineOffset, lineOffset + lineLength);
557557
}
558-
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
558+
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
559559
GC gc = new GC(widget);
560560
gc.copyArea(image, 0, 0);
561561
gc.dispose();

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/source/inlined/LineContentBoundsDrawingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected boolean condition() {
148148
}
149149

150150
public int getMostRightPaintedPixel(StyledText widget) {
151-
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
151+
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
152152
GC gc = new GC(widget);
153153
gc.copyArea(image, 0, 0);
154154
gc.dispose();

tests/org.eclipse.ui.editors.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private static boolean existsPixelWithNonBackgroundColorAtLine(ITextViewer viewe
273273
int lineOffset = document.getLineOffset(line);
274274
Rectangle lineBounds = widget.getTextBounds(lineOffset, lineOffset + lineLength);
275275
String lineStr = document.get(lineOffset, lineLength);
276-
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
276+
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
277277
try {
278278
GC gc = new GC(widget);
279279
gc.copyArea(image, 0, 0);
@@ -306,7 +306,7 @@ private static boolean existsPixelWithNonBackgroundColorAtEndOfLine(ITextViewer
306306
String lineStr = document.get(lineOffset,
307307
document.getLineLength(line) - document.getLineDelimiter(line).length());
308308
Rectangle lineBounds = widget.getTextBounds(lineOffset, lineOffset);
309-
Image image = new Image(widget.getDisplay(), widget.getSize().x, widget.getSize().y);
309+
Image image = new Image(widget.getDisplay(), (gc, width, height) -> {}, widget.getSize().x, widget.getSize().y);
310310
try {
311311
GC gc = new GC(widget);
312312
gc.copyArea(image, 0, 0);

tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/util/FormImagesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public void testToolkitColors() throws Exception {
281281
@Test
282282
public void testDisposeUnknown() throws Exception {
283283
Display display = Display.getCurrent();
284-
Image image = new Image(display, 10, 10);
284+
Image image = new Image(display, (gc, width, height) -> {}, 10, 10);
285285
getFormImagesInstance().markFinished(image, display);
286286
assertTrue("markFinished(...) did not dispose of an unknown image", image.isDisposed());
287287
assertNull("descriptors map", getDescriptors(getFormImagesInstance()));

tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/ScreenshotTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static String takeScreenshot(Class<?> testClass, String name, PrintStream
117117
GC gc = new GC(display);
118118
Rectangle displayBounds= display.getBounds();
119119
out.println("Display @ " + displayBounds);
120-
final Image image= new Image(display, displayBounds.width, displayBounds.height);
120+
final Image image= new Image(display, (iGc, width, height) -> {}, displayBounds.width, displayBounds.height);
121121
gc.copyArea(image, 0, 0);
122122
gc.dispose();
123123

0 commit comments

Comments
 (0)