From 5dde30a89f704a9fdb2aa4aa26a804531a1077b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 4 Jan 2012 19:08:24 +0200 Subject: [PATCH] More thorough testing of different init parameters for different roots --- .../tests/components/root/LazyInitRoots.html | 19 +++++++++++---- .../tests/components/root/LazyInitRoots.java | 23 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html index c89cf3be6d..5448a24816 100644 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html +++ b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.html @@ -13,25 +13,34 @@ open - /run/com.vaadin.tests.components.root.LazyInitRoots/?restartApplication&lazyCreate#lazyCreate + /run/com.vaadin.tests.components.root.LazyInitRoots/normalPath?restartApplication#normalFragment assertText vaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - Lazy create root: lazyCreate + NormalRoot
pathInfo: /normalPath
parameters: [restartApplication]
uri fragment: normalFragment open - /run/com.vaadin.tests.components.root.LazyInitRoots/?restartApplication&lazyInit#lazyInit + /run/com.vaadin.tests.components.root.LazyInitRoots/lazyCreatePath?lazyCreate#lazyCreateFragment assertText vaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] - Lazy init root: lazyInit + LazyCreateRoot
pathInfo: /lazyCreatePath
parameters: [lazyCreate]
uri fragment: lazyCreateFragment + + + open + /run/com.vaadin.tests.components.root.LazyInitRoots/eagerPath/?eagerInit#eagerFragment + + + + assertText + vaadin=runcomvaadintestscomponentsrootLazyInitRoots::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0] + EagerInitRoot
pathInfo: /eagerPath/
parameters: [eagerInit]
uri fragment: null - diff --git a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java index 109e93f1b8..97f6701fdb 100644 --- a/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java +++ b/tests/testbench/com/vaadin/tests/components/root/LazyInitRoots.java @@ -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 += "
pathInfo: " + request.getRequestPathInfo(); + info += "
parameters: " + request.getParameterMap().keySet(); + info += "
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"; -- 2.39.5