diff options
author | Artur Signell <artur@vaadin.com> | 2012-10-24 08:52:27 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-10-24 08:52:27 +0000 |
commit | 73a199d19d730a110689d8a5bb30e2a9f068ff9a (patch) | |
tree | 7927f27e932be295deba927884c2a183eceb771c /uitest | |
parent | e88ecf6c27815ccf99c19259838938f4a2832a27 (diff) | |
parent | eaffcb2f31b8be2b8738685a6e30607dadf58d41 (diff) | |
download | vaadin-framework-73a199d19d730a110689d8a5bb30e2a9f068ff9a.tar.gz vaadin-framework-73a199d19d730a110689d8a5bb30e2a9f068ff9a.zip |
Merge "Create UIProvider & Extension for easily opening popups. (#9513)"
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java b/uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java new file mode 100644 index 0000000000..d69ebfab56 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/BrowserPopupExtensionTest.java @@ -0,0 +1,107 @@ +/* + * Copyright 2012 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.extensions; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.server.BrowserPopupOpener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.components.popupview.ReopenPopupView; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.NativeButton; + +public class BrowserPopupExtensionTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + List<Class<? extends Component>> components = new ArrayList<Class<? extends Component>>(); + components.add(Button.class); + components.add(NativeButton.class); + components.add(Link.class); + components.add(CssLayout.class); + components.add(Label.class); + addComponents(components, "http://vaadin.com/download/nightly/"); + + Button uiClassButton = new Button("Open UI class"); + new BrowserPopupOpener(ReopenPopupView.class).extend(uiClassButton); + addComponent(uiClassButton); + + Button uiWithPath = new Button("Open UI class with path"); + new BrowserPopupOpener(ReopenPopupView.class, "foobar") + .extend(uiWithPath); + addComponent(uiWithPath); + + Button withPopupFeaturesButton = new Button("Open with features"); + BrowserPopupOpener featuresPopup = new BrowserPopupOpener( + "http://vaadin.com/download/nightly/"); + featuresPopup.setFeatures("width=400,height=400"); + featuresPopup.extend(withPopupFeaturesButton); + addComponent(withPopupFeaturesButton); + } + + public void addComponents(List<Class<? extends Component>> components, + String URL) { + final HorizontalLayout hl = new HorizontalLayout(); + for (Class<? extends Component> cls : components) { + try { + AbstractComponent c = (AbstractComponent) cls.newInstance(); + c.setId(cls.getName()); + c.setCaption(cls.getName()); + c.setDescription(URL); + c.setWidth("100px"); + c.setHeight("100px"); + hl.addComponent(c); + + new BrowserPopupOpener(URL).extend(c); + + if (c instanceof Button) { + ((Button) c).addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + } + }); + } + } catch (Exception e) { + System.err.println("Could not instatiate " + cls.getName()); + } + } + addComponent(hl); + } + + @Override + protected String getTestDescription() { + return "Test for " + BrowserPopupOpener.class.getSimpleName() + + " features"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(9513); + } + +} |