Author: mgrigorov
Date: Tue Feb 22 14:27:50 2011
New Revision: 1073341

URL: http://svn.apache.org/viewvc?rev=1073341&view=rev
Log:
WICKET-3465 BaseWicketTester#isInvisible(String path)
WICKET-1214 WicketTester#startPanel does not work (correctly)

BaseWicketTester#is(Visible|Invisible|Enabled|Disabled) now use 
getComponentFromLastRenderedPage() to find the component.
BaseWicketTester#getComponentFromLastRenderedPage() is overloaded so it can 
return invisible components when requested.


Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=1073341&r1=1073340&r2=1073341&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 Tue Feb 22 14:27:50 2011
@@ -1037,15 +1037,16 @@ public class BaseWicketTester
 
        /**
         * Gets the component with the given path from last rendered page. This 
method fails in case the
-        * component couldn't be found, and it will return null if the 
component was found, but is not
-        * visible.
+        * component couldn't be found.
         * 
         * @param path
         *            Path to component
+        * @param wantVisibleInHierarchy
+        *            if true component needs to be VisibleInHierarchy else 
null is returned
         * @return The component at the path
         * @see org.apache.wicket.MarkupContainer#get(String)
         */
-       public Component getComponentFromLastRenderedPage(String path)
+       public Component getComponentFromLastRenderedPage(String path, boolean 
wantVisibleInHierarchy)
        {
                if (startComponent != null)
                {
@@ -1058,7 +1059,7 @@ public class BaseWicketTester
                                
Classes.simpleName(getLastRenderedPage().getClass()));
                        return component;
                }
-               if (component.isVisibleInHierarchy())
+               if (!wantVisibleInHierarchy || component.isVisibleInHierarchy())
                {
                        return component;
                }
@@ -1066,6 +1067,21 @@ public class BaseWicketTester
        }
 
        /**
+        * Gets the component with the given path from last rendered page. This 
method fails in case the
+        * component couldn't be found, and it will return null if the 
component was found, but is not
+        * visible.
+        * 
+        * @param path
+        *            Path to component
+        * @return The component at the path
+        * @see org.apache.wicket.MarkupContainer#get(String)
+        */
+       public Component getComponentFromLastRenderedPage(String path)
+       {
+               return getComponentFromLastRenderedPage(path, true);
+       }
+
+       /**
         * assert the text of <code>Label</code> component.
         * 
         * @param path
@@ -1112,14 +1128,21 @@ public class BaseWicketTester
         */
        public Result isVisible(String path)
        {
-               Component component = getLastRenderedPage().get(path);
+               Component component = getComponentFromLastRenderedPage(path, 
false);
+
+               final Result result;
                if (component == null)
                {
-                       fail("path: '" + path + "' does no exist for page: " +
+                       result = Result.fail("path: '" + path + "' does no 
exist for page: " +
                                
Classes.simpleName(getLastRenderedPage().getClass()));
                }
+               else
+               {
+                       result = isTrue("component '" + path + "' is not 
visible",
+                               component.isVisibleInHierarchy());
+               }
 
-               return isTrue("component '" + path + "' is not visible", 
component.isVisibleInHierarchy());
+               return result;
        }
 
        /**
@@ -1131,7 +1154,21 @@ public class BaseWicketTester
         */
        public Result isInvisible(String path)
        {
-               return isNull("component '" + path + "' is visible", 
getComponentFromLastRenderedPage(path));
+               Component component = getComponentFromLastRenderedPage(path, 
false);
+
+               final Result result;
+               if (component == null)
+               {
+                       result = Result.fail("path: '" + path + "' does no 
exist for page: " +
+                               
Classes.simpleName(getLastRenderedPage().getClass()));
+               }
+               else
+               {
+                       result = isFalse("component '" + path + "' is visible",
+                               component.isVisibleInHierarchy());
+               }
+
+               return result;
        }
 
        /**
@@ -1143,7 +1180,7 @@ public class BaseWicketTester
         */
        public Result isEnabled(String path)
        {
-               Component component = getLastRenderedPage().get(path);
+               Component component = getComponentFromLastRenderedPage(path);
                if (component == null)
                {
                        fail("path: '" + path + "' does no exist for page: " +
@@ -1162,7 +1199,7 @@ public class BaseWicketTester
         */
        public Result isDisabled(String path)
        {
-               Component component = getLastRenderedPage().get(path);
+               Component component = getComponentFromLastRenderedPage(path);
                if (component == null)
                {
                        fail("path: '" + path + "' does no exist for page: " +
@@ -1181,7 +1218,7 @@ public class BaseWicketTester
         */
        public Result isRequired(String path)
        {
-               Component component = getLastRenderedPage().get(path);
+               Component component = getComponentFromLastRenderedPage(path);
                if (component == null)
                {
                        fail("path: '" + path + "' does no exist for page: " +


Reply via email to