Update of /cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9584/test/net/sourceforge/jwebunit

Modified Files:
        AllTests.java 
Added Files:
        FormSubmissionCheckboxesTest.java 
Log Message:
Added test methods to check checkboxes that are only known by a text label. Not 
yet implemented in JacobieDialog.

--- NEW FILE: FormSubmissionCheckboxesTest.java ---
package net.sourceforge.jwebunit;

import net.sourceforge.jwebunit.util.JettySetup;
import junit.framework.Test;
import junit.framework.TestSuite;

/**
 * Test form submission where checkbox name+value is not known.
 */
public class FormSubmissionCheckboxesTest extends JWebUnitAPITestCase {

        public static Test suite() {
                Test suite = new TestSuite(FormSubmissionCheckboxesTest.class);
                return new JettySetup(suite);
        }       
        
        public void setUp() throws Exception {
                super.setUp();
                getTestContext().setBaseUrl(HOST_PATH + "/FormSubmissionTest");
        }

        public void testCheckboxIdentificationLabelBeforeBox() {
                beginAt("/CheckboxFormWithLabels.html");
                // we don't know the name or value, just the label
                checkCheckboxWithLabel("Check 20");
                //submit();
                //assertTextPresent("Params are: chk=20");
                assertFormElementEquals("chk", "20");
        }

        public void testCheckboxIdentificationLabelAfterBox1() {
                doTestCheckboxBefore(1);
        }

        /**
         * Extracting test logic because it must be improved to use jetty
         * @param value
         */
        private void doTestCheckboxBefore(int value) {
                beginAt("/CheckboxFormWithLabels.html");
                checkCheckboxBeforeLabel("Check " + value);
                //submit();
                //assertTextPresent("Params are: chk=" + value);
                assertFormElementEquals("chk", "" + value);
        }       

        public void testCheckboxIdentificationLabelAfterBox2() {
                doTestCheckboxBefore(5);
        }

        public void testCheckboxIdentificationLabelAfterBox3() {
                doTestCheckboxBefore(3);
        }

        private void doTestRadioBefore(int value) {
                beginAt("/CheckboxFormWithLabels.html");
                // we don't know the name or value, just the label
                checkCheckboxBeforeLabel("Radio " + value);
                //submit("button");
                //assertTextPresent("Params are: chk=" + value);
                assertFormElementEquals("rad", "" + value);
        }       
        
        public void testCheckboxIdentificationLabelAfterBox10() {
                doTestRadioBefore(10);
        }
        
        public void testCheckboxIdentificationLabelAfterBox11() {
                doTestRadioBefore(11);
        }
}
Index: AllTests.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit/AllTests.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** AllTests.java       22 Dec 2005 16:19:11 -0000      1.20
--- AllTests.java       22 Dec 2005 18:05:01 -0000      1.21
***************
*** 38,41 ****
--- 38,42 ----
                suite.addTestSuite(TextAndElementWalkerTest.class);
          suite.addTestSuite(TextAndElementWalkerReverseTest.class);
+         suite.addTestSuite(FormSubmissionCheckboxesTest.class);
                
                //not moved over to using jetty / JWebUnitAPITestCase



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to