[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit FormParametersTest.java,1.20,1.21
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-06-24 22:40:40
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv25478/test/com/meterware/httpunit
Modified Files:
FormParametersTest.java
Log Message:
Added support for set/toggle checkbox
Index: FormParametersTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FormParametersTest.java 4 May 2003 12:45:10 -0000 1.20
+++ FormParametersTest.java 24 Jun 2003 22:40:36 -0000 1.21
@@ -250,6 +250,38 @@
}
+ public void testCheckboxShortcuts() throws Exception {
+ defineWebPage( "Default", "<form method=GET id='boxes'>" +
+ "<Input type=checkbox name=use_color>" +
+ "<Input type=checkbox name=running value=fast>" +
+ "<Input type=checkbox name=color value=red>Scarlet" +
+ "<Input type=checkbox name=color value=blue>Turquoise" +
+ "<Input type=text name=fish>" +
+ "<Input type=submit></form>" );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebForm form = page.getFormWithID( "boxes" );
+ form.toggleCheckbox( "use_color" );
+ assertEquals( "'use_color' checkbox after toggle", "on", form.getParameterValue( "use_color" ) );
+ form.setCheckbox( "use_color", false );
+ assertEquals( "'use_color' checkbox after set-false", null, form.getParameterValue( "use_color" ) );
+ form.toggleCheckbox( "running" );
+ assertEquals( "'running' checkbox after toggle", "fast", form.getParameterValue( "running" ) );
+
+ try {
+ form.setCheckbox( "color", true );
+ fail( "Did not forbid setting checkbox with multiple values" );
+ } catch (IllegalRequestParameterException e) {
+ }
+
+ try {
+ form.toggleCheckbox( "fish" );
+ fail( "Did not forbid toggling non-checkbox parameter" );
+ } catch (IllegalRequestParameterException e) {
+ }
+
+ }
+
+
public void testReadOnlyControls() throws Exception {
defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
"<Input readonly type=checkbox name=color value=red checked>" +
|