diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-15 11:06:18 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-15 14:00:58 +0300 |
commit | 6b8412033e680ce6e5c7827ac504adf132305726 (patch) | |
tree | 0df05d16c324b285610af8910c126b58f4c490c5 /uitest/src/com/vaadin/tests/application | |
parent | 9192b0bb5e5e699b506b3d3e7df4cf295fbea44a (diff) | |
download | vaadin-framework-6b8412033e680ce6e5c7827ac504adf132305726.tar.gz vaadin-framework-6b8412033e680ce6e5c7827ac504adf132305726.zip |
Build uitest war with maven
Change-Id: I32625901ca27a282253df44c6e776cf9632bacda
Diffstat (limited to 'uitest/src/com/vaadin/tests/application')
43 files changed, 0 insertions, 3046 deletions
diff --git a/uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java b/uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java deleted file mode 100644 index f1548ea6c2..0000000000 --- a/uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Label; -import com.vaadin.ui.LegacyWindow; - -public class ApplicationCloseTest extends TestBase { - - private String memoryConsumer; - - @Override - protected void setup() { - Label applications = new Label("Applications in session: <br/>", - ContentMode.HTML); - if (getContext() != null) { - applications.setValue(applications.getValue() + "App: " - + getContext() + "<br/>"); - } - applications.setValue(applications.getValue() + "<br/><br/>"); - - addComponent(applications); - Label thisApp = new Label("This applications: " + this); - Button close = new Button("Close this", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - LegacyWindow ui = (LegacyWindow) event.getButton().getUI(); - ui.getApplication().close(); - } - }); - - StringBuilder sb = new StringBuilder(); - - // 100 bytes - String str = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; - - int MB = 5; - for (int i = 0; i < MB * 10000; i++) { - sb.append(str); - } - - memoryConsumer = sb.toString(); - long totalUsage = Runtime.getRuntime().totalMemory(); - String totalUsageString = totalUsage / 1000 / 1000 + "MiB"; - Label memoryUsage = new Label( - "Using about " - + memoryConsumer.length() - / 1000 - / 1000 - + "MiB memory for this application.<br/>Total memory usage reported as " - + totalUsageString + "<br/>", ContentMode.HTML); - - addComponent(thisApp); - addComponent(memoryUsage); - addComponent(close); - } - - @Override - protected String getDescription() { - return "Click close to close the application and open a new one"; - } - - @Override - protected Integer getTicketNumber() { - return 3732; - } - -} diff --git a/uitest/src/com/vaadin/tests/application/CommErrorEmulatorServlet.java b/uitest/src/com/vaadin/tests/application/CommErrorEmulatorServlet.java deleted file mode 100644 index 116ef1c1f2..0000000000 --- a/uitest/src/com/vaadin/tests/application/CommErrorEmulatorServlet.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.vaadin.server.DeploymentConfiguration; -import com.vaadin.server.RequestHandler; -import com.vaadin.server.ServiceException; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinServlet; -import com.vaadin.server.VaadinServletService; -import com.vaadin.server.VaadinSession; -import com.vaadin.server.communication.HeartbeatHandler; -import com.vaadin.server.communication.UidlRequestHandler; -import com.vaadin.ui.UI; - -public class CommErrorEmulatorServlet extends VaadinServlet { - - private Map<UI, Integer> uidlResponseCode = Collections - .synchronizedMap(new HashMap<UI, Integer>()); - private Map<UI, Integer> heartbeatResponseCode = Collections - .synchronizedMap(new HashMap<UI, Integer>()); - - private final CommErrorUIDLRequestHandler uidlHandler = new CommErrorUIDLRequestHandler(); - private final CommErrorHeartbeatHandler heartbeatHandler = new CommErrorHeartbeatHandler(); - - public class CommErrorUIDLRequestHandler extends UidlRequestHandler { - @Override - public boolean synchronizedHandleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - UI ui = session.getService().findUI(request); - if (ui != null && uidlResponseCode.containsKey(ui)) { - response.sendError(uidlResponseCode.get(ui), "Error set in UI"); - return true; - } - - return super.synchronizedHandleRequest(session, request, response); - } - } - - public class CommErrorHeartbeatHandler extends HeartbeatHandler { - @Override - public boolean synchronizedHandleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - UI ui = session.getService().findUI(request); - if (ui != null && heartbeatResponseCode.containsKey(ui)) { - response.sendError(heartbeatResponseCode.get(ui), - "Error set in UI"); - return true; - } - - return super.synchronizedHandleRequest(session, request, response); - } - - } - - public class CommErrorEmulatorService extends VaadinServletService { - - public CommErrorEmulatorService(VaadinServlet servlet, - DeploymentConfiguration deploymentConfiguration) - throws ServiceException { - super(servlet, deploymentConfiguration); - } - - @Override - protected List<RequestHandler> createRequestHandlers() - throws ServiceException { - List<RequestHandler> handlers = super.createRequestHandlers(); - handlers.add(uidlHandler); - handlers.add(heartbeatHandler); - return handlers; - } - } - - @Override - protected VaadinServletService createServletService( - DeploymentConfiguration deploymentConfiguration) - throws ServiceException { - CommErrorEmulatorService s = new CommErrorEmulatorService(this, - deploymentConfiguration); - s.init(); - return s; - } - - public void setUIDLResponseCode(final UI ui, int responseCode, - final int delay) { - uidlResponseCode.put(ui, responseCode); - System.out.println("Responding with " + responseCode - + " to UIDL requests for " + ui + " for the next " + delay - + "s"); - - new Thread(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(delay * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Handing UIDL requests normally again"); - - uidlResponseCode.remove(ui); - } - }).start(); - } - - public void setHeartbeatResponseCode(final UI ui, int responseCode, - final int delay) { - heartbeatResponseCode.put(ui, responseCode); - - System.out.println("Responding with " + responseCode - + " to heartbeat requests for " + ui + " for the next " + delay - + "s"); - - new Thread(new Runnable() { - - @Override - public void run() { - try { - Thread.sleep(delay * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Handing heartbeat requests normally again"); - heartbeatResponseCode.remove(ui); - } - }).start(); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/CommErrorEmulatorUI.java b/uitest/src/com/vaadin/tests/application/CommErrorEmulatorUI.java deleted file mode 100644 index 080d36fa48..0000000000 --- a/uitest/src/com/vaadin/tests/application/CommErrorEmulatorUI.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.annotations.Theme; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.data.Property.ValueChangeListener; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinServlet; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.Component; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; - -/** - * - * @since - * @author Vaadin Ltd - */ -@Theme("valo") -public class CommErrorEmulatorUI extends AbstractTestUIWithLog { - - private static class Response { - private Integer code; - private Integer time; - - /** - * @param code - * @param time - */ - public Response(Integer code, Integer time) { - super(); - this.code = code; - this.time = time; - } - - } - - private Response uidlResponse = new Response(503, 10); - private Response heartbeatResponse = new Response(200, 10); - - // Server exceptions will occur in this test as we are writing the response - // here and not letting the servlet write it - @Override - protected void setup(VaadinRequest request) { - String transport = request.getParameter("transport"); - - if ("websocket".equalsIgnoreCase(transport)) { - log("Using websocket"); - } else if ("websocket-xhr".equalsIgnoreCase(transport)) { - log("Using websocket for push only"); - } else if ("long-polling".equalsIgnoreCase(transport)) { - log("Using long-polling"); - } else { - log("Using XHR"); - } - getLayout().setSpacing(true); - addComponent(createConfigPanel()); - addComponent(createServerConfigPanel()); - - addComponent(new Button("Say hello", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Hello"); - } - })); - } - - /** - * @since - * @return - */ - private Component createServerConfigPanel() { - Panel p = new Panel("Server config (NOTE: affects all users)"); - VerticalLayout vl = new VerticalLayout(); - vl.setSpacing(true); - vl.setMargin(true); - p.setContent(vl); - vl.addComponent(createTemporaryResponseCodeSetters("UIDL", uidlResponse)); - vl.addComponent(createTemporaryResponseCodeSetters("Heartbeat", - heartbeatResponse)); - vl.addComponent(new Button("Activate", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - if (uidlResponse.code != null && uidlResponse.code != 200) { - getServlet().setUIDLResponseCode(CommErrorEmulatorUI.this, - uidlResponse.code, uidlResponse.time); - log("Responding with " + uidlResponse.code - + " to UIDL requests for " + uidlResponse.time - + "s"); - } - if (heartbeatResponse.code != null - && heartbeatResponse.code != 200) { - getServlet().setHeartbeatResponseCode( - CommErrorEmulatorUI.this, heartbeatResponse.code, - heartbeatResponse.time); - log("Responding with " + heartbeatResponse.code - + " to heartbeat requests for " - + heartbeatResponse.time + "s"); - } - } - })); - - return p; - } - - private Component createConfigPanel() { - Panel p = new Panel("Reconnect dialog configuration"); - p.setSizeUndefined(); - final TextField reconnectDialogMessage = new TextField( - "Reconnect message"); - reconnectDialogMessage.setWidth("50em"); - reconnectDialogMessage.setValue(getReconnectDialogConfiguration() - .getDialogText()); - reconnectDialogMessage - .addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getReconnectDialogConfiguration().setDialogText( - reconnectDialogMessage.getValue()); - } - }); - - final TextField reconnectDialogGaveUpMessage = new TextField( - "Reconnect gave up message"); - reconnectDialogGaveUpMessage.setWidth("50em"); - - reconnectDialogGaveUpMessage.setValue(getReconnectDialogConfiguration() - .getDialogTextGaveUp()); - reconnectDialogGaveUpMessage - .addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getReconnectDialogConfiguration().setDialogTextGaveUp( - reconnectDialogGaveUpMessage.getValue()); - } - }); - final TextField reconnectDialogReconnectAttempts = new TextField( - "Reconnect attempts"); - reconnectDialogReconnectAttempts.setConverter(Integer.class); - reconnectDialogReconnectAttempts - .setConvertedValue(getReconnectDialogConfiguration() - .getReconnectAttempts()); - reconnectDialogReconnectAttempts - .addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getReconnectDialogConfiguration().setReconnectAttempts( - (Integer) reconnectDialogReconnectAttempts - .getConvertedValue()); - } - }); - final TextField reconnectDialogReconnectInterval = new TextField( - "Reconnect interval (ms)"); - reconnectDialogReconnectInterval.setConverter(Integer.class); - reconnectDialogReconnectInterval - .setConvertedValue(getReconnectDialogConfiguration() - .getReconnectInterval()); - reconnectDialogReconnectInterval - .addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getReconnectDialogConfiguration().setReconnectInterval( - (Integer) reconnectDialogReconnectInterval - .getConvertedValue()); - } - }); - - final TextField reconnectDialogGracePeriod = new TextField( - "Reconnect dialog grace period (ms)"); - reconnectDialogGracePeriod.setConverter(Integer.class); - reconnectDialogGracePeriod - .setConvertedValue(getReconnectDialogConfiguration() - .getDialogGracePeriod()); - reconnectDialogGracePeriod - .addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getReconnectDialogConfiguration().setDialogGracePeriod( - (Integer) reconnectDialogGracePeriod - .getConvertedValue()); - } - }); - - final CheckBox reconnectDialogModal = new CheckBox( - "Reconnect dialog modality"); - reconnectDialogModal.setValue(getReconnectDialogConfiguration() - .isDialogModal()); - reconnectDialogModal.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - getReconnectDialogConfiguration().setDialogModal( - reconnectDialogModal.getValue()); - } - }); - - VerticalLayout vl = new VerticalLayout(); - vl.setMargin(true); - vl.setSpacing(true); - p.setContent(vl); - vl.addComponents(reconnectDialogMessage, reconnectDialogGaveUpMessage, - reconnectDialogGracePeriod, reconnectDialogModal, - reconnectDialogReconnectAttempts, - reconnectDialogReconnectInterval); - return p; - } - - private Component createTemporaryResponseCodeSetters(String type, - final Response response) { - - HorizontalLayout hl = new HorizontalLayout(); - hl.setSpacing(true); - hl.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); - Label l1 = new Label("Respond to " + type + " requests with code"); - final TextField responseCode = new TextField(null, "" + response.code); - responseCode.setConverter(Integer.class); - responseCode.setWidth("5em"); - Label l2 = new Label("for the following"); - final TextField timeField = new TextField(null, "" + response.time); - timeField.setConverter(Integer.class); - timeField.setWidth("5em"); - Label l3 = new Label("seconds"); - - responseCode.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Integer code = (Integer) responseCode.getConvertedValue(); - response.code = code; - } - }); - - timeField.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - Integer time = (Integer) timeField.getConvertedValue(); - response.time = time; - } - }); - - hl.addComponents(l1, responseCode, l2, timeField, l3); - return hl; - } - - protected CommErrorEmulatorServlet getServlet() { - return (CommErrorEmulatorServlet) VaadinServlet.getCurrent(); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/ConfirmBrowserTabClose.java b/uitest/src/com/vaadin/tests/application/ConfirmBrowserTabClose.java deleted file mode 100644 index 3d3d84f9bd..0000000000 --- a/uitest/src/com/vaadin/tests/application/ConfirmBrowserTabClose.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; - -public class ConfirmBrowserTabClose extends AbstractTestUIWithLog { - - @Override - protected void setup(VaadinRequest request) { - // To test the behavior, do - // 1. Open the test in the browser - // 2. Close the browser tab/window - // 3. Choose to stay on the page after all - // 4. Click the button - // There should be no error - Button b = new Button("Say hello", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Hello"); - } - }); - addComponent(b); - getPage().getJavaScript().eval( - "window.addEventListener('beforeunload', function (e) {" - + "var confirmationMessage = 'Please stay!';" - + "e.returnValue = confirmationMessage;" - + "return confirmationMessage;" + "});"); - } -} diff --git a/uitest/src/com/vaadin/tests/application/CriticalNotifications.java b/uitest/src/com/vaadin/tests/application/CriticalNotifications.java deleted file mode 100644 index 14b4cb62e9..0000000000 --- a/uitest/src/com/vaadin/tests/application/CriticalNotifications.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import java.io.IOException; - -import com.vaadin.server.SystemMessages; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinService; -import com.vaadin.shared.JsonConstants; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.CheckBox; - -public class CriticalNotifications extends AbstractTestUI { - - private SystemMessages systemMessages; - private CheckBox includeDetails; - - @Override - protected void setup(VaadinRequest request) { - systemMessages = VaadinService.getCurrent().getSystemMessages( - getLocale(), request); - - includeDetails = new CheckBox("Include details"); - addComponent(includeDetails); - - Button sessionExpired = new Button("Session expired"); - addComponent(sessionExpired); - sessionExpired.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - showCriticalNotification( - systemMessages.getSessionExpiredCaption(), - systemMessages.getSessionExpiredMessage(), - getDetailsMessage(), - systemMessages.getSessionExpiredURL()); - - } - }); - - Button authenticationError = new Button("Authentication error"); - addComponent(authenticationError); - authenticationError.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - showCriticalNotification( - systemMessages.getAuthenticationErrorCaption(), - systemMessages.getAuthenticationErrorMessage(), - getDetailsMessage(), - systemMessages.getAuthenticationErrorURL()); - - } - }); - - Button communicationError = new Button("Communication error"); - addComponent(communicationError); - communicationError.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - showCriticalNotification( - systemMessages.getCommunicationErrorCaption(), - systemMessages.getCommunicationErrorMessage(), - getDetailsMessage(), - systemMessages.getCommunicationErrorURL()); - - } - }); - - Button internalError = new Button("Internal error"); - addComponent(internalError); - internalError.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - showCriticalNotification( - systemMessages.getInternalErrorCaption(), - systemMessages.getInternalErrorMessage(), - getDetailsMessage(), - systemMessages.getInternalErrorURL()); - - } - }); - - Button cookiesDisabled = new Button("Cookies disabled"); - addComponent(cookiesDisabled); - cookiesDisabled.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - showCriticalNotification( - systemMessages.getCookiesDisabledCaption(), - systemMessages.getCookiesDisabledMessage(), - getDetailsMessage(), - systemMessages.getCookiesDisabledURL()); - - } - }); - Button custom = new Button("Custom"); - addComponent(custom); - custom.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - showCriticalNotification("Custom caption", "Custom message", - "Custom details", "custom url"); - - } - }); - } - - protected String getDetailsMessage() { - if (includeDetails.getValue()) { - return "Some details for the error"; - } else { - return null; - } - } - - protected void showCriticalNotification(String caption, String message, - String details, String url) { - VaadinService service = VaadinService.getCurrent(); - VaadinResponse response = VaadinService.getCurrentResponse(); - - try { - service.writeStringResponse(response, - JsonConstants.JSON_CONTENT_TYPE, VaadinService - .createCriticalNotificationJSON(caption, message, - details, url)); - } catch (IOException e) { - e.printStackTrace(); - } - - } -} diff --git a/uitest/src/com/vaadin/tests/application/CriticalNotificationsTest.java b/uitest/src/com/vaadin/tests/application/CriticalNotificationsTest.java deleted file mode 100644 index 6229edc1ee..0000000000 --- a/uitest/src/com/vaadin/tests/application/CriticalNotificationsTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.CheckBoxElement; -import com.vaadin.testbench.elements.NotificationElement; -import com.vaadin.testbench.parallel.BrowserUtil; -import com.vaadin.tests.tb3.MultiBrowserThemeTest; - -public class CriticalNotificationsTest extends MultiBrowserThemeTest { - - @Override - protected boolean useNativeEventsForIE() { - if (BrowserUtil.isIE(getDesiredCapabilities(), 11)) { - // Use JavaScript events only for IE11 - return false; - } else { - return true; - } - } - - @Test - public void internalError() throws Exception { - testCriticalNotification("Internal error"); - } - - @Test - public void internalErrorDetails() throws Exception { - testCriticalNotification("Internal error", true); - } - - @Test - public void custom() throws Exception { - testCriticalNotification("Custom"); - } - - @Test - public void sessionExpired() throws Exception { - testCriticalNotification("Session expired"); - } - - @Test - public void sessionExpiredDetails() throws Exception { - testCriticalNotification("Session expired", true); - } - - private void testCriticalNotification(String buttonCaption) - throws Exception { - testCriticalNotification(buttonCaption, false); - } - - private void testCriticalNotification(String buttonCaption, - boolean withDetails) throws Exception { - openTestURL(); // "theme=" + getTheme()); - if (withDetails) { - click($(CheckBoxElement.class).caption("Include details").first()); - } - $(ButtonElement.class).caption(buttonCaption).first().click(); - // Give the notification some time to animate - sleep(1000); - compareScreen($(NotificationElement.class).first(), - "systemnotification"); - } - - @Override - protected Class<?> getUIClass() { - return CriticalNotifications.class; - } - -} diff --git a/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java b/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java deleted file mode 100644 index 9c95479bec..0000000000 --- a/uitest/src/com/vaadin/tests/application/DeploymentConfiguration.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.vaadin.tests.application; - -import java.util.Properties; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.shared.ui.MarginInfo; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Label; - -public class DeploymentConfiguration extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - Properties params = getSession().getConfiguration().getInitParameters(); - getLayout().setMargin(new MarginInfo(true, false, false, false)); - - for (Object key : params.keySet()) { - addComponent(new Label(key + ": " - + params.getProperty((String) key))); - } - } - - @Override - protected String getTestDescription() { - return "Init parameters:"; - } -} diff --git a/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java b/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java deleted file mode 100644 index 9a51980c9e..0000000000 --- a/uitest/src/com/vaadin/tests/application/DeploymentConfigurationTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class DeploymentConfigurationTest extends MultiBrowserTest { - - @Test - public void testParameters() { - openTestURL(); - List<String> texts = new ArrayList<String>(Arrays.asList( - "Init parameters:", "legacyPropertyToString: false", - "closeIdleSessions: true", "productionMode: false", - "testParam: 42", "heartbeatInterval: 301", - "resourceCacheTime: 3601")); - - for (LabelElement label : $(LabelElement.class).all()) { - assertTrue(label.getText() + " not found", - texts.contains(label.getText())); - texts.remove(label.getText()); - } - assertTrue(texts.isEmpty()); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java deleted file mode 100644 index a7c9239fae..0000000000 --- a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import java.util.ArrayList; -import java.util.List; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Label; - -public class DetachOldUIOnReload extends AbstractTestUIWithLog { - private static final String PERSISTENT_MESSAGES_ATTRIBUTE = DetachOldUIOnReload.class - .getName() + ".sessionMessages"; - - @Override - protected void setup(VaadinRequest request) { - addComponent(new Label("This is UI " + getUIId())); - addComponent(new Button("Reload page", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - getPage().reload(); - } - })); - addComponent(new Button("Read log messages from session", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - for (String message : getSessionMessages(false)) { - log(message); - } - } - })); - } - - private List<String> getSessionMessages(boolean storeIfNeeded) { - @SuppressWarnings("unchecked") - List<String> messages = (List<String>) getSession().getAttribute( - PERSISTENT_MESSAGES_ATTRIBUTE); - if (messages == null) { - messages = new ArrayList<String>(); - if (storeIfNeeded) { - getSession().setAttribute(PERSISTENT_MESSAGES_ATTRIBUTE, - messages); - } - } - return messages; - } - - private void logToSession(String message) { - getSessionMessages(true).add(message); - } - - @Override - public void detach() { - super.detach(); - logToSession("UI " + getUIId() + " has been detached"); - } - - @Override - protected String getTestDescription() { - return "Tests that the previous UI gets cleaned immediately when refreshing."; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(10338); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java deleted file mode 100644 index 1e156c3e46..0000000000 --- a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReloadTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import java.util.List; - -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class DetachOldUIOnReloadTest extends MultiBrowserTest { - - private static final String RELOAD = "Reload page"; - private static final String READ_LOG = "Read log messages from session"; - - @Test - public void testDetachesUIOnReload() throws InterruptedException { - openTestURL(); - List<LabelElement> labels = $(LabelElement.class).all(); - assertEquals("initial label incorrect", "This is UI 0", - lastLabelText(labels)); - - assertFalse("reloading button not found", $(ButtonElement.class) - .caption(RELOAD).all().isEmpty()); - - openTestURL(); - click(READ_LOG); - - checkLabels("first", 1); - - click(RELOAD); - click(READ_LOG); - - checkLabels("second", 2); - - openTestURL(); - click(READ_LOG); - - checkLabels("third", 3); - - // restarting reverts to 0 - openTestURL("restartApplication"); - - checkLabels("final", 0); - } - - private void checkLabels(String descriptor, int index) { - List<LabelElement> labels = $(LabelElement.class).all(); - assertEquals( - String.format("label incorrect after %s reload", descriptor), - String.format("This is UI %s", index), lastLabelText(labels)); - if (!"final".equals(descriptor)) { - assertEquals(String.format("log message incorrect after %s reload", - descriptor), String.format("%s. UI %s has been detached", - index, index - 1), labels.get(0).getText()); - } - } - - private String lastLabelText(List<LabelElement> labels) { - return labels.get(labels.size() - 1).getText(); - } - - private void click(String caption) { - $(ButtonElement.class).caption(caption).first().click(); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java deleted file mode 100644 index a09c4c845a..0000000000 --- a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEvent.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.event.ShortcutAction.KeyCode; -import com.vaadin.tests.components.AbstractTestCase; -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.FormLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.LegacyWindow; -import com.vaadin.ui.PasswordField; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; - -public class ErrorInUnloadEvent extends AbstractTestCase { - - private LegacyWindow mainWindow; - private Object user = null; - - @Override - public void init() { - if (user == null) { - showLoginWindow(); - } else { - showMainWindow(); - } - } - - private void showLoginWindow() { - if (mainWindow == null) { - mainWindow = new LegacyWindow(); - setMainWindow(mainWindow); - } else { - mainWindow.removeAllComponents(); - } - mainWindow.setCaption("Please login"); - - FormLayout formLayout = new FormLayout(); - final TextField userField = new TextField("Username"); - userField.setId("user"); - final PasswordField passwordField = new PasswordField("Password"); - passwordField.setId("pwd"); - Button login = new Button("login"); - login.setId("loginButton"); - login.setClickShortcut(KeyCode.ENTER); - formLayout.addComponent(userField); - formLayout.addComponent(passwordField); - formLayout.addComponent(login); - mainWindow.setContent(formLayout); - - login.addListener(new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - String username = userField.getValue(); - String password = passwordField.getValue(); - - user = username; - showMainWindow(); - } - }); - } - - private void showMainWindow() { - if (mainWindow == null) { - mainWindow = new LegacyWindow(); - setMainWindow(mainWindow); - } else { - mainWindow.removeAllComponents(); - } - VerticalLayout root = new VerticalLayout(); - root.addComponent(createHeader()); - - mainWindow.addComponent(root); - } - - private Component createHeader() { - HorizontalLayout header = new HorizontalLayout(); - header.addStyleName("header-background"); - Label title = new Label("...Title..."); - title.addStyleName("header-title"); - header.addComponent(title); - Button logout = new Button("Logout"); - logout.addListener(new ClickListener() { - @Override - public void buttonClick(final ClickEvent event) { - user = null; - showLoginWindow(); - } - - }); - header.addComponent(logout); - return header; - } - - @Override - protected String getDescription() { - return "Enter a text in the password field and press enter. Then reload the page. No error message should be printed about ignoring a variable change."; - } - - @Override - protected Integer getTicketNumber() { - return 6316; - } -} diff --git a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java b/uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java deleted file mode 100644 index fa316c6749..0000000000 --- a/uitest/src/com/vaadin/tests/application/ErrorInUnloadEventTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.testbench.elements.PasswordFieldElement; -import com.vaadin.testbench.elements.TextFieldElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class ErrorInUnloadEventTest extends MultiBrowserTest { - - @Test - public void testError() { - openTestURL(); - TextFieldElement user = $(TextFieldElement.class).id("user"); - user.focus(); - user.sendKeys("a"); - PasswordFieldElement pass = $(PasswordFieldElement.class).id("pwd"); - pass.focus(); - pass.sendKeys("d"); - ButtonElement button = $(ButtonElement.class).id("loginButton"); - button.click(); - - assertEquals("label is incorrect, error while loading page", - "...Title...", $(LabelElement.class).first().getText()); - - openTestURL(); - // no errors and page fully reloaded - assertTrue($(LabelElement.class).all().isEmpty()); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/HelloWorld.java b/uitest/src/com/vaadin/tests/application/HelloWorld.java deleted file mode 100644 index 28115c0cb9..0000000000 --- a/uitest/src/com/vaadin/tests/application/HelloWorld.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.ui.UI; - -/** - * A simple application to simplify doing quick testing of features when a full - * test case is not needed - */ -public class HelloWorld extends UI { - - @Override - protected void init(VaadinRequest request) { - - // Type your code here... - } -} diff --git a/uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java b/uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java deleted file mode 100644 index 508ac818f6..0000000000 --- a/uitest/src/com/vaadin/tests/application/MissingHierarchyDetection.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Component; -import com.vaadin.ui.CssLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.SelectiveRenderer; - -public class MissingHierarchyDetection extends AbstractTestUI { - - private boolean isChildRendered = true; - private BrokenCssLayout brokenLayout = new BrokenCssLayout(); - - private CssLayout normalLayout = new CssLayout(new Label( - "Normal layout child")); - - public class BrokenCssLayout extends CssLayout implements SelectiveRenderer { - public BrokenCssLayout() { - setCaption("Broken layout"); - Label label = new Label("Child component"); - label.setId("label"); - addComponent(label); - } - - @Override - public boolean isRendered(Component childComponent) { - return isChildRendered; - } - } - - @Override - protected void setup(VaadinRequest request) { - addComponent(brokenLayout); - addComponent(normalLayout); - addComponent(new Button("Toggle properly", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - toggle(true); - } - })); - addComponent(new Button("Toggle improperly", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - toggle(false); - } - })); - } - - private void toggle(boolean properly) { - isChildRendered = !isChildRendered; - if (properly) { - brokenLayout.markAsDirtyRecursive(); - } - - normalLayout.getComponent(0).setVisible(isChildRendered); - // Must also have a state change of the layout to trigger special case - // related to optimizations - normalLayout.setCaption("With child: " + isChildRendered); - } -} diff --git a/uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java b/uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java deleted file mode 100644 index 3d43b8f885..0000000000 --- a/uitest/src/com/vaadin/tests/application/MissingHierarchyDetectionTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.SingleBrowserTest; - -public class MissingHierarchyDetectionTest extends SingleBrowserTest { - @Test - public void testMissingHierarchyDetection() { - openTestURL(); - - Assert.assertTrue(isElementPresent(By.id("label"))); - - ButtonElement toggleProperly = $(ButtonElement.class).caption( - "Toggle properly").first(); - - toggleProperly.click(); - assertNoSystemNotifications(); - Assert.assertFalse(isElementPresent(By.id("label"))); - - toggleProperly.click(); - assertNoSystemNotifications(); - Assert.assertTrue(isElementPresent(LabelElement.class)); - - ButtonElement toggleInproperly = $(ButtonElement.class).caption( - "Toggle improperly").first(); - toggleInproperly.click(); - - assertSystemNotification(); - } -} diff --git a/uitest/src/com/vaadin/tests/application/NavigateWithOngoingXHR.java b/uitest/src/com/vaadin/tests/application/NavigateWithOngoingXHR.java deleted file mode 100644 index d32ecb583d..0000000000 --- a/uitest/src/com/vaadin/tests/application/NavigateWithOngoingXHR.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.application; - -import java.io.IOException; -import java.io.PrintWriter; - -import com.vaadin.server.ExternalResource; -import com.vaadin.server.RequestHandler; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinResponse; -import com.vaadin.server.VaadinSession; -import com.vaadin.shared.ui.progressindicator.ProgressIndicatorServerRpc; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Link; -import com.vaadin.ui.ProgressIndicator; - -public class NavigateWithOngoingXHR extends AbstractTestUI { - private final RequestHandler slowRequestHandler = new RequestHandler() { - @Override - public boolean handleRequest(VaadinSession session, - VaadinRequest request, VaadinResponse response) - throws IOException { - if ("/slowRequestHandler".equals(request.getPathInfo())) { - // Make the navigation request last longer to keep the - // communication error visible - // System.out.println("Got slow content request"); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - if (request.getParameter("download") != null) { - response.setHeader("Content-Disposition", "attachment"); - } - - response.setContentType("text/plain"); - PrintWriter writer = response.getWriter(); - writer.println("Loaded slowly"); - writer.close(); - - // System.out.println("Finished slow content request"); - - return true; - } - return false; - } - }; - - @Override - protected void setup(VaadinRequest request) { - addComponent(new ProgressIndicator() { - { - registerRpc(new ProgressIndicatorServerRpc() { - @Override - public void poll() { - // System.out.println("Pausing poll request"); - try { - // Make the XHR request last longer to make it - // easier to click the link at the right moment. - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - // System.out.println("Continuing poll request"); - } - }); - setPollingInterval(3000); - } - }); - - // Hacky URLs that are might not work in all deployment scenarios - addComponent(new Link("Navigate away", new ExternalResource( - "slowRequestHandler"))); - addComponent(new Link("Start download", new ExternalResource( - "slowRequestHandler?download"))); - } - - @Override - public void attach() { - super.attach(); - getSession().addRequestHandler(slowRequestHandler); - } - - @Override - public void detach() { - getSession().removeRequestHandler(slowRequestHandler); - super.detach(); - } - - @Override - protected String getTestDescription() { - return "Navigating away from a Vaadin page while there's an ongoing XHR request should not cause a communication error to be displayed"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(8891); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/PreserveWithExpiredHeartbeat.java b/uitest/src/com/vaadin/tests/application/PreserveWithExpiredHeartbeat.java deleted file mode 100644 index de45d2bccb..0000000000 --- a/uitest/src/com/vaadin/tests/application/PreserveWithExpiredHeartbeat.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.annotations.PreserveOnRefresh; -import com.vaadin.launcher.CustomDeploymentConfiguration; -import com.vaadin.launcher.CustomDeploymentConfiguration.Conf; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Label; - -@PreserveOnRefresh -@CustomDeploymentConfiguration({ @Conf(name = "heartbeatInterval", value = "5") }) -public class PreserveWithExpiredHeartbeat extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - Label label = new Label("UI with id " + getUIId() + " in session " - + getSession().getSession().getId()); - label.setId("idLabel"); - addComponent(label); - } -} diff --git a/uitest/src/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java b/uitest/src/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java deleted file mode 100644 index 04dbdca31e..0000000000 --- a/uitest/src/com/vaadin/tests/application/PreserveWithExpiredHeartbeatTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.SingleBrowserTest; - -public class PreserveWithExpiredHeartbeatTest extends SingleBrowserTest { - @Test - public void testNavigateBackAfterMissingHeartbeats() - throws InterruptedException { - final int heartbeatInterval = 5000; - - openTestURL(); - String originalId = getUiIdentification(); - - long startTime = System.currentTimeMillis(); - - while (System.currentTimeMillis() - startTime < heartbeatInterval * 3.1) { - // "Close" the tab - driver.get("about:blank"); - - sleep(heartbeatInterval / 2); - - // "Reopen" tab - openTestURL(); - - // Verify that that we still get the same UI - Assert.assertEquals("Original UI has been closed", originalId, - getUiIdentification()); - } - } - - private String getUiIdentification() { - return $(LabelElement.class).id("idLabel").getText(); - } -} diff --git a/uitest/src/com/vaadin/tests/application/ReconnectDialogThemeTest.java b/uitest/src/com/vaadin/tests/application/ReconnectDialogThemeTest.java deleted file mode 100644 index eb55a7fb5e..0000000000 --- a/uitest/src/com/vaadin/tests/application/ReconnectDialogThemeTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import javax.imageio.ImageIO; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.parallel.BrowserUtil; -import com.vaadin.testbench.parallel.TestCategory; -import com.vaadin.tests.tb3.CustomTestBenchCommandExecutor; -import com.vaadin.tests.tb3.MultiBrowserThemeTestWithProxy; - -@TestCategory("communication") -public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { - - static By reconnectDialogBy = By.className("v-reconnect-dialog"); - - @Test - public void reconnectDialogTheme() throws IOException { - openTestURL(); - ButtonElement helloButton = $(ButtonElement.class).caption("Say hello") - .first(); - helloButton.click(); - Assert.assertEquals("1. Hello from the server", getLogRow(0)); - disconnectProxy(); - helloButton.click(); - testBench().disableWaitForVaadin(); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - boolean present = isElementPresent(reconnectDialogBy); - return present; - } - }); - - WebElement dialog = findElement(reconnectDialogBy); - WebElement spinner = dialog.findElement(By.className("spinner")); - - // Hide spinner to make screenshot stable - executeScript("arguments[0].style.visibility='hidden';", spinner); - compareScreen("onscreen-without-spinner"); - - // Show spinner and make sure it is shown by comparing to the screenshot - // without a spinner - executeScript("arguments[0].style.visibility='visible';", spinner); - BufferedImage fullScreen = ImageIO.read(new ByteArrayInputStream( - ((TakesScreenshot) getDriver()) - .getScreenshotAs(OutputType.BYTES))); - BufferedImage spinnerImage = CustomTestBenchCommandExecutor - .cropToElement(spinner, fullScreen, - BrowserUtil.isIE8(getDesiredCapabilities())); - assertHasManyColors("Spinner is not shown", spinnerImage); - - } - - @Test - public void gaveUpTheme() throws IOException { - openTestURL("reconnectAttempts=3"); - - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - try { - return $(ButtonElement.class).first() != null; - } catch (Exception e) { - return false; - } - } - }); - - disconnectProxy(); - $(ButtonElement.class).first().click(); - - waitForReconnectDialogWithText("Server connection lost."); - compareScreen("gaveupdialog"); - - } - - private void waitForReconnectDialogWithText(final String text) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - try { - final WebElement reconnectDialog = findElement(ReconnectDialogThemeTest.reconnectDialogBy); - return reconnectDialog.findElement(By.className("text")) - .getText().equals(text); - } catch (Exception e) { - return false; - } - } - }, 10); - - } - - private void assertHasManyColors(String message, BufferedImage spinnerImage) { - int backgroundColor = spinnerImage.getRGB(0, 0); - for (int x = 0; x < spinnerImage.getWidth(); x++) { - for (int y = 0; y < spinnerImage.getHeight(); y++) { - if (Math.abs(spinnerImage.getRGB(x, y) - backgroundColor) > 50) { - return; - } - } - } - Assert.fail(message); - - } - - @Override - protected Class<?> getUIClass() { - return ReconnectDialogUI.class; - } - -} diff --git a/uitest/src/com/vaadin/tests/application/ReconnectDialogUI.java b/uitest/src/com/vaadin/tests/application/ReconnectDialogUI.java deleted file mode 100644 index 62de2d49c5..0000000000 --- a/uitest/src/com/vaadin/tests/application/ReconnectDialogUI.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; - -public class ReconnectDialogUI extends AbstractTestUIWithLog { - - @Override - protected void setup(VaadinRequest request) { - if (request.getParameter("reconnectAttempts") != null) { - getReconnectDialogConfiguration() - .setReconnectAttempts( - Integer.parseInt(request - .getParameter("reconnectAttempts"))); - } - Button b = new Button("Say hello"); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - log("Hello from the server"); - } - }); - - addComponent(b); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java b/uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java deleted file mode 100644 index b07124c216..0000000000 --- a/uitest/src/com/vaadin/tests/application/ReconnectDialogUITest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import com.jcraft.jsch.JSchException; -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.parallel.TestCategory; -import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; - -@TestCategory("communication") -public class ReconnectDialogUITest extends MultiBrowserTestWithProxy { - - @Test - public void reconnectTogglesBodyStyle() throws JSchException { - openTestURL(); - getButton().click(); - disconnectProxy(); - getButton().click(); - waitForReconnectDialogPresent(); - WebElement body = findElement(By.xpath("//body")); - Assert.assertTrue("Body should have a style name when reconnecting", - hasCssClass(body, "v-reconnecting")); - connectProxy(); - waitForReconnectDialogToDisappear(); - Assert.assertFalse( - "Body should no longer have a style name when reconnected", - hasCssClass(body, "v-reconnecting")); - } - - @Test - public void reconnectDialogShownAndDisappears() throws JSchException { - openTestURL(); - getButton().click(); - Assert.assertEquals("1. Hello from the server", getLogRow(0)); - disconnectProxy(); - getButton().click(); - waitForReconnectDialogWithText("Server connection lost, trying to reconnect..."); - connectProxy(); - waitForReconnectDialogToDisappear(); - Assert.assertEquals("2. Hello from the server", getLogRow(0)); - } - - private void waitForReconnectDialogWithText(final String text) { - waitForReconnectDialogPresent(); - final WebElement reconnectDialog = findElement(ReconnectDialogThemeTest.reconnectDialogBy); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return reconnectDialog.findElement(By.className("text")) - .getText().equals(text); - } - }, 10); - - } - - private void waitForReconnectDialogToDisappear() { - waitForElementNotPresent(ReconnectDialogThemeTest.reconnectDialogBy); - - } - - private void waitForReconnectDialogPresent() { - waitForElementPresent(ReconnectDialogThemeTest.reconnectDialogBy); - } - - private WebElement getButton() { - return $(ButtonElement.class).first(); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/RefreshFragmentChangeTest.java b/uitest/src/com/vaadin/tests/application/RefreshFragmentChangeTest.java deleted file mode 100644 index ea415bcaae..0000000000 --- a/uitest/src/com/vaadin/tests/application/RefreshFragmentChangeTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.vaadin.tests.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class RefreshFragmentChangeTest extends MultiBrowserTest { - @Override - protected Class<?> getUIClass() { - return com.vaadin.tests.application.RefreshStatePreserve.class; - } - - @Test - public void testFragmentChange() throws Exception { - openTestURL(); - assertLogText("1. Initial fragment: null"); - getDriver().get(getTestUrl() + "#asdf"); - assertLogText("2. Fragment changed to asdf"); - openTestURL(); - assertLogText("3. Fragment changed to null"); - } - - private void assertLogText(String expected) { - waitForElementPresent(By.className("v-label")); - Assert.assertEquals("Incorrect log text,", expected, getLogRow(0)); - } -} diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java b/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java deleted file mode 100644 index e7f81167d9..0000000000 --- a/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.annotations.PreserveOnRefresh; -import com.vaadin.server.Page.UriFragmentChangedEvent; -import com.vaadin.server.Page.UriFragmentChangedListener; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Label; - -@PreserveOnRefresh -public class RefreshStatePreserve extends AbstractTestUIWithLog { - - @Override - protected void setup(VaadinRequest request) { - // Internal parameter sent by vaadinBootstrap.js, - addComponent(new Label("window.name: " + request.getParameter("v-wn"))); - addComponent(new Label("UI id: " + getUIId())); - - log("Initial fragment: " + getPage().getUriFragment()); - getPage().addUriFragmentChangedListener( - new UriFragmentChangedListener() { - @Override - public void uriFragmentChanged(UriFragmentChangedEvent event) { - log("Fragment changed to " + event.getUriFragment()); - } - }); - } - - @Override - protected String getTestDescription() { - return "Refreshing the browser window should preserve the state"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(8068); - } -} diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTest.java b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTest.java deleted file mode 100644 index a54d8b4ce9..0000000000 --- a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.vaadin.tests.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class RefreshStatePreserveTest extends MultiBrowserTest { - private static String UI_ID_TEXT = "UI id: 0"; - - @Test - public void testPreserveState() throws Exception { - openTestURL(); - assertCorrectState(); - // URL needs to be different or some browsers don't count it as history - openTestURL("debug"); - assertCorrectState(); - executeScript("history.back()"); - assertCorrectState(); - } - - private void assertCorrectState() { - waitForElementPresent(By.className("v-label")); - LabelElement uiIdLabel = $(LabelElement.class).get(7); - Assert.assertEquals("Incorrect UI id,", UI_ID_TEXT, uiIdLabel.getText()); - } -} diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java deleted file mode 100644 index ff9c84a20a..0000000000 --- a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.annotations.PreserveOnRefresh; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Label; - -@PreserveOnRefresh -public class RefreshStatePreserveTitle extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - getPage().setTitle("TEST"); - addComponent(new Label( - "Refresh the page and observe that window title 'TEST' is lost.")); - } - - @Override - protected String getTestDescription() { - return "Refreshing the browser window should preserve the window title"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(11054); - } -} diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java deleted file mode 100644 index e2740f9537..0000000000 --- a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitleTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.vaadin.tests.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class RefreshStatePreserveTitleTest extends MultiBrowserTest { - @Test - public void testReloadingPageDoesNotResetTitle() throws Exception { - openTestURL(); - assertTitleText(); - openTestURL(); - assertTitleText(); - } - - private void assertTitleText() { - Assert.assertEquals("Incorrect page title,", "TEST", driver.getTitle()); - } -} diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java b/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java deleted file mode 100644 index d8f7fface3..0000000000 --- a/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemoval.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.vaadin.tests.application; - -import java.lang.reflect.Field; -import java.util.Map; -import java.util.Set; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.ConnectorTracker; -import com.vaadin.ui.Window; - -public class ResynchronizeAfterAsyncRemoval extends AbstractTestUIWithLog { - - @Override - public void setup(VaadinRequest vaadinRequest) { - final Window window = new Window("Asynchronously removed window"); - window.center(); - - // The window will enqueue a non-immediate message reporting its current - // position. - addWindow(window); - - // Remove window immediately when the current response is sent - runAfterResponse(new Runnable() { - @Override - public void run() { - removeWindow(window); - } - }); - - // Clicking the button will trigger sending the window coordinates, but - // the window is already removed at that point. - addComponent(new Button("Am I dirty?", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - log("Window removed: " + (window.getParent() == null)); - - boolean dirty = getUI().getConnectorTracker().isDirty( - event.getButton()); - log("Dirty: " + dirty); - } - })); - addComponent(new Button("Log unregistered connector count", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - logUnregisteredConnectorCount(); - } - })); - } - - private void logUnregisteredConnectorCount() { - int count = 0; - - Map<Integer, Set<String>> unregisterIdMap = getUnregisterIdMap(); - for (Set<String> set : unregisterIdMap.values()) { - count += set.size(); - } - log("syncId: " + getConnectorTracker().getCurrentSyncId()); - log("Unregistered connector count: " + count); - } - - @SuppressWarnings("unchecked") - private Map<Integer, Set<String>> getUnregisterIdMap() { - try { - ConnectorTracker tracker = getConnectorTracker(); - Field field = tracker.getClass().getDeclaredField( - "syncIdToUnregisteredConnectorIds"); - field.setAccessible(true); - return (Map<Integer, Set<String>>) field.get(tracker); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemovalTest.java b/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemovalTest.java deleted file mode 100644 index 7f2dabe9f1..0000000000 --- a/uitest/src/com/vaadin/tests/application/ResynchronizeAfterAsyncRemovalTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.SingleBrowserTest; - -public class ResynchronizeAfterAsyncRemovalTest extends SingleBrowserTest { - @Test - public void noResyncAfterAsyncRemoval() { - openTestURL(); - - $(ButtonElement.class).first().click(); - - Assert.assertEquals("Timing issue in the test?", - "1. Window removed: true", getLogRow(1)); - - Assert.assertEquals( - "Removing window should not cause button to be marked as dirty", - "2. Dirty: false", getLogRow(0)); - - ButtonElement logCountButton = $(ButtonElement.class).all().get(1); - logCountButton.click(); - - Assert.assertEquals("Sanity check", "3. syncId: 2", getLogRow(1)); - Assert.assertEquals("Sanity check", - "4. Unregistered connector count: 1", getLogRow(0)); - - logCountButton.click(); - - Assert.assertEquals("Sanity check", "5. syncId: 3", getLogRow(1)); - Assert.assertEquals( - "Unregistered connector map should have been cleared", - "6. Unregistered connector count: 0", getLogRow(0)); - } -} diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java deleted file mode 100644 index 62331ec95e..0000000000 --- a/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; - -public class ResynchronizeUI extends AbstractTestUIWithLog { - - @Override - protected void setup(VaadinRequest request) { - Button b = new Button("Resynchronize", new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - // Theme change is currently the only operation which always - // does resynchronize - setTheme("runo"); - log("Set theme to runo"); - } - }); - addComponent(b); - } -} diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java deleted file mode 100644 index 726616d7b8..0000000000 --- a/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import java.util.Collections; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.StaleElementReferenceException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.parallel.Browser; -import com.vaadin.tests.tb3.SingleBrowserTest; - -public class ResynchronizeUITest extends SingleBrowserTest { - - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - // PhantomJS does not send onload events for styles - return Collections.singletonList(Browser.FIREFOX - .getDesiredCapabilities()); - } - - @Test - public void ensureResynchronizeRecreatesDOM() { - openTestURL(); - ButtonElement button = $(ButtonElement.class).first(); - button.click(); - // Click causes repaint, after this the old button element should no - // longer be available - // Ensure that the theme has changed - waitForThemeToChange("runo"); - try { - button.click(); - Assert.fail("The old button element should have been removed by the click and replaced by a new one."); - } catch (StaleElementReferenceException e) { - // This is what should happen - } - } -} diff --git a/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java deleted file mode 100644 index 7dbfa8cf40..0000000000 --- a/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Notification; -import com.vaadin.ui.UI; - -public class TerminalErrorNotification extends TestBase { - - @Override - protected void setup() { - Button button = new Button("Throw exception", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - throw new RuntimeException("You asked for it"); - } - }); - - addComponent(button); - } - - @Override - public void error(com.vaadin.server.ErrorEvent event) { - event.getThrowable().printStackTrace(); - - UI mainWindow = getMainWindow(); - if (mainWindow != null) { - Throwable throwable = event.getThrowable(); - - // Find the root cause - while (throwable.getCause() != null) { - throwable = throwable.getCause(); - } - - Notification.show("Got an exception: " + throwable.getMessage(), - Notification.TYPE_ERROR_MESSAGE); - } else { - System.out.println("No main window found"); - } - } - - @Override - protected String getDescription() { - return "Showing a notification in the terminalError method should make the notification appear in the browser."; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(8778); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/TerminalErrorNotificationTest.java b/uitest/src/com/vaadin/tests/application/TerminalErrorNotificationTest.java deleted file mode 100644 index ac7d55b396..0000000000 --- a/uitest/src/com/vaadin/tests/application/TerminalErrorNotificationTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.vaadin.tests.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.NotificationElement; -import com.vaadin.tests.tb3.MultiBrowserTest; -import com.vaadin.tests.tb3.newelements.FixedNotificationElement; - -public class TerminalErrorNotificationTest extends MultiBrowserTest { - @Test - public void tb2test() throws Exception { - openTestURL(); - $(ButtonElement.class).first().click(); - Assert.assertTrue(isElementPresent(NotificationElement.class)); - Assert.assertEquals("Got an exception: You asked for it", - $(FixedNotificationElement.class).first().getCaption()); - } -} diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java b/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java deleted file mode 100644 index ed611117d0..0000000000 --- a/uitest/src/com/vaadin/tests/application/ThreadLocalInstances.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.server.DownloadStream; -import com.vaadin.server.PaintException; -import com.vaadin.server.VaadinRequest; -import com.vaadin.server.VaadinSession; -import com.vaadin.tests.components.AbstractTestCase; -import com.vaadin.tests.integration.FlagSeResource; -import com.vaadin.tests.util.Log; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Embedded; -import com.vaadin.ui.LegacyWindow; -import com.vaadin.ui.UI; - -public class ThreadLocalInstances extends AbstractTestCase { - private static final VaadinSession staticInitApplication = VaadinSession - .getCurrent(); - private static final UI staticInitRoot = UI.getCurrent(); - - private final LegacyWindow mainWindow = new LegacyWindow() { - boolean paintReported = false; - - @Override - protected void init(VaadinRequest request) { - reportCurrentStatus("root init"); - } - - @Override - public void paintContent(com.vaadin.server.PaintTarget target) - throws PaintException { - if (!paintReported) { - reportCurrentStatus("root paint"); - Thread thread = new Thread() { - @Override - public void run() { - getSession().lock(); - try { - reportCurrentStatus("background thread"); - } finally { - getSession().unlock(); - } - } - }; - thread.start(); - paintReported = true; - } - super.paintContent(target); - } - }; - - private final FlagSeResource resource = new FlagSeResource() { - @Override - public DownloadStream getStream() { - ThreadLocalInstances.this.getContext().lock(); - try { - reportCurrentStatus("resource handler"); - } finally { - ThreadLocalInstances.this.getContext().unlock(); - } - return super.getStream(); - } - }; - - private final Log log = new Log(16); - - public ThreadLocalInstances() { - mainWindow.addComponent(log); - mainWindow.addComponent(new Embedded("Icon", resource)); - mainWindow.addComponent(new Button("Sync", new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - reportCurrentStatus("button listener"); - } - })); - - reportStatus("class init", staticInitApplication, staticInitRoot); - reportCurrentStatus("app constructor"); - } - - @Override - protected void init() { - reportCurrentStatus("app init"); - setMainWindow(mainWindow); - } - - @Override - protected String getDescription() { - return "Tests the precence of Application.getCurrentApplication() and UI.getCurrentRoot() from different contexts"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7895); - } - - private void reportCurrentStatus(String phase) { - reportStatus(phase, VaadinSession.getCurrent(), UI.getCurrent()); - } - - private void reportStatus(String phase, VaadinSession application, UI uI) { - log.log(getState(application, this) + " app in " + phase); - log.log(getState(uI, mainWindow) + " root in " + phase); - } - - private static String getState(Object value, Object reference) { - if (value == null) { - return "null"; - } else if (value == reference) { - return "this"; - } else { - return "some"; - } - } - -} diff --git a/uitest/src/com/vaadin/tests/application/ThreadLocalInstancesTest.java b/uitest/src/com/vaadin/tests/application/ThreadLocalInstancesTest.java deleted file mode 100644 index 9498413f9b..0000000000 --- a/uitest/src/com/vaadin/tests/application/ThreadLocalInstancesTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.vaadin.tests.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class ThreadLocalInstancesTest extends MultiBrowserTest { - @Test - public void tb2test() throws Exception { - openTestURL(); - $(ButtonElement.class).first().click(); - assertLogText("1. some app in class init", 15); - assertLogText("2. null root in class init", 14); - assertLogText("3. some app in app constructor", 13); - assertLogText("4. null root in app constructor", 12); - assertLogText("5. some app in app init", 11); - assertLogText("6. null root in app init", 10); - assertLogText("7. some app in root init", 9); - assertLogText("8. this root in root init", 8); - assertLogText("9. some app in root paint", 7); - assertLogText("10. this root in root paint", 6); - assertLogText("11. some app in background thread", 5); - assertLogText("12. this root in background thread", 4); - assertLogText("13. some app in resource handler", 3); - assertLogText("14. this root in resource handler", 2); - assertLogText("15. some app in button listener", 1); - assertLogText("16. this root in button listener", 0); - } - - private void assertLogText(String expected, int index) { - Assert.assertEquals("Incorrect log text,", expected, getLogRow(index)); - } -} diff --git a/uitest/src/com/vaadin/tests/application/TimingInfoReported.java b/uitest/src/com/vaadin/tests/application/TimingInfoReported.java deleted file mode 100644 index 83d31b184e..0000000000 --- a/uitest/src/com/vaadin/tests/application/TimingInfoReported.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.JavaScriptFunction; - -import elemental.json.JsonArray; - -public class TimingInfoReported extends AbstractTestUIWithLog { - - private String reportTimings = "setTimeout(function() {" - + "report(window.vaadin.clients[Object.keys(window.vaadin.clients)].getProfilingData());" - + "},0);"; - - @Override - protected void setup(VaadinRequest request) { - getPage().getJavaScript().addFunction("report", - new JavaScriptFunction() { - - @Override - public void call(JsonArray arguments) { - log("Got: " + arguments.toJson()); - JsonArray values = arguments.getArray(0); - - if (values.length() != 5) { - log("ERROR: expected 5 values, got " - + values.length()); - return; - } - - for (int i = 0; i < values.length(); i++) { - if (i < 0 || i > 10000) { - log("ERROR: expected value " + i - + " to be between 0 and 10000, was " - + values.getNumber(i)); - return; - } - } - log("Timings ok"); - } - }); - getPage().getJavaScript().execute(reportTimings); - Button b = new Button("test request", new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getPage().getJavaScript().execute(reportTimings); - - } - }); - addComponent(b); - } -} diff --git a/uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java b/uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java deleted file mode 100644 index 0b9ab77d81..0000000000 --- a/uitest/src/com/vaadin/tests/application/TimingInfoReportedTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; - -public class TimingInfoReportedTest extends SingleBrowserTestPhantomJS2 { - - @Test - public void ensureTimingsAvailable() { - openTestURL(); - Assert.assertEquals("2. Timings ok", getLogRow(0)); - $(ButtonElement.class).first().click(); - Assert.assertEquals("4. Timings ok", getLogRow(0)); - } -} diff --git a/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.java b/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.java deleted file mode 100644 index c8fc96f596..0000000000 --- a/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Notification; - -public class VaadinSessionAttribute extends AbstractTestUI { - - private static final String ATTR_NAME = "myAttribute"; - - @Override - protected void setup(VaadinRequest request) { - getSession().setAttribute(ATTR_NAME, Integer.valueOf(42)); - getSession().setAttribute(Integer.class, Integer.valueOf(42 * 2)); - - addComponent(new Button("Show attribute values", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - Notification notification = new Notification( - getSession().getAttribute(ATTR_NAME) - + " & " - + getSession().getAttribute( - Integer.class)); - notification.setDelayMsec(Notification.DELAY_FOREVER); - notification.show(getPage()); - } - })); - } - - @Override - protected String getTestDescription() { - return "Test to verify that session attributes are saved between requests."; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(9514); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java b/uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java deleted file mode 100644 index 47e86d9039..0000000000 --- a/uitest/src/com/vaadin/tests/application/VaadinSessionAttributeTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2014 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.application; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; -import com.vaadin.tests.tb3.newelements.FixedNotificationElement; - -public class VaadinSessionAttributeTest extends MultiBrowserTest { - - @Test - public void testSessionAttribute() { - openTestURL(); - $(ButtonElement.class).first().click(); - assertEquals("notification does not contain suitable text", "42 & 84", - $(FixedNotificationElement.class).first().getCaption()); - } - -} diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserSize.java b/uitest/src/com/vaadin/tests/application/WebBrowserSize.java deleted file mode 100644 index 0ce8e95290..0000000000 --- a/uitest/src/com/vaadin/tests/application/WebBrowserSize.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.vaadin.tests.application; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Label; - -public class WebBrowserSize extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - - final Label screenSizeLabel = new Label("n/a"); - screenSizeLabel.setCaption("Screen size"); - - final Label browserSizeLabel = new Label("n/a"); - browserSizeLabel.setCaption("Client (browser window) size"); - - final Button update = new Button("Refresh", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x " - + getBrowser().getScreenHeight()); - browserSizeLabel.setValue(getPage().getBrowserWindowWidth() - + " x " + getPage().getBrowserWindowHeight()); - } - }); - - addComponent(update); - addComponent(screenSizeLabel); - addComponent(browserSizeLabel); - - } - - @Override - protected String getTestDescription() { - return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations."; - } - - @Override - protected Integer getTicketNumber() { - return 5655; - } - -} diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java b/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java deleted file mode 100644 index b06d8e4388..0000000000 --- a/uitest/src/com/vaadin/tests/application/WebBrowserSizeTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.vaadin.tests.application; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class WebBrowserSizeTest extends MultiBrowserTest { - @Test - public void testBrowserSize() { - openTestURL(); - $(ButtonElement.class).first().click(); - // Thanks to selenium the browser size should always be 1500 x 850 - assertEquals("Browser size is not correct.", "1500 x 850", - $(LabelElement.class).get(2).getText()); - } -} diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserTimeZone.java b/uitest/src/com/vaadin/tests/application/WebBrowserTimeZone.java deleted file mode 100644 index 5253b0b0e7..0000000000 --- a/uitest/src/com/vaadin/tests/application/WebBrowserTimeZone.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.vaadin.tests.application; - -import java.util.Arrays; -import java.util.Date; -import java.util.TimeZone; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.testbench.annotations.RunLocally; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Label; - -@RunLocally -public class WebBrowserTimeZone extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - - final Label offsetLabel = addLabel("Browser offset"); - final Label rawOffsetLabel = addLabel("Browser raw offset"); - final Label dstDiffLabel = addLabel("Difference between raw offset and DST"); - final Label dstInEffectLabel = addLabel("Is DST currently active?"); - final Label curDateLabel = addLabel("Current date in the browser"); - final Label diffLabel = addLabel("Browser to Europe/Helsinki offset difference"); - final Label containsLabel = addLabel("Browser could be in Helsinki"); - - addButton("Get TimeZone from browser", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - TimeZone hkiTZ = TimeZone.getTimeZone("Europe/Helsinki"); - int hkiOffset = hkiTZ.getOffset(new Date().getTime()); - - int browserOffset = getBrowser().getTimezoneOffset(); - int browserRawOffset = getBrowser().getRawTimezoneOffset(); - String[] tzs = TimeZone.getAvailableIDs(browserRawOffset); - - boolean contains = Arrays.asList(tzs).contains(hkiTZ.getID()); - - offsetLabel.setValue(String.valueOf(browserOffset)); - rawOffsetLabel.setValue(String.valueOf(browserRawOffset)); - diffLabel.setValue(String.valueOf(browserOffset - hkiOffset)); - containsLabel.setValue(contains ? "Yes" : "No"); - dstDiffLabel.setValue(String.valueOf(getBrowser() - .getDSTSavings())); - dstInEffectLabel.setValue(getBrowser().isDSTInEffect() ? "Yes" - : "No"); - curDateLabel.setValue(getBrowser().getCurrentDate().toString()); - } - }); - } - - private Label addLabel(String caption) { - final Label label = new Label("n/a"); - label.setCaption(caption); - addComponent(label); - return label; - } - - @Override - protected String getTestDescription() { - return "Verifies that browser TimeZone offset works - should be same as server in our case (NOTE assumes server+browser in same TZ)"; - } - - @Override - protected Integer getTicketNumber() { - return 6691; - } - -} diff --git a/uitest/src/com/vaadin/tests/application/WebBrowserTimeZoneTest.java b/uitest/src/com/vaadin/tests/application/WebBrowserTimeZoneTest.java deleted file mode 100644 index 10b6dfb7a9..0000000000 --- a/uitest/src/com/vaadin/tests/application/WebBrowserTimeZoneTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.vaadin.tests.application; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.LabelElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class WebBrowserTimeZoneTest extends MultiBrowserTest { - @Test - public void testBrowserTimeZoneInfo() throws Exception { - openTestURL(); - $(ButtonElement.class).first().click(); - assertLabelText("Browser raw offset", "7200000"); - assertLabelText("Browser to Europe/Helsinki offset difference", "0"); - assertLabelText("Browser could be in Helsinki", "Yes"); - } - - private void assertLabelText(String caption, String expected) { - String actual = $(LabelElement.class).caption(caption).first() - .getText(); - Assert.assertEquals( - String.format("Unexpected text in label '%s',", caption), - expected, actual); - } -} diff --git a/uitest/src/com/vaadin/tests/application/calculator/Calc.java b/uitest/src/com/vaadin/tests/application/calculator/Calc.java deleted file mode 100644 index 3059017faa..0000000000 --- a/uitest/src/com/vaadin/tests/application/calculator/Calc.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2000-2014 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.application.calculator; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.Table; -import com.vaadin.ui.Table.ColumnHeaderMode; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.Window; - -@SuppressWarnings("serial") -public class Calc extends AbstractTestUI { - - private class Log extends VerticalLayout { - - private Table table; - private Button addCommentButton; - private int line = 0; - - public Log() { - super(); - - table = new Table(); - table.setSizeFull(); - - setWidth("200px"); - setHeight("100%"); - - table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); - table.addContainerProperty("Operation", String.class, ""); - - addComponent(table); - - addCommentButton = new Button("Add Comment"); - addCommentButton.setWidth("100%"); - - addCommentButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - - final Window w = new Window("Add comment"); - VerticalLayout vl = new VerticalLayout(); - vl.setMargin(true); - - final TextField tf = new TextField(); - tf.setSizeFull(); - vl.addComponent(tf); - - HorizontalLayout hl = new HorizontalLayout(); - - Button okButton = new Button("OK"); - okButton.setWidth("100%"); - okButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - addRow("[ " + tf.getValue() + " ]"); - tf.setValue(""); - w.close(); - removeWindow(w); - } - }); - - Button cancelButton = new Button("Cancel"); - cancelButton.setWidth("100%"); - cancelButton.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - tf.setValue(""); - w.close(); - removeWindow(w); - } - }); - - hl.addComponent(cancelButton); - hl.addComponent(okButton); - hl.setSpacing(true); - hl.setWidth("100%"); - - vl.addComponent(hl); - vl.setSpacing(true); - - w.setContent(vl); - addWindow(w); - } - }); - - addComponent(addCommentButton); - - setExpandRatio(table, 1); - setSpacing(true); - } - - public void addRow(String row) { - Integer id = ++line; - table.addItem(new Object[] { row }, id); - table.setCurrentPageFirstItemIndex(line + 1); - } - - } - - // All variables are automatically stored in the session. - private Double current = 0.0; - private double stored = 0.0; - private char lastOperationRequested = 'C'; - private VerticalLayout topLayout = new VerticalLayout(); - - // User interface components - private final TextField display = new TextField(); - - private final Log log = new Log(); - - // Calculator "business logic" implemented here to keep the example - // minimal - private double calculate(char requestedOperation) { - if ('0' <= requestedOperation && requestedOperation <= '9') { - if (current == null) { - current = 0.0; - } - current = current * 10 - + Double.parseDouble("" + requestedOperation); - return current; - } - - if (current == null) { - current = stored; - } - switch (lastOperationRequested) { - case '+': - stored += current; - break; - case '-': - stored -= current; - break; - case '/': - stored /= current; - break; - case '*': - stored *= current; - break; - default: - stored = current; - break; - } - - switch (requestedOperation) { - case '+': - log.addRow(current + " +"); - break; - case '-': - log.addRow(current + " -"); - break; - case '/': - log.addRow(current + " /"); - break; - case '*': - log.addRow(current + " x"); - break; - case '=': - log.addRow(current + " ="); - log.addRow("------------"); - log.addRow("" + stored); - break; - } - - lastOperationRequested = requestedOperation; - current = null; - if (requestedOperation == 'C') { - log.addRow("0.0"); - stored = 0.0; - } - return stored; - } - - @Override - protected void setup(VaadinRequest request) { - setContent(topLayout); - - // Create the main layout for our application (4 columns, 5 rows) - final GridLayout layout = new GridLayout(4, 5); - - topLayout.setMargin(true); - topLayout.setSpacing(true); - Label title = new Label("Calculator"); - topLayout.addComponent(title); - topLayout.addComponent(log); - - HorizontalLayout horizontalLayout = new HorizontalLayout(); - horizontalLayout.setSpacing(true); - horizontalLayout.addComponent(layout); - horizontalLayout.addComponent(log); - topLayout.addComponent(horizontalLayout); - - // Create a result label that over all 4 columns in the first row - layout.setSpacing(true); - layout.addComponent(display, 0, 0, 3, 0); - layout.setComponentAlignment(display, Alignment.MIDDLE_RIGHT); - display.setSizeFull(); - display.setId("display"); - display.setValue("0.0"); - - // The operations for the calculator in the order they appear on the - // screen (left to right, top to bottom) - String[] operations = new String[] { "7", "8", "9", "/", "4", "5", "6", - "*", "1", "2", "3", "-", "0", "=", "C", "+" }; - - for (String caption : operations) { - - // Create a button and use this application for event handling - Button button = new Button(caption); - button.setWidth("40px"); - button.addClickListener(new ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - // Get the button that was clicked - Button button = event.getButton(); - - // Get the requested operation from the button caption - char requestedOperation = button.getCaption().charAt(0); - - // Calculate the new value - double newValue = calculate(requestedOperation); - - // Update the result label with the new value - display.setValue("" + newValue); - } - }); - button.setId("button_" + caption); - - // Add the button to our main layout - layout.addComponent(button); - } - - } - - @Override - protected String getTestDescription() { - return "Provide test application for generic testing purposes"; - } - - @Override - protected Integer getTicketNumber() { - return 12444; - } - -} |