|
Alex Ruiz made changes - 24/Mar/09 06:45 PM
My first comments on trying to debug this issue. ACTUAL SCREENSHOT (XP, from Robot)
EXPECTED SCREENSHOT (VISTA64, from file)
while debugging through ImageAssert.hasEqualColor() I was expecting a failure on the first pixel but no! There was no error in the first pixels line! actual = -1314056 (0xFFEBF2F8) hence, a 1-bit difference in the Red component (EB Vs. EC)! Now what I don't know is if this difference was due to internal conversions performed by getRGB() or if the 2 PNG are really different! I need to find some way to investigate that point further... Bad news! After checking both screenshots files with MS Digital Image, and viewing the pixel color they effectively differ!
Hard to tell, I feel a bit lost now, don't really know where to look (and how) to fix that problem... Anyway, I think this issue should at least enhance the exception message so that we see immediately which pixel differs and the respective colors for expected and actual pixels. In addition, another enhancement could also be to have some threshold in pixel color comparison, passed as an argument to ImageAssert (default = 0). for each actual pixel that looks more like a workaround, but I would already be pleased with it One next check I will do is to compare, on Vista, the actual screenshot (BufferedImage taken by Robot) with the saved PNG file. This way I would know if the problem is in Robot or ImageIO... I'll check that later on tonight and post my conclusions. Thanks Jean-Francois for looking into this bug in so much detail! Like you said, it is kind of hard to fix. If the bug is in either takeScreenshotOf or in saveImage, the bug will be actually in the JDK, since FEST simply delegates to methods in the JDK that perform those actions. My guess is that there are actual unexpected differences in JDK implementations for different OSs. Both your suggestions are excellent! (as usual.) I'll be adding more details to the exception message and a threshold for comparison. Thanks, Hi Jean-Francois, I just added the changes you suggested and it works perfectly for the images you sent me. The code in the test org.fest.assertions.FEST107_EqualImagesAreConsideredDifferent looks like this: BufferedImage actual = reader.read(file("Basics1SimpleGridActual.png")); BufferedImage expected = reader.read(file("Basics1SimpleGridExpected.png")); assertThat(actual).isEqualTo(expected, threshold(1)); This is a lot better than what we previously had! Thanks a lot! Thanks Alex for this prompt fix. I think you are right about the fact we won't be able to solve the problems of different screenshots between XP and Vista; maybe I won't waste time to try to spot the origin, Robot or ImageIO, since anyway this would not change the fact we cannot do anything! Cheers Jean-Francois
Alex Ruiz made changes - 25/Mar/09 02:48 PM
Alex Ruiz made changes - 25/Mar/09 02:48 PM
Hi Jean-Francois, I just uploaded a snapshot release for FEST-Swing (which will use a snapshot release of FEST-Assert.) The new Maven repo can be found http://svn.codehaus.org/fest/m2/repo/ The version that contains fixes for the bugs you filed is fest-swing-1.2a1-SNAPSHOT. Please let me know if this is working OK Thanks, Hello Alex, thanks for uploading the snapshot. Unfortunately on the new maven repo, you didn't upload fest-swing-testng jar (all my tests are based on TestNG) and that makes it impossible for me to test the latest fest-swing snapshot (I cannot even try to tune maven artifacts loading to get both jars from the old and new maven repos because the group names have changed so the "old" fest-swing-testng would not find the new fest-swing. You also mentioned uploading a snapshot fest-swing release elsewhere but I could not find it in any location other than the new maven repo. Is there a new download location for FEST? Is it normal that the docs on codehaus still refer to locations on code.google? Sorry to bother you a bit more with that but it would be hard for me to revert from TestNG (which I like much) to JUnit 4 (which I still don't appreciate much). Hope I can test the whole stuff tonight and report my results here. Cheers, Jean-Francois Hello Alex, now everything is fine with the snapshot in maven repository. All my tests run well now on both XP and VISTA. Jean-Francois |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Thank you Alex for opening this issue. The exception stack trace I sent you is actually not the one matching the screenshots in the attachment (made a copy/paste mistake from my test log).
The actual stack trace is:
java.lang.AssertionError: [src/test/resources/screenshots/java6/basics/Basics1SimpleGrid.png] images do not have the same color(s)
at org.fest.assertions.Fail.fail(Fail.java:85)
at org.fest.assertions.GenericAssert.fail(GenericAssert.java:211)
at org.fest.assertions.ImageAssert.isEqualTo(ImageAssert.java:166)
at net.java.dev.designgridlayout.AbstractGuiTest.checkSnapshot(AbstractGuiTest.java:167)
at net.java.dev.designgridlayout.AbstractGuiTest.checkSnapshot(AbstractGuiTest.java:143)
at net.java.dev.designgridlayout.AbstractGuiTest.checkExample(AbstractGuiTest.java:109)
at net.java.dev.designgridlayout.basics.BasicFeaturesTest.checkSimpleGrid(BasicFeaturesTest.java:33)
....
It is essentially the same as the original one except that it was run from another test case and the screenshot reference is correct that time.
After a quick look at the source of ImageAssert, I could not find any obvious hint that would explain this behavior.
It might be interesting to run the TC in debug mode and check how the 2 BufferedImages are different (I suspect their ColorModels might differ but there is no certitude).
By the way it might be useful that the ImageAssert.isEqualTo() creates an exception with a more detailed message, in particular which pixel (x,y) was found different, what was the exepected and the actual colors?
I'll see tonight if I can try to check my tests in debug mode (I never run them from eclipse normally, only from maven...)