Author: A.Skokov
Date: 2007-05-14 04:34:21 -0400 (Mon, 14 May 2007)
New Revision: 739
Modified:
trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
Log:
tests fixed
Modified:
trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
---
trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-05-11
17:29:23 UTC (rev 738)
+++
trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-05-14
08:34:21 UTC (rev 739)
@@ -74,17 +74,17 @@
/**
* Create the test case
- *
+ *
* @param testName
* name of the test case
*/
-
+
static {
javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
javaScripts.add("scripts/scriptaculous-js-1.6.5/src/slider.js");
}
-
+
public DataFilterSliderComponentTest(String testName) {
super(testName);
}
@@ -98,7 +98,7 @@
command = new HtmlCommandLink();
command.setId("command");
form.getChildren().add(command);
-
+
dfSlider = application.createComponent(UIDataFltrSlider.COMPONENT_TYPE);
dfSlider.setId("slider");
((UIDataFltrSlider)dfSlider).setStartRange(Integer.valueOf(0));
@@ -116,7 +116,7 @@
/**
* Test component renders correctly
- *
+ *
* @throws Exception
*/
public void testComponent() throws Exception {
@@ -124,36 +124,36 @@
HtmlPage renderedView = renderView();
HtmlElement htmlSlider =
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-range");
- assertTrue(htmlSlider.getAttributeValue("class").contains("range"));
+ assertTrue(htmlSlider.getAttributeValue("class").contains("range"));
assertTrue(((HtmlElement)htmlSlider.getParentNode()).getAttributeValue("class").contains("slider-container"));
-
+
HtmlElement htmlSliderTrailer =
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-trailer");
assertTrue(htmlSliderTrailer.getAttributeValue("class").contains("trailer"));
-
+
HtmlElement htmlSliderTrack =
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-track");
assertTrue(htmlSliderTrack.getAttributeValue("class").contains("track"));
assertTrue(htmlSliderTrack.getAttributeValue("style").equals("width:"
+ dfSlider.getAttributes().get("width")));
HtmlElement htmlSliderHandle =
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-handle");
assertTrue(htmlSliderHandle.getAttributeValue("class").contains("handle"));
-
+
HtmlElement htmlSliderInput =
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider_val");
assertTrue(((HtmlInput)htmlSliderInput).getTypeAttribute().equals("text"));
assertTrue(htmlSliderInput.getAttributeValue("class").contains("slider-input-field"));
assertTrue(htmlSliderInput.getAttributeValue("onchange").equals("dataFilterSlider.setValue(this.value);"));
}
-
+
public void testImages() throws Exception {
InternetResource image = InternetResourceBuilder.getInstance().createResource(null,
SliderFieldGradient.class.getName());
Dimension imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
assertTrue( imageDim.getWidth() == 31 && imageDim.getHeight() == 55);
-
+
image = InternetResourceBuilder.getInstance().createResource(null,
SliderTrackGradient.class.getName());
imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
assertTrue( imageDim.getWidth() == 7 && imageDim.getHeight() == 10);
}
-
+
public void testRenderImages() throws Exception {
renderView();
InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
@@ -167,7 +167,7 @@
SliderFieldGradient.class.getName(),
SliderTrackGradient.class.getName(),
};
-
+
for (int i = 0; i < resources.length; i++) {
resource = builder.getResource(resources[i]);
assertNotNull(resource);
@@ -181,14 +181,14 @@
assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
}
}
-
+
public void testHiddenInput() throws Exception {
((UIDataFltrSlider)dfSlider).setManualInput(false);
HtmlPage renderedView = renderView();
HtmlElement htmlSliderInput =
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider_val");
assertTrue(((HtmlInput)htmlSliderInput).getTypeAttribute().equals("hidden"));
}
-
+
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
@@ -197,7 +197,7 @@
HtmlElement link = (HtmlElement) links.get(0);
assertTrue(link.getAttributeValue("href").contains("css/dataFilterSlider.xcss"));
}
-
+
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
@@ -225,37 +225,37 @@
public void testUpdate() throws Exception {
//tests if component handles value bindings correctly
HtmlPage renderedView = renderView();
-
+
String value = "5";
-
+
HtmlInput htmlSliderInput = (HtmlInput)
renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider_val");
htmlSliderInput.setValueAttribute(value);
-
+
HtmlAnchor htmlLink = (HtmlAnchor)
renderedView.getHtmlElementById(command.getClientId(facesContext));
htmlLink.click();
List lastParameters = this.webConnection.getLastParameters();
for (Iterator iterator = lastParameters.iterator(); iterator.hasNext();) {
KeyValuePair keyValue = (KeyValuePair) iterator.next();
-
+
externalContext.addRequestParameterMap((String) keyValue.getKey(), (String)
keyValue.getValue());
}
- UIViewRoot root = facesContext.getViewRoot();
- root.processDecodes(facesContext);
- root.processValidators(facesContext);
- root.processUpdates(facesContext);
- root.processApplication(facesContext);
-
- renderedView = renderView();
- assertTrue(
value.equals(String.valueOf(((UIDataFltrSlider)dfSlider).getHandleValue())));
+
externalContext.addRequestParameterMap(dfSlider.getClientId(facesContext)+"slider_val",
value);
+
+ dfSlider.processDecodes(facesContext);
+ dfSlider.processValidators(facesContext);
+ dfSlider.processUpdates(facesContext);
+
+ renderedView = renderView();
+ assertTrue(
value.equals(String.valueOf(((UIDataFltrSlider)dfSlider).getHandleValue())));
}
-
+
public void testDecode() throws Exception{
- //Tests if component accepts request parameters and stores them in submittedValue().
+ //Tests if component accepts request parameters and stores them in submittedValue().
//If component is immediate, validation (possibly with conversion) should occur on that
phase.
final SliderBean bean = new SliderBean();
- ((UIDataFltrSlider)dfSlider).setValueBinding("value",
+ ((UIDataFltrSlider)dfSlider).setValueBinding("value",
new ValueBinding() {
public Class getType(FacesContext context) throws EvaluationException,
PropertyNotFoundException {
return String.class;
@@ -277,33 +277,33 @@
dfSlider.processDecodes(facesContext);
assertTrue(bean.getValue().equals("66"));
}
-
+
public void testListener() throws Exception{
HtmlPage renderedView = renderView();
-
+
HtmlAnchor htmlLink = (HtmlAnchor)
renderedView.getHtmlElementById(command.getClientId(facesContext));
htmlLink.click();
-
- MethodBinding binding = new MethodBinding(){
+
+ MethodBinding binding = new MethodBinding(){
public Object invoke(FacesContext context, Object[] params) throws
EvaluationException, MethodNotFoundException {
facesContext.addMessage(dfSlider.getClientId(facesContext), new
FacesMessage("Method invoked!"));
- return "invoked";
+ return "invoked";
}
public Class getType(FacesContext context) throws MethodNotFoundException {
return String.class;
}
};
-
+
DataFilterSliderEvent event = new DataFilterSliderEvent( ((UIDataFltrSlider) dfSlider),
new Integer(20), new Integer (50 ) );
new DataFilterSliderAdapter(binding).processSlider(event);
assertTrue(facesContext.getMessages().hasNext());
- }
-
+ }
+
private final class SliderBean {
-
+
private String value;
-
+
SliderBean (){
this.value = "66";
}
@@ -315,6 +315,6 @@
public void setValue(String value) {
this.value = value;
}
-
+
}
}
\ No newline at end of file
Show replies by date