Skip to content
Merged
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 @@ -18,8 +18,8 @@
import java.util.List;

import org.eclipse.swt.graphics.Resource;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.platform.suite.api.AfterSuite;
import org.junit.platform.suite.api.BeforeSuite;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

Expand Down Expand Up @@ -79,8 +79,8 @@
public class AllNonBrowserTests {
private static List<Error> leakedResources;

@BeforeAll
public static void beforeClass() {
@BeforeSuite
public static void beforeSuite() {
// Set up ResourceTracked to detect any leaks
leakedResources = new ArrayList<> ();
Resource.setNonDisposeHandler (error -> {
Expand All @@ -93,11 +93,11 @@ public static void beforeClass() {

/*
* It would be easier to understand if errors here were reported
* through a test and not through @AfterClass, but this is a
* through a test and not through @AfterSuite, but this is a
* suite class and not a test class, so it can't have tests.
*/
@AfterAll
public static void afterClass() {
@AfterSuite
public static void afterSuite() {
// Run GC in order do detect any outstanding leaks
System.gc ();
// And wait a bit to let Resource.ResourceTracker, that is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ public void test_Validate() throws Exception {
assertEquals(0, imageDataComparator().compare(imageData, getContents()));

assertThrows(IllegalArgumentException.class, () -> setContents(""));
assertThrows(IllegalArgumentException.class, () -> setContents(new Image(display, imageData)));
Image image = new Image(display, imageData);
try {
// verify that ImageTransfer rejects actual images, as ImageData is required
assertThrows(IllegalArgumentException.class, () -> setContents(image));
} finally {
image.dispose();
}
assertThrows(IllegalArgumentException.class, () -> setContents(new Object()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,16 +1028,20 @@ public void test_bug1288_createGCFromImageFromNonDisplayThread() throws Interrup
public void test_noMemoryLeakAfterDispose() {
GC testGC = new GC(display);
Image image = new Image(display, 1, 1);
testGC.setFont(display.getSystemFont());
testGC.setClipping(new Rectangle(0, 0, 2, 2));
testGC.drawImage(image, 0, 0);
testGC.drawText("Test", 0, 0);
testGC.drawLine(0, 0, 5, 5);
WeakReference<GC> testGCReference = new WeakReference<>(testGC);
testGC.dispose();
testGC = null;
System.gc();
assertNull(testGCReference.get());
try {
testGC.setFont(display.getSystemFont());
testGC.setClipping(new Rectangle(0, 0, 2, 2));
testGC.drawImage(image, 0, 0);
testGC.drawText("Test", 0, 0);
testGC.drawLine(0, 0, 5, 5);
WeakReference<GC> testGCReference = new WeakReference<>(testGC);
testGC.dispose();
testGC = null;
System.gc();
assertNull(testGCReference.get());
} finally {
image.dispose();
}
}

/* custom */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,15 @@ public void test_imageDataIsCached() {
return imagePath;
};
Image fileNameProviderImage = new Image(display, imageFileNameProvider);
callCount.set(0);
fileNameProviderImage.getImageData(100);
fileNameProviderImage.getImageData(100);
fileNameProviderImage.getImageData(100);
assertEquals(0, callCount.get());
try {
callCount.set(0);
fileNameProviderImage.getImageData(100);
fileNameProviderImage.getImageData(100);
fileNameProviderImage.getImageData(100);
assertEquals(0, callCount.get());
} finally {
fileNameProviderImage.dispose();
}
}

@Test
Expand Down
Loading