]> source.dussan.org Git - vaadin-framework.git/commitdiff
More thorough testing of different init parameters for different roots
authorLeif Åstrand <leif@vaadin.com>
Wed, 4 Jan 2012 17:08:24 +0000 (19:08 +0200)
committerLeif Åstrand <leif@vaadin.com>
Wed, 4 Jan 2012 17:08:24 +0000 (19:08 +0200)
tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html
tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java

index c89cf3be6d8483c085212259bb736dc13e1bf4d5..5448a2481683450b9d58ad11d2f1310c8e030f1f 100644 (file)
 </thead><tbody>
 <tr>
        <td>open</td>
-       <td>/run/com.vaadin.tests.components.root.LazyInitRoots/?restartApplication&amp;lazyCreate#lazyCreate</td>
+       <td>/run/com.vaadin.tests.components.root.LazyInitRoots/normalPath?restartApplication#normalFragment</td>
        <td></td>
 </tr>
 <tr>
        <td>assertText</td>
        <td>vaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
-       <td>Lazy create root: lazyCreate</td>
+       <td>NormalRoot<br />pathInfo: /normalPath<br />parameters: [restartApplication]<br />uri fragment: normalFragment</td>
 </tr>
 <tr>
        <td>open</td>
-       <td>/run/com.vaadin.tests.components.root.LazyInitRoots/?restartApplication&amp;lazyInit#lazyInit</td>
+       <td>/run/com.vaadin.tests.components.root.LazyInitRoots/lazyCreatePath?lazyCreate#lazyCreateFragment</td>
        <td></td>
 </tr>
 <tr>
        <td>assertText</td>
        <td>vaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
-       <td>Lazy init root: lazyInit</td>
+       <td>LazyCreateRoot<br />pathInfo: /lazyCreatePath<br />parameters: [lazyCreate]<br />uri fragment: lazyCreateFragment</td>
+</tr>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.root.LazyInitRoots/eagerPath/?eagerInit#eagerFragment</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+       <td>EagerInitRoot<br />pathInfo: /eagerPath/<br />parameters: [eagerInit]<br />uri fragment: null</td>
 </tr>
-
 </tbody></table>
 </body>
 </html>
index 109e93f1b8ac572b6739cd0a65e2affb1cfbbbf7..97f6701fdbec985643d1f89de0b48a39ab9b001e 100644 (file)
@@ -7,6 +7,7 @@ import com.vaadin.terminal.WrappedRequest;
 import com.vaadin.terminal.WrappedRequest.BrowserDetails;
 import com.vaadin.tests.components.AbstractTestApplication;
 import com.vaadin.ui.Label;
+import com.vaadin.ui.Label.ContentMode;
 import com.vaadin.ui.Link;
 import com.vaadin.ui.Root;
 
@@ -16,9 +17,7 @@ public class LazyInitRoots extends AbstractTestApplication {
     private static class EagerInitRoot extends Root {
         @Override
         public void init(WrappedRequest request) {
-            BrowserDetails browserDetails = request.getBrowserDetails();
-            getContent().addComponent(
-                    new Label("Lazy init root: " + browserDetails));
+            addComponent(getRequestInfo("EagerInitRoot", request));
         }
     }
 
@@ -27,7 +26,7 @@ public class LazyInitRoots extends AbstractTestApplication {
             throws RootRequiresMoreInformationException {
         if (request.getParameter("lazyCreate") != null) {
             // Root created on second request
-            final BrowserDetails browserDetails = request.getBrowserDetails();
+            BrowserDetails browserDetails = request.getBrowserDetails();
             if (browserDetails == null
                     || browserDetails.getUriFragment() == null) {
                 throw new RootRequiresMoreInformationException();
@@ -35,20 +34,21 @@ public class LazyInitRoots extends AbstractTestApplication {
                 Root root = new Root() {
                     @Override
                     protected void init(WrappedRequest request) {
-                        addComponent(new Label("Lazy create root: "
-                                + browserDetails.getUriFragment()));
+                        addComponent(getRequestInfo("LazyCreateRoot", request));
                     }
                 };
                 return root;
             }
         } else if (request.getParameter("eagerInit") != null) {
-            // Root inited on second request
+            // Root inited on first request
             return new EagerInitRoot();
         } else {
             // The standard root
             Root root = new Root() {
                 @Override
                 protected void init(WrappedRequest request) {
+                    addComponent(getRequestInfo("NormalRoot", request));
+
                     Link lazyCreateLink = new Link("Open lazyCreate root",
                             new ExternalResource(getURL()
                                     + "?lazyCreate#lazyCreate"));
@@ -67,6 +67,15 @@ public class LazyInitRoots extends AbstractTestApplication {
         }
     }
 
+    public static Label getRequestInfo(String name, WrappedRequest request) {
+        String info = name;
+        info += "<br />pathInfo: " + request.getRequestPathInfo();
+        info += "<br />parameters: " + request.getParameterMap().keySet();
+        info += "<br />uri fragment: "
+                + request.getBrowserDetails().getUriFragment();
+        return new Label(info, ContentMode.XHTML);
+    }
+
     @Override
     protected String getTestDescription() {
         return "BrowserDetails should be available in Application.getRoot if RootRequiresMoreInformation has been thrown and in Root.init if the root has the @RootInitRequiresBrowserDetals annotation";