Is there already a test utility to check two image data's contents are effectively the same #2664
-
|
I am working on adding missing tests for the Clipboard (as part of my work on #2126) I am currently trying to verify that we copy images to/from the clipboard properly. When that copy happens, we may not have the same binary contents for ImageData, so comparing the What I am looking to know is if there is in the testsuite already some code that compares two ImageDatas for their rendered values. I think the code looks something like this, but perhaps I am missing something. public static void assertImageDataEquals(ImageData expected, ImageData actual) {
if (expected == null) {
assertNull(actual);
}
assertEquals(expected.width, actual.width);
assertEquals(expected.height, actual.height);
if (expected.getRGBs() != null || actual.getRGBs() != null) {
fail("We don't have code yet for comparing non-direct color palettes");
}
for (int x = 0; x < expected.width; x++) {
for (int y = 0; y < expected.width; y++) {
assertEquals(expected.getPixel(x, y), actual.getPixel(x, y));
assertEquals(expected.getAlpha(x, y), actual.getAlpha(x, y));
}
}
}Do we need to check any other values? Maybe transparencies? I also need to determine what is expected when copying/pasting (or drag and drop which uses much of the same code). Should everything be preserved? Even the colour depth? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Hi, We already have a comparator in the test for the images, that does more or less as your snippet in I am not 100% sure about your copy implementation but I think this comparator is not enough. In case of different type of transparency for example we don't have alpha data at all. Some images like GIF uses mask data to define transparency. So to answer your question, I would preserve everything. |
Beta Was this translation helpful? Give feedback.
Hi, We already have a comparator in the test for the images, that does more or less as your snippet in
Test_org_eclipse_swt_graphics_ImageI am not 100% sure a…