diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-30 17:24:36 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-08-30 17:24:36 +0300 |
commit | 7b25b3886ea95bc6495506fbe9472e45fcbde684 (patch) | |
tree | 0b93cb65dab437feb46720659a63b8f1ef48f7f4 /uitest/src/com/vaadin/tests/components/AbstractTestUI.java | |
parent | 8941056349e302e687e40e94c13709e75f256d73 (diff) | |
download | vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.tar.gz vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.zip |
Renamed tests -> uitest and tests/testbench -> uitest/src (#9299)
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/AbstractTestUI.java')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/AbstractTestUI.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java new file mode 100644 index 0000000000..ff235c5d9f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -0,0 +1,69 @@ +package com.vaadin.tests.components; + +import com.vaadin.Application; +import com.vaadin.server.AbstractWebApplicationContext; +import com.vaadin.server.WebBrowser; +import com.vaadin.server.WrappedRequest; +import com.vaadin.service.ApplicationContext; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +public abstract class AbstractTestUI extends UI { + + @Override + public void init(WrappedRequest request) { + getPage().setTitle(getClass().getName()); + + Label label = new Label(getTestDescription(), ContentMode.XHTML); + label.setWidth("100%"); + + layout = new VerticalLayout(); + + getContent().addComponent(label); + getContent().addComponent(layout); + ((VerticalLayout) getContent()).setExpandRatio(layout, 1); + + setup(request); + } + + private VerticalLayout layout; + + protected VerticalLayout getLayout() { + return layout; + } + + protected abstract void setup(WrappedRequest request); + + @Override + public void addComponent(Component c) { + getLayout().addComponent(c); + } + + @Override + public void removeComponent(Component c) { + getLayout().removeComponent(c); + } + + @Override + public void replaceComponent(Component oldComponent, Component newComponent) { + getLayout().replaceComponent(oldComponent, newComponent); + } + + protected abstract String getTestDescription(); + + protected abstract Integer getTicketNumber(); + + protected WebBrowser getBrowser() { + ApplicationContext context = Application.getCurrent().getContext(); + if (context instanceof AbstractWebApplicationContext) { + AbstractWebApplicationContext webContext = (AbstractWebApplicationContext) context; + return webContext.getBrowser(); + } + + return null; + } + +} |