summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-05 15:42:02 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-05 15:42:02 +0300
commitde3ac989c85451767510917822463353bcab71cd (patch)
tree48a991db5d3a700e99e37d53df4fa7902bbb780b /uitest/src/com/vaadin/tests/components
parent8bdaf8732e660d1b9595c9d503999022320b0314 (diff)
downloadvaadin-framework-de3ac989c85451767510917822463353bcab71cd.tar.gz
vaadin-framework-de3ac989c85451767510917822463353bcab71cd.zip
Change LegacyApplication to be a UIProvider (#9402)
Diffstat (limited to 'uitest/src/com/vaadin/tests/components')
-rw-r--r--uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java (renamed from uitest/src/com/vaadin/tests/components/AbstractTestApplication.java)5
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java3
-rw-r--r--uitest/src/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java15
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java35
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java36
5 files changed, 43 insertions, 51 deletions
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestApplication.java b/uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java
index db17c67fdd..3d380c7835 100644
--- a/uitest/src/com/vaadin/tests/components/AbstractTestApplication.java
+++ b/uitest/src/com/vaadin/tests/components/AbstractTestUIProvider.java
@@ -1,16 +1,17 @@
package com.vaadin.tests.components;
import com.vaadin.Application;
+import com.vaadin.server.AbstractUIProvider;
import com.vaadin.server.ApplicationContext;
import com.vaadin.server.WebBrowser;
-public abstract class AbstractTestApplication extends Application {
+public abstract class AbstractTestUIProvider extends AbstractUIProvider {
protected abstract String getTestDescription();
protected abstract Integer getTicketNumber();
protected WebBrowser getBrowser() {
- ApplicationContext context = getContext();
+ ApplicationContext context = Application.getCurrent().getContext();
WebBrowser webBrowser = context.getBrowser();
return webBrowser;
}
diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java
index 9b29ae1bab..327ed0f86b 100644
--- a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java
+++ b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractComponentDataBindingTest.java
@@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
+import com.vaadin.Application;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent;
@@ -54,7 +55,7 @@ public abstract class AbstractComponentDataBindingTest extends TestBase
}
protected void updateLocale(Locale locale) {
- setLocale(locale);
+ Application.getCurrent().setLocale(locale);
for (Component c : fields) {
removeComponent(c);
}
diff --git a/uitest/src/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java b/uitest/src/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java
index 84c14763ab..f640b3f9c4 100644
--- a/uitest/src/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java
+++ b/uitest/src/com/vaadin/tests/components/loginform/LoginFormWithMultipleWindows.java
@@ -1,26 +1,17 @@
package com.vaadin.tests.components.loginform;
-import com.vaadin.Application;
-import com.vaadin.server.AbstractUIProvider;
-import com.vaadin.server.WrappedRequest;
+import com.vaadin.Application.LegacyApplication;
import com.vaadin.ui.LoginForm;
import com.vaadin.ui.LoginForm.LoginEvent;
import com.vaadin.ui.LoginForm.LoginListener;
-import com.vaadin.ui.UI;
import com.vaadin.ui.UI.LegacyWindow;
@SuppressWarnings("serial")
-public class LoginFormWithMultipleWindows extends Application {
+public class LoginFormWithMultipleWindows extends LegacyApplication {
@Override
public void init() {
- addUIProvider(new AbstractUIProvider() {
- @Override
- public Class<? extends UI> getUIClass(Application application,
- WrappedRequest request) {
- return LoginFormWindow.class;
- }
- });
+ setMainWindow(new LoginFormWindow());
}
public static class LoginFormWindow extends LegacyWindow {
diff --git a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
index f33037f171..b141dc0990 100644
--- a/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
+++ b/uitest/src/com/vaadin/tests/components/ui/LazyInitUIs.java
@@ -1,16 +1,15 @@
package com.vaadin.tests.components.ui;
import com.vaadin.Application;
-import com.vaadin.server.AbstractUIProvider;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.WrappedRequest;
import com.vaadin.shared.ui.label.ContentMode;
-import com.vaadin.tests.components.AbstractTestApplication;
+import com.vaadin.tests.components.AbstractTestUIProvider;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.UI;
-public class LazyInitUIs extends AbstractTestApplication {
+public class LazyInitUIs extends AbstractTestUIProvider {
// @EagerInit
private static class EagerInitUI extends UI {
@@ -21,21 +20,15 @@ public class LazyInitUIs extends AbstractTestApplication {
}
@Override
- public void init() {
- addUIProvider(new AbstractUIProvider() {
-
- @Override
- public UI createInstance(Application application,
- Class<? extends UI> type, WrappedRequest request) {
- return getUI(request);
- }
+ public UI createInstance(Application application, Class<? extends UI> type,
+ WrappedRequest request) {
+ return getUI(request);
+ }
- @Override
- public Class<? extends UI> getUIClass(Application application,
- WrappedRequest request) {
- return getUI(request).getClass();
- }
- });
+ @Override
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) {
+ return getUI(request).getClass();
}
private UI getUI(WrappedRequest request) {
@@ -59,14 +52,14 @@ public class LazyInitUIs extends AbstractTestApplication {
addComponent(getRequestInfo("NormalUI", request));
Link lazyCreateLink = new Link("Open lazyCreate UI",
- new ExternalResource(getURL()
- + "?lazyCreate#lazyCreate"));
+ new ExternalResource(Application.getCurrent()
+ .getURL() + "?lazyCreate#lazyCreate"));
lazyCreateLink.setTargetName("_blank");
addComponent(lazyCreateLink);
Link lazyInitLink = new Link("Open eagerInit UI",
- new ExternalResource(getURL()
- + "?eagerInit#eagerInit"));
+ new ExternalResource(Application.getCurrent()
+ .getURL() + "?eagerInit#eagerInit"));
lazyInitLink.setTargetName("_blank");
addComponent(lazyInitLink);
}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java
index fe2fe16d93..9a66e9ad0a 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java
+++ b/uitest/src/com/vaadin/tests/components/ui/UIsInMultipleTabs.java
@@ -1,34 +1,40 @@
package com.vaadin.tests.components.ui;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
import com.vaadin.Application;
-import com.vaadin.server.AbstractUIProvider;
import com.vaadin.server.WrappedRequest;
-import com.vaadin.tests.components.AbstractTestApplication;
+import com.vaadin.tests.components.AbstractTestUIProvider;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
-public class UIsInMultipleTabs extends AbstractTestApplication {
- private int numberOfUIsOpened;
+public class UIsInMultipleTabs extends AbstractTestUIProvider {
+ // No cleanup -> will leak, but shouldn't matter for tests
+ private static ConcurrentHashMap<Application, AtomicInteger> numberOfUIsOpened = new ConcurrentHashMap<Application, AtomicInteger>();
public static class TabUI extends UI {
@Override
protected void init(WrappedRequest request) {
- UIsInMultipleTabs application = (UIsInMultipleTabs) getApplication();
- String message = "This is UI number "
- + ++application.numberOfUIsOpened;
+ Application application = Application.getCurrent();
+ AtomicInteger count = numberOfUIsOpened.get(application);
+ if (count == null) {
+ numberOfUIsOpened.putIfAbsent(application, new AtomicInteger());
+ // Get our added instance or another instance that was added by
+ // another thread between previous get and putIfAbsent
+ count = numberOfUIsOpened.get(application);
+ }
+ int currentCount = count.incrementAndGet();
+ String message = "This is UI number " + currentCount;
addComponent(new Label(message));
}
}
- public UIsInMultipleTabs() {
- addUIProvider(new AbstractUIProvider() {
- @Override
- public Class<? extends UI> getUIClass(Application application,
- WrappedRequest request) {
- return TabUI.class;
- }
- });
+ @Override
+ public Class<? extends UI> getUIClass(Application application,
+ WrappedRequest request) {
+ return TabUI.class;
}
@Override