Author: nbelaevski
Date: 2008-05-23 09:11:53 -0400 (Fri, 23 May 2008)
New Revision: 8724
Modified:
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-3483
Modified:
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
---
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2008-05-23
13:05:10 UTC (rev 8723)
+++
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2008-05-23
13:11:53 UTC (rev 8724)
@@ -45,7 +45,6 @@
import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.HtmlTestUtils;
-import org.apache.commons.lang.StringUtils;
import org.richfaces.renderkit.html.images.SliderArrowImage;
import org.richfaces.renderkit.html.images.SliderArrowSelectedImage;
import org.richfaces.renderkit.html.images.SliderFieldGradient;
@@ -58,7 +57,6 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
/** Unit test for simple Component. */
public class InputNumberSliderComponentTest extends AbstractAjax4JsfTestCase {
@@ -219,6 +217,22 @@
assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);
}
+ private void checkResource(String name, int format) throws Exception {
+ InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
+ InternetResource resource = builder.getResource(name);
+
+ assertNotNull(resource);
+ String uri = "http:" + resource.getUri(facesContext, null);
+ Page page = webClient.getPage(uri);
+ assertTrue(page.getWebResponse().getStatusCode()
+ == HttpServletResponse.SC_OK);
+ ImageInfo info = new ImageInfo();
+ info.setInput(page.getWebResponse().getContentAsStream());
+ //image recognizable?
+ assertTrue(info.check());
+ assertEquals(format, info.getFormat());
+ }
+
public void testRenderImages() throws Exception {
renderView();
InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
@@ -229,26 +243,23 @@
assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse
.SC_OK);
- String[] resources = new String[]{
- SliderArrowImage.class.getName(),
- SliderArrowSelectedImage.class.getName(),
+ String[] pngResources = new String[]{
SliderFieldGradient.class.getName(),
SliderTrackGradient.class.getName()
};
- for (int i = 0; i < resources.length; i++) {
- resource = builder.getResource(resources[i]);
- assertNotNull(resource);
- uri = "http:" + resource.getUri(facesContext, null);
- page = webClient.getPage(uri);
- assertTrue(page.getWebResponse().getStatusCode()
- == HttpServletResponse.SC_OK);
- ImageInfo info = new ImageInfo();
- info.setInput(page.getWebResponse().getContentAsStream());
- //image recognizable?
- assertTrue(info.check());
- assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
- }
+ for (int i = 0; i < pngResources.length; i++) {
+ checkResource(pngResources[i], ImageInfo.FORMAT_PNG);
+ }
+
+ String[] gifResources = new String[]{
+ SliderArrowImage.class.getName(),
+ SliderArrowSelectedImage.class.getName(),
+ };
+
+ for (int i = 0; i < gifResources.length; i++) {
+ checkResource(gifResources[i], ImageInfo.FORMAT_GIF);
+ }
}
public void testUpdate() throws Exception {