benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

Method on component fixture to capture target component state as a BufferedImage #181

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I think that it would be useful to have a method on all component fixtures
which would return a BufferedImage representing the target component in a
given point in time.

This method could be useful to compare for equality different states of a
complex component. A complex component might contain several text fields,
labels, tables, and so on. Comparing two different states of each and every
subcomponent (text field, label, etc...) would require quite a lot of logic.

Using such a method the component could be painted in a BufferedImage as
many times as needed to capture all relevant states. After that, the images
could be compared for equality pixel-by-pixel.

There are some things to consider. At what size should the component be
painted? I'd say that the preferred or current size would be appropriate.
Another issue would be that in most cases FEST and Swing run from two
different threads. Yet another issue is how to compare the images. I don't
know what BufferedImage#equals does, but if it doesn't perform a
pixel-by-pixel comparison, then the FEST assertion module together with
custom comparator support (described in issue 148) should work. What about
tables with narrow columns?

From a phylosophical point of view this type of comparison is reasonable.
It only uses information presented to the user through the GUI and the user
himself can and does similar comparisons. Humans process a lot of graphical
information, this is what we're best at.

Check out: http://moose.unibe.ch/ . The site has changed a lot so there's a
lot of digging to do, but it's worth it.

I'd like to hear your opinion.

Thanks,
Csabi

Original issue reported on code.google.com by csaba.ju...@gmail.com on 17 Jul 2008 at 7:44

GoogleCodeExporter commented 9 years ago
Hi Csabi,

We already have the class org.fest.swing.image.ScreenshotTaker which can either 
take
a screenshot of a Component ('takeScreenshotOf(Component c)') or save the 
screenshot
in a png file.

The project FEST-Assert has already an ImageAssert class that compares two 
images
using their sizes and the color in each pixel.

If I understood correctly, we already have similar functionality in place and 
we can
mark this issue as 'invalid'. Please let me know if that is the case.

Regards,
-Alex

Original comment by Alex.Rui...@gmail.com on 17 Jul 2008 at 9:33

GoogleCodeExporter commented 9 years ago
Hi Alex,

This is exactly what I had in mind.

Thanks,
Csabi

Original comment by csaba.ju...@gmail.com on 18 Jul 2008 at 6:26

GoogleCodeExporter commented 9 years ago
Thanks Csabi, I'm marking this issue as invalid.

Regards,
-Alex

Original comment by Alex.Rui...@gmail.com on 18 Jul 2008 at 12:59

GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 2:09