Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Get imagefilename with swtbot
Get imagefilename with swtbot [message #489035] Thu, 01 October 2009 09:50 Go to next message
Michelle Davidson is currently offline Michelle DavidsonFriend
Messages: 41
Registered: August 2009
Member
Hello,

is there a way to check with swtbot, if the image, which is shown on a lable, or a treeitem or on another widget, ist the correct image.

I look for a methode that returns the name of this image file, so that i can compare this filename with the correct file name.
Re: Get imagefilename with swtbot [message #489068 is a reply to message #489035] Thu, 01 October 2009 12:29 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Images in SWT are just data structures that store image information --
colors, pixels, etc, but not the file information.

You may read an existing file and perform an equals with the image on
the widget to see if the image is what you expect.

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr

On 01/10/09 3:20 PM, Michelle Davidson wrote:
> Hello,
>
> is there a way to check with swtbot, if the image, which is shown on a
> lable, or a treeitem or on another widget, ist the correct image.
>
> I look for a methode that returns the name of this image file, so that i
> can compare this filename with the correct file name.
>
Re: Get imagefilename with swtbot [message #489297 is a reply to message #489068] Fri, 02 October 2009 09:42 Go to previous message
Eclipse UserFriend
Originally posted by: cedric.chabanois.entropysoft.net

Here is what I use to compare two ImageData (you can get ImageData from
ImageDescriptor or from Image)

public static void assertImageDataIs(ImageData expectedImageData,
ImageData actualImageData) {
if (expectedImageData.width != actualImageData.width
|| expectedImageData.height != actualImageData.height) {
fail(MessageFormat
.format(
"Image data do not have the same dimensions ({0}x{1} expected, got
{2}x{3})",
expectedImageData.width, expectedImageData.height,
actualImageData.width, actualImageData.height));
}

for (int y = 0; y < expectedImageData.height; y++) {
for (int x = 0; x < expectedImageData.width; x++) {
int actualPixel = actualImageData.getPixel(x, y);
int expectedPixel = expectedImageData.getPixel(x, y);
RGB actualRGB = actualImageData.palette.getRGB(actualPixel);
RGB expectedRGB = expectedImageData.palette
.getRGB(expectedPixel);
if (!actualRGB.equals(expectedRGB)) {
fail(MessageFormat.format(
"Image data do not match at ({0},{1})", x, y));
}
}
}
}

C
Previous Topic:Enhancement suggestions for the WithId matcher
Next Topic:How can you enable a cell editor in a tree viewer with multiple columns?
Goto Forum:
  


Current Time: Thu Mar 28 23:05:04 GMT 2024

Powered by FUDForum. Page generated in 0.03171 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top