Author: nbelaevski
Date: 2008-05-23 09:05:10 -0400 (Fri, 23 May 2008)
New Revision: 8723
Modified:
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-3483
Modified:
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
---
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2008-05-23
12:59:54 UTC (rev 8722)
+++
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2008-05-23
13:05:10 UTC (rev 8723)
@@ -46,7 +46,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.SpinnerButtonDown;
import org.richfaces.renderkit.html.images.SpinnerButtonGradient;
import org.richfaces.renderkit.html.images.SpinnerButtonUp;
@@ -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 InputNumberSpinnerComponentTest extends AbstractAjax4JsfTestCase {
@@ -186,6 +184,22 @@
assertTrue(imageDim.getWidth() == 14 && imageDim.getHeight() == 7);
}
+ 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();
@@ -196,25 +210,22 @@
assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse
.SC_OK);
- String[] resources = new String[]{
+ String[] pngResources = new String[]{
SpinnerButtonGradient.class.getName(),
SpinnerFieldGradient.class.getName(),
+ };
+
+ for (int i = 0; i < pngResources.length; i++) {
+ checkResource(pngResources[i], ImageInfo.FORMAT_PNG);
+ }
+
+ String[] gifResources = new String[]{
SpinnerButtonDown.class.getName(),
SpinnerButtonUp.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 < gifResources.length; i++) {
+ checkResource(pngResources[i], ImageInfo.FORMAT_PNG);
}
}