diff options
Diffstat (limited to 'uitest')
175 files changed, 6996 insertions, 1227 deletions
diff --git a/uitest/ivy.xml b/uitest/ivy.xml index add29985f1..ea22172937 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -87,13 +87,16 @@ conf="ide, build->default" /> <dependency org="commons-codec" name="commons-codec" rev="1.5" conf="build,ide->default" /> - <dependency org="commons-io" name="commons-io" rev="2.2" + <dependency org="commons-io" name="commons-io" rev="${commons-io.version}" conf="build,ide->default" /> <!-- Mainly for SQLContainer tests --> <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" conf="build,ide -> default" /> <dependency org="com.vaadin" name="vaadin-testbench" rev="3.1.3" conf="build-provided,ide -> default" /> + <!-- This should be removed once tests have been updated to use lang3 --> + <dependency org="commons-lang" name="commons-lang" + rev="2.6" conf="build,ide -> default" /> </dependencies> </ivy-module> diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java index a8d639cbc8..ecaf4ded32 100644 --- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java +++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java @@ -217,7 +217,6 @@ public class DevelopmentServerLauncher { Socket accept = serverSocket.accept(); // First stop listening to the port serverSocket.close(); - final Thread stopThread = Thread.currentThread(); // Start a thread that kills the JVM if // server.stop() doesn't have any effect @@ -257,7 +256,7 @@ public class DevelopmentServerLauncher { } catch (Exception e) { e.printStackTrace(); } - }; + } }.start(); diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html new file mode 100644 index 0000000000..33fc46f060 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.application.DetachOldUIOnReload?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> + <td>This is UI 0</td> +</tr> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.application.DetachOldUIOnReload</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td> + <td>1. UI 0 has been detached</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> + <td>This is UI 1</td> +</tr> +<tr> + <td>clickAndWait</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td> + <td>2. UI 1 has been detached</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> + <td>This is UI 2</td> +</tr> +<tr> + <td>open</td> + <td>/</td> + <td></td> +</tr> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.application.DetachOldUIOnReload</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td> + <td>3. UI 2 has been detached</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> + <td>This is UI 3</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java new file mode 100644 index 0000000000..154c84b4f5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2013 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) { + 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/components/orderedlayout/NestedLayoutCaptionTooltip.html b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.html index 4f574a92c7..f366054f45 100644 --- a/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionTooltip.html +++ b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.html @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> +<link rel="selenium.base" href="http://localhost:8888/run/com.vaadin.tests.application.RefreshStatePreserveTitle?restartApplication" /> <title>New Test</title> </head> <body> @@ -13,19 +13,22 @@ </thead><tbody> <tr> <td>open</td> - <td>/run/com.vaadin.tests.applicationcontext.CloseSession?restartApplication&debug</td> + <td>/run/com.vaadin.tests.application.RefreshStatePreserveTitle?restartApplication</td> <td></td> </tr> -<!-- Show tooltip for the Events caption --> <tr> - <td>showTooltip</td> - <td>//div[@id='gwt-uid-4']/span</td> + <td>assertTitle</td> + <td>TEST</td> <td></td> </tr> -<!-- Verify that there's no error notification --> <tr> - <td>assertElementNotPresent</td> - <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::Root/VNotification[0]</td> + <td>open</td> + <td>/run/com.vaadin.tests.application.RefreshStatePreserveTitle</td> + <td></td> +</tr> +<tr> + <td>assertTitle</td> + <td>TEST</td> <td></td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java new file mode 100644 index 0000000000..88b3a9b9f4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/RefreshStatePreserveTitle.java @@ -0,0 +1,30 @@ +package com.vaadin.tests.application; + +import com.vaadin.annotations.PreserveOnRefresh; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Label; + +@PreserveOnRefresh +public class RefreshStatePreserveTitle extends AbstractTestUI { + + private Log log = new Log(5); + + @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); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html index f20967c8de..e7d437eeca 100644 --- a/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html +++ b/uitest/src/com/vaadin/tests/application/TerminalErrorNotification.html @@ -28,7 +28,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestsapplicationTerminalErrorNotification::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestsapplicationTerminalErrorNotification::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>Got an exception: You asked for it</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.html b/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.html index e03027f308..150ab3ff3d 100644 --- a/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.html +++ b/uitest/src/com/vaadin/tests/application/VaadinSessionAttribute.html @@ -23,7 +23,7 @@ </tr> <tr> <td>assertText</td> - <td>//body/div[2]</td> + <td>//body/div[2]//h1</td> <td>42 & 84</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/application/calculator/Calc.java b/uitest/src/com/vaadin/tests/application/calculator/Calc.java new file mode 100644 index 0000000000..7911556f4e --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/calculator/Calc.java @@ -0,0 +1,268 @@ +/* + * Copyright 2000-2013 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; + } + +} diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java b/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java index c88f482a7b..9bfef35d8c 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseUI.java @@ -78,7 +78,7 @@ public class CloseUI extends AbstractTestUI { @Override protected void runSafely() { close(); - }; + } }.start(); } })); diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java b/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java new file mode 100644 index 0000000000..df46c92f56 --- /dev/null +++ b/uitest/src/com/vaadin/tests/applicationservlet/SessionExpiration.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 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.applicationservlet; + +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 SessionExpiration extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + getSession().getSession().setMaxInactiveInterval(2); + Button b = new Button("Click to avoid expiration"); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log("Clicked"); + } + }); + addComponent(b); + } + + @Override + protected String getTestDescription() { + return "Test for what happens when the session expires (2 second expiration time)."; + } + + @Override + protected Integer getTicketNumber() { + return 12139; + } +} diff --git a/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html b/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html index 18129a72e2..18129a72e2 100644 --- a/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html +++ b/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html diff --git a/uitest/src/com/vaadin/tests/components/AbstractComponentTest.java b/uitest/src/com/vaadin/tests/components/AbstractComponentTest.java index 8dae56b079..59f3a46c3b 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractComponentTest.java +++ b/uitest/src/com/vaadin/tests/components/AbstractComponentTest.java @@ -200,7 +200,7 @@ public abstract class AbstractComponentTest<T extends AbstractComponent> super.addTestComponent(c); getLayout().setExpandRatio(c, 1); - }; + } /** * Construct the component that is to be tested. This method uses a no-arg diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index 6213993257..d7fb7d03fb 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -113,27 +113,48 @@ public abstract class AbstractTestUI extends UI { protected void setTransport(VaadinRequest request) { String transport = request.getParameter("transport"); PushConfiguration config = getPushConfiguration(); - PushMode mode = config.getPushMode(); if ("xhr".equals(transport)) { config.setPushMode(PushMode.DISABLED); } else if ("websocket".equals(transport)) { - if (!mode.isEnabled()) { - config.setPushMode(PushMode.AUTOMATIC); - } - config.setTransport(Transport.WEBSOCKET); - // Ensure no fallback is used - getPushConfiguration().setParameter( - PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + enablePush(Transport.WEBSOCKET); } else if ("streaming".equals(transport)) { - if (!mode.isEnabled()) { - config.setPushMode(PushMode.AUTOMATIC); - } - config.setTransport(Transport.STREAMING); - // Ensure no fallback is used - getPushConfiguration().setParameter( - PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + enablePush(Transport.STREAMING); + } else if ("long-polling".equals(transport)) { + enablePush(Transport.LONG_POLLING); + } else if (transport != null) { + throw new IllegalArgumentException("Unknown transport value '" + + transport + + "'. Supported are xhr,websocket,streaming,long-polling"); + } + } + + protected void enablePush(Transport transport) { + PushConfiguration config = getPushConfiguration(); + if (!config.getPushMode().isEnabled()) { + config.setPushMode(PushMode.AUTOMATIC); } + config.setTransport(transport); + // Ensure no fallback is used + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + + /** + * This method is inherited from the super class, but it should generally + * not be used. If you want to just add components to your test, use e.g. + * {@link #addComponent(Component)} instead to add the component to the + * layout used by this UI. If you don't want to use the top-level layout + * used by this class, you instead inherit directly from UI. + * + * @deprecated Use {@link #addComponent(Component)} or inherit from UI + * instead. + */ + @Override + @Deprecated + public void setContent(Component content) { + // Overridden just to deprecate + super.setContent(content); } private VerticalLayout layout; diff --git a/uitest/src/com/vaadin/tests/components/ErrorMessages.html b/uitest/src/com/vaadin/tests/components/ErrorMessages.html index 5379ff59e0..2b7032ea79 100644 --- a/uitest/src/com/vaadin/tests/components/ErrorMessages.html +++ b/uitest/src/com/vaadin/tests/components/ErrorMessages.html @@ -3,17 +3,17 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://artur-laptop.office.itmill.com:8888/" /> -<title>New Test</title> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>ErrorMessages</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> +<tr><td rowspan="1" colspan="3">ErrorMessages</td></tr> </thead><tbody> <tr> <td>open</td> - <td>/run/com.vaadin.tests.components.ErrorMessages</td> + <td>/run/com.vaadin.tests.components.ErrorMessages?restartApplication</td> <td></td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/SaneErrors.java b/uitest/src/com/vaadin/tests/components/SaneErrors.java new file mode 100644 index 0000000000..b82c1dd18b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/SaneErrors.java @@ -0,0 +1,86 @@ +package com.vaadin.tests.components; + +import com.vaadin.event.ItemClickEvent; +import com.vaadin.event.ItemClickEvent.ItemClickListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractComponent; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.RowHeaderMode; +import com.vaadin.ui.VerticalLayout; + +public class SaneErrors extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Button b = new Button("Show me my NPE!"); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + throwError(); + } + + }); + + /* + * Errors from "legacy variable changes" + */ + final Table table = new Table(); + table.addItem("Show me my NPE!"); + table.setRowHeaderMode(RowHeaderMode.ID); + table.addItemClickListener(new ItemClickListener() { + @Override + public void itemClick(ItemClickEvent event) { + throwError(); + } + }); + + final VerticalLayout content = new VerticalLayout(b, table); + + /** + * Button that shows reported exception for TB integration test + */ + Button button = new Button("Collect exceptions", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + reportException(b, content); + reportException(table, content); + } + + private void reportException(final AbstractComponent b, + final VerticalLayout content) { + String message = b.getErrorMessage().getFormattedHtmlMessage(); + message = message.replaceAll(".", "."); + message = message.substring(message.indexOf("h2>") + 3, + message.indexOf(" ")); + Label label = new Label(message); + content.addComponent(label); + } + }); + content.addComponent(button); + + setContent(content); + + } + + private void throwError() { + Object o = null; + o.getClass(); + } + + @Override + protected String getTestDescription() { + return "Vaadin should by default report exceptions relevant for the developer."; + } + + @Override + protected Integer getTicketNumber() { + return 11599; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/SaneErrorsTest.java b/uitest/src/com/vaadin/tests/components/SaneErrorsTest.java new file mode 100644 index 0000000000..6cf49151b3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/SaneErrorsTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 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.components; + +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.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SaneErrorsTest extends MultiBrowserTest { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest() + */ + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return Collections.singletonList(DesiredCapabilities.firefox()); + } + + @Test + public void test() { + openTestURL(); + List<WebElement> elements = getDriver().findElements( + By.xpath("//*[text() = 'Show me my NPE!']")); + for (WebElement webElement : elements) { + webElement.click(); + } + + getDriver().findElement(By.xpath("//*[text() = 'Collect exceptions']")) + .click(); + + List<WebElement> errorMessages = getDriver().findElements( + By.className("v-label")); + for (WebElement webElement : errorMessages) { + String text = webElement.getText(); + Assert.assertEquals("java.lang.NullPointerException", text); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java index 7b2b945f23..692ca25b07 100644 --- a/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java +++ b/uitest/src/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java @@ -149,7 +149,7 @@ public abstract class AbstractFieldTest<T extends AbstractField> extends public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { log(event.getClass().getSimpleName() + ", new value: " + getValue(event.getProperty())); - }; + } @SuppressWarnings({ "rawtypes", "unchecked" }) private String getValue(Property property) { diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java new file mode 100644 index 0000000000..da0ad3685a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTab.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2013 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.components.accordion; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Accordion; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.TabSheet.Tab; +import com.vaadin.ui.VerticalLayout; + +/** + * Test UI for Accordion: old widget should be removed from the tab. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class AccordionAddTab extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Accordion tabs = new Accordion(); + addComponent(tabs); + tabs.setHeight(500, Unit.PIXELS); + Button remove = new Button("Remove 'First'"); + final Tab me = tabs.addTab(addTab("First")); + remove.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + tabs.removeTab(me); + Tab tab = tabs.addTab(addTab("Next")); + tabs.setSelectedTab(tab); + } + }); + addComponent(remove); + } + + private Component addTab(String tag) { + VerticalLayout layout = new VerticalLayout(); + layout.addComponent(new Label("On tab: " + tag)); + return new Panel(tag, layout); + } + + @Override + protected String getTestDescription() { + return "Remove previous widget in the accordion tab when content is replaced"; + } + + @Override + protected Integer getTicketNumber() { + return 11367; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java new file mode 100644 index 0000000000..68aa61cc87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionAddTabTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2013 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.components.accordion; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for Accordion : replace widget in tab should remove old widget. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class AccordionAddTabTest extends MultiBrowserTest { + + @Test + public void testRemoveAndAdd() { + openTestURL(); + + WebElement button = driver.findElement(By.className("v-button")); + button.click(); + + List<WebElement> panels = driver.findElements(By.className("v-panel")); + + Assert.assertEquals("Found two widgets inside one tab after " + + "subsequent tab removal and addition", 1, panels.size()); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java b/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java index d24def22dd..e82336c1e8 100644 --- a/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java +++ b/uitest/src/com/vaadin/tests/components/accordion/RemoveTabs.java @@ -46,38 +46,34 @@ public class RemoveTabs extends TestBase { getLayout().addComponent(accordion); closeCurrent = new Button("Close current tab"); - closeCurrent.addListener(new Button.ClickListener() { + closeCurrent.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { closeCurrentTab(); - } }); closeFirst = new Button("close first tab"); - closeFirst.addListener(new Button.ClickListener() { + closeFirst.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { closeFirstTab(); - } }); closeLast = new Button("close last tab"); - closeLast.addListener(new Button.ClickListener() { + closeLast.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { closeLastTab(); - } }); reorderTabs = new Button("reorder"); - reorderTabs.addListener(new Button.ClickListener() { + reorderTabs.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { reorder(); - } }); @@ -96,11 +92,11 @@ public class RemoveTabs extends TestBase { } private void closeFirstTab() { - accordion.removeComponent(accordion.getComponentIterator().next()); + accordion.removeComponent(accordion.iterator().next()); } private void closeLastTab() { - Iterator<Component> i = accordion.getComponentIterator(); + Iterator<Component> i = accordion.iterator(); Component last = null; while (i.hasNext()) { last = i.next(); @@ -114,7 +110,7 @@ public class RemoveTabs extends TestBase { if (container != null) { List<Component> c = new ArrayList<Component>(); - Iterator<Component> i = container.getComponentIterator(); + Iterator<Component> i = container.iterator(); while (i.hasNext()) { Component comp = i.next(); c.add(comp); @@ -124,7 +120,6 @@ public class RemoveTabs extends TestBase { for (int j = c.size() - 1; j >= 0; j--) { container.addComponent(c.get(j)); } - } } diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonClick.java b/uitest/src/com/vaadin/tests/components/button/ButtonClick.java new file mode 100644 index 0000000000..30692649c5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/button/ButtonClick.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-2013 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.components.button; + +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.Label; +import com.vaadin.ui.VerticalLayout; + +public class ButtonClick extends AbstractTestUI { + + public final static String SUCCESS_TEXT = "Click received succesfully!"; + public final static String WRONG_BUTTON_TEXT = "Wrong button clicked."; + + @Override + protected void setup(VaadinRequest request) { + final VerticalLayout rootLayout = new VerticalLayout(); + final Label statusLabel = new Label("Test initialized"); + rootLayout.addComponent(new Button("Click here", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + statusLabel.setValue(SUCCESS_TEXT); + } + + })); + Button visitLocation = new Button("Drag here", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + statusLabel.setValue(WRONG_BUTTON_TEXT); + } + + }); + rootLayout.addComponent(statusLabel); + rootLayout.addComponent(visitLocation); + rootLayout.setComponentAlignment(visitLocation, Alignment.BOTTOM_RIGHT); + rootLayout.setSizeFull(); + rootLayout.setMargin(true); + setContent(rootLayout); + } + + @Override + protected String getTestDescription() { + return "Verify button click logic"; + } + + @Override + protected Integer getTicketNumber() { + return 13550; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonClickTest.java b/uitest/src/com/vaadin/tests/components/button/ButtonClickTest.java new file mode 100644 index 0000000000..77b35092de --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/button/ButtonClickTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 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.components.button; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ButtonClickTest extends MultiBrowserTest { + + @Test + public void buttonMouseDownOutOverUp() { + openTestURL(); + + WebElement clickedButton = vaadinElement("/VVerticalLayout[0]/VButton[0]"); + WebElement visitedButton = vaadinElement("/VVerticalLayout[0]/VButton[1]"); + + new Actions(driver).moveToElement(clickedButton).clickAndHold() + .moveToElement(visitedButton).moveToElement(clickedButton) + .release().perform(); + + assertEquals(ButtonClick.SUCCESS_TEXT, + vaadinElement("/VVerticalLayout[0]/VLabel[0]").getText()); + } +} diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonsAndIcons.java b/uitest/src/com/vaadin/tests/components/button/ButtonsAndIcons.java index 4ab18e994a..64f690dbf5 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonsAndIcons.java +++ b/uitest/src/com/vaadin/tests/components/button/ButtonsAndIcons.java @@ -27,7 +27,7 @@ public class ButtonsAndIcons extends TestBase { b = new Button("Only text"); addComponent(b); - b = new Button(null); + b = new Button((String) null); b.setIcon(new ThemeResource("../runo/icons/16/ok.png")); addComponent(b); diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java index 1208b8be3b..24dc942171 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java +++ b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java @@ -22,6 +22,7 @@ public class ButtonsWaiAria extends ComponentTestCase<Button> { l = createButton("Icon Button, empty alt", nat); l.setIcon(ICON_16_USER_PNG_CACHEABLE); + l.setDescription("Empty alt text"); addTestComponent(l); l = createButton("Icon Button with alt", nat); @@ -31,6 +32,10 @@ public class ButtonsWaiAria extends ComponentTestCase<Button> { l = createButton("Tooltip Button", nat); l.setDescription("Tooltip"); addTestComponent(l); + + l = createButton("Another tooltip", nat); + l.setDescription("Another"); + addTestComponent(l); } private Button createButton(String text, boolean nativeButton) { diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html index fd51a0daad..6add1deba5 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeeklyViewNewEvents.html @@ -313,7 +313,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>8,9</td> </tr> <!--Edit previously created events and change properties--> @@ -438,7 +438,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,8</td> </tr> <tr> @@ -558,7 +558,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>7,8</td> </tr> <tr> @@ -583,7 +583,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentscalendarCalendarTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>12,10</td> </tr> <!--Go to monthly view and assert inserted events--> diff --git a/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java b/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java index b8b55048f9..60e8720d44 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java +++ b/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java @@ -21,7 +21,8 @@ public class TestHideTimeAndSeparator extends AbstractTestUI { private final String caption; private final boolean hideTime; - public GenericEvent(Date start, Date end, String caption, boolean hideTime) { + public GenericEvent(Date start, Date end, String caption, + boolean hideTime) { this.start = start; this.end = end; this.caption = caption; @@ -60,10 +61,16 @@ public class TestHideTimeAndSeparator extends AbstractTestUI { } - CalendarEvent shortEventHidden = new GenericEvent(makeDate(2013, 1, 2, 8, 0), makeDate(2013, 1, 2, 8, 30), "Short event", true); - CalendarEvent longEventHidden = new GenericEvent(makeDate(2013, 1, 2, 10, 0), makeDate(2013, 1, 2, 12, 0), "Long event", true); - CalendarEvent shortEvent = new GenericEvent(makeDate(2013, 1, 3, 8, 0), makeDate(2013, 1, 3, 8, 30), "Short event", false); - CalendarEvent longEvent = new GenericEvent(makeDate(2013, 1, 3, 10, 0), makeDate(2013, 1, 3, 12, 0), "Long event", false); + CalendarEvent shortEventHidden = new GenericEvent( + makeDate(2013, 1, 2, 8, 0), makeDate(2013, 1, 2, 8, 30), + "Short event", true); + CalendarEvent longEventHidden = new GenericEvent( + makeDate(2013, 1, 2, 10, 0), makeDate(2013, 1, 2, 12, 0), + "Long event", true); + CalendarEvent shortEvent = new GenericEvent(makeDate(2013, 1, 3, 8, 0), + makeDate(2013, 1, 3, 8, 30), "Short event", false); + CalendarEvent longEvent = new GenericEvent(makeDate(2013, 1, 3, 10, 0), + makeDate(2013, 1, 3, 12, 0), "Long event", false); @Override protected void setup(VaadinRequest request) { @@ -100,6 +107,7 @@ public class TestHideTimeAndSeparator extends AbstractTestUI { juc.set(year, month, day, hour, minute); return juc.getTime(); } + private Date makeDate(int year, int month, int day) { java.util.Calendar juc = java.util.Calendar.getInstance(); juc.set(year, month, day); diff --git a/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSize.java b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSize.java new file mode 100644 index 0000000000..a3e19513b0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSize.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2013 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.components.customfield; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.CustomField; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class CustomFieldSize extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + setContent(layout); + layout.setWidth("50px"); + + layout.addComponent(new TextField()); + + layout.addComponent(new CustomField<String>() { + + @Override + protected Component initContent() { + return new TextField(); + } + + @Override + public Class<? extends String> getType() { + return String.class; + } + + }); + } + + @Override + protected String getTestDescription() { + return "Any part of a TextField wrapped in a CustomField should not be cut off even when the dimensions of the TextField exceed those of the CustomField"; + } + + @Override + protected Integer getTicketNumber() { + return 12482; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSizeTest.java b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSizeTest.java new file mode 100644 index 0000000000..c47ec0b792 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSizeTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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.components.customfield; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class CustomFieldSizeTest extends MultiBrowserTest { + + @Test + public void checkScreenshot() throws IOException { + openTestURL(); + compareScreen("size"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.html b/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.html index 1acdded4cb..b20e7295f7 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.html +++ b/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.html @@ -292,7 +292,7 @@ </tr> <tr> <td>assertValue</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::PID_Syyyy'年'M'月'd'日'/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::PID_Syyyy'X'M'X'd'X'/domChild[0]</td> <td>2010年2月1日</td> </tr> <tr> @@ -363,12 +363,12 @@ </tr> <tr> <td>assertValue</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::PID_SMMMM d, yyyy/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::PID_SMMMM dX yyyy/domChild[0]</td> <td>February 1, 2010</td> </tr> <tr> <td>assertValue</td> - <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::PID_SMMM d, yyyy/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::PID_SMMM dX yyyy/domChild[0]</td> <td>Feb 1, 2010</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java b/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java index 015a974b3e..77637fb339 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java +++ b/uitest/src/com/vaadin/tests/components/datefield/CustomDateFormats.java @@ -147,6 +147,8 @@ public class CustomDateFormats extends TestBase { df.setDateFormat(pattern); df.setImmediate(true); String debugId = pattern.replace('/', 'X'); + // only certain characters are allowed in debug IDs + debugId = debugId.replaceAll("[^-a-zA-Z .'_]", "X"); while (usedDebugIds.contains(debugId)) { debugId = debugId + "-"; } diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java index d92199a214..10718cae8b 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java @@ -37,7 +37,7 @@ public class DateFieldTest<T extends DateField> extends AbstractFieldTest<T> { createDateFormatSelectAction(CATEGORY_FEATURES); createSetValueAction(CATEGORY_FEATURES); - }; + } private void createSetValueAction(String category) { LinkedHashMap<String, Date> options = new LinkedHashMap<String, Date>(); diff --git a/uitest/src/com/vaadin/tests/components/datefield/DisabledParentLayout.java b/uitest/src/com/vaadin/tests/components/datefield/DisabledParentLayout.java new file mode 100644 index 0000000000..cf09ff029d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DisabledParentLayout.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2013 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.components.datefield; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.DateField; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @author Vaadin Ltd + */ +public class DisabledParentLayout extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout content = new VerticalLayout(); + + content.setSpacing(true); + content.setMargin(true); + + final VerticalLayout pane = new VerticalLayout(); + pane.setEnabled(false); + pane.addComponent(new DateField()); + + content.addComponent(pane); + + Button button = new Button("Test"); + button.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + pane.setEnabled(true); + } + }); + content.addComponent(button); + + addComponent(content); + } + + @Override + protected String getTestDescription() { + return "Data field should be functional after enabling disabled parent."; + } + + @Override + protected Integer getTicketNumber() { + return 13124; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java b/uitest/src/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java new file mode 100644 index 0000000000..3ee4544693 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DisabledParentLayoutTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2000-2013 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.components.datefield; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @author Vaadin Ltd + */ +public class DisabledParentLayoutTest extends MultiBrowserTest { + + @Test + public void testEnableParentLayout() { + openTestURL(); + + WebElement button = driver.findElement(By.className("v-button")); + button.click(); + + WebElement dataFieldButton = driver.findElement(By + .className("v-datefield-button")); + dataFieldButton.click(); + + WebElement popup = driver + .findElement(By.className("v-datefield-popup")); + + Assert.assertFalse("Unexpected disabled element found", + isElementPresent(By.className("v-disabled"))); + + Assert.assertNotNull( + "Date popup is not opened after click to its button", popup); + } +} diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html index 03ec163e40..3c91c8b24f 100644 --- a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html @@ -18,7 +18,7 @@ </tr> <tr> <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper3</td> + <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper3/VLabel[0]</td> <td>0,0</td> </tr> <tr> @@ -26,9 +26,10 @@ <td></td> <td>tooltip-initial</td> </tr> +<!--Drag Block 4 between Block 1 and Block 2--> <tr> <td>drag</td> - <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper4</td> + <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper4/VLabel[0]</td> <td>30,41</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.html b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.html index 2dcd1b5071..ae81cfe61c 100644 --- a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.html +++ b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedClickListenerRelativeCoordinates.html @@ -23,7 +23,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedClickListenerRelativeCoordinates::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedClickListenerRelativeCoordinates::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>41, 22</td> </tr> <tr> @@ -33,7 +33,7 @@ </tr> <tr> <td>waitForElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedClickListenerRelativeCoordinates::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedClickListenerRelativeCoordinates::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td></td> </tr> <tr> @@ -43,7 +43,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedClickListenerRelativeCoordinates::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsembeddedEmbeddedClickListenerRelativeCoordinates::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>0, 0</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html index ee693fd4be..5e412c3aad 100644 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8070" /> +<link rel="selenium.base" href="http://localhost:8888" /> <title>FormTooltips</title> </head> <body> @@ -38,10 +38,15 @@ <td></td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>-1000</td> +</tr> <!--first name caption tooltip--> <tr> <td>showTooltip</td> @@ -64,10 +69,15 @@ <td></td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>-1000</td> +</tr> <!--Form should not have a description tooltip--> <tr> <td>showTooltip</td> @@ -80,9 +90,9 @@ <td></td> </tr> <tr> - <td>assertElementNotPresent</td> + <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td> - <td></td> + <td>-1000</td> </tr> <!--Form error message should not have a tooltip--> <tr> @@ -96,9 +106,9 @@ <td></td> </tr> <tr> - <td>assertElementNotPresent</td> + <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]</td> - <td></td> + <td>-1000</td> </tr> <!--last name should have no tooltip--> <tr> @@ -112,9 +122,9 @@ <td></td> </tr> <tr> - <td>assertElementNotPresent</td> + <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> + <td>-1000</td> </tr> <!--last name caption should have no tooltip--> <tr> @@ -128,9 +138,9 @@ <td></td> </tr> <tr> - <td>assertElementNotPresent</td> + <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> + <td>-1000</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/label/LabelTest.java b/uitest/src/com/vaadin/tests/components/label/LabelTest.java index 5db2669f95..8c9a76ea47 100644 --- a/uitest/src/com/vaadin/tests/components/label/LabelTest.java +++ b/uitest/src/com/vaadin/tests/components/label/LabelTest.java @@ -101,6 +101,6 @@ public class LabelTest extends AbstractComponentTest<Label> implements } log(event.getClass().getSimpleName() + ", new value: " + value); - }; + } } diff --git a/uitest/src/com/vaadin/tests/components/listselect/ListSelects.java b/uitest/src/com/vaadin/tests/components/listselect/ListSelects.java index a3fa973bc2..8998fd3a3d 100644 --- a/uitest/src/com/vaadin/tests/components/listselect/ListSelects.java +++ b/uitest/src/com/vaadin/tests/components/listselect/ListSelects.java @@ -31,7 +31,7 @@ public class ListSelects extends AbstractSelectTestCase<ListSelect> { super.createActions(); createRowsAction(CATEGORY_FEATURES); createColsAction(CATEGORY_FEATURES); - }; + } private void createRowsAction(String category) { LinkedHashMap<String, Integer> options = createIntegerOptions(20); diff --git a/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigation.java b/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigation.java new file mode 100644 index 0000000000..338219d848 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigation.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 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.components.menubar; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.Command; +import com.vaadin.ui.MenuBar.MenuItem; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class SpaceMenuBarNavigation extends AbstractTestUI implements Command { + + @Override + protected void setup(VaadinRequest request) { + MenuBar menuBar = new MenuBar(); + menuBar.addStyleName("menu-bar"); + + MenuItem item = menuBar.addItem("menu", null); + + item.addItem("subitem", this); + + addComponent(menuBar); + } + + @Override + protected String getTestDescription() { + return "Space key code should trigger menu actions/submenu"; + } + + @Override + protected Integer getTicketNumber() { + return 12525; + } + + @Override + public void menuSelected(MenuItem selectedItem) { + Label label = new Label("action result"); + label.addStyleName("action-result"); + addComponent(label); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java b/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java new file mode 100644 index 0000000000..f10e1551df --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2013 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.components.menubar; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class SpaceMenuBarNavigationTest extends MultiBrowserTest { + + @Test + public void testEnableParentLayout() { + openTestURL(); + + WebElement menu = driver.findElement(By.className("menu-bar")); + menu.sendKeys(Keys.ARROW_RIGHT); + menu.sendKeys(Keys.SPACE); + + List<WebElement> captions = driver.findElements(By + .className("v-menubar-menuitem-caption")); + boolean found = false; + for (WebElement caption : captions) { + if ("subitem".equals(caption.getText())) { + found = true; + } + } + Assert.assertTrue("Sub menu is not opened on SPACE key", found); + + menu.sendKeys(Keys.SPACE); + + Assert.assertTrue("No result of action triggered by SPACE key", + isElementPresent(By.className("action-result"))); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndText.java b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndText.java new file mode 100644 index 0000000000..fdeed316ba --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndText.java @@ -0,0 +1,124 @@ +/* + * Copyright 2000-2013 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.components.nativebutton; + +import com.vaadin.server.ThemeResource; +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.Button.ClickListener; +import com.vaadin.ui.NativeButton; + +public class NativeButtonIconAndText extends AbstractTestUI implements + ClickListener { + + static final String UPDATED_ALTERNATE_TEXT = "Now has alternate text"; + static final String INITIAL_ALTERNATE_TEXT = "Initial alternate text"; + static final String BUTTON_TEXT = "buttonText"; + static final String BUTTON_TEXT_ICON = "buttonTextIcon"; + static final String BUTTON_TEXT_ICON_ALT = "buttonTextIconAlt"; + static final String NATIVE_BUTTON_TEXT = "nativeButtonText"; + static final String NATIVE_BUTTON_TEXT_ICON = "nativeButtonTextIcon"; + static final String NATIVE_BUTTON_TEXT_ICON_ALT = "nativeButtonTextIconAlt"; + + @Override + protected void setup(VaadinRequest request) { + Button buttonText = new Button("Only text"); + + Button buttonTextIcon = new Button("Text icon"); + buttonTextIcon.setIcon(new ThemeResource("../runo/icons/64/ok.png")); + + Button buttonTextIconAlt = new Button("Text icon alt"); + buttonTextIconAlt.setIcon(new ThemeResource( + "../runo/icons/64/cancel.png")); + buttonTextIconAlt.setIconAlternateText(INITIAL_ALTERNATE_TEXT); + + buttonText.addClickListener(this); + buttonTextIcon.addClickListener(this); + buttonTextIconAlt.addClickListener(this); + + buttonText.setId(BUTTON_TEXT); + buttonTextIcon.setId(BUTTON_TEXT_ICON); + buttonTextIconAlt.setId(BUTTON_TEXT_ICON_ALT); + + addComponent(buttonText); + addComponent(buttonTextIcon); + addComponent(buttonTextIconAlt); + + NativeButton nativeButtonText = new NativeButton("Only text"); + + NativeButton nativeButtonTextIcon = new NativeButton("Text icon"); + nativeButtonTextIcon.setIcon(new ThemeResource( + "../runo/icons/64/ok.png")); + + NativeButton nativeButtonTextIconAlt = new NativeButton("Text icon alt"); + nativeButtonTextIconAlt.setIcon(new ThemeResource( + "../runo/icons/64/cancel.png")); + nativeButtonTextIconAlt.setIconAlternateText(INITIAL_ALTERNATE_TEXT); + + nativeButtonText.addClickListener(this); + nativeButtonTextIcon.addClickListener(this); + nativeButtonTextIconAlt.addClickListener(this); + + nativeButtonText.setId(NATIVE_BUTTON_TEXT); + nativeButtonTextIcon.setId(NATIVE_BUTTON_TEXT_ICON); + nativeButtonTextIconAlt.setId(NATIVE_BUTTON_TEXT_ICON_ALT); + + addComponent(nativeButtonText); + addComponent(nativeButtonTextIcon); + addComponent(nativeButtonTextIconAlt); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Click the buttons to toggle icon alternate text"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12780; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui.Button. + * ClickEvent) + */ + @Override + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + String was = b.getIconAlternateText(); + if (was == null || was.isEmpty()) { + b.setIconAlternateText(UPDATED_ALTERNATE_TEXT); + } else { + b.setIconAlternateText(null); + } + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java new file mode 100644 index 0000000000..2cb294de77 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2013 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.components.nativebutton; + +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.BUTTON_TEXT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.BUTTON_TEXT_ICON; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.BUTTON_TEXT_ICON_ALT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.INITIAL_ALTERNATE_TEXT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT_ICON; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT_ICON_ALT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.UPDATED_ALTERNATE_TEXT; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class NativeButtonIconAndTextTest extends MultiBrowserTest { + + @Test + public void testNativeButtonIconAltText() { + openTestURL(); + assertAltText(BUTTON_TEXT, ""); + assertAltText(BUTTON_TEXT_ICON, ""); + assertAltText(BUTTON_TEXT_ICON_ALT, INITIAL_ALTERNATE_TEXT); + assertAltText(NATIVE_BUTTON_TEXT, ""); + assertAltText(NATIVE_BUTTON_TEXT_ICON, ""); + assertAltText(NATIVE_BUTTON_TEXT_ICON_ALT, INITIAL_ALTERNATE_TEXT); + + clickElements(BUTTON_TEXT, BUTTON_TEXT_ICON, BUTTON_TEXT_ICON_ALT, + NATIVE_BUTTON_TEXT, NATIVE_BUTTON_TEXT_ICON, + NATIVE_BUTTON_TEXT_ICON_ALT); + + // Button without icon - should not get alt text + assertAltText(BUTTON_TEXT, ""); + assertAltText(BUTTON_TEXT_ICON, UPDATED_ALTERNATE_TEXT); + assertAltText(BUTTON_TEXT_ICON_ALT, ""); + // Button without icon - should not get alt text + assertAltText(NATIVE_BUTTON_TEXT, ""); + assertAltText(NATIVE_BUTTON_TEXT_ICON, UPDATED_ALTERNATE_TEXT); + assertAltText(NATIVE_BUTTON_TEXT_ICON_ALT, ""); + + } + + private void clickElements(String... ids) { + for (String id : ids) { + vaadinElementById(id).click(); + } + } + + /** + * If the button identified by 'buttonId' has an icon, asserts that the + * alternate text of the icon matches 'expected'. "" and null are considered + * equivalent. + * + * @param buttonId + * the id of the button who possibly contains an icon + * @param expected + * the expected alternate text, cannot be null + */ + private void assertAltText(String buttonId, String expected) { + WebElement button = vaadinElementById(buttonId); + List<WebElement> imgList = button.findElements(By.xpath(".//img")); + if (imgList.isEmpty()) { + return; + } + WebElement img = imgList.get(0); + String alt = img.getAttribute("alt"); + if (alt == null) { + alt = ""; + } + + Assert.assertEquals(expected, alt); + + } +} diff --git a/uitest/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html b/uitest/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html index 1ab75e1176..c9d9e186bc 100644 --- a/uitest/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html +++ b/uitest/src/com/vaadin/tests/components/notification/CloseErrorNotificationWithEscape.html @@ -28,12 +28,12 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>Hello world</td> </tr> <tr> <td>keyDown</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotifications::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>\27</td> </tr> <!-- Fade delay is 400 ms by default - VNotification --> diff --git a/uitest/src/com/vaadin/tests/components/notification/MiddleNotificationPosition.java b/uitest/src/com/vaadin/tests/components/notification/MiddleNotificationPosition.java new file mode 100644 index 0000000000..4050e4505e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/notification/MiddleNotificationPosition.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2013 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.components.notification; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.Position; +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.Notification; + +/** + * Test UI class for Notification with middle left and middle right positions. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class MiddleNotificationPosition extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Button left = new Button("Show Notification in middle left"); + left.addStyleName("show-middle-left"); + left.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Notification notification = new Notification("Notification"); + notification.setDelayMsec(10000); + notification.setPosition(Position.MIDDLE_LEFT); + notification.show(getUI().getPage()); + } + }); + addComponent(left); + + Button right = new Button("Show Notification in middle right"); + right.addStyleName("show-middle-right"); + right.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Notification notification = new Notification("Notification"); + notification.setDelayMsec(10000); + notification.setPosition(Position.MIDDLE_RIGHT); + notification.show(getUI().getPage()); + } + }); + addComponent(right); + + } + + @Override + protected String getTestDescription() { + return "Position.MIDDLE_LEFT and Position.MIDDLE_RIGHT should work for Notification"; + } + + @Override + protected Integer getTicketNumber() { + return 12931; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java b/uitest/src/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java new file mode 100644 index 0000000000..9f31719a10 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/notification/MiddleNotificationPositionTest.java @@ -0,0 +1,98 @@ +/* + * Copyright 2000-2013 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.components.notification; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Unit test class for Notification with middle left and middle right positions. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class MiddleNotificationPositionTest extends MultiBrowserTest { + + @Test + public void testMiddleLeft() { + openTestURL(); + + WebElement webElement = driver.findElement(By + .className("show-middle-left")); + webElement.click(); + + WebElement notification = driver.findElement(By + .className("v-Notification")); + + Assert.assertNotNull(notification); + String left = notification.getCssValue("left"); + Assert.assertEquals( + "Left position of notification element should be 0px", "0px", + left); + Point location = notification.getLocation(); + Assert.assertEquals("X coordinate of notifiation element should be 0", + 0, location.getX()); + + WebElement body = driver.findElement(By.tagName("body")); + int height = body.getSize().height; + + Assert.assertTrue("Y coordinate of notification element is too small", + height / 2 - notification.getSize().height / 2 - 1 <= location + .getY()); + Assert.assertTrue("Y coordinate of notification element is too big", + height / 2 + 1 >= location.getY()); + } + + @Test + public void testMiddleRight() { + openTestURL(); + + WebElement webElement = driver.findElement(By + .className("show-middle-right")); + webElement.click(); + + WebElement notification = driver.findElement(By + .className("v-Notification")); + + Assert.assertNotNull(notification); + String right = notification.getCssValue("right"); + Assert.assertEquals( + "Right position of notification element should be 0px", "0px", + right); + + WebElement body = driver.findElement(By.tagName("body")); + int height = body.getSize().height; + int width = body.getSize().width; + + Point location = notification.getLocation(); + Assert.assertTrue( + "Notification right border should be in the rightmost position", + width - 1 <= location.getX() + + notification.getSize().getWidth()); + + Assert.assertTrue("Y coordinate of notification element is too small", + height / 2 - notification.getSize().height / 2 - 1 <= location + .getY()); + Assert.assertTrue("Y coordinate of notification element is too big", + height / 2 + 1 >= location.getY()); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html new file mode 100644 index 0000000000..fb00953e48 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>NotificationsWaiAria</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">NotificationsWaiAria</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.notification.NotificationsWaiAria?restartApplication</td> + <td></td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTextField[0]</td> + <td>Prefix:</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VTextField[0]</td> + <td>- press ESC to close</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VNativeSelect[0]/domChild[0]</td> + <td>label=ALERT</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]</td> + <td></td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]@role</td> + <td>alert</td> +</tr> +<tr> + <td>assertText</td> + <td>xpath=//div[@class='v-Notification humanized v-Notification-humanized']//span[@class='v-assistive-device-only'][1]</td> + <td>Prefix:</td> +</tr> +<tr> + <td>assertText</td> + <td>xpath=//div[@class='v-Notification humanized v-Notification-humanized']//span[@class='v-assistive-device-only'][2]</td> + <td>- press ESC to close</td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>select</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VNativeSelect[0]/domChild[0]</td> + <td>label=STATUS</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertAttribute</td> + <td>xpath=/html/body/div[2]/div@role</td> + <td>status</td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java new file mode 100644 index 0000000000..ecf704835f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java @@ -0,0 +1,121 @@ +package com.vaadin.tests.components.notification; + +import com.vaadin.data.Item; +import com.vaadin.server.Page; +import com.vaadin.shared.ui.ui.NotificationRole; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Notification.Type; +import com.vaadin.ui.NotificationConfiguration; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; + +public class NotificationsWaiAria extends TestBase { + + private static final String CAPTION = "CAPTION"; + private static final String ROLE = "ROLE"; + + private TextField prefix; + private TextField postfix; + private NativeSelect role; + + private TextArea tf; + private ComboBox type; + + @SuppressWarnings("deprecation") + @Override + protected void setup() { + prefix = new TextField("Prefix", "Info"); + addComponent(prefix); + + postfix = new TextField("Postfix", + " - closes automatically after 10 seconds"); + addComponent(postfix); + + role = new NativeSelect("NotificationRole"); + role.addItem(NotificationRole.ALERT); + role.addItem(NotificationRole.STATUS); + role.setValue(role.getItemIds().iterator().next()); + addComponent(role); + + tf = new TextArea("Text", "Hello world"); + tf.setRows(10); + addComponent(tf); + type = new ComboBox(); + type.setNullSelectionAllowed(false); + type.addContainerProperty(CAPTION, String.class, ""); + + type.setItemCaptionPropertyId(CAPTION); + + Item item = type.addItem(Notification.TYPE_HUMANIZED_MESSAGE); + item.getItemProperty(CAPTION).setValue("Humanized"); + + item = type.addItem(Notification.TYPE_ERROR_MESSAGE); + item.getItemProperty(CAPTION).setValue("Error"); + + item = type.addItem(Notification.TYPE_WARNING_MESSAGE); + item.getItemProperty(CAPTION).setValue("Warning"); + + item = type.addItem(Notification.TYPE_TRAY_NOTIFICATION); + item.getItemProperty(CAPTION).setValue("Tray"); + + item = type.addItem(Notification.Type.ASSISTIVE_NOTIFICATION); + item.getItemProperty(CAPTION).setValue("Assistive"); + + type.setValue(type.getItemIds().iterator().next()); + addComponent(type); + + Button showNotification = new Button("Show notification", + new SettingHandler()); + addComponent(showNotification); + + Button showDefaultNotification = new Button("Default notification", + new DefaultHandler()); + addComponent(showDefaultNotification); + } + + @Override + protected String getDescription() { + return "Generic test case for notifications"; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + + private class SettingHandler implements ClickListener { + @Override + public void buttonClick(ClickEvent event) { + Type typeValue = (Type) type.getValue(); + + Notification n = new Notification(tf.getValue(), typeValue); + n.setHtmlContentAllowed(true); + NotificationConfiguration notificationConf = UI.getCurrent() + .getNotificationConfiguration(); + notificationConf.setAssistivePrefix(typeValue, prefix.getValue()); + notificationConf.setAssistivePostfix(typeValue, postfix.getValue()); + notificationConf + .setAssistiveRole(typeValue, (NotificationRole) role.getValue()); + + n.show(Page.getCurrent()); + } + } + + private class DefaultHandler implements ClickListener { + @Override + public void buttonClick(ClickEvent event) { + Notification n = new Notification(tf.getValue(), + (Type) type.getValue()); + n.setHtmlContentAllowed(true); + n.show(Page.getCurrent()); + } + } +} diff --git a/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html index 80d10a05ca..db5a268ecd 100644 --- a/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html +++ b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupParentDisabled.html @@ -1,4 +1,4 @@ -?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionHover.java b/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionHover.java new file mode 100644 index 0000000000..e9b022eac2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionHover.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2013 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.components.orderedlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.VerticalLayout; + +/** + * Test hovering over nested layout caption + * + * @author Vaadin Ltd + */ +public class NestedLayoutCaptionHover extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout test = new VerticalLayout(); + test.setCaption("inner layout"); + addComponent(new VerticalLayout(new VerticalLayout(new VerticalLayout( + test)))); + } + + @Override + protected String getTestDescription() { + return "Hovering over nested layout caption should not freeze the browser"; + } + + @Override + protected Integer getTicketNumber() { + return 12469; + } +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionHoverTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionHoverTest.java new file mode 100644 index 0000000000..24a27f343a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/NestedLayoutCaptionHoverTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 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.components.orderedlayout; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests hovering over caption in nested layout + */ +public class NestedLayoutCaptionHoverTest extends MultiBrowserTest { + + @Test + public void testTooltipInNestedLayout() throws Exception { + openTestURL(); + + WebElement caption = getDriver().findElement( + By.className("v-captiontext")); + + assertEquals("inner layout", caption.getText()); + + // Hover over the caption + Coordinates coords = ((Locatable) caption).getCoordinates(); + ((HasInputDevices) getDriver()).getMouse().mouseMove(coords); + sleep(1000); + + String selector = "Root/VNotification[0]"; + try { + // Verify that there's no error notification + vaadinElement(selector); + fail("No error notification should be found"); + } catch (NoSuchElementException e) { + // Exception caught. Verify it's the right one. + assertTrue(e.getMessage().contains(selector)); + } + } +} diff --git a/uitest/src/com/vaadin/tests/components/page/PageTitle.java b/uitest/src/com/vaadin/tests/components/page/PageTitle.java new file mode 100644 index 0000000000..38dcd4673c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/page/PageTitle.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2013 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.components.page; + +import com.vaadin.annotations.Title; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; + +@Title("bar") +public class PageTitle extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + String title = request.getParameter("title"); + if (title != null) { + getPage().setTitle(title); + } + + } + + @Override + protected String getTestDescription() { + return "Sets the title according to a given ?title parameter. By default the ApplicationServletRunner will set the title to the fully qualified class name"; + } + + @Override + protected Integer getTicketNumber() { + return 13430; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/page/PageTitleTest.java b/uitest/src/com/vaadin/tests/components/page/PageTitleTest.java new file mode 100644 index 0000000000..039f52be73 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/page/PageTitleTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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.components.page; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PageTitleTest extends MultiBrowserTest { + + @Test + public void nullTitle() { + driver.get(getTestUrl()); + Assert.assertEquals(PageTitle.class.getName(), driver.getTitle()); + } + + @Test + public void fooTitle() { + driver.get(getTestUrl() + "?title=foo"); + Assert.assertEquals("foo", driver.getTitle()); + } +} diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewCaption.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewCaption.java new file mode 100644 index 0000000000..8cb9f01d93 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewCaption.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2013 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.components.popupview; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.PopupView; + +/** + * + * @author Vaadin Ltd + */ +public class PopupViewCaption extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + FormLayout layout = new FormLayout(); + addComponent(layout); + Label label = new Label("Label"); + PopupView popup = new PopupView("Popup short text", label); + popup.setCaption("Popup Caption:"); + layout.addComponent(popup); + } + + @Override + protected String getTestDescription() { + return "Caption for popup view should be shown by layout"; + } + + @Override + protected Integer getTicketNumber() { + return 10618; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java new file mode 100644 index 0000000000..9c59e2ca6e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewCaptionTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2013 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.components.popupview; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @author Vaadin Ltd + */ +public class PopupViewCaptionTest extends MultiBrowserTest { + + @Test + public void testCaption() { + openTestURL(); + + WebElement caption = driver.findElement(By.className("v-caption")); + Assert.assertNotNull(caption); + + List<WebElement> elements = caption.findElements(By.xpath("*")); + + boolean foundCaptionText = false; + for (WebElement element : elements) { + if ("Popup Caption:".equals(element.getText())) { + foundCaptionText = true; + break; + } + } + Assert.assertTrue("Unable to find caption text", foundCaptionText); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorTest.java b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorTest.java index fce5cdfa14..93e8c6d8f2 100644 --- a/uitest/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorTest.java +++ b/uitest/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorTest.java @@ -49,7 +49,7 @@ public class ProgressIndicatorTest extends AbstractFieldTest<ProgressIndicator> createSetValueAction(); createPollingIntervalAction(); createIndeterminateToggle(); - }; + } private void createIndeterminateToggle() { createBooleanAction("Indeterminate", CATEGORY_FEATURES, false, diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderResize.java b/uitest/src/com/vaadin/tests/components/slider/SliderResize.java new file mode 100644 index 0000000000..55ed56299c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/slider/SliderResize.java @@ -0,0 +1,60 @@ +/* + * 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.components.slider; + +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.Slider; +import com.vaadin.ui.VerticalLayout; + +public class SliderResize extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final VerticalLayout layout = new VerticalLayout(); + layout.setSpacing(true); + layout.setWidth("500px"); + addComponent(layout); + + Slider slider = new Slider(); + slider.setId("horizontal"); + slider.setValue(100.0); + slider.setWidth("100%"); + + Button changeWidth = new Button("Set layout width to 300px", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.setWidth("300px"); + } + }); + layout.addComponents(slider, changeWidth); + } + + @Override + protected String getTestDescription() { + return "Slider handle should be updated to correct position when the component size changes"; + } + + @Override + protected Integer getTicketNumber() { + return 12550; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderResizeTest.java b/uitest/src/com/vaadin/tests/components/slider/SliderResizeTest.java new file mode 100644 index 0000000000..22df3e4211 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/slider/SliderResizeTest.java @@ -0,0 +1,49 @@ +/* + * 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.components.slider; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SliderResizeTest extends MultiBrowserTest { + + @Test + public void resizeSlider() throws IOException { + openTestURL(); + + // Verify the starting position. + assertEquals("488px", getSliderHandlePosition()); + + // Click on the button that reduces the layout width by 200px. + driver.findElement(By.className("v-button")).click(); + + // Assert that the slider handle was also moved. + assertEquals("288px", getSliderHandlePosition()); + } + + private String getSliderHandlePosition() { + WebElement handle = driver.findElement(By.className("v-slider-handle")); + return handle.getCssValue("margin-left"); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html index 4e8296050f..806e7d1b44 100644 --- a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html +++ b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html @@ -3,13 +3,13 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://arturwin.office.itmill.com:9999/" /> -<title>New Test</title> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>SliderTooltip</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> +<tr><td rowspan="1" colspan="3">SliderTooltip</td></tr> </thead><tbody> <tr> <td>open</td> @@ -57,9 +57,14 @@ <td>40,16</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>pause</td> <td></td> + <td>1000</td> +</tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>-1000</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java b/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java index 355cd43d37..4cf2506eeb 100644 --- a/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java +++ b/uitest/src/com/vaadin/tests/components/table/DoublesInTable.java @@ -9,7 +9,7 @@ import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.BeanItemContainer; import com.vaadin.data.util.converter.Converter; -import com.vaadin.data.util.converter.StringToNumberConverter; +import com.vaadin.data.util.converter.StringToDoubleConverter; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.Country; @@ -276,7 +276,7 @@ public class DoublesInTable extends TestBase { }); - t.setConverter("rent", new StringToNumberConverter() { + t.setConverter("rent", new StringToDoubleConverter() { @Override protected NumberFormat getFormat(Locale locale) { return NumberFormat.getCurrencyInstance(locale); diff --git a/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java b/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java index 829c29b95b..a7d387477d 100644 --- a/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java +++ b/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java @@ -51,7 +51,7 @@ public class ExpandingContainer extends AbstractContainer implements updateLabel(); } return currentSize; - }; + } @Override public void fireItemSetChange() { diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java index f7cb306100..cf6a92c283 100644 --- a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java @@ -21,6 +21,7 @@ import static com.vaadin.tests.components.table.SelectAllRows.TABLE; import static com.vaadin.tests.components.table.SelectAllRows.TOTAL_NUMBER_OF_ROWS; import static org.junit.Assert.assertEquals; +import java.util.ArrayList; import java.util.List; import org.junit.Test; @@ -46,12 +47,10 @@ public class SelectAllRowsTest extends MultiBrowserTest { @Override public List<DesiredCapabilities> getBrowsersToTest() { - // Pressing Shift modifier key does not work with TestBench and IE - // (#8621) - - List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + // Pressing Shift modifier key does not work with Firefox + ArrayList<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>( + super.getBrowsersToTest()); browsers.remove(Browser.FIREFOX.getDesiredCapabilities()); - return browsers; } @@ -76,15 +75,14 @@ public class SelectAllRowsTest extends MultiBrowserTest { private void selectAllRowsInTable() { clickFirstRow(); scrollTableToBottom(); - new Actions(getDriver()).keyDown(Keys.SHIFT).perform(); - clickLastRow(); - new Actions(getDriver()).keyUp(Keys.SHIFT).perform(); + new Actions(getDriver()).keyDown(Keys.SHIFT).click(getLastRow()) + .keyUp(Keys.SHIFT).perform(); } - private void clickLastRow() { + private WebElement getLastRow() { List<WebElement> rows = allVisibleTableRows(); WebElement lastRow = rows.get(rows.size() - 1); - lastRow.click(); + return lastRow; } private void clickFirstRow() { diff --git a/uitest/src/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html b/uitest/src/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html new file mode 100644 index 0000000000..e225091b5f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>TableDragColumn</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TableDragColumn</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td> + <td></td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>51,6</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td> + <td>70,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>1 basic ghost element</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>10,10</td> +</tr> +<!--Add style name "red-border-1px" to table--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td> + <td>24,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>18,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4</td> + <td>19,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item2</td> + <td>75,7</td> +</tr> +<!-- Drag and drop column 1 to the left of column 4 --> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>51,6</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td> + <td>70,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>2 themed ghost element should have red borders</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>10,10</td> +</tr> +<!--Add style name "red-border-1px" to table--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td> + <td>24,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>18,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4</td> + <td>19,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item3</td> + <td>164,10</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>51,6</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td> + <td>70,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>3 themed ghost element should have 2px blue borders</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>10,10</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html index eb3efc28fd..2df9fb678c 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html +++ b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html @@ -3,13 +3,13 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://arturwin.office.itmill.com:8888/" /> -<title>New Test</title> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>TableItemDescriptionGeneratorTest</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> +<tr><td rowspan="1" colspan="3">TableItemDescriptionGeneratorTest</td></tr> </thead><tbody> <tr> <td>open</td> @@ -39,10 +39,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Button tooltip--> <tr> <td>mouseMoveAt</td> @@ -65,10 +70,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--TextField tooltip--> <tr> <td>mouseMoveAt</td> @@ -91,10 +101,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Cell and row tooltips--> <tr> <td>mouseClick</td> @@ -123,10 +138,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Button tooltip--> <tr> <td>mouseMoveAt</td> @@ -149,10 +169,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--TextField tooltip--> <tr> <td>mouseMoveAt</td> @@ -175,10 +200,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Row and Component tooltips--> <tr> <td>mouseClick</td> @@ -212,10 +242,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Button tooltip--> <tr> <td>mouseMoveAt</td> @@ -238,10 +273,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--TextField tooltip--> <tr> <td>mouseMoveAt</td> @@ -264,10 +304,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Row tooltips--> <tr> <td>mouseClick</td> @@ -296,10 +341,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--Button tooltip--> <tr> <td>mouseMoveAt</td> @@ -322,10 +372,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> <!--TextField tooltip--> <tr> <td>mouseMoveAt</td> @@ -348,10 +403,15 @@ <td>22,7</td> </tr> <tr> - <td>waitForElementNotPresent</td> - <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>pause</td> + <td>1000</td> <td></td> </tr> +<tr> + <td>assertElementPositionLeft</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td>-1000</td> +</tr> </tbody></table> </body> diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java new file mode 100644 index 0000000000..ab0198f39c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java @@ -0,0 +1,281 @@ +/* + * Copyright 2000-2013 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.components.table; + +import java.util.ArrayList; +import java.util.Collection; + +import org.json.JSONObject; + +import com.vaadin.annotations.Push; +import com.vaadin.server.ClientConnector; +import com.vaadin.server.StreamVariable; +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.ConnectorTracker; +import com.vaadin.ui.Table; + +@Push +public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { + + public static final String SUCCESS_CAPTION = "Success!"; + public static final String BUTTON_ID = "blinkbutton"; + public static final String FAILURE_CAPTION = "Test failed"; + + private class WrappedConnectorTracker extends ConnectorTracker { + private ConnectorTracker tracker; + + private boolean initialDirtyHasBeenCalled = false; + + public WrappedConnectorTracker(ConnectorTracker tracker) { + super(TableRemovedQuicklySendsInvalidRpcCalls.this); + this.tracker = tracker; + } + + @Override + public void markAllConnectorsDirty() { + tracker.markAllConnectorsDirty(); + if (initialDirtyHasBeenCalled) { + button.setCaption(FAILURE_CAPTION); + } + initialDirtyHasBeenCalled = true; + } + + // DELEGATED METHODS BELOW: + + @Override + public void registerConnector(ClientConnector connector) { + tracker.registerConnector(connector); + } + + @Override + public void unregisterConnector(ClientConnector connector) { + tracker.unregisterConnector(connector); + } + + @Override + public boolean isClientSideInitialized(ClientConnector connector) { + return tracker.isClientSideInitialized(connector); + } + + @Override + public void markClientSideInitialized(ClientConnector connector) { + tracker.markClientSideInitialized(connector); + } + + @Override + public void markAllClientSidesUninitialized() { + tracker.markAllClientSidesUninitialized(); + } + + @Override + public ClientConnector getConnector(String connectorId) { + return tracker.getConnector(connectorId); + } + + @Override + public void cleanConnectorMap() { + tracker.cleanConnectorMap(); + } + + @Override + public void markDirty(ClientConnector connector) { + tracker.markDirty(connector); + } + + @Override + public void markClean(ClientConnector connector) { + tracker.markClean(connector); + } + + @Override + public void markAllConnectorsClean() { + tracker.markAllConnectorsClean(); + } + + @Override + public Collection<ClientConnector> getDirtyConnectors() { + return tracker.getDirtyConnectors(); + } + + @Override + public boolean hasDirtyConnectors() { + return tracker.hasDirtyConnectors(); + } + + @Override + public ArrayList<ClientConnector> getDirtyVisibleConnectors() { + return tracker.getDirtyVisibleConnectors(); + } + + @Override + public JSONObject getDiffState(ClientConnector connector) { + return tracker.getDiffState(connector); + } + + @Override + public void setDiffState(ClientConnector connector, JSONObject diffState) { + tracker.setDiffState(connector, diffState); + } + + @Override + public boolean isDirty(ClientConnector connector) { + return tracker.isDirty(connector); + } + + @Override + public boolean isWritingResponse() { + return tracker.isWritingResponse(); + } + + @Override + public void setWritingResponse(boolean writingResponse) { + tracker.setWritingResponse(writingResponse); + } + + @Override + public StreamVariable getStreamVariable(String connectorId, + String variableName) { + return tracker.getStreamVariable(connectorId, variableName); + } + + @Override + public void addStreamVariable(String connectorId, String variableName, + StreamVariable variable) { + tracker.addStreamVariable(connectorId, variableName, variable); + } + + @Override + public void cleanStreamVariable(String connectorId, String variableName) { + tracker.cleanStreamVariable(connectorId, variableName); + } + + @Override + public String getSeckey(StreamVariable variable) { + return tracker.getSeckey(variable); + } + + @Override + public boolean connectorWasPresentAsRequestWasSent(String connectorId, + long lastSyncIdSeenByClient) { + return tracker.connectorWasPresentAsRequestWasSent(connectorId, + lastSyncIdSeenByClient); + } + + @Override + public int getCurrentSyncId() { + return tracker.getCurrentSyncId(); + } + + @Override + public void cleanConcurrentlyRemovedConnectorIds( + int lastSyncIdSeenByClient) { + tracker.cleanConcurrentlyRemovedConnectorIds(lastSyncIdSeenByClient); + } + + @Override + public boolean equals(Object obj) { + return tracker.equals(obj); + } + + @Override + public int hashCode() { + return tracker.hashCode(); + } + + @Override + public String toString() { + return tracker.toString(); + } + } + + private Button button; + private WrappedConnectorTracker wrappedTracker = null; + + @Override + protected void setup(VaadinRequest request) { + button = new Button("Blink a table", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + blinkTable(); + } + }); + button.setId(BUTTON_ID); + addComponent(button); + } + + @Override + public ConnectorTracker getConnectorTracker() { + if (wrappedTracker == null) { + wrappedTracker = new WrappedConnectorTracker( + super.getConnectorTracker()); + } + return wrappedTracker; + } + + private void blinkTable() { + final Table table = new Table(); + table.setPageLength(5); + table.addContainerProperty(new Object(), String.class, null); + + for (int i = 0; i < 50; i++) { + table.addItem(new Object[] { "Row" }, new Object()); + } + + System.out.println("adding component"); + addComponent(table); + + new Thread() { + @Override + public void run() { + getSession().lock(); + try { + Thread.sleep(500); + access(new Runnable() { + @Override + public void run() { + System.out.println("removing component"); + removeComponent(table); + button.setCaption(SUCCESS_CAPTION); + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + getSession().unlock(); + } + } + }.start(); + } + + @Override + protected String getTestDescription() { + return "Adding and subsequently quickly removing a table " + + "should not leave any pending RPC calls waiting " + + "in a Timer. Issue can be reproduced by " + + "1) pressing the button 2) checking the server " + + "log for any error messages starting with " + + "\"RPC call to...\" ."; + } + + @Override + protected Integer getTicketNumber() { + return 12337; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java new file mode 100644 index 0000000000..68c8dc9884 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2013 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.components.table; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TableRemovedQuicklySendsInvalidRpcCallsTest extends + MultiBrowserTest { + + private static final String BUTTON_ID = TableRemovedQuicklySendsInvalidRpcCalls.BUTTON_ID; + private static final String FAILURE_CAPTION = TableRemovedQuicklySendsInvalidRpcCalls.FAILURE_CAPTION; + private static final String SUCCESS_CAPTION = TableRemovedQuicklySendsInvalidRpcCalls.SUCCESS_CAPTION; + + @Test + public void test() throws Exception { + setDebug(true); + openTestURL(); + + assertFalse("Test started with the error present.", button().getText() + .equals(FAILURE_CAPTION)); + assertFalse("Test jumped the gun.", + button().getText().equals(SUCCESS_CAPTION)); + + button().click(); + Thread.sleep(5000); + + assertFalse("Test failed after trying to trigger the error.", button() + .getText().equals(FAILURE_CAPTION)); + assertTrue("Test didn't end up in correct success state.", button() + .getText().equals(SUCCESS_CAPTION)); + } + + private WebElement button() { + return vaadinElementById(BUTTON_ID); + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.html b/uitest/src/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.html index bab6c8dc16..e24f4ddca4 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.html +++ b/uitest/src/com/vaadin/tests/components/table/TableShouldNotEatValueChanges.html @@ -33,7 +33,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableShouldNotEatValueChanges::Root/VNotification[0]</td> + <td>vaadin=runcomvaadintestscomponentstableTableShouldNotEatValueChanges::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>TF Value on the server:fooo</td> </tr> <tr> @@ -63,7 +63,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableShouldNotEatValueChanges::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentstableTableShouldNotEatValueChanges::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>TF Value on the server:baar</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html index c2481e6be6..441324bb6a 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html +++ b/uitest/src/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.html @@ -3,7 +3,6 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:9999/" /> <title>TableWithBrokenGeneratorAndContainer</title> </head> <body> @@ -163,7 +162,7 @@ <!--error notification--> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::Root/VNotification[0]/HTML[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentstableTableWithBrokenGeneratorAndContainer::Root/VNotification[0]/HTML[0]/domChild[1]</td> <td>Problem updating table. Please try again later</td> </tr> <!--table should be empty--> diff --git a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java index 733f46959a..ae16eff2dd 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java +++ b/uitest/src/com/vaadin/tests/components/table/TableWithContainerRequiringEqualsForItemId.java @@ -39,7 +39,7 @@ public class TableWithContainerRequiringEqualsForItemId extends TestBase { // instance does not stay the same BeanItem<MyEntity> beanItem = getItem(super.getIdByIndex(index)); return getBeanIdResolver().getIdForBean(beanItem.getBean()); - }; + } } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheet.java b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheet.java new file mode 100644 index 0000000000..3cbe624ee0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheet.java @@ -0,0 +1,27 @@ +package com.vaadin.tests.components.tabsheet; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.TabSheet; + +public class EmptyTabSheet extends TestBase { + + private TabSheet tabSheet; + + @Override + protected String getDescription() { + return "Test a TabSheet without any tabs."; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + @Override + protected void setup() { + tabSheet = new TabSheet(); + tabSheet.setId("tabsheet"); + addComponent(tabSheet); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java new file mode 100644 index 0000000000..dabc9c8e0b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/EmptyTabSheetTest.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2013 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.components.tabsheet; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class EmptyTabSheetTest extends MultiBrowserTest { + @Test + public void emptyTabSheet() throws Exception { + openTestURL(); + + compareScreen("empty"); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.html b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.html deleted file mode 100644 index c4f5998f47..0000000000 --- a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.html +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8080/" /> -<title>PreventTabChange</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">PreventTabChange</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.tabsheet.PreventTabChange</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstabsheetPreventTabChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java index 434c73f778..fddb036728 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChange.java @@ -31,7 +31,8 @@ public class PreventTabChange extends TestBase implements @Override protected void setup() { tabSheet = new TabSheet(); - tabSheet.addListener(this); + tabSheet.setId("tabsheet"); + tabSheet.addSelectedTabChangeListener(this); tab1 = new Label("Tab 1 contents"); tab2 = new Label("Tab 2 contents"); tab3 = new Label("Tab 3 contents"); @@ -48,8 +49,8 @@ public class PreventTabChange extends TestBase implements @Override public void selectedTabChange(SelectedTabChangeEvent event) { - TabSheet tabsheet = event.getTabSheet(); + if (lastTab == tab1) { if (tabsheet.getSelectedTab() != tab2) { tabsheet.setSelectedTab(lastTab); @@ -63,6 +64,7 @@ public class PreventTabChange extends TestBase implements tabsheet.setSelectedTab(lastTab); } } + lastTab = tabsheet.getSelectedTab(); } } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java new file mode 100644 index 0000000000..31a59aaed6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/PreventTabChangeTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2000-2013 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.components.tabsheet; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PreventTabChangeTest extends MultiBrowserTest { + @Test + public void preventTabChange() throws Exception { + openTestURL(); + + clickTab(1); + clickTab(2); + Thread.sleep(2000); + assertTabSelected(2); + Assert.assertEquals("Tab 3 contents", getSelectedTabContent().getText()); + clickTab(0); + clickTab(2); + assertTabSelected(0); + Assert.assertEquals("Tab 1 contents", getSelectedTabContent().getText()); + } + + private void assertTabSelected(int i) throws NoSuchElementException { + WebElement tabItem = findTab(i).findElement(By.xpath("..")); + Assert.assertTrue("Tab " + i + " should be selected but isn't", tabItem + .getAttribute("class").contains("v-tabsheet-tabitem-selected")); + } + + private void clickTab(int i) { + findTab(i).click(); + } + + private WebElement findTab(int i) { + return driver.findElement(com.vaadin.testbench.By + .vaadin("//TabSheet#tab[" + i + "]")); + } + + private WebElement getSelectedTabContent() { + return driver.findElement(com.vaadin.testbench.By + .vaadin("//TabSheet#tabpanel")); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html index 4b2ad890c3..825988173a 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html @@ -33,6 +33,16 @@ <tr> <td>assertText</td> <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]</td> + <td>Tab 1</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>space</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]</td> <td>Tab 2</td> </tr> <tr> @@ -58,6 +68,16 @@ <tr> <td>assertText</td> <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]</td> + <td>Tab 2</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>space</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]</td> <td>Tab 5</td> </tr> <tr> @@ -83,6 +103,16 @@ <tr> <td>assertText</td> <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]</td> + <td>Tab 5</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>space</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]</td> <td>Tab 6</td> </tr> <tr> @@ -143,6 +173,16 @@ <tr> <td>assertText</td> <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]</td> + <td>Tab 9</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[10]</td> + <td>space</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]</td> <td>Tab 12</td> </tr> <tr> @@ -178,6 +218,16 @@ <tr> <td>assertText</td> <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> + <td>Tab 5</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>space</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> <td>Tab 1</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java new file mode 100644 index 0000000000..e394594176 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabKeyboardNavigationWaiAria.java @@ -0,0 +1,86 @@ +package com.vaadin.tests.components.tabsheet; + +import java.util.ArrayList; + +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.Button.ClickListener; +import com.vaadin.ui.Component; +import com.vaadin.ui.Layout; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.Tab; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class TabKeyboardNavigationWaiAria extends AbstractTestUI { + + int index = 1; + ArrayList<Component> tabs = new ArrayList<Component>(); + TabSheet ts = new TabSheet(); + + @Override + protected void setup(VaadinRequest request) { + ts.setWidth("500px"); + ts.setHeight("500px"); + + for (int i = 0; i < 5; ++i) { + addTab(); + } + + Button addTab = new Button("Add a tab", new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + addTab(); + } + }); + Button focus = new Button("Focus tabsheet", new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + ts.focus(); + } + }); + + addComponent(addTab); + addComponent(focus); + + addComponent(ts); + } + + @Override + protected String getTestDescription() { + return "The tab bar should be focusable and arrow keys should change focus for tabs. Space key selects a focused tab. The del key should close a tab if closable."; + } + + @Override + protected Integer getTicketNumber() { + return 11827; + } + + private Tab addTab() { + Layout content = new VerticalLayout(); + tabs.add(content); + + TextField field = new TextField("Tab " + index + " label"); + content.addComponent(field); + + Tab tab = ts.addTab(content, "Tab " + index, null); + + if (index == 2) { + tab.setClosable(true); + tab.setDescription("Tab 2 Tooltip"); + } + + if (index == 4) { + tab.setEnabled(false); + } + + if (index == 5) { + tab.setDefaultFocusComponent(field); + } + + index++; + return tab; + } +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java index 88bc23d12b..f6ce33121c 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java @@ -15,14 +15,17 @@ */ package com.vaadin.tests.components.tabsheet; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + import java.io.IOException; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; +import com.vaadin.testbench.commands.TestBenchElementCommands; import com.vaadin.tests.tb3.MultiBrowserTest; public class TabSheetErrorTooltipTest extends MultiBrowserTest { @@ -31,20 +34,37 @@ public class TabSheetErrorTooltipTest extends MultiBrowserTest { public void checkTooltips() throws IOException { openTestURL(); - testBenchElement(getTab(0)).showTooltip(); - assertNoTooltip(); + assertTabHasNoTooltipNorError(0); + + assertTabHasTooltipAndError(1, "", "Error!"); + + assertTabHasTooltipAndError(2, "This is a tab", ""); + + assertTabHasTooltipAndError(3, + "This tab has both an error and a description", "Error!"); + } + + private void assertTabHasTooltipAndError(int index, String tooltip, + String errorMessage) { + showTooltip(index); + assertTooltip(tooltip); + assertErrorMessage(errorMessage); + } + + private void assertTabHasNoTooltipNorError(int index) { + showTooltip(index); + WebElement tooltip = getCurrentTooltip(); + + assertThat(tooltip.getText(), is("")); - testBenchElement(getTab(1)).showTooltip(); - assertErrorMessage("Error!"); - assertTooltip(""); + WebElement errorMessage = getCurrentErrorMessage(); + assertThat(errorMessage.isDisplayed(), is(false)); - testBenchElement(getTab(2)).showTooltip(); - assertErrorMessage(""); - assertTooltip("This is a tab"); + } - testBenchElement(getTab(3)).showTooltip(); - assertErrorMessage("Error!"); - assertTooltip("This tab has both an error and a description"); + private void showTooltip(int index) { + TestBenchElementCommands element = testBenchElement(getTab(index)); + element.showTooltip(); } private WebElement getTab(int index) { @@ -52,30 +72,21 @@ public class TabSheetErrorTooltipTest extends MultiBrowserTest { + index + "]/domChild[0]"); } - private WebElement getTooltip() { + private WebElement getCurrentTooltip() { return getDriver().findElement( By.xpath("//div[@class='v-tooltip-text']")); } - private WebElement getErrorMessage() { + private WebElement getCurrentErrorMessage() { return getDriver().findElement( By.xpath("//div[@class='v-errormessage']")); } private void assertTooltip(String tooltip) { - Assert.assertEquals(tooltip, getTooltip().getText()); + Assert.assertEquals(tooltip, getCurrentTooltip().getText()); } private void assertErrorMessage(String message) { - Assert.assertEquals(message, getErrorMessage().getText()); - } - - private void assertNoTooltip() { - try { - getTooltip(); - } catch (NoSuchElementException e) { - return; - } - Assert.fail("Tooltip exists"); + Assert.assertEquals(message, getCurrentErrorMessage().getText()); } } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java new file mode 100644 index 0000000000..81648c1b52 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2013 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.components.tabsheet; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabSheetFocusedTabTest extends MultiBrowserTest { + + @Override + protected Class<?> getUIClass() { + return TabsheetScrolling.class; + } + + @Test + public void clickingChangesFocusedTab() throws Exception { + openTestURL(); + + getTab(1).click(); + + assertTrue(isFocused(getTab(1))); + + new Actions(getDriver()).sendKeys(Keys.RIGHT).perform(); + + assertFalse(isFocused(getTab(1))); + assertTrue(isFocused(getTab(3))); + + getTab(5).click(); + + assertFalse(isFocused(getTab(3))); + assertTrue(isFocused(getTab(5))); + + getTab(1).click(); + + assertFalse(isFocused(getTab(5))); + assertTrue(isFocused(getTab(1))); + } + + private WebElement getTab(int index) { + return getDriver() + .findElement( + By.xpath("(//table[contains(@class, 'v-tabsheet-tabs')])[1]/tbody/tr/td[" + + (index + 1) + "]/div")); + } + + private boolean isFocused(WebElement tab) { + return tab.getAttribute("class").contains("v-tabsheet-tabitem-focus"); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.html index 425da11af4..6876497a1f 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.html +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.html @@ -21,6 +21,16 @@ <td></td> <td></td> </tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetIcons::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]@alt</td> + <td>iconalt1</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetIcons::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]@alt</td> + <td>iconalt3</td> +</tr> </tbody></table> </body> diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.java index 5d814ec48f..c5e01969a1 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetIcons.java @@ -46,6 +46,8 @@ public class TabSheetIcons extends TestBase { for (Component c : tab) { tabsheet.addTab(c); + tabsheet.getTab(c).setIconAlternateText( + "iconalt" + tabsheet.getComponentCount()); } return tabsheet; diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetTest.java index 6c39cdab73..56836037b7 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetTest.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetTest.java @@ -26,7 +26,7 @@ public class TabSheetTest<T extends TabSheet> extends @Override public void execute(T c, Integer value, Object data) { - c.getTab(value).setIcon((Resource) data); + c.getTab(value).setIcon((Resource) data, "tabicon"); } }; diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html new file mode 100644 index 0000000000..64e85f55e3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.html @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>TabSheetWithTabIds</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TabSheetWithTabIds</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.tabsheet.TabSheetWithTabIds</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>tab1</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>tab2</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>tab3</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetWithTabIds::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>tab1</td> + <td></td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>tab2</td> + <td></td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>tab3</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetWithTabIds::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>tab1</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>tab2</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>tab3</td> + <td></td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java new file mode 100644 index 0000000000..ae5adea45e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetWithTabIds.java @@ -0,0 +1,77 @@ +/* + * Copyright 2000-2013 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.components.tabsheet; + +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; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.Tab; + +public class TabSheetWithTabIds extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TabSheet tabSheet = new TabSheet(); + + final Tab tab1 = tabSheet.addTab(new Label("Label 1"), "Tab 1", null); + + final Tab tab2 = tabSheet.addTab(new Label("Label 2"), "Tab 2", null); + + final Tab tab3 = tabSheet.addTab(new Label("Label 3"), "Tab 3", null); + + addComponent(tabSheet); + + Button b = new Button("Set ids", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + tab1.setId("tab1"); + tab2.setId("tab2"); + tab3.setId("tab3"); + } + }); + addComponent(b); + + Button b2 = new Button("Clear ids", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + tab1.setId(null); + tab2.setId(null); + tab3.setId(null); + } + }); + addComponent(b2); + } + + @Override + protected String getTestDescription() { + return "Add support for setId to TabSheet.Tab"; + } + + @Override + protected Integer getTicketNumber() { + return 12064; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java index 1670963b9b..b55f1057b5 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java @@ -33,6 +33,7 @@ public class TabsheetScrollingTest extends MultiBrowserTest { for (int i = 0; i < 10; i++) { sendKey(Keys.ARROW_RIGHT); } + sendKey(Keys.SPACE); Assert.assertEquals("Hide this tab (21)", getHideButtonText()); } diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetTooltip.html b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetTooltip.html index d133ab9937..38ff6ab8ca 100644 --- a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetTooltip.html +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetTooltip.html @@ -13,7 +13,7 @@ </thead><tbody> <tr> <td>open</td> - <td>/run/com.vaadin.tests.components.tabsheet.TabsheetTooltip</td> + <td>/run/com.vaadin.tests.components.tabsheet.TabsheetTooltip?restartApplication</td> <td></td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java new file mode 100644 index 0000000000..26716846fc --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java @@ -0,0 +1,147 @@ +/* + * Copyright 2000-2013 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.components.textfield; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +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.CheckBox; +import com.vaadin.ui.TextField; + +/** + * Test to verify fields become implicitly "immediate" when adding value change + * listener to them. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class AutomaticImmediate extends AbstractTestUIWithLog { + + /** + * + */ + static final String BUTTON = "button"; + /** + * + */ + static final String EXPLICIT_FALSE = "explicit-false"; + /** + * + */ + static final String FIELD = "field"; + /** + * + */ + static final String LISTENER_TOGGLE = "listener-toggle"; + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + final TextField textField = new TextField() { + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractField#fireValueChange(boolean) + */ + @Override + protected void fireValueChange(boolean repaintIsNotNeeded) { + log("fireValueChange"); + super.fireValueChange(repaintIsNotNeeded); + } + }; + textField.setId(FIELD); + + final ValueChangeListener listener = new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + log("Value changed: " + event.getProperty().getValue()); + } + }; + + final CheckBox checkBox = new CheckBox("Toggle listener"); + checkBox.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + if (checkBox.getValue()) { + textField.addValueChangeListener(listener); + } else { + textField.removeValueChangeListener(listener); + } + } + }); + checkBox.setId(LISTENER_TOGGLE); + + Button b = new Button( + "setImmediate(false), sets explicitly false and causes server roundtrip", + new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + textField.setImmediate(false); + } + }); + b.setId(EXPLICIT_FALSE); + + Button b2 = new Button("Hit server, causes server roundtrip", + new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + } + }); + b2.setId(BUTTON); + + addComponent(textField); + addComponent(checkBox); + addComponent(b); + addComponent(b2); + + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Field should be immediate automatically if it has value change listener"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 8029; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java new file mode 100644 index 0000000000..4b522a1f37 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java @@ -0,0 +1,109 @@ +/* + * Copyright 2000-2013 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.components.textfield; + +import org.apache.commons.lang.RandomStringUtils; +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class AutomaticImmediateTest extends MultiBrowserTest { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass() + */ + @Override + protected Class<?> getUIClass() { + return AutomaticImmediate.class; + } + + @Test + public void test() { + openTestURL(); + + WebElement field = getDriver().findElement( + By.id(AutomaticImmediate.FIELD)); + + WebElement toggle = getDriver().findElement( + By.xpath("//input[@type = 'checkbox']")); + + WebElement explicitFalseButton = getDriver().findElement( + By.id(AutomaticImmediate.EXPLICIT_FALSE)); + + WebElement hitServerButton = getDriver().findElement( + By.id(AutomaticImmediate.BUTTON)); + + String string = getRandomString(); + field.sendKeys(string + Keys.ENTER); + + // Non immediate, just the initial server side valuechange + assertLastLog("1. fireValueChange"); + + hitServerButton.click(); + + // No value change, but value sent to server + assertLastLog("2. fireValueChange"); + + // listener on -> immediate on + toggle.click(); + + string = getRandomString(); + String delSequence = "" + Keys.BACK_SPACE + Keys.BACK_SPACE; + field.sendKeys(delSequence + string + Keys.ENTER); + assertLastLog("4. Value changed: " + string); + + // listener off -> immediate off + String lastvalue = string; + toggle.click(); + string = getRandomString(); + field.sendKeys(delSequence + string + Keys.ENTER); + // No new value change should happen... + assertLastLog("4. Value changed: " + lastvalue); + hitServerButton.click(); + // ... but server should receive value with roundtrip + assertLastLog("5. fireValueChange"); + + // explicitly non immediate, but with listener + explicitFalseButton.click(); + toggle.click(); + + string = getRandomString(); + field.sendKeys(delSequence + string + Keys.ENTER); + // non immediate, no change... + assertLastLog("5. fireValueChange"); + // ... until server round trip + hitServerButton.click(); + assertLastLog("7. Value changed: " + string); + + } + + private String getRandomString() { + String string = RandomStringUtils.randomAlphanumeric(2); + return string; + } + + private void assertLastLog(String string) { + String text = getDriver().findElement(By.id("Log_row_0")).getText(); + Assert.assertEquals(string, text); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html new file mode 100644 index 0000000000..2428e8b4bb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.html @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.textfield.BigDecimalTextField?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>15,2</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td> + <td>1. Commit ok. Property value: 15.2</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>70,12</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>130</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::</td> + <td>160,327</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td> + <td>2. Commit ok. Property value: 130</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>75,16</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>130abc</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::</td> + <td>96,280</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td> + <td>3. Commit failed: Commit failed</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-errorindicator</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>71,12</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[1]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td>130,130</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::</td> + <td>118,280</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<!--The converter automatically removes trailing zeros--> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentstextfieldBigDecimalTextField::PID_SLog_row_0</td> + <td>4. Commit ok. Property value: 130.13</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java new file mode 100644 index 0000000000..18d8679c2f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/BigDecimalTextField.java @@ -0,0 +1,123 @@ +/* + * Copyright 2000-2013 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.components.textfield; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Locale; + +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.util.BeanItem; +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.FormLayout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +/** + * @since 7.2 + * @author Vaadin Ltd + */ +public class BigDecimalTextField extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + final VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setLocale(new Locale("fi", "FI")); + + BeanBigDecimal beanBigDecimal = new BeanBigDecimal(); + BeanItem<BeanBigDecimal> beanItem = new BeanItem<BeanBigDecimal>( + beanBigDecimal); + + FormLayout formLayout = new FormLayout(); + TextField textField = new TextField("BigDecimal field"); + textField.setImmediate(true); + textField.setValue("12"); + formLayout.addComponent(textField); + + final FieldGroup fieldGroup = new FieldGroup(beanItem); + fieldGroup.bind(textField, "decimal"); + + Button setValue = new Button("Set value to 15,2", new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + ((TextField) fieldGroup.getField("decimal")).setValue("15,2"); + } + }); + + Button button = new Button("Commit"); + button.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + try { + fieldGroup.commit(); + log("Commit ok. Property value: " + + fieldGroup.getItemDataSource() + .getItemProperty("decimal").getValue()); + } catch (FieldGroup.CommitException e) { + log("Commit failed: " + e.getMessage()); + } + } + }); + + layout.addComponent(formLayout); + layout.addComponent(setValue); + layout.addComponent(button); + + setContent(layout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Tests that BigDecimals work correctly with TextFields"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 9997; + } + + public static class BeanBigDecimal implements Serializable { + BigDecimal decimal; + + public BeanBigDecimal() { + + } + + public BigDecimal getDecimal() { + return decimal; + } + + public void setDecimal(BigDecimal decimal) { + this.decimal = decimal; + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java b/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java index 2fd3f05dbb..06b8af1ec6 100644 --- a/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java +++ b/uitest/src/com/vaadin/tests/components/tree/SimpleTree.java @@ -8,6 +8,8 @@ import com.vaadin.event.Action; import com.vaadin.server.ThemeResource; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractSelect; +import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; +import com.vaadin.ui.Component; import com.vaadin.ui.Tree; public class SimpleTree extends TestBase implements Action.Handler { @@ -53,6 +55,17 @@ public class SimpleTree extends TestBase implements Action.Handler { tree.setItemIcon(9, notCachedFolderIconLargeOther, "First Choice"); tree.setItemIcon(11, notCachedFolderIconLarge); + tree.setItemDescriptionGenerator(new ItemDescriptionGenerator() { + @Override + public String generateDescription(Component source, Object itemId, + Object propertyId) { + if ((Integer) itemId == 3) { + return "tree item tooltip"; + } + return ""; + } + }); + // Expand whole tree for (Object id : tree.rootItemIds()) { tree.expandItemsRecursively(id); diff --git a/uitest/src/com/vaadin/tests/components/tree/Trees.java b/uitest/src/com/vaadin/tests/components/tree/Trees.java index 412840a937..f12d6adbb3 100644 --- a/uitest/src/com/vaadin/tests/components/tree/Trees.java +++ b/uitest/src/com/vaadin/tests/components/tree/Trees.java @@ -45,7 +45,7 @@ public class Trees extends AbstractSelectTestCase<Tree> implements @Override public String toString() { return "Root green, second level red"; - }; + } }; @@ -76,7 +76,7 @@ public class Trees extends AbstractSelectTestCase<Tree> implements @Override public String toString() { return "Even items bold"; - }; + } }; diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java index 8fafdb2d26..02f848cd40 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTableTest.java @@ -84,7 +84,7 @@ public class TreeTableTest extends Tables<TreeTable> implements @Override public String toString() { return "Even items bold"; - }; + } }; diff --git a/uitest/src/com/vaadin/tests/components/ui/MultiFileUploadTest.java b/uitest/src/com/vaadin/tests/components/ui/MultiFileUploadTest.java new file mode 100644 index 0000000000..8f3e08335f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/MultiFileUploadTest.java @@ -0,0 +1,128 @@ +/* + * Copyright 2000-2013 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.components.ui; + +import java.io.IOException; +import java.io.OutputStream; + +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.Upload; +import com.vaadin.ui.Upload.ChangeEvent; +import com.vaadin.ui.Upload.ChangeListener; +import com.vaadin.ui.Upload.FailedEvent; +import com.vaadin.ui.Upload.FailedListener; +import com.vaadin.ui.Upload.Receiver; +import com.vaadin.ui.Upload.SucceededEvent; +import com.vaadin.ui.Upload.SucceededListener; +import com.vaadin.ui.VerticalLayout; + +public class MultiFileUploadTest extends AbstractTestUIWithLog { + + private ChangeListener changeListener = new ChangeListener() { + + @Override + public void filenameChanged(ChangeEvent event) { + if (event.getFilename().equals("")) { + removeUpload(event.getSource()); + } else { + addUpload(); + } + + } + }; + private VerticalLayout uploadsLayout = new VerticalLayout(); + + @Override + protected void setup(VaadinRequest request) { + getPage().getStyles().add( + ".v-upload-hidden-button .v-button {display:none};"); + addUpload(); + addComponent(uploadsLayout); + addComponent(new Button("Upload files", new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + for (Upload u : getUploads()) { + u.submitUpload(); + } + } + })); + } + + protected Iterable<Upload> getUploads() { + return (Iterable) uploadsLayout; + } + + protected void removeUpload(Upload source) { + uploadsLayout.removeComponent(source); + + } + + protected void addUpload() { + Upload upload = createUpload(); + upload.addSucceededListener(new SucceededListener() { + + @Override + public void uploadSucceeded(SucceededEvent event) { + log("Upload of " + event.getFilename() + " complete"); + uploadsLayout.removeComponent(event.getUpload()); + } + }); + + upload.addFailedListener(new FailedListener() { + @Override + public void uploadFailed(FailedEvent event) { + log("Upload of " + event.getFilename() + " FAILED"); + } + }); + + upload.setReceiver(new Receiver() { + @Override + public OutputStream receiveUpload(String filename, String mimeType) { + return new OutputStream() { + @Override + public void write(int arg0) throws IOException { + + } + }; + } + }); + upload.setStyleName("hidden-button"); + uploadsLayout.addComponent(upload); + + } + + private Upload createUpload() { + Upload upload = new Upload(); + upload.addChangeListener(changeListener); + return upload; + } + + @Override + protected String getTestDescription() { + return "Tests that an Upload change event can be used to create a multiple file upload component"; + } + + @Override + protected Integer getTicketNumber() { + return 13222; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.html b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.html new file mode 100644 index 0000000000..ac39d1f03c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.html @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>PollListenerTest</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">PollListenerTest</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.ui.PollListenerTest?restartApplication</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>5000</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>PollEvent received</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.java b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.java new file mode 100644 index 0000000000..0e5ddaab87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2013 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.components.ui; + +import com.vaadin.event.UIEvents.PollEvent; +import com.vaadin.event.UIEvents.PollListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +public class PollListenerTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Label statusLabel = new Label("Default Label"); + addComponent(statusLabel); + + setPollInterval(2000); + addPollListener(new PollListener() { + @Override + public void poll(PollEvent event) { + setPollInterval(-1); + statusLabel.setValue(event.getClass().getSimpleName() + + " received"); + removePollListener(this); + } + }); + } + + @Override + protected String getTestDescription() { + return "Polling should fire a PollEvent on the server-side"; + } + + @Override + protected Integer getTicketNumber() { + return 12466; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html index e41cf5e176..338e4a2c5b 100644 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html +++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html @@ -4,12 +4,12 @@ <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> +<title>TooltipConfiguration</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> +<tr><td rowspan="1" colspan="3">TooltipConfiguration</td></tr> </thead><tbody> <tr> <td>open</td> @@ -43,9 +43,9 @@ <td></td> </tr> <tr> - <td>assertElementNotPresent</td> + <td>assertElementPositionLeft</td> <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> + <td>-1000</td> </tr> <!--Long close delay--> <tr> @@ -140,6 +140,7 @@ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> <td>100</td> </tr> + </tbody></table> </body> </html> diff --git a/uitest/src/com/vaadin/tests/components/ui/UIRefresh.java b/uitest/src/com/vaadin/tests/components/ui/UIRefresh.java new file mode 100644 index 0000000000..b61e32c984 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIRefresh.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 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.components.ui; + +import com.vaadin.annotations.PreserveOnRefresh; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +@PreserveOnRefresh +public class UIRefresh extends AbstractTestUI { + + public static final String REINIT_ID = "reinit"; + + @Override + protected void setup(VaadinRequest request) { + } + + @Override + protected void refresh(VaadinRequest request) { + Label l = new Label("Reinit!"); + l.setId(REINIT_ID); + addComponent(l); + } + + @Override + public String getTestDescription() { + return "UI reinit after refresh"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(12191); + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/UIRefreshTest.java b/uitest/src/com/vaadin/tests/components/ui/UIRefreshTest.java new file mode 100644 index 0000000000..974c4bfe5a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIRefreshTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2013 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.components.ui; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class UIRefreshTest extends MultiBrowserTest { + + @Test + public void testUIRefresh() { + openTestURL(); + Assert.assertFalse(reinitLabelExists()); + // Reload the page; UI.refresh should be invoked + openTestURL(); + Assert.assertTrue(reinitLabelExists()); + } + + private boolean reinitLabelExists() { + return !getDriver().findElements(By.id(UIRefresh.REINIT_ID)).isEmpty(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html b/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html index b5326e4660..acbe30c5d2 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html +++ b/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html @@ -43,7 +43,7 @@ </tr> <tr> <td>assertText</td> - <td>//div[@id='runcomvaadintestscomponentsuitestUIScrollTest-1797389287-overlays']/div</td> + <td>//div[@id='runcomvaadintestscomponentsuitestUIScrollTest-1797389287-overlays']//h1</td> <td>Scrolled to 1020 px</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html index 614ae7bcda..cdbcf8bacc 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/base_theme_test.html @@ -289,7 +289,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,8</td> </tr> <tr> @@ -304,7 +304,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,6</td> </tr> <tr> @@ -319,7 +319,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>8,5</td> </tr> <tr> @@ -334,7 +334,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,6</td> </tr> <tr> @@ -349,7 +349,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>10,7</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html index 7d9ffc65b8..d5d70a62d2 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/chameleon_theme_test.html @@ -289,7 +289,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,8</td> </tr> <tr> @@ -304,7 +304,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,6</td> </tr> <tr> @@ -319,7 +319,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>8,5</td> </tr> <tr> @@ -334,7 +334,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,6</td> </tr> <tr> @@ -349,7 +349,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>10,7</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/uitest/components/FormsCssTest.java b/uitest/src/com/vaadin/tests/components/uitest/components/FormsCssTest.java index 9c8678730e..1d6527e624 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/components/FormsCssTest.java +++ b/uitest/src/com/vaadin/tests/components/uitest/components/FormsCssTest.java @@ -41,6 +41,6 @@ public class FormsCssTest extends HorizontalLayout { public void addComponent(com.vaadin.ui.Component c) { parent.registerComponent(c); super.addComponent(c); - }; + } } diff --git a/uitest/src/com/vaadin/tests/components/uitest/components/WindowsCssTest.java b/uitest/src/com/vaadin/tests/components/uitest/components/WindowsCssTest.java index 8e6b68d666..9a2ebae7f3 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/components/WindowsCssTest.java +++ b/uitest/src/com/vaadin/tests/components/uitest/components/WindowsCssTest.java @@ -110,7 +110,7 @@ public class WindowsCssTest extends VerticalLayout { @Override public void addStyleName(String style) { styleName = style; - }; + } @Override public void removeStyleName(String style) { diff --git a/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html index d0ee96c7ef..783784e993 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/liferay_theme_test.html @@ -289,7 +289,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,8</td> </tr> <tr> @@ -304,7 +304,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,6</td> </tr> <tr> @@ -319,7 +319,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>8,5</td> </tr> <tr> @@ -334,7 +334,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,6</td> </tr> <tr> @@ -349,7 +349,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>10,7</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html index a330f5bf61..175def94d3 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/reindeer_theme_test.html @@ -289,7 +289,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,8</td> </tr> <tr> @@ -304,7 +304,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,6</td> </tr> <tr> @@ -319,7 +319,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>8,5</td> </tr> <tr> @@ -334,7 +334,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,6</td> </tr> <tr> @@ -349,7 +349,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>10,7</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html b/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html index 61ba58a0e6..0db6614a9c 100644 --- a/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html +++ b/uitest/src/com/vaadin/tests/components/uitest/runo_theme_test.html @@ -289,7 +289,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,8</td> </tr> <tr> @@ -304,7 +304,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,6</td> </tr> <tr> @@ -319,7 +319,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>8,5</td> </tr> <tr> @@ -334,7 +334,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>9,6</td> </tr> <tr> @@ -349,7 +349,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runThemeTestUI::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>10,7</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html b/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html index ac81dfdefb..ae77628bff 100644 --- a/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html +++ b/uitest/src/com/vaadin/tests/components/window/CloseSubWindow.html @@ -40,7 +40,7 @@ <!--Click close in title bar--> <tr> <td>click</td> - <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentswindowCloseSubWindow::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td></td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html new file mode 100644 index 0000000000..f5f89d13ef --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>ExtraWindowShownWaiAria</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">ExtraWindowShownWaiAria</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.window.ExtraWindowShownWaiAria?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementPresent</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/</td> + <td></td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@role</td> + <td>dialog</td> +</tr> +<tr> + <td>storeAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]@id</td> + <td>headerid</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-labelledby</td> + <td>${headerid}</td> +</tr> +<tr> + <td>storeAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[0]@id</td> + <td>descriptionid</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-describedby</td> + <td>${descriptionid}</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]@role</td> + <td>button</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]@role</td> + <td>button</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VCheckBox[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>storeAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[0]@id</td> + <td>descriptionid</td> +</tr> +<tr> + <td>storeAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[1]@id</td> + <td>description2id</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-describedby</td> + <td>${descriptionid} ${description2id}</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/</td> + <td></td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VTextField[0]</td> + <td>Important</td> +</tr> +<tr> + <td>type</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[7]/VTextField[0]</td> + <td> - do ASAP</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>xpath=//div[@class='v-window-header']/span[@class='v-assistive-device-only'][1]</td> + <td>Important</td> +</tr> +<tr> + <td>assertText</td> + <td>xpath=//div[@class='v-window-header']/span[@class='v-assistive-device-only'][2]</td> + <td>- do ASAP</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java new file mode 100644 index 0000000000..c7379f666b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.java @@ -0,0 +1,172 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.server.ThemeResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.window.WindowRole; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Window; + +public class ExtraWindowShownWaiAria extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final CheckBox modal = new CheckBox("Modal dialog"); + modal.setTabIndex(7); + final CheckBox additionalDescription = new CheckBox( + "Additional Description"); + final CheckBox tabStop = new CheckBox( + "Prevent leaving window with Tab key"); + final CheckBox tabOrder = new CheckBox("Change Taborder"); + final TextField prefix = new TextField("Prefix: "); + final TextField postfix = new TextField("Postfix: "); + + final TextField topTabStopMessage = new TextField( + "Top Tab Stop Message"); + final TextField bottomTabStopMessage = new TextField( + "Bottom Tab Stop Message"); + + Button simple = new Button("Open Alert Dialog", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + CssLayout layout = new CssLayout(); + + final Window w = new Window("Sub window", layout); + w.center(); + w.setModal(modal.getValue()); + w.setAssistiveRole(WindowRole.ALERTDIALOG); + w.setAssistivePrefix(prefix.getValue()); + w.setAssistivePostfix(postfix.getValue()); + + Label description1 = new Label("Simple alert dialog."); + layout.addComponent(description1); + + if (!additionalDescription.getValue()) { + w.setAssistiveDescription(description1); + } else { + Label description2 = new Label( + "Please select what to do!"); + layout.addComponent(description2); + + w.setAssistiveDescription(description1, + description2); + } + + w.setTabStopEnabled(tabStop.getValue()); + w.setTabStopTopAssistiveText(topTabStopMessage + .getValue()); + w.setTabStopBottomAssistiveText(bottomTabStopMessage + .getValue()); + + Button close = new Button("Close", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + w.close(); + } + }); + layout.addComponent(close); + Button iconButton = new Button("A button with icon"); + iconButton.setIcon(new ThemeResource( + "../runo/icons/16/ok.png")); + layout.addComponent(iconButton); + + event.getButton().getUI().addWindow(w); + iconButton.focus(); + + if (tabOrder.getValue()) { + close.setTabIndex(5); + } + } + + }); + getLayout().addComponent(simple); + + Button complex = new Button("Open Entry Dialog", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + FormLayout form = new FormLayout(); + + final Window w = new Window("Form Window", form); + w.center(); + w.setModal(modal.getValue()); + w.setAssistivePrefix(prefix.getValue()); + w.setAssistivePostfix(postfix.getValue()); + + Label description1 = new Label( + "Please fill in your data"); + form.addComponent(description1); + + if (!additionalDescription.getValue()) { + w.setAssistiveDescription(description1); + } else { + Label description2 = new Label( + "and press the button save."); + form.addComponent(description2); + + w.setAssistiveDescription(description1, + description2); + } + + w.setTabStopEnabled(tabStop.getValue()); + w.setTabStopTopAssistiveText(topTabStopMessage + .getValue()); + w.setTabStopBottomAssistiveText(bottomTabStopMessage + .getValue()); + + TextField name = new TextField("Name:"); + form.addComponent(name); + + form.addComponent(new TextField("Address")); + + Button saveButton = new Button("Save", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + w.close(); + } + }); + form.addComponent(saveButton); + + event.getButton().getUI().addWindow(w); + name.focus(); + + if (tabOrder.getValue()) { + name.setTabIndex(5); + } + } + }); + getLayout().addComponent(complex); + + getLayout().addComponent(modal); + getLayout().addComponent(additionalDescription); + getLayout().addComponent(tabStop); + getLayout().addComponent(tabOrder); + + getLayout().addComponent(prefix); + getLayout().addComponent(postfix); + + getLayout().addComponent(topTabStopMessage); + getLayout().addComponent(bottomTabStopMessage); + + } + + @Override + protected String getTestDescription() { + return "Test for WAI-ARIA implementation"; + } + + @Override + protected Integer getTicketNumber() { + return 11821; + } +} diff --git a/uitest/src/com/vaadin/tests/components/window/MoveToTop.java b/uitest/src/com/vaadin/tests/components/window/MoveToTop.java new file mode 100644 index 0000000000..4fd748183a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/MoveToTop.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 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.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Window; + +/** + * + * @author Vaadin Ltd + */ +public class MoveToTop extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Window window = new Window("one"); + window.addStyleName("first-window"); + window.setWidth(200, Unit.PIXELS); + window.setHeight(100, Unit.PIXELS); + window.setPositionX(100); + window.setPositionY(100); + addWindow(window); + + window = new Window("two"); + window.setWidth(200, Unit.PIXELS); + window.setHeight(100, Unit.PIXELS); + window.setPositionX(150); + window.setPositionY(150); + window.addStyleName("second-window"); + addWindow(window); + } + + @Override + protected String getTestDescription() { + return "Bring to front window on click it's header"; + } + + @Override + protected Integer getTicketNumber() { + return 13445; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/MoveToTopTest.java b/uitest/src/com/vaadin/tests/components/window/MoveToTopTest.java new file mode 100644 index 0000000000..26d7a06531 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/MoveToTopTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2000-2013 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.components.window; + +import java.io.IOException; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @author Vaadin Ltd + */ +public class MoveToTopTest extends MultiBrowserTest { + + @Test + public void testBringToFrontViaHeader() throws IOException { + openTestURL(); + + WebElement firstWindow = driver.findElement(By + .className("first-window")); + + WebElement secondWindow = driver.findElement(By + .className("second-window")); + + secondWindow.click(); + + compareScreen("second-window-over-first"); + + WebElement headerFirst = firstWindow.findElement(By + .className("v-window-outerheader")); + headerFirst.click(); + + compareScreen("first-window-over-second"); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html b/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html index 8374a90b52..6fd99caa19 100644 --- a/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html +++ b/uitest/src/com/vaadin/tests/components/window/SubWindowOrder.html @@ -90,7 +90,7 @@ <!--Close window 4, which is the topmost window--> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[3]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[3]/domChild[0]/domChild[0]/domChild[3]</td> <td>11,15</td> </tr> <tr> @@ -101,7 +101,7 @@ <!--Close Dialog 3 (topmost)--> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[3]</td> <td>6,8</td> </tr> <!--Make Dialog 5 (topmost) non-modal--> @@ -139,7 +139,7 @@ <!--Close dialog 5--> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentswindowSubWindowOrder::/VWindow[2]/domChild[0]/domChild[0]/domChild[3]</td> <td>10,5</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html deleted file mode 100644 index 63e371e379..0000000000 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>TooltipInWindow</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">TooltipInWindow</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.window.TooltipInWindow?restartApplication</td> - <td></td> -</tr> -<!--Show tooltip in Root--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VVerticalLayout[0]/VVerticalLayout[0]/VTextField[0]</td> - <td>5,5</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>My tooltip</td> -</tr> -<!--Hide the tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VVerticalLayout[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]</td> - <td></td> -</tr> -<!--Show tooltip in Window--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VTextField[0]</td> - <td>5,5</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>My tooltip</td> -</tr> -<!-- Hide tooltip in Window --> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>assertElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java index d3c7a616cd..02ec0c047b 100644 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java @@ -31,15 +31,16 @@ public class TooltipInWindow extends AbstractTestUI { Window window = new Window("Window", layout); layout.setSizeUndefined(); window.center(); - layout.addComponent(createTextField()); + layout.addComponent(createTextField("tf1")); addWindow(window); - addComponent(createTextField()); + addComponent(createTextField("tf2")); } - private TextField createTextField() { + private TextField createTextField(String id) { TextField tf = new TextField("TextField with a tooltip"); tf.setDescription("My tooltip"); + tf.setId(id); return tf; } diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java new file mode 100644 index 0000000000..0e11041e3b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java @@ -0,0 +1,98 @@ +/* + * Copyright 2000-2013 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.components.window; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class TooltipInWindowTest extends MultiBrowserTest { + + @Test + public void testTooltipsInSubWindow() throws Exception { + openTestURL(); + + WebElement textfield = vaadinElementById("tf1"); + Coordinates textfieldCoordinates = ((Locatable) textfield) + .getCoordinates(); + + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + + // Show tooltip + mouse.mouseMove(textfieldCoordinates, 10, 10); + sleep(1000); + + ensureVisibleTooltipPositionedCorrectly(); + assertEquals("My tooltip", getTooltipElement().getText()); + + // Hide tooltip + mouse.mouseMove(textfieldCoordinates, -100, -100); + sleep(1000); + + ensureHiddenTooltipPositionedCorrectly(); + assertEquals("", getTooltipElement().getText()); + + // Show tooltip again + mouse.mouseMove(textfieldCoordinates, 10, 10); + sleep(1000); + + ensureVisibleTooltipPositionedCorrectly(); + assertEquals("My tooltip", getTooltipElement().getText()); + + // Hide tooltip + mouse.mouseMove(textfieldCoordinates, -100, -100); + sleep(1000); + + ensureHiddenTooltipPositionedCorrectly(); + assertEquals("", getTooltipElement().getText()); + } + + private WebElement getTooltipElement() { + return getDriver().findElement(By.className("v-tooltip-text")); + } + + private WebElement getTooltipContainerElement() { + return getDriver().findElement(By.className("v-tooltip")); + } + + private void ensureVisibleTooltipPositionedCorrectly() { + WebElement textfield = vaadinElementById("tf1"); + int tooltipX = getTooltipContainerElement().getLocation().getX(); + int textfieldX = textfield.getLocation().getX(); + assertGreaterOrEqual("Tooltip should be positioned on the textfield (" + + tooltipX + " < " + textfieldX + ")", tooltipX, textfieldX); + } + + private void ensureHiddenTooltipPositionedCorrectly() { + int tooltipX = getTooltipContainerElement().getLocation().getX(); + assertLessThanOrEqual( + "Tooltip should be positioned outside of viewport (was at " + + tooltipX + ")", tooltipX, -1000); + } +} diff --git a/uitest/src/com/vaadin/tests/components/window/WindowCaptionTest.html b/uitest/src/com/vaadin/tests/components/window/WindowCaptionTest.html index a9a6fd621e..85ab67e4f6 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowCaptionTest.html +++ b/uitest/src/com/vaadin/tests/components/window/WindowCaptionTest.html @@ -3,7 +3,6 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://arturwin.office.itmill.com:8888/" /> <title>New Test</title> </head> <body> @@ -18,7 +17,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td>Short</td> </tr> <tr> @@ -43,7 +42,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td>This is a semi-long text that might wrap.</td> </tr> <tr> @@ -68,7 +67,7 @@ </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowTest::PID_StestComponent/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td></td> </tr> diff --git a/uitest/src/com/vaadin/tests/components/window/WindowInUiWithNoContent.java b/uitest/src/com/vaadin/tests/components/window/WindowInUiWithNoContent.java new file mode 100644 index 0000000000..720f751cef --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowInUiWithNoContent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 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.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Window; + +/** + * Test UI for Window attached to the UI with not content. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class WindowInUiWithNoContent extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + // This is requires for the test + setContent(null); + + Window window = new Window("window"); + addWindow(window); + } + + @Override + protected String getTestDescription() { + return "Client UI component should not use VWindow as a content component"; + } + + @Override + protected Integer getTicketNumber() { + return 13127; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java b/uitest/src/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java new file mode 100644 index 0000000000..8378c8cf7b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowInUiWithNoContentTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2013 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.components.window; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for Window attached to the UI with not content. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class WindowInUiWithNoContentTest extends MultiBrowserTest { + + @Test + public void testWindowInEmptyUI() { + openTestURL(); + + WebElement window = driver.findElement(By.className("v-window")); + String position = window.getCssValue("position"); + + Assert.assertEquals("Window element has non-absolute position and " + + "is broken in the UI", "absolute", position); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html index dcdfa05687..a27963a066 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html +++ b/uitest/src/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.html @@ -3,7 +3,6 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/run/" /> <title>WindowMaximizeRestoreTest</title> </head> <body> @@ -19,59 +18,59 @@ <!--Test maximize-restore button--> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-maximizebox</td> </tr> <tr> <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td>Window 1</td> </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>7,8</td> </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-restorebox</td> </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>9,7</td> </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-maximizebox</td> </tr> <!--test double click on header--> <tr> <td>doubleClickAt</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td></td> </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-restorebox</td> </tr> <tr> <td>doubleClickAt</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td></td> </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-maximizebox</td> </tr> <!--Resizable = false should hide max-restore button--> <tr> <td>assertVisible</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td></td> </tr> <tr> @@ -81,7 +80,7 @@ </tr> <tr> <td>assertNotVisible</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td></td> </tr> <!--Test server side max-restore--> @@ -92,7 +91,7 @@ </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-restorebox</td> </tr> <tr> @@ -102,28 +101,28 @@ </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-maximizebox</td> </tr> <!--test double click on header doesn't work--> <tr> <td>doubleClickAt</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td></td> </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-maximizebox</td> </tr> <tr> <td>doubleClickAt</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td></td> </tr> <tr> <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>v-window-maximizebox</td> </tr> <tr> @@ -149,7 +148,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>10,8</td> </tr> <tr> @@ -175,7 +174,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[2]</td> <td>6,11</td> </tr> <tr> @@ -185,7 +184,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[3]</td> <td>7,5</td> </tr> <tr> @@ -210,12 +209,12 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[1]/domChild[0]/domChild[0]/domChild[2]</td> <td>6,11</td> </tr> <tr> <td>doubleClickAt</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td>113,10</td> </tr> <tr> @@ -226,27 +225,27 @@ <!--Test that size and position is preserved when maximizing and restoring--> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>8,4</td> </tr> <tr> <td>dragAndDrop</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td> <td>-200,-200</td> </tr> <tr> <td>dragAndDrop</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[5]/domChild[0]</td> <td>+100,+100</td> </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>6,5</td> </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowMaximizeRestoreTest::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> <td>5,8</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html index fa63e5e1e6..3ea1f8f732 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html +++ b/uitest/src/com/vaadin/tests/components/window/WindowWithInvalidCloseListener.html @@ -18,7 +18,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>vaadin=runcomvaadintestscomponentswindowWindowWithInvalidCloseListener::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]</td> <td>6,7</td> </tr> <tr> diff --git a/uitest/src/com/vaadin/tests/dd/HorizontalSortableCssLayoutWithWrappers.java b/uitest/src/com/vaadin/tests/dd/HorizontalSortableCssLayoutWithWrappers.java index 4e9e89add5..d17c618f59 100644 --- a/uitest/src/com/vaadin/tests/dd/HorizontalSortableCssLayoutWithWrappers.java +++ b/uitest/src/com/vaadin/tests/dd/HorizontalSortableCssLayoutWithWrappers.java @@ -24,7 +24,7 @@ public class HorizontalSortableCssLayoutWithWrappers extends Window { @Override protected String getCss(Component c) { return "float:left; width:60px;height:60px;background: yellow;padding:2px;"; - }; + } }; class WrappedLabel extends DragAndDropWrapper { diff --git a/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html deleted file mode 100644 index f5b7e0a1df..0000000000 --- a/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayouts.html +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.debug.HierarchyAfterAnalyzeLayouts?restartApplication&debug</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestsdebugHierarchyAfterAnalyzeLayouts::Root/VDebugWindow[0]/FlowPanel[0]/FlowPanel[0]/FlowPanel[0]/DebugButton[2]</td> - <td>18,9</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestsdebugHierarchyAfterAnalyzeLayouts::Root/VDebugWindow[0]/FlowPanel[0]/FlowPanel[0]/FlowPanel[2]/FlowPanel[0]/domChild[2]</td> - <td>18,9</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsdebugHierarchyAfterAnalyzeLayouts::Root/VDebugWindow[0]/FlowPanel[0]/SimplePanel[0]/FlowPanel[0]/domChild[0]</td> - <td>Layouts analyzed, no top level problems</td> -</tr> -<tr> - <td>assertElementPresent</td> - <td>vaadin=runcomvaadintestsdebugHierarchyAfterAnalyzeLayouts::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayoutsTest.java b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayoutsTest.java new file mode 100644 index 0000000000..43c9737963 --- /dev/null +++ b/uitest/src/com/vaadin/tests/debug/HierarchyAfterAnalyzeLayoutsTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2013 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.debug; + +import java.io.IOException; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Check that analyze layouts does not find problems for a trivial application. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class HierarchyAfterAnalyzeLayoutsTest extends MultiBrowserTest { + + @Test + public void checkNoLayoutProblemsFound() throws IOException { + setDebug(true); + openTestURL(); + + // select tab + pressDebugWindowButton(findByXpath("//button[@title = 'Examine component hierarchy']")); + + // click "analyze layouts" + pressDebugWindowButton(findByXpath("//button[@title = 'Check layouts for potential problems']")); + + // check that no problems found + findByXpath("//div[text() = 'Layouts analyzed, no top level problems']"); + + // check that original label still there + findByXpath("//div[text() = 'This is a label']"); + } + + private void pressDebugWindowButton(WebElement element) { + element.click(); + // This is for IE8, which otherwise just focuses the button. + // This may result in duplicate events on other browsers, but they + // should not break the test. + element.sendKeys(" "); + } + + private WebElement findByXpath(String path) { + return getDriver().findElement(By.xpath(path)); + } +} diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveUI.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveUI.java new file mode 100644 index 0000000000..417821f1ea --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveUI.java @@ -0,0 +1,87 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.extensions; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.Responsive; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.Label; + +@Theme("tests-responsive") +public class ResponsiveUI extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + HorizontalSplitPanel split = new HorizontalSplitPanel(); + setContent(split); + split.setSplitPosition(50, Unit.PERCENTAGE); + split.setMinSplitPosition(100, Unit.PIXELS); + split.setMaxSplitPosition(1200, Unit.PIXELS); + setStyleName("responsive-test"); + + CssLayout firstGrid = makeGrid("first"); + CssLayout secondGrid = makeGrid("second"); + CssLayout grids = new CssLayout(); + grids.setSizeFull(); + grids.addComponent(firstGrid); + grids.addComponent(secondGrid); + split.addComponent(grids); + + Label description = new Label( + "<h3>This application demonstrates the Responsive extension in Vaadin.</h3>" + + "<p>Drag the splitter to see how the boxes on the left side adapt to " + + "different widths. They maintain a width of 100-200px, and always " + + "span the entire width of the container.</p><p>This label will " + + "adapt its font size and line height for different widths.</p>" + + "<p><a href=\"http://vaadin.com/download\">Download " + + "Vaadin</a></p>", ContentMode.HTML); + description.addStyleName("description"); + split.addComponent(description); + + // Add the responsive capabilities to the components + Responsive.makeResponsive(firstGrid); + Responsive.makeResponsive(secondGrid); + Responsive.makeResponsive(description); + } + + private CssLayout makeGrid(String styleName) { + CssLayout grid = new CssLayout(); + grid.setWidth("100%"); + grid.addStyleName("grid"); + grid.addStyleName(styleName); + + for (int i = 1; i < 10; i++) { + Label l = new Label("" + i); + l.setSizeUndefined(); + grid.addComponent(l); + } + return grid; + } + + @Override + protected String getTestDescription() { + return "The CssLayouts (grids) and Label should be responsive"; + } + + @Override + protected Integer getTicketNumber() { + return 12394; + } +} diff --git a/uitest/src/com/vaadin/tests/extensions/ResponsiveUITest.java b/uitest/src/com/vaadin/tests/extensions/ResponsiveUITest.java new file mode 100644 index 0000000000..9b86350ebc --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/ResponsiveUITest.java @@ -0,0 +1,109 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.extensions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ResponsiveUITest extends MultiBrowserTest { + + @Before + public void setUp() throws Exception { + // We need this in order to ensure that the initial width-range is + // 401px-600px + testBench().resizeViewPortTo(1024, 768); + } + + // JQuery style selector + private WebElement $(String cssSelector) { + return getDriver().findElement(By.cssSelector(cssSelector)); + } + + @Test + public void testResizingSplitPanelReflowsLayout() throws Exception { + openTestURL(); + + // IE sometimes has trouble waiting long enough. + new WebDriverWait(getDriver(), 30).until(ExpectedConditions + .presenceOfElementLocated(By + .cssSelector(".v-csslayout-grid.first"))); + + assertEquals("401px-600px", + $(".v-csslayout-grid.first").getAttribute("width-range")); + assertEquals("501px-", + $(".v-csslayout-grid.second").getAttribute("width-range")); + + moveSplitter(200); + + assertEquals("601-800", + $(".v-csslayout-grid.first").getAttribute("width-range")); + assertEquals("501px-", + $(".v-csslayout-grid.second").getAttribute("width-range")); + + moveSplitter(-350); + + assertEquals("201px-400px", + $(".v-csslayout-grid.first").getAttribute("width-range")); + assertEquals("301px-400px", + $(".v-csslayout-grid.second").getAttribute("width-range")); + + compareScreen("responsive"); + + moveSplitter(-200); + assertEquals("-200px", + $(".v-csslayout-grid.first").getAttribute("width-range")); + + } + + private void moveSplitter(int xOffset) { + new Actions(getDriver()).clickAndHold($(".v-splitpanel-hsplitter")) + .moveByOffset(xOffset, 0).release().build().perform(); + } + + @Test + public void testResizingWindowReflowsLayout() throws Exception { + openTestURL(); + + assertEquals("401px-600px", + $(".v-csslayout-grid.first").getAttribute("width-range")); + assertEquals("501px-", + $(".v-csslayout-grid.second").getAttribute("width-range")); + + testBench().resizeViewPortTo(1224, 768); + + assertEquals("601-800", + $(".v-csslayout-grid.first").getAttribute("width-range")); + assertEquals("501px-", + $(".v-csslayout-grid.second").getAttribute("width-range")); + + testBench().resizeViewPortTo(674, 768); + + assertEquals("201px-400px", + $(".v-csslayout-grid.first").getAttribute("width-range")); + assertEquals("301px-400px", + $(".v-csslayout-grid.second").getAttribute("width-range")); + } +} diff --git a/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html b/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html index f0fe883d57..aaaa0a6625 100644 --- a/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html +++ b/uitest/src/com/vaadin/tests/fieldgroup/CommitHandlerFailures.html @@ -1,220 +1,215 @@ -package com.vaadin.tests.fieldgroup; +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> +</tr> +<!--assert we are starting with what we think we are starting with--> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>NAAAAAH</td> +</tr> +<!--Make changes to fields--> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doeve</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>Mike</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>me@me.com</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>12</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td> + <td>31,10</td> +</tr> +<!--show bean values--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>1. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<!--pre commit fails--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>35,6</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>2. Commit failed: Commit failed</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>3. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<!--post commit fails--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> + <td>10,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> + <td>9,7</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>4. Commit failed: Commit failed</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>5. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<!--discard and ensure old values are returned as all commits have failed--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> + <td>John</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doe</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> + <td>john@doe.com</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> + <td>v-selected</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> + <td>NAAAAAH</td> +</tr> +<!--show bean values--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>7. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> -public class CommitHandlerFailures_html { - <?xml version="1.0" encoding="UTF-8"?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head profile="http://selenium-ide.openqa.org/profiles/test-case"> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <link rel="selenium.base" href="" /> - <title>New Test</title> - </head> - <body> - <table cellpadding="1" cellspacing="1" border="1"> - <thead> - <tr><td rowspan="1" colspan="3">New Test</td></tr> - </thead><tbody> - <tr> - <td>open</td> - <td>/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication</td> - <td></td> - </tr> - <!--assert we are starting with what we think we are starting with--> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> - <td>John</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> - <td>Doe</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> - <td>john@doe.com</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> - <td>64</td> - </tr> - <tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>v-selected</td> - </tr> - <tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> - <td>v-selected</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> - <td>NAAAAAH</td> - </tr> - <!--Make changes to fields--> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> - <td>Doeve</td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> - <td>Mike</td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> - <td>me@me.com</td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> - <td>12</td> - </tr> - <tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]</td> - <td>31,10</td> - </tr> - <!--show bean values--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>1. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - <!--pre commit fails--> - <tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> - <td>35,6</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> - <td>0,0</td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>2. Commit failed: Commit failed</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>3. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - <!--post commit fails--> - <tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td> - <td>10,7</td> - </tr> - <tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td> - <td>9,7</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> - <td>0,0</td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>4. Commit failed: Commit failed</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>5. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - <!--discard and ensure old values are returned as all commits have failed--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextField[0]</td> - <td>John</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> - <td>Doe</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTextField[0]</td> - <td>john@doe.com</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> - <td>64</td> - </tr> - <tr> - <td>assertCSSClass</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> - <td>v-selected</td> - </tr> - <tr> - <td>assertNotCSSClass</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td> - <td>v-selected</td> - </tr> - <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VTextField[0]</td> - <td>NAAAAAH</td> - </tr> - <!--show bean values--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>7. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - - </tbody></table> - </body> - </html> - -} +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html b/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html index e32633513b..8681c6485e 100644 --- a/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html +++ b/uitest/src/com/vaadin/tests/fieldgroup/CommitWithValidationOrConversionError.html @@ -1,150 +1,148 @@ - <?xml version="1.0" encoding="UTF-8"?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head profile="http://selenium-ide.openqa.org/profiles/test-case"> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <link rel="selenium.base" href="" /> - <title>New Test</title> - </head> - <body> - <table cellpadding="1" cellspacing="1" border="1"> - <thead> - <tr><td rowspan="1" colspan="3">New Test</td></tr> - </thead><tbody> - <tr> - <td>open</td> - <td>/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication</td> - <td></td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> - <td>Doev</td> - </tr> - <!--commit with invalid field must fail--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> - <td>0,0</td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>1. Commit failed: Commit failed</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>2. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> - <td>64,2</td> - </tr> - <!--commit with 2 fails--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> - <td>0,0</td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>3. Commit failed: Commit failed</td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> - <td>Doever</td> - </tr> - <!--1 error fixed, still 1 conversion error--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> - <td>0,0</td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>4. Commit failed: Commit failed</td> - </tr> - <tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> - <td>123</td> - </tr> - <!--all fields ok, commit should be ok--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> - <td>0,0</td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>5. Commit succesful</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>6. Person [firstName=John, lastName=Doever, email=john@doe.com, age=123, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - <!--discard should now have no effect--> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>7. Discarded changes</td> - </tr> - <tr> - <td>click</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]</td> - <td></td> - </tr> - <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> - <td>8. Person [firstName=John, lastName=Doever, email=john@doe.com, age=123, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> - </tr> - - </tbody></table> - </body> - </html> - -} +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication</td> + <td></td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doev</td> +</tr> +<!--commit with invalid field must fail--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>1. Commit failed: Commit failed</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>2. Person [firstName=John, lastName=Doe, email=john@doe.com, age=64, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>64,2</td> +</tr> +<!--commit with 2 fails--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>3. Commit failed: Commit failed</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VTextArea[0]</td> + <td>Doever</td> +</tr> +<!--1 error fixed, still 1 conversion error--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>4. Commit failed: Commit failed</td> +</tr> +<tr> + <td>enterCharacter</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> + <td>123</td> +</tr> +<!--all fields ok, commit should be ok--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>closeNotification</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VNotification[0]</td> + <td>0,0</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>5. Commit succesful</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>6. Person [firstName=John, lastName=Doever, email=john@doe.com, age=123, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> +<!--discard should now have no effect--> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>7. Discarded changes</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[10]/VButton[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::PID_SLog_row_0</td> + <td>8. Person [firstName=John, lastName=Doever, email=john@doe.com, age=123, sex=Male, address=Address [streetAddress=John street, postalCode=11223, city=John's town, country=USA], deceased=false, salary=null, salaryDouble=null, rent=null]</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java b/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java index 4f83f5d0fd..2c202af02b 100644 --- a/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java +++ b/uitest/src/com/vaadin/tests/fieldgroup/FieldBinderWithBeanValidation.java @@ -7,7 +7,6 @@ import com.vaadin.data.util.BeanItem; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.data.bean.Address; import com.vaadin.tests.data.bean.Country; -import com.vaadin.tests.data.bean.Person; import com.vaadin.tests.data.bean.PersonWithBeanValidationAnnotations; import com.vaadin.tests.data.bean.Sex; import com.vaadin.tests.util.Log; @@ -90,8 +89,10 @@ public class FieldBinderWithBeanValidation extends TestBase { p)); } - public static Person getPerson(FieldGroup binder) { - return ((BeanItem<Person>) binder.getItemDataSource()).getBean(); + public static PersonWithBeanValidationAnnotations getPerson( + FieldGroup binder) { + return ((BeanItem<PersonWithBeanValidationAnnotations>) binder + .getItemDataSource()).getBean(); } @Override diff --git a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html index 57b267530c..48d48ede80 100644 --- a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html +++ b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html @@ -4,12 +4,12 @@ <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="selenium.base" href="" /> -<title>New Test</title> +<title>IntegerRangeValidator</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> +<tr><td rowspan="1" colspan="3">IntegerRangeValidator</td></tr> </thead><tbody> <tr> <td>open</td> @@ -82,12 +82,7 @@ </tr> <tr> <td>showTooltip</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]</td> + <td>vaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VTextField[0]</td> <td></td> </tr> <tr> @@ -98,4 +93,3 @@ </tbody></table> </body> </html> - diff --git a/uitest/src/com/vaadin/tests/fonticon/FontIcons.java b/uitest/src/com/vaadin/tests/fonticon/FontIcons.java new file mode 100644 index 0000000000..5511acf3bf --- /dev/null +++ b/uitest/src/com/vaadin/tests/fonticon/FontIcons.java @@ -0,0 +1,226 @@ +/* + * Copyright 2000-2013 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.fonticon; + +import com.vaadin.event.Action; +import com.vaadin.event.Action.Handler; +import com.vaadin.server.FontAwesome; +import com.vaadin.server.FontIcon; +import com.vaadin.server.Page; +import com.vaadin.server.Resource; +import com.vaadin.server.ThemeResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.Position; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.AbstractSelect; +import com.vaadin.ui.Accordion; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Component; +import com.vaadin.ui.DateField; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Link; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.MenuBar; +import com.vaadin.ui.MenuBar.MenuItem; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.NativeSelect; +import com.vaadin.ui.Notification; +import com.vaadin.ui.OptionGroup; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Slider; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.Align; +import com.vaadin.ui.Table.RowHeaderMode; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Tree; +import com.vaadin.ui.TwinColSelect; +import com.vaadin.ui.Upload; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class FontIcons extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + buildUI(FontAwesome.ANDROID); + } + + private void buildUI(final Resource icon) { + VerticalLayout layout = new VerticalLayout(); + setContent(layout); + layout.setMargin(true); + + layout.setIcon(icon); + + layout.addComponent(new Button("Switch icon type", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + buildUI(icon instanceof FontIcon ? new ThemeResource( + "../runo/icons/16/user.png") + : FontAwesome.ANDROID); + } + })); + + Handler actionHandler = new Handler() { + Action[] actions = { new Action("Do it!", icon) }; + + @Override + public void handleAction(Action action, Object sender, Object target) { + + } + + @Override + public Action[] getActions(Object target, Object sender) { + return actions; + } + }; + + // Notification + Notification n = new Notification("Hey there!"); + n.setIcon(icon); + n.setPosition(Position.BOTTOM_CENTER); + n.setDelayMsec(-1); + n.show(Page.getCurrent()); + + // grid of compoents + GridLayout gl = new GridLayout(4, 5); + gl.setSpacing(true); + layout.addComponent(gl); + + // Basic components, caption icon only + Class<?>[] components = { Button.class, CheckBox.class, + DateField.class, NativeButton.class, Link.class, Label.class, + Panel.class, Slider.class, TextArea.class, TextField.class, + Upload.class }; + for (Class<?> clazz : components) { + Component c; + try { + c = (Component) clazz.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + continue; + } + c.setCaption(clazz.getSimpleName()); + c.setIcon(icon); + gl.addComponent(c); + } + + // TabSheet, caption + tab icons + TabSheet tabs = new TabSheet(); + tabs.setCaption("TabSheet"); + tabs.setIcon(icon); + tabs.addStyleName("myTabs"); + tabs.addTab(new Label("Content 1"), "Tab 1", icon); + tabs.addTab(new Label("Content 2"), "Tab 2", icon); + tabs.setWidth("150px"); + gl.addComponent(tabs); + + // Accordion, caption + tab icons + Accordion acc = new Accordion(); + acc.setCaption("Accordion"); + acc.setIcon(icon); + acc.addTab(new Label(), "Section 1", icon); + acc.addTab(new Label(), "Section 2", icon); + gl.addComponent(acc); + + // Table, caption + column + row + action icons + Table tbl = new Table("Table"); + tbl.setRowHeaderMode(RowHeaderMode.ICON_ONLY); + tbl.setIcon(icon); + tbl.addContainerProperty("Column 1", String.class, "Row", "Column 1", + icon, Align.LEFT); + tbl.addContainerProperty("Column 2", String.class, "Row", "Column 2", + icon, Align.LEFT); + tbl.setItemIcon(tbl.addItem(), icon); + tbl.setItemIcon(tbl.addItem(), icon); + tbl.setItemIcon(tbl.addItem(), icon); + tbl.setPageLength(3); + gl.addComponent(tbl); + tbl.addActionHandler(actionHandler); + + // Selects, caption + item icons + Class<?>[] selects = { ComboBox.class, NativeSelect.class, + ListSelect.class, TwinColSelect.class, OptionGroup.class }; + for (Class<?> clazz : selects) { + AbstractSelect sel; + try { + sel = (AbstractSelect) clazz.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + continue; + } + sel.setCaption(clazz.getSimpleName()); + sel.setIcon(icon); + sel.addItem("One"); + sel.setItemIcon("One", icon); + sel.addItem("Two"); + sel.setItemIcon("Two", icon); + gl.addComponent(sel); + } + + // MenuBar, caption + item + sub-item icons + MenuBar menu = new MenuBar(); + menu.setIcon(icon); + menu.setCaption("MenuBar"); + MenuItem mi = menu.addItem("File", icon, null); + MenuItem smi = mi.addItem("Item", icon, null); + smi = mi.addItem("Item", icon, null); + smi = smi.addItem("Item", icon, null); + gl.addComponent(menu); + + // Tree, caption + item + subitem + action icons + Tree tree = new Tree("Tree"); + tree.addItem("Root"); + tree.setItemIcon("Root", icon); + tree.addItem("Leaf"); + tree.setItemIcon("Leaf", icon); + tree.setParent("Leaf", "Root"); + tree.expandItemsRecursively("Root"); + tree.addActionHandler(actionHandler); + gl.addComponent(tree); + + // All of FontAwesome + String allIcons = ""; + for (FontIcon ic : FontAwesome.values()) { + allIcons += ic.getHtml() + " "; + } + layout.addComponent(new Label(allIcons, ContentMode.HTML)); + } + + @Override + protected String getTestDescription() { + return "Font icons should show up in all the right places"; + } + + @Override + protected Integer getTicketNumber() { + return 13152; + } + +} diff --git a/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java b/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java new file mode 100644 index 0000000000..af54b73ae3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/fonticon/FontIconsTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 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.fonticon; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class FontIconsTest extends MultiBrowserTest { + + @Test + public void checkScreenshot() throws IOException { + openTestURL(); + compareScreen("all"); + } +} diff --git a/uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java b/uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java new file mode 100644 index 0000000000..c5d6a65d87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2013 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.integration; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.PrivateTB3Configuration; + +public class JSPIntegrationTest extends PrivateTB3Configuration { + + final String appRunnerTestUrl = getBaseURL() + "/run/Buttons"; + final String jspUrl = getBaseURL() + "/statictestfiles/vaadinsessions.jsp"; + final String integrationUrl = getBaseURL() + "/integration"; + + @Test + public void listVaadinSessions() { + + assertUICount(0); + + // Open a new UI + getDriver().get(integrationUrl); + assertUICount(1); + + // Open a new UI + getDriver().get(integrationUrl); + + // Should now have two UIs for the same service with different uiIds + List<UIData> twoUIs = getUIs(); + assertEquals(2, twoUIs.size()); + assertNotEquals(twoUIs.get(0).uiId, twoUIs.get(1).uiId); + assertEquals(twoUIs.get(0).serviceName, twoUIs.get(1).serviceName); + + getDriver().get(appRunnerTestUrl); + // Should now have two services with 2 + 1 UIs + List<UIData> threeUIs = getUIs(); + assertEquals(3, threeUIs.size()); + Set<String> serviceNames = new HashSet<String>(); + Set<Integer> uiIds = new HashSet<Integer>(); + for (UIData uiData : threeUIs) { + serviceNames.add(uiData.serviceName); + uiIds.add(uiData.uiId); + } + assertGreaterOrEqual( + "There should be at least two unique service names", + serviceNames.size(), 2); + assertGreaterOrEqual("There should be at least two unique ui ids", + uiIds.size(), 2); + } + + private static class UIData { + private String serviceName; + private int uiId; + } + + private List<UIData> getUIs() { + List<UIData> uis = new ArrayList<UIData>(); + + getDriver().get(jspUrl); + List<WebElement> rows = getDriver().findElements( + By.xpath("//tr[@class='uirow']")); + for (WebElement row : rows) { + UIData data = new UIData(); + List<WebElement> tds = row.findElements(By.xpath("./td")); + + data.serviceName = tds.get(0).getText(); + data.uiId = Integer.parseInt(tds.get(2).getText()); + + uis.add(data); + } + + return uis; + } + + private void assertUICount(int i) { + assertEquals(i, getUIs().size()); + } +} diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationLongPollingUI.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationLongPollingUI.java new file mode 100644 index 0000000000..f96000f1ce --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationLongPollingUI.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2013 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.integration; + +import com.vaadin.annotations.Push; +import com.vaadin.shared.ui.ui.Transport; + +/** + * Server test which uses long polling + * + * @since 7.1 + * @author Vaadin Ltd + */ +@Push(transport = Transport.LONG_POLLING) +public class ServletIntegrationLongPollingUI extends ServletIntegrationUI { + +} diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java new file mode 100644 index 0000000000..70ca890b31 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationLongPollingUITest.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2013 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.integration; + +public class ServletIntegrationLongPollingUITest extends + AbstractServletIntegrationTest { + // Uses the test method declared in the super class +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java b/uitest/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java index 674287312d..5abe915307 100644 --- a/uitest/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java +++ b/uitest/src/com/vaadin/tests/layouts/TestAbsoluteLayout.java @@ -67,7 +67,7 @@ public class TestAbsoluteLayout extends TestBase { } return instance; } - }; + } @Override protected String getDescription() { diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java index be2768a5f7..8485bba499 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a1/FormatTableValue.java @@ -3,7 +3,7 @@ package com.vaadin.tests.minitutorials.v7a1; import java.text.NumberFormat; import java.util.Locale; -import com.vaadin.data.util.converter.StringToNumberConverter; +import com.vaadin.data.util.converter.StringToDoubleConverter; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Table; @@ -30,14 +30,14 @@ public class FormatTableValue extends AbstractTestUI { table.getItem(itemId).getItemProperty(DEFAULT_PROPERTY) .setValue(3.1415); - table.setConverter(PERCENT_PROPERTY, new StringToNumberConverter() { + table.setConverter(PERCENT_PROPERTY, new StringToDoubleConverter() { @Override protected NumberFormat getFormat(Locale locale) { return NumberFormat.getPercentInstance(locale); } }); - table.setConverter(CURRENCY_PROPERTY, new StringToNumberConverter() { + table.setConverter(CURRENCY_PROPERTY, new StringToDoubleConverter() { @Override protected NumberFormat getFormat(Locale locale) { return NumberFormat.getCurrencyInstance(locale); diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java index 3ea1cf4796..17d2fc3f93 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/MyPickerConnector.java @@ -16,7 +16,7 @@ package com.vaadin.tests.minitutorials.v7a2; -import com.google.gwt.user.client.Element; +import com.google.gwt.dom.client.Element; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.layout.ElementResizeEvent; diff --git a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java index 81944abd40..ebbc684c9c 100644 --- a/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java +++ b/uitest/src/com/vaadin/tests/navigator/NavigatorTest.java @@ -113,7 +113,7 @@ public class NavigatorTest extends UI { @Override public void afterViewChange(ViewChangeEvent event) { } - }; + } class NaviButton extends Button { public NaviButton(final String path) { diff --git a/uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java b/uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java new file mode 100644 index 0000000000..bbb7895f20 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2013 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.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.LONG_POLLING) +public class BasicPushLongPolling extends BasicPush { + + @Override + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect if long polling fails + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java b/uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java new file mode 100644 index 0000000000..b526a11d38 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2013 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.push; + +public class BasicPushLongPollingTest extends BasicPushTest { +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java index 670876e0f4..7f4492aeba 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPushTest.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java @@ -15,9 +15,10 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; import org.junit.Test; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.tb3.AbstractTB3Test; @@ -26,49 +27,28 @@ import com.vaadin.tests.tb3.MultiBrowserTest; @TestCategory("push") public abstract class BasicPushTest extends MultiBrowserTest { + @Override + public void setup() throws Exception { + super.setup(); + } + @Test public void testPush() throws InterruptedException { openTestURL(); - // Test client initiated push - Assert.assertEquals(0, getClientCounter()); getIncrementButton().click(); - Assert.assertEquals("Client counter not incremented by button click", - 1, getClientCounter()); + testBench().disableWaitForVaadin(); + + waitUntilClientCounterChanges(1); + getIncrementButton().click(); getIncrementButton().click(); getIncrementButton().click(); - Assert.assertEquals("Four clicks should have incremented counter to 4", - 4, getClientCounter()); + waitUntilClientCounterChanges(4); // Test server initiated push getServerCounterStartButton().click(); - try { - Assert.assertEquals(0, getServerCounter()); - sleep(3000); - int serverCounter = getServerCounter(); - if (serverCounter < 1) { - // No push has happened - Assert.fail("No push has occured within 3s"); - } - sleep(3000); - if (getServerCounter() <= serverCounter) { - // No push has happened - Assert.fail("Only one push took place within 6s"); - - } - } finally { - // Avoid triggering push assertions - getServerCounterStopButton().click(); - } - } - - private int getServerCounter() { - return getServerCounter(this); - } - - private int getClientCounter() { - return getClientCounter(this); + waitUntilServerCounterChanges(); } public static int getClientCounter(AbstractTB3Test t) { @@ -81,10 +61,6 @@ public abstract class BasicPushTest extends MultiBrowserTest { return getIncrementButton(this); } - private WebElement getServerCounterStopButton() { - return getServerCounterStopButton(this); - } - private WebElement getServerCounterStartButton() { return getServerCounterStartButton(this); } @@ -107,4 +83,25 @@ public abstract class BasicPushTest extends MultiBrowserTest { return t.vaadinElementById(BasicPush.INCREMENT_BUTTON_ID); } + private void waitUntilClientCounterChanges(final int expectedValue) { + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest.getClientCounter(BasicPushTest.this) == expectedValue; + } + }, 10); + } + + private void waitUntilServerCounterChanges() { + final int counter = BasicPushTest.getServerCounter(this); + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest.getServerCounter(BasicPushTest.this) > counter; + } + }, 10); + } + }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java index ac37e75fea..d5646c976b 100644 --- a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java +++ b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java @@ -50,7 +50,7 @@ public class EnableDisablePush extends AbstractTestUI { } catch (UIDetachedException e) { } } - }; + } @Override protected void setup(VaadinRequest request) { diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeLongPolling.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeLongPolling.java new file mode 100644 index 0000000000..7c0899c481 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeLongPolling.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 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.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.LONG_POLLING) +public class ExtremelyLongPushTimeLongPolling extends ExtremelyLongPushTime { + + @Override + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect failures + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } +} diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeLongPollingTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeLongPollingTest.java new file mode 100644 index 0000000000..eb28634dfa --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeLongPollingTest.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2013 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.push; + +public class ExtremelyLongPushTimeLongPollingTest extends + ExtremelyLongPushTimeTest { + +} diff --git a/uitest/src/com/vaadin/tests/push/IdlePushChannelLongPollingTest.java b/uitest/src/com/vaadin/tests/push/IdlePushChannelLongPollingTest.java new file mode 100644 index 0000000000..5a90c4333d --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/IdlePushChannelLongPollingTest.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2013 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.push; + +public class IdlePushChannelLongPollingTest extends IdlePushChannelTest { + @Override + protected Class<?> getUIClass() { + return BasicPushLongPolling.class; + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java new file mode 100644 index 0000000000..c0503d5240 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2013 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.push; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.Select; + +public class PushConfigurationLongPollingTest extends PushConfigurationTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + + browsers.remove(Browser.IE8.getDesiredCapabilities()); + + return browsers; + } + + @Test + public void testLongPolling() throws InterruptedException { + new Select(getTransportSelect()).selectByVisibleText("LONG_POLLING"); + new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + + assertThat(getStatusText(), + containsString("fallbackTransport: long-polling")); + assertThat(getStatusText(), containsString("transport: long-polling")); + + waitForServerCounterToUpdate(); + + // Use debug console to verify we used the correct transport type + assertThat( + driver.getPageSource(), + containsString("Push connection established using long-polling")); + + new Select(getPushModeSelect()).selectByVisibleText("DISABLED"); + + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java new file mode 100644 index 0000000000..46fcc5f44b --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 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.push; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.Select; + +public class PushConfigurationStreamingTest extends PushConfigurationTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + + browsers.remove(Browser.IE8.getDesiredCapabilities()); + + return browsers; + } + + @Test + public void testStreaming() throws InterruptedException { + new Select(getTransportSelect()).selectByVisibleText("STREAMING"); + new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + + assertThat(getStatusText(), + containsString("fallbackTransport: long-polling")); + assertThat(getStatusText(), containsString("transport: streaming")); + + waitForServerCounterToUpdate(); + + // Use debug console to verify we used the correct transport type + assertThat( + driver.getPageSource(), + not(containsString("Push connection established using websocket"))); + assertThat(driver.getPageSource(), + containsString("Push connection established using streaming")); + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java index a8ea9d0010..20399fc67e 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java @@ -17,107 +17,71 @@ package com.vaadin.tests.push; import static org.junit.Assert.assertEquals; -import org.junit.Assert; -import org.junit.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.Select; -import com.vaadin.tests.tb3.WebsocketTest; +import com.vaadin.tests.annotations.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; -public class PushConfigurationTest extends WebsocketTest { +@TestCategory("push") +abstract class PushConfigurationTest extends MultiBrowserTest { - @Test - public void testWebsocketAndStreaming() throws InterruptedException { - setDebug(true); - openTestURL(); - // Websocket - verifyPushDisabled(); - new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET"); - new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); - Assert.assertTrue(vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]") - .getText() - .matches( - "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: websocket[\\s\\S]*$")); - int counter = getServerCounter(); - final int waitCounter = counter + 2; - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return (getServerCounter() >= waitCounter); - } - }); + @Override + public void setup() throws Exception { + super.setup(); - // Use debug console to verify we used the correct transport type - Assert.assertTrue(driver.getPageSource().contains( - "Push connection established using websocket")); - Assert.assertFalse(driver.getPageSource().contains( - "Push connection established using streaming")); - - new Select(getPushModeSelect()).selectByVisibleText("DISABLED"); + openTestURL(); + disablePush(); + } - // Streaming - driver.get(getTestUrl()); - verifyPushDisabled(); - - new Select(getTransportSelect()).selectByVisibleText("STREAMING"); - new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); - Assert.assertTrue(vaadinElement( - "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]") - .getText() - .matches( - "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: streaming[\\s\\S]*$")); - - counter = getServerCounter(); - for (int second = 0;; second++) { - if (second >= 5) { - Assert.fail("timeout"); - } - if (getServerCounter() >= (counter + 2)) { - break; - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - } + @Override + protected String getDeploymentPath() { + return "/run/" + PushConfiguration.class.getCanonicalName() + + "?restartApplication&debug"; + } - // Use debug console to verify we used the correct transport type - Assert.assertFalse(driver.getPageSource().contains( - "Push connection established using websocket")); - Assert.assertTrue(driver.getPageSource().contains( - "Push connection established using streaming")); + protected String getStatusText() { + WebElement statusLabel = vaadinElementById("status"); + return statusLabel.getText(); } - /** - * Verifies that push is currently not enabled. - * - * @throws InterruptedException - */ - private void verifyPushDisabled() throws InterruptedException { + protected void disablePush() throws InterruptedException { + new Select(getPushModeSelect()).selectByVisibleText("DISABLED"); + int counter = getServerCounter(); sleep(2000); assertEquals("Server count changed without push enabled", counter, getServerCounter()); } - private WebElement getPushModeSelect() { + protected WebElement getPushModeSelect() { return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]"); } - private WebElement getTransportSelect() { + protected WebElement getTransportSelect() { return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]"); } - private int getServerCounter() { + protected int getServerCounter() { return Integer.parseInt(getServerCounterElement().getText()); } - private WebElement getServerCounterElement() { + protected WebElement getServerCounterElement() { return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]"); } + + protected void waitForServerCounterToUpdate() { + int counter = getServerCounter(); + final int waitCounter = counter + 2; + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return (getServerCounter() >= waitCounter); + } + }); + } }
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java new file mode 100644 index 0000000000..c8308e72f1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationWebSocketTest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2013 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.push; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.Select; + +public class PushConfigurationWebSocketTest extends PushConfigurationTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + browsers.remove(Browser.IE9.getDesiredCapabilities()); + + return browsers; + } + + @Test + public void testWebsocket() throws InterruptedException { + new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET"); + new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + + assertThat(getStatusText(), + containsString("fallbackTransport: long-polling")); + assertThat(getStatusText(), containsString("transport: websocket")); + + waitForServerCounterToUpdate(); + + // Use debug console to verify we used the correct transport type + assertThat(driver.getPageSource(), + containsString("Push connection established using websocket")); + assertThat( + driver.getPageSource(), + not(containsString("Push connection established using streaming"))); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurator.java b/uitest/src/com/vaadin/tests/push/PushConfigurator.java index 6528366b59..6dbe130b73 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurator.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurator.java @@ -101,6 +101,7 @@ public class PushConfigurator extends VerticalLayout { paramValue.setDefaultComponentAlignment(Alignment.BOTTOM_RIGHT); paramValue.addComponents(parameter, value, set); + status.setId("status"); vl.addComponents(pushMode, transport, fallbackTransport, paramValue, new Label("<hr/>", ContentMode.HTML), status); addComponent(vl); diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java new file mode 100644 index 0000000000..52a647115a --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2013 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.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.LONG_POLLING) +public class PushLargeDataLongPolling extends PushLargeData { + + @Override + protected void setup(VaadinRequest request) { + super.setup(request); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java new file mode 100644 index 0000000000..34150ea5af --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2013 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.push; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.vaadin.tests.annotations.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +@TestCategory("push") +public class PushLargeDataLongPollingTest extends MultiBrowserTest { + + @Test + public void testLongPollingLargeData() throws Exception { + openTestURL(); + + // Without this there is a large chance that we will wait for all pushes + // to complete before moving on + testBench(driver).disableWaitForVaadin(); + + push(); + // Push complete. Browser will reconnect now as > 10MB has been sent + // Push again to ensure push still works + push(); + + } + + private void push() throws InterruptedException { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + + String logRow0Id = "Log_row_0"; + By logRow0 = vaadinLocatorById(logRow0Id); + + vaadinElementById("startButton").click(); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package ")); + + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + + // Wait until push is actually done + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Push complete")); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/PushReconnectTest.java b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java deleted file mode 100644 index 325f2542d7..0000000000 --- a/uitest/src/com/vaadin/tests/push/PushReconnectTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2000-2013 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.push; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; - -public abstract class PushReconnectTest extends MultiBrowserTestWithProxy { - - @Test - public void testShortDisconnect() throws Exception { - setDebug(true); - openTestURL(); - startTimer(); - waitUntilServerCounterChanges(); - disconnectProxy(); - Thread.sleep(1000); - connectProxy(); - waitUntilServerCounterChanges(); - } - - @Test - public void testUserActionWhileDisconnectedWithDelay() throws Exception { - setDebug(true); - openTestURL(); - startTimer(); - waitUntilServerCounterChanges(); - disconnectProxy(); - Assert.assertEquals(0, getClientCounter()); - getIncrementClientCounterButton().click(); - // No change while disconnected - Assert.assertEquals(0, getClientCounter()); - // Firefox sends extra onopen calls after a while, which breaks - // everything - Thread.sleep(10000); - connectProxy(); - waitUntilServerCounterChanges(); - // The change should have appeared when reconnected - Assert.assertEquals(1, getClientCounter()); - } - - @Test - public void testUserActionWhileDisconnected() throws Exception { - setDebug(true); - openTestURL(); - startTimer(); - waitUntilServerCounterChanges(); - disconnectProxy(); - Assert.assertEquals(0, getClientCounter()); - getIncrementClientCounterButton().click(); - // No change while disconnected - Assert.assertEquals(0, getClientCounter()); - Thread.sleep(1000); - connectProxy(); - waitUntilServerCounterChanges(); - // The change should have appeared when reconnected - Assert.assertEquals(1, getClientCounter()); - - // IE has problems with another reconnect - disconnectProxy(); - getIncrementClientCounterButton().click(); - Assert.assertEquals(1, getClientCounter()); - Thread.sleep(1000); - connectProxy(); - waitUntilServerCounterChanges(); - Assert.assertEquals(2, getClientCounter()); - } - - @Test - public void testLongDisconnect() throws Exception { - setDebug(true); - openTestURL(); - startTimer(); - waitUntilServerCounterChanges(); - disconnectProxy(); - Thread.sleep(12000); - connectProxy(); - waitUntilServerCounterChanges(); - } - - @Test - public void testReallyLongDisconnect() throws Exception { - setDebug(true); - openTestURL(); - startTimer(); - waitUntilServerCounterChanges(); - disconnectProxy(); - Thread.sleep(120000); - connectProxy(); - waitUntilServerCounterChanges(); - } - - @Test - public void testMultipleDisconnects() throws Exception { - setDebug(true); - openTestURL(); - startTimer(); - waitUntilServerCounterChanges(); - for (int i = 0; i < 5; i++) { - disconnectProxy(); - Thread.sleep(1000); - connectProxy(); - waitUntilServerCounterChanges(); - } - } - - private int getClientCounter() { - return BasicPushTest.getClientCounter(this); - } - - private WebElement getIncrementClientCounterButton() { - return BasicPushTest.getIncrementButton(this); - } - - private void waitUntilServerCounterChanges() { - final int counter = BasicPushTest.getServerCounter(this); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return BasicPushTest.getServerCounter(PushReconnectTest.this) > counter; - } - }, 30); - } - - private void startTimer() { - BasicPushTest.getServerCounterStartButton(this).click(); - } - -} diff --git a/uitest/src/com/vaadin/tests/push/ReconnectLongPollingTest.java b/uitest/src/com/vaadin/tests/push/ReconnectLongPollingTest.java new file mode 100644 index 0000000000..4ea0c7daf4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ReconnectLongPollingTest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2013 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.push; + + +public class ReconnectLongPollingTest extends ReconnectTest { + + @Override + protected Class<?> getUIClass() { + return BasicPushLongPolling.class; + } + +} diff --git a/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java b/uitest/src/com/vaadin/tests/push/ReconnectStreamingTest.java index 24dfdd8ba1..4e2143f9e0 100755 --- a/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java +++ b/uitest/src/com/vaadin/tests/push/ReconnectStreamingTest.java @@ -15,7 +15,8 @@ */ package com.vaadin.tests.push; -public class StreamingReconnectTest extends PushReconnectTest { + +public class ReconnectStreamingTest extends ReconnectTest { @Override protected Class<?> getUIClass() { diff --git a/uitest/src/com/vaadin/tests/push/ReconnectTest.java b/uitest/src/com/vaadin/tests/push/ReconnectTest.java new file mode 100644 index 0000000000..b4159ff4c2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ReconnectTest.java @@ -0,0 +1,144 @@ +/* + * Copyright 2000-2013 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.push; + +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.tests.tb3.MultiBrowserTestWithProxy; + +public abstract class ReconnectTest extends MultiBrowserTestWithProxy { + + @Override + public void setup() throws Exception { + super.setup(); + + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + + testBench().disableWaitForVaadin(); + } + + @Test + public void messageIsQueuedOnDisconnect() throws JSchException { + disconnectProxy(); + + clickButtonAndWaitForTwoReconnectAttempts(); + + connectAndVerifyConnectionEstablished(); + waitUntilClientCounterChanges(1); + } + + @Test + public void messageIsNotSentBeforeConnectionIsEstablished() + throws JSchException, InterruptedException { + disconnectProxy(); + + waitForNextReconnectionAttempt(); + clickButtonAndWaitForTwoReconnectAttempts(); + + connectAndVerifyConnectionEstablished(); + waitUntilClientCounterChanges(1); + } + + private void clickButtonAndWaitForTwoReconnectAttempts() { + clickClientButton(); + + // Reconnection attempt is where pending messages can + // falsely be sent to server. + waitForNextReconnectionAttempt(); + + // Waiting for the second reconnection attempt makes sure that the + // first attempt has been completed or aborted. + waitForNextReconnectionAttempt(); + } + + private void clickClientButton() { + getIncrementClientCounterButton().click(); + } + + private void waitForNextReconnectionAttempt() { + clearDebugMessages(); + waitForDebugMessage("Reopening push connection"); + } + + private void clearDebugMessages() { + driver.findElement( + By.xpath("//button[@class='v-debugwindow-button' and @title='Clear log']")) + .click(); + } + + private boolean hasDebugMessage(String message) { + return getDebugMessage(message) != null; + } + + private WebElement getDebugMessage(String message) { + return driver.findElement(By.xpath(String.format( + "//span[@class='v-debugwindow-message' and text()='%s']", + message))); + } + + private void waitForDebugMessage(final String expectedMessage) { + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return hasDebugMessage(expectedMessage); + } + }, 30); + } + + private void connectAndVerifyConnectionEstablished() throws JSchException { + connectProxy(); + waitUntilServerCounterChanges(); + } + + private WebElement getIncrementClientCounterButton() { + return BasicPushTest.getIncrementButton(this); + } + + private void waitUntilServerCounterChanges() { + final int counter = BasicPushTest.getServerCounter(this); + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest.getServerCounter(ReconnectTest.this) > counter; + } + }, 30); + } + + private void waitUntilClientCounterChanges(final int expectedValue) { + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest.getClientCounter(ReconnectTest.this) == expectedValue; + } + }, 5); + } + + private void startTimer() { + BasicPushTest.getServerCounterStartButton(this).click(); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.java b/uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java index 075a18c0e7..57fe0a040d 100644 --- a/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.java +++ b/uitest/src/com/vaadin/tests/push/ReconnectWebsocketTest.java @@ -21,7 +21,7 @@ import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.tests.tb3.WebsocketTest; -public class WebsocketReconnectTest extends PushReconnectTest { +public class ReconnectWebsocketTest extends ReconnectTest { @Override public List<DesiredCapabilities> getBrowsersToTest() { diff --git a/uitest/src/com/vaadin/tests/serialization/GenericWidgetHandling.java b/uitest/src/com/vaadin/tests/serialization/GenericWidgetHandling.java new file mode 100644 index 0000000000..dca96a46ea --- /dev/null +++ b/uitest/src/com/vaadin/tests/serialization/GenericWidgetHandling.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2013 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.serialization; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; +import com.vaadin.tests.widgetset.server.GenericWidgetComponent; + +@Widgetset(TestingWidgetSet.NAME) +public class GenericWidgetHandling extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final GenericWidgetComponent component = new GenericWidgetComponent(); + component.setId("label"); + component.setGenericText("The generic text is strong in this one"); + addComponent(component); + } + + @Override + protected String getTestDescription() { + return "Tests that a connector works even if its widget is of a generic type"; + } + + @Override + protected Integer getTicketNumber() { + // Also 12900 if someone happens to care + return Integer.valueOf(12873); + } + +} diff --git a/uitest/src/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java b/uitest/src/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java new file mode 100644 index 0000000000..a6ff0c4459 --- /dev/null +++ b/uitest/src/com/vaadin/tests/serialization/GenericWidgetHandlingTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 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.serialization; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GenericWidgetHandlingTest extends MultiBrowserTest { + + @Test + public void testWidgetInit() { + openTestURL(); + WebElement label = vaadinElementById("label"); + + Assert.assertEquals("The generic text is strong in this one", + label.getText()); + } + +} diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.html b/uitest/src/com/vaadin/tests/serialization/SerializerTest.html deleted file mode 100644 index 63219de5c2..0000000000 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.html +++ /dev/null @@ -1,116 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.serialization.SerializerTest?restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[18]</td> - <td>sendBeanSubclass: 43</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[17]</td> - <td>sendBoolean: false, false, [false, false, true, false, true, true]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[16]</td> - <td>sendByte: 5, -12, [3, 1, 2]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[15]</td> - <td>sendChar: Å, ∫, [a, b, c, d]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[14]</td> - <td>sendInt: 2, 5, [2147483647, 0]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[13]</td> - <td>sendLong: -57841235865, 577431841358, [57, 0]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[12]</td> - <td>sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[11]</td> - <td>sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[10]</td> - <td>sendString: Taegghiiiinnrsssstt‡</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[9]</td> - <td>sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[8]</td> - <td>sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[7]</td> - <td>sendNull: null, Not null</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[6]</td> - <td>sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[5]</td> - <td>sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[4]</td> - <td>sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[3]</td> - <td>sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[2]</td> - <td>sendMap: {a=SimpleTestBean(1)}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=SimpleTestBean(4)], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]</td> - <td>sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]</td> - <td>sendEnum: PREFORMATTED, [HTML, RAW], [PREFORMATTED, XML]</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java index 0561f73b21..d4849ce667 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java @@ -16,15 +16,19 @@ package com.vaadin.tests.serialization; +import java.text.DateFormat; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.TimeZone; import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; @@ -137,6 +141,8 @@ public class SerializerTest extends AbstractTestUI { ContentMode.PREFORMATTED, ContentMode.XML }, Arrays.asList(ContentMode.HTML, ContentMode.RAW)); + rpc.sendDate(new Date(1)); + rpc.sendDate(new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13)); testExtension.registerRpc(new SerializerTestRpc() { @Override public void sendBoolean(boolean value, Boolean boxedValue, @@ -316,6 +322,15 @@ public class SerializerTest extends AbstractTestUI { log.log("sendBeanSubclass: " + bean.getValue()); } + @Override + public void sendDate(Date date) { + DateFormat format = DateFormat.getDateTimeInstance( + DateFormat.LONG, DateFormat.FULL, + new Locale("en", "fi")); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + log.log("sendDate: " + format.format(date)); + } + }); } diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java new file mode 100644 index 0000000000..d093a30ea7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 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.serialization; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SerializerTestTest extends MultiBrowserTest { + + @Test + public void testSerialization() { + openTestURL(); + int logRow = 0; + + Assert.assertEquals("sendDate: May 31, 2013 8:12:13 AM UTC", + getLogRow(logRow++)); + Assert.assertEquals("sendDate: January 1, 1970 12:00:00 AM UTC", + getLogRow(logRow++)); + Assert.assertEquals( + "sendEnum: PREFORMATTED, [HTML, RAW], [PREFORMATTED, XML]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}", + getLogRow(logRow++)); + Assert.assertEquals( + "sendMap: {a=SimpleTestBean(1)}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=SimpleTestBean(4)], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}", + getLogRow(logRow++)); + Assert.assertEquals( + "sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]", + getLogRow(logRow++)); + Assert.assertEquals("sendNull: null, Not null", getLogRow(logRow++)); + Assert.assertEquals( + "sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension", + getLogRow(logRow++)); + Assert.assertEquals("sendString: Taegghiiiinnrsssstt‡", + getLogRow(logRow++)); + Assert.assertEquals( + "sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]", + getLogRow(logRow++)); + Assert.assertEquals("sendLong: -57841235865, 577431841358, [57, 0]", + getLogRow(logRow++)); + Assert.assertEquals("sendInt: 2, 5, [2147483647, 0]", + getLogRow(logRow++)); + Assert.assertEquals("sendChar: Å, ∫, [a, b, c, d]", getLogRow(logRow++)); + Assert.assertEquals("sendByte: 5, -12, [3, 1, 2]", getLogRow(logRow++)); + Assert.assertEquals( + "sendBoolean: false, false, [false, false, true, false, true, true]", + getLogRow(logRow++)); + Assert.assertEquals("sendBeanSubclass: 43", getLogRow(logRow++)); + } +} diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java index d600b5fef2..d3e9ed6ef8 100755 --- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java @@ -19,7 +19,6 @@ import java.io.File; import java.util.concurrent.atomic.AtomicInteger; import org.junit.After; -import org.junit.Before; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; @@ -38,8 +37,9 @@ public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { System.getProperty("sshkey.file"), sshDir + "id_rsa", sshDir + "id_dsa", sshDir + "id_rsa2" }; - @Before - public void setupInitialProxy() throws JSchException { + @Override + public void setup() throws Exception { + super.setup(); connectProxy(); } diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index 400a2fe429..a00ff7ab4d 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -125,7 +125,8 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { || nwInterface.isVirtual()) { continue; } - Enumeration<InetAddress> addresses = nwInterface.getInetAddresses(); + Enumeration<InetAddress> addresses = nwInterface + .getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress address = addresses.nextElement(); if (address.isLoopbackAddress()) { diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java index c423eaff11..261a1c1b2e 100644 --- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java @@ -61,7 +61,7 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test { String className = testClass.getSimpleName(); screenshotBaseName = className + "-" + testMethod; - }; + } }; /** diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket20.java b/uitest/src/com/vaadin/tests/tickets/Ticket20.java index 34ff1274ed..5f6305bcb0 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket20.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket20.java @@ -76,7 +76,7 @@ public class Ticket20 extends LegacyApplication { com.vaadin.ui.Button.ClickEvent event) { mainWin.showNotification("The field is " + (tx.isValid() ? "" : "not ") + "valid"); - }; + } })); } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2337.java b/uitest/src/com/vaadin/tests/tickets/Ticket2337.java index 71034f7e3d..80654ff678 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket2337.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2337.java @@ -32,7 +32,6 @@ public class Ticket2337 extends LegacyApplication { @Override public void buttonClick(ClickEvent event) { gl.removeAllComponents(); - ; } diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket846.java b/uitest/src/com/vaadin/tests/tickets/Ticket846.java index 1450db2f6e..adc5663a8a 100644 --- a/uitest/src/com/vaadin/tests/tickets/Ticket846.java +++ b/uitest/src/com/vaadin/tests/tickets/Ticket846.java @@ -40,7 +40,7 @@ public class Ticket846 extends LegacyApplication { com.vaadin.ui.Button.ClickEvent event) { mainWin.showNotification("The field is " + (tx.isValid() ? "" : "not ") + "valid"); - }; + } })); TextField caption = new TextField("Caption", new MethodProperty<String>(tx, "caption")); diff --git a/uitest/src/com/vaadin/tests/util/TestUtils.java b/uitest/src/com/vaadin/tests/util/TestUtils.java index 5c6315a23a..dcd28c3413 100644 --- a/uitest/src/com/vaadin/tests/util/TestUtils.java +++ b/uitest/src/com/vaadin/tests/util/TestUtils.java @@ -99,22 +99,13 @@ public class TestUtils { "YE", "ZAMBIA", "ZM", "ZIMBABWE", "ZW" }; /** - * Crossbrowser hack to dynamically add css current window. Can be used to - * keep tests css in source files. + * Injects css into the current window. Can be used to keep tests css in + * source files. * * @param cssString */ public static void injectCSS(UI w, String cssString) { - String script = "if ('\\v'=='v') /* ie only */ {\n" - + " document.createStyleSheet().cssText = '" - + cssString - + "';\n" - + " } else {var tag = document.createElement('style'); tag.type = 'text/css';" - + " document.getElementsByTagName('head')[0].appendChild(tag);tag[ (typeof " - + "document.body.style.WebkitAppearance=='string') /* webkit only */ ? 'innerText' " - + ": 'innerHTML'] = '" + cssString + "';}"; - - w.getPage().getJavaScript().execute(script); + w.getPage().getStyles().add(cssString); } public static void installPerformanceReporting(TextArea targetTextArea) { diff --git a/uitest/src/com/vaadin/tests/widgetset/client/GenericWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/GenericWidget.java new file mode 100644 index 0000000000..bf191d1e87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/GenericWidget.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2013 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.widgetset.client; + +import com.google.gwt.user.client.ui.Label; + +public class GenericWidget<T> extends Label { + public void setGenericText(T value) { + setText(String.valueOf(value)); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/GenericWidgetConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/GenericWidgetConnector.java new file mode 100644 index 0000000000..a05bedfa27 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/GenericWidgetConnector.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 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.widgetset.client; + +import com.vaadin.client.ui.AbstractComponentConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.tests.widgetset.server.GenericWidgetComponent; + +@Connect(GenericWidgetComponent.class) +public class GenericWidgetConnector extends AbstractComponentConnector { + @Override + public GenericWidget<String> getWidget() { + return (GenericWidget<String>) super.getWidget(); + } + + @Override + public GenericWidgetState getState() { + return (GenericWidgetState) super.getState(); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/GenericWidgetState.java b/uitest/src/com/vaadin/tests/widgetset/client/GenericWidgetState.java new file mode 100644 index 0000000000..79dce8de9f --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/GenericWidgetState.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2013 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.widgetset.client; + +import com.vaadin.shared.AbstractComponentState; +import com.vaadin.shared.annotations.DelegateToWidget; + +public class GenericWidgetState extends AbstractComponentState { + @DelegateToWidget + public String genericText; +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 0f6ad577ed..01ec6cc4bb 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -19,6 +19,7 @@ package com.vaadin.tests.widgetset.client; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -251,6 +252,11 @@ public class SerializerTestConnector extends AbstractExtensionConnector { } }); } + + @Override + public void sendDate(Date date) { + rpc.sendDate(date); + } }); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java index 4bda067242..fb5b6a1980 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java @@ -16,6 +16,7 @@ package com.vaadin.tests.widgetset.client; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; @@ -79,4 +80,5 @@ public interface SerializerTestRpc extends ServerRpc, ClientRpc { public void sendBeanSubclass(SimpleTestBean bean); + public void sendDate(Date date); } diff --git a/uitest/src/com/vaadin/tests/widgetset/server/GenericWidgetComponent.java b/uitest/src/com/vaadin/tests/widgetset/server/GenericWidgetComponent.java new file mode 100644 index 0000000000..2be59ee96b --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/GenericWidgetComponent.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2013 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.widgetset.server; + +import com.vaadin.tests.widgetset.client.GenericWidgetState; +import com.vaadin.ui.AbstractComponent; + +public class GenericWidgetComponent extends AbstractComponent { + + @Override + protected GenericWidgetState getState() { + return (GenericWidgetState) super.getState(); + } + + public void setGenericText(String genericText) { + getState().genericText = genericText; + } +} |