On 29 sep, 18:25, mfuzzey <[EMAIL PROTECTED]> wrote: > Hi; > I'm trying to integration test a GWT application using ImageBundle > with WebDriver. > At one point I have images that represent various states of an object > and I need to check the correct image is being displayed. > However due to the use of ImageBundle the browser is actually seeing > something like : > > img border="0" style="background: transparent url(http://localhost: > 8180/aftDemo/aftDemo.gwtui.Application/ > 2EC9C8781E703938548B91FFE5106226.cache.png) no-repeat scroll -16px > 0px; width: 16px; height: 16px; -moz-background-clip: -moz-initial; - > moz-background-origin: -moz-initial; -moz-background-inline-policy: - > moz-initial;" src="http://localhost:8180/aftDemo/ > aftDemo.gwtui.Application/clear.cache.gif" > > How can I decode this back into the initial images? > > I tried doing GWT.create(MyImageBundle.class).my_image.getHTML() from > java but i'm not allowed to call GWT.create there (only from client > side code or GWTUnit) > > Other solutions I can imagine: > 1) extract just the pixel offsets from the style attribute and > manually map these to the effective image name in the test fixture : > simple but probably quite brittle (if new images are added the offsets > are likely to change) > > 2) Load the composite image and perform image manipulation to extract > the displayed part and compare to the original image : seems rather > complicated and I don't want to test GWT but my code! > > Any other Ideas?
Implement an ImageBundleGenerator-like that: - copy each image into the public/ folder (actually, "emit a public resource" in generator parlance) - implement the methods to simply returns unclipped images (there's a ClippedImagePrototype in com.google.gwt.user.client.ui.impl; copy it and transform it for "unclipped" images; passing in the file name of each image, that has been copied to the public folder, so accessible from the compiled app) And then use that particular generator in your module in place of the "normal" one (that assemble images in a sprite): <generate-with class="my.NonSpriteImageBundleGenerator"> <when-type-assignable class="com.google.gwt.user.client.ui.ImageBundle" /> </generate-with> This will have the same effect as if you were creating images with new Image(...) instead of myBundle.im_image().createImage(), i.e. not what you expect from an ImageBundle, but something that you can easily test. Other possibilities: - add some classes to the com.google.gwt.user.rebind.ui package to gain access to the package-protected methods from ImageBundleGenerator and ImageBundleBuilder, to try to determine the position of each image within the sprite (arrangement is deterministic, this is tested by ImageBundleGeneratorTest; see the code from this class to find some uses of the package-protected methods) - override/overwrite the ImageBundleGenerator to output a "debug log" file with the position of each image in the generated sprite; and then use this file from you test code. It would be valuable if GWT provided such an UnclippedImageBundleGenerator (call it DebugImageBundleGenerator if you want) and/or "debug log" file. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---