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

Modified Files:
        HttpUnitDialog.java WebTester.java WebTestCase.java 
Log Message:
jw: add window navigation / assertion by title

Index: WebTester.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** WebTester.java      30 Jun 2004 19:06:52 -0000      1.48
--- WebTester.java      28 Jul 2004 17:39:06 -0000      1.49
***************
*** 755,758 ****
--- 755,767 ----
  
      /**
+      * Assert that at least one window with the given title is open.
+      *
+      * @param title
+      */
+     public void assertWindowPresentWithTitle(String title) {
+         Assert.assertNotNull("Unable to locate window with title [" + title + "].", 
dialog.getWindowByTitle(title));
+     }
+ 
+     /**
       * Assert that a frame with the given name is present.
       *
***************
*** 868,872 ****
       */
      public void selectOption(String selectName, String option) {
!         assertFormElementPresent(selectName);
          dialog.selectOption(selectName, option);
      }
--- 877,881 ----
       */
      public void selectOption(String selectName, String option) {
!         assertOptionPresent(selectName, option);
          dialog.selectOption(selectName, option);
      }
***************
*** 983,986 ****
--- 992,1005 ----
  
      /**
+      * Make first window with the given title active.
+      *
+      * @param windowName
+      */
+     public void gotoWindowByTitle(String title) {
+         assertWindowPresentWithTitle(title);
+         dialog.gotoWindowByTitle(title);
+     }
+ 
+     /**
       * Make the named frame active (current response will be frame's contents).
       *

Index: HttpUnitDialog.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/HttpUnitDialog.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** HttpUnitDialog.java 30 Jun 2004 19:06:51 -0000      1.43
--- HttpUnitDialog.java 28 Jul 2004 17:39:05 -0000      1.44
***************
*** 87,90 ****
--- 87,109 ----
                return wc.getOpenWindow(windowName);
        }
+       
+       /**
+        * Return the first open window with the given title.
+        */
+       public WebWindow getWindowByTitle(String title) {
+           WebWindow [] webWindows = wc.getOpenWindows();
+           for (int i = 0; i < webWindows.length; i++) {
+             WebWindow window = webWindows[i];
+             try {
+                 if 
(context.toEncodedString(window.getCurrentPage().getTitle()).equals(title)) {
+                     return window;
+                 }
+             } catch (SAXException e) {
+                       throw new 
RuntimeException(ExceptionUtility.stackTraceToString(e));
+             }
+         }
+           return null;
+       }
+       
        /**
         * Return the HttpUnit WebClient object for this dialog.
***************
*** 977,980 ****
--- 996,1011 ----
  
        /**
+        * Goto first window with the given title.
+        * 
+        * @param windowName
+        */
+       public void gotoWindowByTitle(String title) {
+           WebWindow window = getWindowByTitle(title);
+           if (window != null) {
+               setMainWindow(window);
+           }
+       }
+ 
+       /**
         * Make the root window in the current conversation active.
         */

Index: WebTestCase.java
===================================================================
RCS file: /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTestCase.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** WebTestCase.java    3 Jul 2004 16:45:07 -0000       1.45
--- WebTestCase.java    28 Jul 2004 17:39:06 -0000      1.46
***************
*** 300,303 ****
--- 300,307 ----
      }
  
+     public void assertWindowPresentWithTitle(String title) {
+         tester.assertWindowPresentWithTitle(title);
+     }
+ 
      public void assertFramePresent(String frameName) {
          tester.assertFramePresent(frameName);
***************
*** 401,404 ****
--- 405,412 ----
      }
  
+     public void gotoWindowByTitle(String title) {
+         tester.gotoWindowByTitle(title);
+     }
+ 
      public void gotoWindow(String windowName) {
          tester.gotoWindow(windowName);



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Jwebunit-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development

Reply via email to