[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript FormScriptingTest.java,1.6,1.
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-08-27 16:26:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv9481/test/com/meterware/httpunit/javascript Modified Files: FormScriptingTest.java Log Message: Added support for reset button and associated JavaScript Index: FormScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- FormScriptingTest.java 23 Aug 2002 19:33:13 -0000 1.6 +++ FormScriptingTest.java 27 Aug 2002 16:26:05 -0000 1.7 @@ -88,6 +88,51 @@ } + public void testResetViaScript() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=text name=change value=color>" + + "</form>" + + "<a href='#' onClick='document.spectrum.reset(); return false;'>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + + WebForm form = response.getFormWithName( "spectrum" ); + form.setParameter( "color", "blue" ); + response.getLinks()[ 0 ].click(); + assertEquals( "Value after reset", "green", form.getParameterValue( "color" ) ); + } + + + public void testOnResetEvent() throws Exception { + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt' onreset='alert( \"Ran the event\" );'>" + + " <input type=text name=color value=green>" + + " <input type=reset id='clear'>" + + "</form>" + + "<a href='#' onClick='document.spectrum.reset(); return false;'>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + + WebForm form = response.getFormWithName( "spectrum" ); + + form.setParameter( "color", "blue" ); + form.getButtonWithID( "clear" ).click(); + assertEquals( "Value after reset", "green", form.getParameterValue( "color" ) ); + assertEquals( "Alert message", "Ran the event", wc.popNextAlert() ); + + form.setParameter( "color", "blue" ); + response.getLinks()[ 0 ].click(); + assertEquals( "Value after reset", "green", form.getParameterValue( "color" ) ); + assertNull( "Event ran unexpectedly", wc.getNextAlert() ); + } + + public void testSubmitViaScript() throws Exception { defineResource( "DoIt?color=green", "You made it!" ); defineResource( "OnCommand.html", "<html><head></head>" + |