You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Win32] Ensure consistent image data returned for filename/data provider
Due to the on-demand creation of image handles, there is not necessarily
a handles anymore from which image data is retrieved when requesting is
via the getImageData(...) methods. This results in potentially different
kinds of image data (including different anti-aliasing results)
depending on whether a handle has already been created for an image at
the given zoom or not.
This change adapts the Image implementation for ImageDataProvider and
ImageFileNameProvider to always use the image data retrieved from a
native handle. To this end, it temporarily creates a handle if
necessary. In order to avoid repeated loading and handle creation for
the same source of image, a cache for the already retrieved image data
is introduced. For both the consistent retrieval of image data and the
avoidance of repeated loading of image data according test cases are
added.
Copy file name to clipboardExpand all lines: tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_Image.java
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,13 +20,19 @@
20
20
importstaticorg.junit.Assert.assertFalse;
21
21
importstaticorg.junit.Assert.assertNotNull;
22
22
importstaticorg.junit.Assert.assertNull;
23
+
importstaticorg.junit.Assert.assertSame;
23
24
importstaticorg.junit.Assert.assertTrue;
24
25
importstaticorg.junit.Assert.fail;
26
+
importstaticorg.junit.Assume.assumeFalse;
27
+
importstaticorg.junit.Assume.assumeTrue;
25
28
26
29
importjava.io.File;
27
30
importjava.io.IOException;
28
31
importjava.io.InputStream;
29
32
importjava.net.URL;
33
+
importjava.nio.file.Files;
34
+
importjava.nio.file.Path;
35
+
importjava.util.Comparator;
30
36
importjava.util.function.Consumer;
31
37
32
38
importorg.eclipse.swt.SWT;
@@ -1262,4 +1268,58 @@ public void test_updateWidthHeightAfterDPIChange() {
1262
1268
DPIUtil.setDeviceZoom(deviceZoom);
1263
1269
}
1264
1270
}
1271
+
1272
+
@Test
1273
+
publicvoidtest_imageDataIsCached() {
1274
+
assumeTrue("On-demand image creation only implemented for Windows", SwtTestUtil.isWindows);
0 commit comments