From dc08a1c857d75e964a47842f4a2a9538878457b9 Mon Sep 17 00:00:00 2001 From: Teemu Pöntelin Date: Fri, 13 Jun 2014 18:07:48 +0300 Subject: ComboBox no longer displays input prompt if disabled or read-only (#10573) Change-Id: I3e0ad83bc5ec4a98a0c8e7658dfb606c6c5dc191 --- .../components/combobox/ComboBoxInputPrompt.java | 62 +++++++++++++++++++ .../combobox/ComboBoxInputPromptTest.java | 70 ++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPrompt.java create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPromptTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPrompt.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPrompt.java new file mode 100644 index 0000000000..082aca6989 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPrompt.java @@ -0,0 +1,62 @@ +/* + * 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.combobox; + +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.ComboBox; + +public class ComboBoxInputPrompt extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final ComboBox cb1 = new ComboBox("Normal"); + cb1.setInputPrompt("Normal input prompt"); + + final ComboBox cb2 = new ComboBox("Disabled"); + cb2.setEnabled(false); + cb2.setInputPrompt("Disabled input prompt"); + + final ComboBox cb3 = new ComboBox("Read-only"); + cb3.setReadOnly(true); + cb3.setInputPrompt("Read-only input prompt"); + + Button enableButton = new Button("Toggle enabled", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + cb2.setEnabled(!cb2.isEnabled()); + cb3.setReadOnly(!cb3.isReadOnly()); + } + }); + + addComponents(cb1, cb2, cb3, enableButton); + } + + @Override + protected String getTestDescription() { + return "ComboBox should not display the input prompt if disabled or read-only."; + } + + @Override + protected Integer getTicketNumber() { + return 10573; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPromptTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPromptTest.java new file mode 100644 index 0000000000..96151022ff --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxInputPromptTest.java @@ -0,0 +1,70 @@ +/* + * 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.combobox; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isEmptyString; +import static org.junit.Assert.assertEquals; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.AbstractTB3Test; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ComboBoxInputPromptTest extends MultiBrowserTest { + + @Test + public void promptIsHiddenForDisabledAndReadonly() { + openTestURL(); + + ComboBoxElement normalComboBox = getComboBoxWithCaption("Normal"); + ComboBoxElement disabledComboBox = getComboBoxWithCaption("Disabled"); + ComboBoxElement readOnlyComboBox = getComboBoxWithCaption("Read-only"); + + assertThat(getInputPromptValue(normalComboBox), is("Normal input prompt")); + assertThat(getInputPromptValue(disabledComboBox), isEmptyString()); + assertThat(getInputPromptValue(readOnlyComboBox), isEmptyString()); + + toggleDisabledAndReadonly(); + assertThat(getInputPromptValue(disabledComboBox), is("Disabled input prompt")); + assertThat(getInputPromptValue(readOnlyComboBox), is("Read-only input prompt")); + + toggleDisabledAndReadonly(); + assertThat(getInputPromptValue(disabledComboBox), isEmptyString()); + assertThat(getInputPromptValue(readOnlyComboBox), isEmptyString()); + } + + private void toggleDisabledAndReadonly() { + $(ButtonElement.class).first().click(); + } + + private String getInputPromptValue(ComboBoxElement comboBox) { + WebElement input = comboBox.findElement(By.tagName("input")); + + return input.getAttribute("value"); + } + + private ComboBoxElement getComboBoxWithCaption(String caption) { + return $(ComboBoxElement.class).caption(caption).first(); + } + +} -- cgit v1.2.3 From f455b391b76b1a2ad9169c5308645ad9764505ec Mon Sep 17 00:00:00 2001 From: Juuso Valli Date: Thu, 12 Jun 2014 15:43:37 +0300 Subject: Delay tooltips when moving between adjacent elements (#13998) Change-Id: Ia0845c9439e22ecece0825aaad521e900153fc81 --- client/src/com/vaadin/client/VTooltip.java | 46 ++++++------ .../tooltip/AdjacentElementsWithTooltips.java | 82 ++++++++++++++++++++++ .../tooltip/AdjacentElementsWithTooltipsTest.java | 75 ++++++++++++++++++++ 3 files changed, 181 insertions(+), 22 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 8e653a0476..1385a52469 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -229,18 +229,23 @@ public class VTooltip extends VWindowOverlay { /** * For assistive tooltips to work correctly we must have the tooltip visible - * and attached to the DOM well in advance. + * and attached to the DOM well in advance. For this reason both isShowing + * and isVisible return false positives. We can't override either of them as + * external code may depend on this behavior. * - * @return + * @return boolean */ - public boolean isActuallyVisible() { - return super.isShowing() && getPopupLeft() > 0 && getPopupTop() > 0; + public boolean isTooltipOpen() { + return super.isShowing() && super.isVisible() && getPopupLeft() > 0 + && getPopupTop() > 0; } private void closeNow() { hide(); setWidth(""); closing = false; + justClosedTimer.schedule(getQuickOpenTimeout()); + justClosed = true; } private Timer showTimer = new Timer() { @@ -255,8 +260,6 @@ public class VTooltip extends VWindowOverlay { @Override public void run() { closeNow(); - justClosedTimer.schedule(getQuickOpenTimeout()); - justClosed = true; } }; @@ -279,7 +282,7 @@ public class VTooltip extends VWindowOverlay { // already about to close return; } - if (isActuallyVisible()) { + if (isTooltipOpen()) { closeTimer.schedule(getCloseTimeout()); closing = true; } @@ -331,6 +334,8 @@ public class VTooltip extends VWindowOverlay { if (closing) { closeTimer.cancel(); closeNow(); + justClosedTimer.cancel(); + justClosed = false; } showTooltip(); @@ -449,7 +454,7 @@ public class VTooltip extends VWindowOverlay { // hasn't changed, we ignore the event. // TooltipInfo contains a reference to the parent component that is // checked in it's equals-method. - if (currentElement != null && isActuallyVisible()) { + if (currentElement != null && isTooltipOpen()) { TooltipInfo currentTooltip = getTooltipFor(currentElement); TooltipInfo newTooltip = getTooltipFor(element); if (currentTooltip != null && currentTooltip.equals(newTooltip)) { @@ -465,24 +470,21 @@ public class VTooltip extends VWindowOverlay { closeTimer.cancel(); closing = false; } + + if (isTooltipOpen()) { + closeNow(); + } + setTooltipText(info); updatePosition(event, isFocused); - if (isActuallyVisible() && !isFocused) { + // Schedule timer for showing the tooltip according to if it + // was recently closed or not. + int timeout = justClosed ? getQuickOpenDelay() : getOpenDelay(); + if (timeout == 0) { showTooltip(); } else { - if (isActuallyVisible()) { - closeNow(); - } - // Schedule timer for showing the tooltip according to if it - // was recently closed or not. - int timeout = justClosed ? getQuickOpenDelay() - : getOpenDelay(); - if (timeout == 0) { - showTooltip(); - } else { - showTimer.schedule(timeout); - opening = true; - } + showTimer.schedule(timeout); + opening = true; } } diff --git a/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java new file mode 100644 index 0000000000..60167e43b4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java @@ -0,0 +1,82 @@ +/* + * 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.tooltip; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Component; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TooltipConfiguration; + +/** + * When moving between adjacent elements, the tooltip replace should obey + * quickOpenDelay + * + * @author Vaadin Ltd + */ +public class AdjacentElementsWithTooltips extends AbstractTestUI { + + private int buttonCount = 0; + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + TooltipConfiguration ttc = super.getTooltipConfiguration(); + ttc.setMaxWidth(350); + ttc.setOpenDelay(200); + ttc.setCloseTimeout(200); + ttc.setQuickOpenDelay(1000); + ttc.setQuickOpenTimeout(1000); + HorizontalLayout layout = new HorizontalLayout(); + layout.addComponent(makeButton("first")); + layout.addComponent(makeButton("second")); + addComponent(layout); + + } + + private Component makeButton(String tooltip) { + Button button = new Button("Button " + buttonCount++); + button.setDescription(tooltip); + return button; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Moving between adjacent elements with tooltips should open quickOpenDelay"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 13998; + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java new file mode 100644 index 0000000000..b9fc788008 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java @@ -0,0 +1,75 @@ +/* + * 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.tooltip; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThan; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; +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 org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test to see if tooltips obey quickOpenDelay when moving between directly + * adjacent elements. + * + * @author Vaadin Ltd + */ +public class AdjacentElementsWithTooltipsTest extends MultiBrowserTest { + + @Override + public List getBrowsersToTest() { + return getBrowsersExcludingIE(); + } + + @Test + public void tooltipsHaveQuickOpenDelay() throws InterruptedException { + openTestURL(); + Coordinates button0Coordinates = getButtonCoordinates("Button 0"); + Coordinates button1Coordinates = getButtonCoordinates("Button 1"); + + Mouse mouse = getMouse(); + mouse.mouseMove(button0Coordinates, 10, 10); + sleep(1000); + assertThat(getTooltipElement().getLocation().x, is(greaterThan(0))); + + mouse.mouseMove(button1Coordinates, 10, 10); + assertThat(getTooltipElement().getLocation().x, is(lessThan(-1000))); + + sleep(1000); + assertThat(getTooltipElement().getLocation().x, + is(greaterThan(button1Coordinates.onPage().x))); + } + + private Coordinates getButtonCoordinates(String caption) { + return getCoordinates(getButton(caption)); + } + + private ButtonElement getButton(String caption) { + return $(ButtonElement.class) + .caption(caption).first(); + } +} -- cgit v1.2.3 From 545b3a43bf8953c8976de518bfc618cae0564b9a Mon Sep 17 00:00:00 2001 From: Juuso Valli Date: Mon, 26 May 2014 17:25:49 +0300 Subject: Improve CaptionLeakTest on IE8 (#13829) Change-Id: I0c04f3318af2c9c53e5967485008faa260830996 --- .../components/orderedlayout/CaptionLeak.java | 53 +++++++++++++++++----- .../components/orderedlayout/CaptionLeakTest.java | 49 ++++++++++++-------- 2 files changed, 71 insertions(+), 31 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeak.java b/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeak.java index 7d347d6180..c715aa383a 100644 --- a/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeak.java +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeak.java @@ -1,13 +1,13 @@ package com.vaadin.tests.components.orderedlayout; import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.ComponentContainer; import com.vaadin.ui.CssLayout; -import com.vaadin.ui.Label; +import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; -import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; /** @@ -17,23 +17,32 @@ import com.vaadin.ui.VerticalLayout; * @since 7.1.13 * @author Vaadin Ltd */ -public class CaptionLeak extends UI { - - public static final String USAGE = "Open this UI with ?debug and count" - + " measured non-connector elements after setting leaky and non leaky" - + " content."; +public class CaptionLeak extends AbstractTestUI { + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ @Override - public void init(VaadinRequest req) { - final VerticalLayout root = new VerticalLayout(); - setContent(root); - Label usage = new Label(USAGE); + protected void setup(VaadinRequest request) { + VerticalLayout root = new VerticalLayout(); + root.setSizeFull(); + root.setMargin(false); + root.setSpacing(false); + + HorizontalLayout layout = new HorizontalLayout(); Panel parent = new Panel(); Button setLeakyContent = makeButton("Set leaky content", parent, VerticalLayout.class); Button setNonLeakyContent = makeButton("Set non leaky content", parent, CssLayout.class); - root.addComponents(usage, setLeakyContent, setNonLeakyContent, parent); + layout.addComponent(setLeakyContent); + layout.addComponent(setNonLeakyContent); + root.addComponent(layout); + root.addComponent(parent); + setContent(root); } private Button makeButton(String caption, final Panel parent, @@ -59,4 +68,24 @@ public class CaptionLeak extends UI { return btn; } + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Open this UI with ?debug and count measured non-connector elements after setting leaky and non leaky content."; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return null; + } + } diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeakTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeakTest.java index 0fbd0e5f69..a95ceca22b 100644 --- a/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeakTest.java +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/CaptionLeakTest.java @@ -18,6 +18,7 @@ package com.vaadin.tests.components.orderedlayout; import org.junit.Test; import org.openqa.selenium.By; +import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.tests.tb3.MultiBrowserTest; public class CaptionLeakTest extends MultiBrowserTest { @@ -26,43 +27,53 @@ public class CaptionLeakTest extends MultiBrowserTest { public void testCaptionLeak() throws Exception { setDebug(true); openTestURL(); - openDebugLogTab(); + + openLog(); // this should be present // 3 general non-connector elements, none accumulated on click - getDriver() - .findElement( - By.xpath("//span[text() = 'Measured 3 non connector elements']")); + checkConnectorCount(); - getDriver().findElement(By.xpath("//button[@title = 'Clear log']")) - .click(); - getDriver().findElement(By.id("Set leaky content")).click(); + clearLog(); - getDriver() - .findElement( - By.xpath("//span[text() = 'Measured 3 non connector elements']")); + $(ButtonElement.class).caption("Set leaky content").first().click(); + + checkConnectorCount(); // nothing accumulates over clicks - getDriver().findElement(By.xpath("//button[@title = 'Clear log']")) - .click(); - getDriver().findElement(By.id("Set leaky content")).click(); - getDriver() - .findElement( - By.xpath("//span[text() = 'Measured 3 non connector elements']")); + clearLog(); + + $(ButtonElement.class).caption("Set leaky content").first().click(); + checkConnectorCount(); } @Test public void testNoCaptionLeak() throws Exception { setDebug(true); openTestURL(); + + openLog(); + + clearLog(); + $(ButtonElement.class).caption("Set non leaky content").first().click(); + // this should be present + // 3 general non-connector elements, none accumulated on click + checkConnectorCount(); + } + + private void openLog() { openDebugLogTab(); + if (BrowserUtil.isIE8(getDesiredCapabilities())) { + openDebugLogTab(); + } + } + private void clearLog() { getDriver().findElement(By.xpath("//button[@title = 'Clear log']")) .click(); - getDriver().findElement(By.id("Set non leaky content")).click(); + } - // this should be present - // 3 general non-connector elements, none accumulated on click + private void checkConnectorCount() { getDriver() .findElement( By.xpath("//span[text() = 'Measured 3 non connector elements']")); -- cgit v1.2.3 From d076dc7317b4f211e95ef560442793cb1200cfc9 Mon Sep 17 00:00:00 2001 From: Markus Koivisto Date: Thu, 12 Jun 2014 17:38:44 +0300 Subject: Prevent table from scrolling on selectionChange when in Multiselect mode (#13341) Change-Id: Ie3df61fab6d76dce3e2027cd732d0e6e7dd299e9 --- client/src/com/vaadin/client/ui/VScrollTable.java | 14 +++- .../table/SelectAllConstantViewport.java | 98 ++++++++++++++++++++++ .../table/SelectAllConstantViewportTest.java | 61 ++++++++++++++ 3 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewport.java create mode 100644 uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index d3317abd4d..f8b1ff8d83 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -1082,12 +1082,20 @@ public class VScrollTable extends FlowPanel implements HasWidgets, selected = true; keyboardSelectionOverRowFetchInProgress = true; } - if (selected) { + if (isSingleSelectMode() && selected) { + if (focusedRow == null || !selectedRowKeys.contains(focusedRow .getKey())) { - // The focus is no longer on a selected row, - // move focus to first selected row + /* + * The focus is no longer on a selected row. If we + * are in single select mode, move focus to the + * selected row. (#10522) + * + * Don't modify the focused row when in multiselect + * mode. (#13341) + */ + setRowFocus(row); } } diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewport.java b/uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewport.java new file mode 100644 index 0000000000..5a406eac48 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewport.java @@ -0,0 +1,98 @@ +/* + * 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.table; + +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Table; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class SelectAllConstantViewport extends AbstractTestUIWithLog { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + final Table table = new Table(); + table.addContainerProperty("", Integer.class, null); + table.setSizeFull(); + table.setMultiSelect(true); + table.setNullSelectionAllowed(true); + table.setSelectable(true); + + CheckBox selectAllCheckbox = new CheckBox("Select All"); + selectAllCheckbox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange( + com.vaadin.data.Property.ValueChangeEvent event) { + Object checked = event.getProperty().getValue(); + if (checked instanceof Boolean) { + if (((Boolean) checked).booleanValue()) { + table.setValue(table.getItemIds()); + } else { + table.setValue(null); + } + } + } + }); + + for (int i = 0; i < 200; i++) { + table.addItem(new Object[] { new Integer(i) }, new Integer(i)); + } + + table.setCurrentPageFirstItemIndex(185); + + final CssLayout layout = new CssLayout(); + layout.addComponent(selectAllCheckbox); + layout.addComponent(table); + layout.setSizeFull(); + addComponent(layout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + + return "The scroll position of a table with many items should remain constant if all items are selected."; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 13341; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java b/uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java new file mode 100644 index 0000000000..0e7a7c08a4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllConstantViewportTest.java @@ -0,0 +1,61 @@ +/* + * 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.table; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.IOException; + +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SelectAllConstantViewportTest extends MultiBrowserTest { + + @Test + public void testViewportUnchanged() throws IOException { + openTestURL(); + + CheckBoxElement checkbox = $(CheckBoxElement.class).first(); + + WebElement row = $(TableElement.class).first().getCell(190, 0); + final WebElement scrollPositionDisplay = getDriver().findElement( + By.className("v-table-scrollposition")); + waitUntilNot(new ExpectedCondition() { + + @Override + public Boolean apply(WebDriver input) { + return scrollPositionDisplay.isDisplayed(); + } + }, 10); + + int rowLocation = row.getLocation().getY(); + + // use click x,y with non-zero offset to actually toggle the checkbox. (#13763) + checkbox.click(5, 5); + int newRowLocation = row.getLocation().getY(); + + assertThat(newRowLocation, is(rowLocation)); + + } +} -- cgit v1.2.3 From 8b0846967af04070bf692d444f7d684499410d24 Mon Sep 17 00:00:00 2001 From: Teemu Pöntelin Date: Thu, 12 Jun 2014 19:34:49 +0300 Subject: Fix for unnecessary RPC request when clicking on CheckBox label (#8259) Change-Id: I7efb8b10a0d1b19ffdc9eb1d29db1f00b45f17aa --- .../client/ui/checkbox/CheckBoxConnector.java | 22 ++++---- .../components/checkbox/CheckBoxRpcCount.java | 62 ++++++++++++++++++++++ .../components/checkbox/CheckBoxRpcCountTest.java | 50 +++++++++++++++++ 3 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java create mode 100644 uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java index a72049aa90..28f6beefa6 100644 --- a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java +++ b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java @@ -144,14 +144,18 @@ public class CheckBoxConnector extends AbstractFieldConnector implements return; } - getState().checked = getWidget().getValue(); - - // Add mouse details - MouseEventDetails details = MouseEventDetailsBuilder - .buildMouseEventDetails(event.getNativeEvent(), getWidget() - .getElement()); - getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked, - details); - + // We get click events also from the label text, which do not alter the + // actual value. The server-side is only interested in real changes to + // the state. + if (getState().checked != getWidget().getValue()) { + getState().checked = getWidget().getValue(); + + // Add mouse details + MouseEventDetails details = MouseEventDetailsBuilder + .buildMouseEventDetails(event.getNativeEvent(), getWidget() + .getElement()); + getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked, + details); + } } } diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java new file mode 100644 index 0000000000..bd44e8a074 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java @@ -0,0 +1,62 @@ +/* + * 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.checkbox; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.Label; + +public class CheckBoxRpcCount extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Label countLabel = new Label("No RPC calls made yet."); + countLabel.setId("count-label"); + addComponent(countLabel); + + CheckBox cb = new CheckBox("Click me to start counting...") { + { + // Register a new RPC that counts the number of invocations. + registerRpc(new CheckBoxServerRpc() { + private int rpcCount = 0; + + @Override + public void setChecked(boolean checked, + MouseEventDetails mouseEventDetails) { + rpcCount++; + countLabel.setValue(rpcCount + " RPC call(s) made."); + } + + }); + } + }; + addComponent(cb); + } + + @Override + protected String getTestDescription() { + return "Test for verifying that no extra RPC calls are made when clicking on CheckBox label."; + } + + @Override + protected Integer getTicketNumber() { + return 8259; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java new file mode 100644 index 0000000000..c32051b593 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java @@ -0,0 +1,50 @@ +/* + * 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.checkbox; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class CheckBoxRpcCountTest extends MultiBrowserTest { + + @Test + public void testNumberOfRpcCalls() { + openTestURL(); + + WebElement labelElem = driver.findElement(By + .cssSelector(".v-checkbox label")); + WebElement inputElem = driver.findElement(By + .cssSelector(".v-checkbox input")); + WebElement countElem = driver.findElement(By.id("count-label")); + + // Click on the actual checkbox. + inputElem.click(); + assertEquals("1 RPC call(s) made.", countElem.getText()); + + // Click on the checkbox label. + labelElem.click(); + assertEquals("2 RPC call(s) made.", countElem.getText()); + + // Again on the label. + labelElem.click(); + assertEquals("3 RPC call(s) made.", countElem.getText()); + } +} -- cgit v1.2.3 From f28d710aee0279ee484acd5c645e9c425e6f4b3a Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Wed, 11 Jun 2014 10:09:18 +0300 Subject: Change PhantomJS to run on Linux instead of Windows. Change-Id: Ibb7080c37a67516c852e00d08c2d5d822fda654e --- .../com/vaadin/tests/VerifyBrowserVersionTest.java | 2 +- .../combobox/ComboBoxScrollingWithArrowsTest.java | 81 ++++++++++++++-------- .../ComboBoxSetNullWhenNewItemsAllowedTest.java | 2 + .../gridlayout/GridLayoutExpandRatioTest.java | 53 +++++++++----- .../gridlayout/GridLayoutHideMiddleCellsTest.java | 40 +---------- .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 2 +- 6 files changed, 92 insertions(+), 88 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java index 53317bd581..43d6a55a8b 100644 --- a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -49,7 +49,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36"); expectedUserAgent .put(Browser.PHANTOMJS.getDesiredCapabilities(), - "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"); + "Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"); } diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java index bc03593e3f..fa6f5a3a93 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java @@ -15,16 +15,19 @@ */ package com.vaadin.tests.components.combobox; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; import org.junit.Test; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; /** * When pressed down key, while positioned on the last item - should show next @@ -32,52 +35,72 @@ import com.vaadin.tests.tb3.MultiBrowserTest; */ public class ComboBoxScrollingWithArrowsTest extends MultiBrowserTest { - @Before - public void openURL() { + private final int PAGESIZE = 10; + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + openPopup(); } - @Test - public void scrollDownArrowKeyTest() throws InterruptedException { - final int ITEMS_PER_PAGE = 10; + private WebElement getDropDown() { // Selenium is used instead of TestBench4, because there is no method to // access the popup of the combobox // The method ComboBoxElement.openPopup() opens the popup, but doesn't // provide any way to access the popup and send keys to it. // Ticket #13756 - WebElement dropDownComboBox = driver.findElement(By + + return driver.findElement(By .className("v-filterselect-input")); - // opens Lookup - dropDownComboBox.sendKeys(Keys.DOWN); + } + + private void openPopup() { + ComboBoxElement cb = $(ComboBoxElement.class).first(); + cb.openPopup(); + } + + @Test + public void scrollDownArrowKeyTest() throws InterruptedException { + WebElement dropDownComboBox = getDropDown(); + // go to the last item and then one more - for (int i = 0; i < ITEMS_PER_PAGE + 1; i++) { + for (int i = 0; i < PAGESIZE + 1; i++) { dropDownComboBox.sendKeys(Keys.DOWN); } - String expected = "item " + ITEMS_PER_PAGE;// item 10 + assertThat(getSelectedItemText(), is("item " + PAGESIZE)); //item 10 + } + + private String getSelectedItemText() { List items = driver.findElements(By .className("gwt-MenuItem-selected")); - String actual = items.get(0).getText(); - Assert.assertEquals(expected, actual); + return items.get(0).getText(); } @Test public void scrollUpArrowKeyTest() throws InterruptedException { - final int ITEMS_PER_PAGE = 10; - WebElement dropDownComboBox = driver.findElement(By - .className("v-filterselect-input")); - // opens Lookup - dropDownComboBox.sendKeys(Keys.DOWN); + WebElement dropDownComboBox = getDropDown(); + // go to the last item and then one more - for (int i = 0; i < ITEMS_PER_PAGE + 1; i++) { + for (int i = 0; i < PAGESIZE + 1; i++) { dropDownComboBox.sendKeys(Keys.DOWN); } + // move to one item up + waitUntilNextPageIsVisible(); dropDownComboBox.sendKeys(Keys.UP); - String expected = "item " + (ITEMS_PER_PAGE - 1);// item 9 - List items = driver.findElements(By - .className("gwt-MenuItem-selected")); - String actual = items.get(0).getText(); - Assert.assertEquals(expected, actual); + + assertThat(getSelectedItemText(), is("item " + (PAGESIZE - 1))); //item 9 + } + + private void waitUntilNextPageIsVisible() { + waitUntil(new ExpectedCondition() { + @Override + public Boolean apply(WebDriver input) { + return getSelectedItemText().equals("item " + PAGESIZE); + } + }, 5); } } diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java index 54d355ab0a..7951187fa7 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java @@ -46,9 +46,11 @@ public class ComboBoxSetNullWhenNewItemsAllowedTest extends MultiBrowserTest { assertEquals("New value", element.getAttribute("value")); if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + Thread.sleep(500); } else { element.sendKeys(Keys.RETURN); } + assertEquals("", element.getAttribute("value")); } } diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java index 7d5ad1fbc4..d4d36bd10f 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java @@ -15,32 +15,30 @@ */ package com.vaadin.tests.components.gridlayout; -import static org.junit.Assert.assertEquals; - -import java.util.List; - +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; 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.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.GridLayoutElement; -import com.vaadin.tests.tb3.MultiBrowserTest; +import java.util.List; + +import static org.junit.Assert.assertEquals; public class GridLayoutExpandRatioTest extends MultiBrowserTest { @Test - public void gridLayoutExpandRatioTest() { + public void cellSizesAreCorrectlyCalculated() { openTestURL(); - GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); - GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); - ButtonElement hidingButton = $(ButtonElement.class).get(0); - hidingButton.click(); - List slots5x5 = gridLayout5x5.findElements(By - .className("v-gridlayout-slot")); - List slots4x4 = gridLayout4x4.findElements(By - .className("v-gridlayout-slot")); - assertEquals("Different amount of slots", slots5x5.size(), - slots4x4.size()); + + hideMiddleRowAndColumn(); + final List slots4x4 = getSlots(1); + + waitUntilColumnAndRowAreHidden(slots4x4); + final List slots5x5 = getSlots(0); + for (int i = 0; i < slots5x5.size(); i++) { WebElement compared = slots5x5.get(i); WebElement actual = slots4x4.get(i); @@ -50,4 +48,23 @@ public class GridLayoutExpandRatioTest extends MultiBrowserTest { compared.getCssValue("left"), actual.getCssValue("left")); } } + + private void waitUntilColumnAndRowAreHidden(final List slots4x4) { + waitUntil(new ExpectedCondition() { + @Override + public Boolean apply(WebDriver input) { + return getSlots(0).size() == slots4x4.size(); + } + }, 5); + } + + private List getSlots(int index) { + GridLayoutElement layout = $(GridLayoutElement.class).get(index); + + return layout.findElements(By.className("v-gridlayout-slot")); + } + + private void hideMiddleRowAndColumn() { + $(ButtonElement.class).first().click(); + } } diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java index d0225275f7..a5eb9b6e04 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java @@ -15,43 +15,5 @@ */ package com.vaadin.tests.components.gridlayout; -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.GridLayoutElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class GridLayoutHideMiddleCellsTest extends MultiBrowserTest { - @Test - public void gridLayoutInvisibleElementsTest() { - openTestURL(); - GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); - GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); - ButtonElement hidingButton = $(ButtonElement.class).get(0); - hidingButton.click(); - List slots5x5 = gridLayout5x5.findElements(By - .className("v-gridlayout-slot")); - List slots4x4 = gridLayout4x4.findElements(By - .className("v-gridlayout-slot")); - assertEquals("Different amount of slots", slots5x5.size(), - slots4x4.size()); - - for (int i = 0; i < slots5x5.size(); i++) { - assertEquals("Different left coordinate for element " + i, slots5x5 - .get(i).getCssValue("left"), - slots4x4.get(i).getCssValue("left")); - } - for (int i = 0; i < slots5x5.size(); i++) { - assertEquals("Different top coordinate for element " + i, slots5x5 - .get(i).getCssValue("top"), - slots4x4.get(i).getCssValue("top")); - } - } - +public class GridLayoutHideMiddleCellsTest extends GridLayoutExpandRatioTest { } diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 8783a4dc42..406f1fe27c 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -791,7 +791,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ public static DesiredCapabilities phantomJS(int version) { DesiredCapabilities c = DesiredCapabilities.phantomjs(); - c.setPlatform(Platform.XP); + c.setPlatform(Platform.LINUX); c.setVersion("" + version); return c; } -- cgit v1.2.3 From 26f74f5b45dc5d7c2646b792d1ac12851eed1285 Mon Sep 17 00:00:00 2001 From: Teemu Pöntelin Date: Thu, 22 May 2014 21:22:09 +0300 Subject: Fixed an NPE while changing a DateField from 24 to 12h clock (#13722) A client-side NullPointerException was fixed by not reusing the existing VTime panel and always recreating it instead. Otherwise the ListBox for switching between AM/PM might have been null. Change-Id: I8d54d91627043a12b52ac5d5e54d6f7a729af1ac --- .../src/com/vaadin/client/ui/VCalendarPanel.java | 4 +- .../tests/components/datefield/LocaleChange.java | 82 ++++++++++++++++++++++ .../components/datefield/LocaleChangeTest.java | 62 ++++++++++++++++ 3 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/datefield/LocaleChange.java create mode 100644 uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java index d8c96917d8..eaa2292c69 100644 --- a/client/src/com/vaadin/client/ui/VCalendarPanel.java +++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java @@ -813,14 +813,12 @@ public class VCalendarPanel extends FocusableFlexTable implements buildCalendarBody(); } - if (isTimeSelectorNeeded() && time == null) { + if (isTimeSelectorNeeded()) { time = new VTime(); setWidget(2, 0, time); getFlexCellFormatter().setColSpan(2, 0, 5); getFlexCellFormatter().setStyleName(2, 0, parent.getStylePrimaryName() + "-calendarpanel-time"); - } else if (isTimeSelectorNeeded()) { - time.updateTimes(); } else if (time != null) { remove(time); } diff --git a/uitest/src/com/vaadin/tests/components/datefield/LocaleChange.java b/uitest/src/com/vaadin/tests/components/datefield/LocaleChange.java new file mode 100644 index 0000000000..f69c93419b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/LocaleChange.java @@ -0,0 +1,82 @@ +/* + * 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.datefield; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.datefield.Resolution; +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.DateField; + +public class LocaleChange extends AbstractTestUI { + + private final Locale locale12hClock = Locale.US; + private final Locale locale24hClock = Locale.FRANCE; + + private final String caption = "Switch to %s hour clock"; + private static final Date dateValue; + static { + try { + dateValue = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") + .parse("2014-05-22 20:00:00"); + } catch (ParseException e) { + throw new ExceptionInInitializerError("Should never happen."); + } + } + + @Override + protected void setup(VaadinRequest request) { + final DateField df = new DateField(); + df.setLocale(locale24hClock); + df.setResolution(Resolution.SECOND); + df.setValue(dateValue); + + Button button = new Button(String.format(caption, "12")); + button.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (locale12hClock.equals(df.getLocale())) { + df.setLocale(locale24hClock); + event.getButton().setCaption(String.format(caption, "12")); + } else { + df.setLocale(locale12hClock); + event.getButton().setCaption(String.format(caption, "24")); + } + } + }); + + addComponent(df); + addComponent(button); + } + + @Override + protected String getTestDescription() { + return "Testing locale change from one with 24h clock to a 12h clock locale."; + } + + @Override + protected Integer getTicketNumber() { + return 13722; + } +} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java b/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java new file mode 100644 index 0000000000..cf756034a1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java @@ -0,0 +1,62 @@ +/* + * 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.datefield; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class LocaleChangeTest extends MultiBrowserTest { + + @Test + public void testLocaleChange() { + openTestURL(); + + // Check the initial value and that popup can be opened. + assertEquals("22/05/14 20:00:00", getDateValue()); + toggleDatePopup(); + assertPopupOpen(true); + + // Close the popup and change the locale. + toggleDatePopup(); + assertPopupOpen(false); + driver.findElement(By.className("v-button")).click(); // Locale change. + + // Check that the value has changed and the popup can still be opened + // without problems. + assertEquals("5/22/14 08:00:00 PM", getDateValue()); + toggleDatePopup(); + assertPopupOpen(true); + } + + private void assertPopupOpen(boolean open) { + assertEquals("Date popup was not " + (open ? "open" : "closed") + ".", + (open ? 1 : 0), + driver.findElements(By.className("v-datefield-popup")).size()); + } + + private void toggleDatePopup() { + driver.findElement(By.className("v-datefield-button")).click(); + } + + private String getDateValue() { + return driver.findElement(By.className("v-datefield-textfield")) + .getAttribute("value"); + } +} -- cgit v1.2.3 From 5981b6e6b693eb2a4166c1954f96ab0f93c7f744 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Fri, 13 Jun 2014 10:45:40 +0300 Subject: Convert GridLayoutMoveComponentTest to TB4. (#8855) Change-Id: I4be636273b2fd8dae544a6f0b88d8fdb00c33826 --- .../tests/layouts/GridLayoutMoveComponent.html | 57 ----------------- .../tests/layouts/GridLayoutMoveComponent.java | 69 --------------------- .../gridlayout/GridLayoutMoveComponent.java | 72 ++++++++++++++++++++++ .../gridlayout/GridLayoutMoveComponentTest.java | 31 ++++++++++ 4 files changed, 103 insertions(+), 126 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.html delete mode 100644 uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.java create mode 100644 uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java create mode 100644 uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponentTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.html b/uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.html deleted file mode 100644 index 77a17263f8..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.layouts.GridLayoutMoveComponent?restartApplication
screenCaptureall-left
clickvaadin=runcomvaadintestslayoutsGridLayoutMoveComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturelabel-right
clickvaadin=runcomvaadintestslayoutsGridLayoutMoveComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
screenCapturelabel-button-right
clickvaadin=runcomvaadintestslayoutsGridLayoutMoveComponent::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
screenCapturelabel-button-textfield-right
- - diff --git a/uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.java b/uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.java deleted file mode 100644 index efd1277653..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/GridLayoutMoveComponent.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.vaadin.tests.layouts; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.Label; -import com.vaadin.ui.TextField; - -public class GridLayoutMoveComponent extends TestBase { - - @Override - protected void setup() { - final GridLayout grid = new GridLayout(2, 3); - grid.setCaption("Fixed size grid"); - grid.setWidth("300px"); - grid.setHeight("100px"); - addComponent(grid); - - final Label l = new Label("100% label"); - final Button b = new Button("100px button"); - b.setWidth("100px"); - final TextField tf = new TextField("Undef textfield"); - - // Adding component to grid - grid.addComponent(l, 0, 0); - grid.addComponent(b, 0, 1); - grid.addComponent(tf, 0, 2); - - addComponent(new Button("Shift label right", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - // Moving component from 0,0 -> 1,0 - grid.removeComponent(l); - grid.addComponent(l, 1, 0); - } - })); - - addComponent(new Button("Shift button right", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - grid.removeComponent(b); - grid.addComponent(b, 1, 1); - } - })); - - addComponent(new Button("Shift text field right", - new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - grid.removeComponent(tf); - grid.addComponent(tf, 1, 2); - } - })); - } - - @Override - protected String getDescription() { - return "Click the buttons below the GridLayout to move the components to the right. Should definitely work no matter what."; - } - - @Override - protected Integer getTicketNumber() { - return 5525; - } - -} diff --git a/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java new file mode 100644 index 0000000000..cd86fbcf3c --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponent.java @@ -0,0 +1,72 @@ +package com.vaadin.tests.layouts.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; + +public class GridLayoutMoveComponent extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final GridLayout grid = new GridLayout(2, 3); + grid.setCaption("Fixed size grid"); + grid.setWidth("300px"); + grid.setHeight("100px"); + addComponent(grid); + + final Label l = new Label("100% label"); + final Button b = new Button("100px button"); + b.setWidth("100px"); + final TextField tf = new TextField("Undef textfield"); + + // Adding component to grid + grid.addComponent(l, 0, 0); + grid.addComponent(b, 0, 1); + grid.addComponent(tf, 0, 2); + + addComponent(new Button("Shift label right", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // Moving component from 0,0 -> 1,0 + grid.removeComponent(l); + grid.addComponent(l, 1, 0); + } + })); + + addComponent(new Button("Shift button right", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + grid.removeComponent(b); + grid.addComponent(b, 1, 1); + } + })); + + addComponent(new Button("Shift text field right", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + grid.removeComponent(tf); + grid.addComponent(new Label("I'm on left"), 0, 2); + grid.addComponent(tf, 1, 2); + } + })); + } + + @Override + protected String getTestDescription() { + return "Click the buttons below the GridLayout to move the components to the right. Should definitely work no matter what."; + } + + @Override + protected Integer getTicketNumber() { + return 5525; + } + +} diff --git a/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponentTest.java b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponentTest.java new file mode 100644 index 0000000000..0fab64989a --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutMoveComponentTest.java @@ -0,0 +1,31 @@ +package com.vaadin.tests.layouts.gridlayout; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; + +import java.io.IOException; + +public class GridLayoutMoveComponentTest extends MultiBrowserTest { + + @Test + public void componentsShouldMoveRight() throws IOException { + openTestURL(); + + compareScreen("all-left"); + + clickButtonWithCaption("Shift label right"); + compareScreen("label-right"); + + clickButtonWithCaption("Shift button right"); + compareScreen("label-button-right"); + + clickButtonWithCaption("Shift text field right"); + compareScreen("label-button-textfield-right"); + } + + private void clickButtonWithCaption(String caption) { + $(ButtonElement.class).caption(caption).first().click(); + } + +} \ No newline at end of file -- cgit v1.2.3 From 7de2808b04dcf10628b7952251d834d38925dfa4 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Wed, 18 Jun 2014 11:28:14 +0300 Subject: Refactor CheckBoxRcpCountTest to be more stable. Change-Id: Icc1965e6bc23423d8af66ab91b80143d07b49483 --- .../components/checkbox/CheckBoxRpcCountTest.java | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java index c32051b593..9d6640eb6d 100644 --- a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java @@ -17,34 +17,47 @@ package com.vaadin.tests.components.checkbox; import static org.junit.Assert.assertEquals; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.LabelElement; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import com.vaadin.tests.tb3.MultiBrowserTest; +import org.openqa.selenium.support.ui.ExpectedCondition; public class CheckBoxRpcCountTest extends MultiBrowserTest { @Test - public void testNumberOfRpcCalls() { + public void numberOfRpcCallsIsEqualToClicks() { openTestURL(); - WebElement labelElem = driver.findElement(By - .cssSelector(".v-checkbox label")); - WebElement inputElem = driver.findElement(By - .cssSelector(".v-checkbox input")); - WebElement countElem = driver.findElement(By.id("count-label")); + CheckBoxElement checkBoxElement = $(CheckBoxElement.class).first(); + WebElement labelElem = checkBoxElement.findElement(By.tagName("label")); + WebElement inputElem = checkBoxElement.findElement(By.tagName("input")); + final WebElement countElem = $(LabelElement.class).id("count-label"); // Click on the actual checkbox. inputElem.click(); - assertEquals("1 RPC call(s) made.", countElem.getText()); + //Have to use waitUntil to make this test more stable. + waitUntilLabelIsUpdated(countElem, "1 RPC call(s) made."); // Click on the checkbox label. labelElem.click(); - assertEquals("2 RPC call(s) made.", countElem.getText()); + waitUntilLabelIsUpdated(countElem, "2 RPC call(s) made."); // Again on the label. labelElem.click(); - assertEquals("3 RPC call(s) made.", countElem.getText()); + waitUntilLabelIsUpdated(countElem, "3 RPC call(s) made."); + } + + private void waitUntilLabelIsUpdated(final WebElement countElem, final String expectedText) { + waitUntil(new ExpectedCondition() { + @Override + public Boolean apply(WebDriver input) { + return countElem.getText().equals(expectedText); + } + }, 5); } } -- cgit v1.2.3 From dd8cf12dde433198070f77d97d9220dd66a7e7d5 Mon Sep 17 00:00:00 2001 From: Dmitrii Rogozin Date: Tue, 17 Jun 2014 14:43:34 +0300 Subject: Bug fix menu navigation with space (#14041) Change-Id: I1466381b12a147fea90240420d3f6c05cd156a1b --- client/src/com/vaadin/client/Util.java | 19 ++++- client/src/com/vaadin/client/ui/VMenuBar.java | 84 +++++++++++++--------- .../menubar/SpaceMenuBarNavigationTest.java | 17 +++-- 3 files changed, 77 insertions(+), 43 deletions(-) (limited to 'uitest') diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index e031b37422..f12a02c64f 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -35,6 +35,7 @@ import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Touch; +import com.google.gwt.event.dom.client.KeyEvent; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; @@ -66,7 +67,23 @@ public class Util { }-*/; /** - * + * Helper method for a bug fix #14041. For mozilla getKeyCode return 0 for + * space bar (because space is considered as char). If return 0 use + * getCharCode. + * + * @param event + * @return return key code + */ + public static int getKeyCode(KeyEvent event) { + int keyCode = event.getNativeEvent().getKeyCode(); + if (keyCode == 0) { + keyCode = event.getNativeEvent().getCharCode(); + } + return keyCode; + } + + /** + * * Returns the topmost element of from given coordinates. * * TODO fix crossplat issues clientX vs pageX. See quircksmode. Not critical diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java index 11fda6222c..909b25f7fb 100644 --- a/client/src/com/vaadin/client/ui/VMenuBar.java +++ b/client/src/com/vaadin/client/ui/VMenuBar.java @@ -1,12 +1,12 @@ /* * 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 @@ -243,7 +243,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * This is called by the items in the menu and it communicates the * information to the server - * + * * @param clickedItemId * id of the item that was clicked */ @@ -280,7 +280,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Returns the containing element of the menu - * + * * @return */ @Override @@ -290,7 +290,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Add a new item to this menu - * + * * @param html * items text * @param cmd @@ -307,7 +307,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Add a new item to this menu - * + * * @param item */ public void addItem(CustomMenuItem item) { @@ -332,7 +332,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Remove the given item from this menu - * + * * @param item */ public void removeItem(CustomMenuItem item) { @@ -429,7 +429,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * When an item is clicked - * + * * @param item */ public void itemClick(CustomMenuItem item) { @@ -460,7 +460,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * When the user hovers the mouse over the item - * + * * @param item */ public void itemOver(CustomMenuItem item) { @@ -485,7 +485,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * When the mouse is moved away from an item - * + * * @param item */ public void itemOut(CustomMenuItem item) { @@ -543,7 +543,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Shows the child menu of an item. The caller must ensure that the item has * a submenu. - * + * * @param item */ public void showChildMenu(CustomMenuItem item) { @@ -665,7 +665,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Hides the submenu of an item - * + * * @param item */ public void hideChildMenu(CustomMenuItem item) { @@ -729,7 +729,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Returns the parent menu of this menu, or null if this is the top-level * menu - * + * * @return */ public VMenuBar getParentMenu() { @@ -738,7 +738,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Set the parent menu of this menu - * + * * @param parent */ public void setParentMenu(VMenuBar parent) { @@ -748,7 +748,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Returns the currently selected item of this menu, or null if nothing is * selected - * + * * @return */ public CustomMenuItem getSelected() { @@ -757,7 +757,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Set the currently selected item of this menu - * + * * @param item */ public void setSelected(CustomMenuItem item) { @@ -774,9 +774,9 @@ public class VMenuBar extends SimpleFocusablePanel implements } /** - * + * * A class to hold information on menu items - * + * */ public static class CustomMenuItem extends Widget implements HasHTML { @@ -795,7 +795,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Default menu item {@link Widget} constructor for GWT.create(). - * + * * Use {@link #setHTML(String)} and {@link #setCommand(Command)} after * constructing a menu item. */ @@ -805,7 +805,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Creates a menu item {@link Widget}. - * + * * @param html * @param cmd * @deprecated use the default constructor and {@link #setHTML(String)} @@ -1039,7 +1039,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Checks if the item can be selected. - * + * * @return true if it is possible to select this item, false otherwise */ public boolean isSelectable() { @@ -1157,7 +1157,14 @@ public class VMenuBar extends SimpleFocusablePanel implements */ @Override public void onKeyPress(KeyPressEvent event) { - if (handleNavigation(event.getNativeEvent().getKeyCode(), + // A bug fix for #14041 + // getKeyCode and getCharCode return different values for different + // browsers + int keyCode = event.getNativeEvent().getKeyCode(); + if (keyCode == 0) { + keyCode = event.getNativeEvent().getCharCode(); + } + if (handleNavigation(keyCode, event.isControlKeyDown() || event.isMetaKeyDown(), event.isShiftKeyDown())) { event.preventDefault(); @@ -1173,7 +1180,14 @@ public class VMenuBar extends SimpleFocusablePanel implements */ @Override public void onKeyDown(KeyDownEvent event) { - if (handleNavigation(event.getNativeEvent().getKeyCode(), + // A bug fix for #14041 + // getKeyCode and getCharCode return different values for different + // browsers + int keyCode = event.getNativeEvent().getKeyCode(); + if (keyCode == 0) { + keyCode = event.getNativeEvent().getCharCode(); + } + if (handleNavigation(keyCode, event.isControlKeyDown() || event.isMetaKeyDown(), event.isShiftKeyDown())) { event.preventDefault(); @@ -1184,7 +1198,7 @@ public class VMenuBar extends SimpleFocusablePanel implements * Get the key that moves the selection upwards. By default it is the up * arrow key but by overriding this you can change the key to whatever you * want. - * + * * @return The keycode of the key */ protected int getNavigationUpKey() { @@ -1195,7 +1209,7 @@ public class VMenuBar extends SimpleFocusablePanel implements * Get the key that moves the selection downwards. By default it is the down * arrow key but by overriding this you can change the key to whatever you * want. - * + * * @return The keycode of the key */ protected int getNavigationDownKey() { @@ -1206,7 +1220,7 @@ public class VMenuBar extends SimpleFocusablePanel implements * Get the key that moves the selection left. By default it is the left * arrow key but by overriding this you can change the key to whatever you * want. - * + * * @return The keycode of the key */ protected int getNavigationLeftKey() { @@ -1217,7 +1231,7 @@ public class VMenuBar extends SimpleFocusablePanel implements * Get the key that moves the selection right. By default it is the right * arrow key but by overriding this you can change the key to whatever you * want. - * + * * @return The keycode of the key */ protected int getNavigationRightKey() { @@ -1227,7 +1241,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Get the key that selects a menu item. By default it is the Enter key but * by overriding this you can change the key to whatever you want. - * + * * @deprecated use {@link #isNavigationSelectKey(int)} instead * @return */ @@ -1240,7 +1254,7 @@ public class VMenuBar extends SimpleFocusablePanel implements * Checks whether key code selects a menu item. By default it is the Enter * and Space keys but by overriding this you can change the keys to whatever * you want. - * + * * @since 7.2 * @param keycode * @return true if key selects menu item @@ -1253,7 +1267,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Get the key that closes the menu. By default it is the escape key but by * overriding this yoy can change the key to whatever you want. - * + * * @return */ protected int getCloseMenuKey() { @@ -1262,7 +1276,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Handles the keyboard events handled by the MenuBar - * + * * @param event * The keyboard event received * @return true iff the navigation event was handled @@ -1549,7 +1563,7 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Get menu item with given DOM element - * + * * @param element * Element used in search * @return Menu item or null if not found @@ -1578,11 +1592,11 @@ public class VMenuBar extends SimpleFocusablePanel implements /** * Get menu item with given DOM element - * + * * @param element * Element used in search * @return Menu item or null if not found - * + * * @since 7.2 */ public CustomMenuItem getMenuItemWithElement(Element element) { diff --git a/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java b/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java index 3e0053d0d1..a32a611d9a 100644 --- a/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java +++ b/uitest/src/com/vaadin/tests/components/menubar/SpaceMenuBarNavigationTest.java @@ -1,12 +1,12 @@ /* * 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 @@ -23,10 +23,11 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.MenuBarElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** - * + * * @since 7.2 * @author Vaadin Ltd */ @@ -36,19 +37,21 @@ public class SpaceMenuBarNavigationTest extends MultiBrowserTest { public void testEnableParentLayout() { openTestURL(); - WebElement menu = driver.findElement(By.className("menu-bar")); + MenuBarElement menu = $(MenuBarElement.class).get(0); + menu.focus(); menu.sendKeys(Keys.ARROW_RIGHT); - menu.sendKeys(Keys.SPACE); + menu.sendKeys(Keys.ENTER); List 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); + Assert.assertTrue("Sub menu is not opened on ENTER key", found); menu.sendKeys(Keys.SPACE); -- cgit v1.2.3 From 3e925629ae50281dcbf4af00b0bbe3cfa05164ae Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Fri, 13 Jun 2014 09:32:47 +0300 Subject: Convert MoveComponentsFromGridLayoutToInnerLayoutTest to TB4. (#8855) Change-Id: I90079bad38a82d8a7d3b053daedc99e52633e027 --- .../MoveComponentFromGridLayoutToInnerLayout.html | 37 ---------------------- .../MoveComponentsFromGridLayoutToInnerLayout.java | 14 ++++---- ...eComponentsFromGridLayoutToInnerLayoutTest.java | 22 +++++++++++++ 3 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentFromGridLayoutToInnerLayout.html create mode 100644 uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayoutTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentFromGridLayoutToInnerLayout.html b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentFromGridLayoutToInnerLayout.html deleted file mode 100644 index ed6d39f63d..0000000000 --- a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentFromGridLayoutToInnerLayout.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.gridlayout.MoveComponentsFromGridLayoutToInnerLayout?restartApplication
clickvaadin=runcomvaadintestscomponentsgridlayoutMoveComponentsFromGridLayoutToInnerLayout::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentsgridlayoutMoveComponentsFromGridLayoutToInnerLayout::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturebuttons-with-captions
- - diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java index 0106f2e218..4f5b29c91f 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayout.java @@ -1,20 +1,19 @@ package com.vaadin.tests.components.gridlayout; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; +import com.vaadin.ui.*; import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.ComponentContainer; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.VerticalLayout; -public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase { +public class MoveComponentsFromGridLayoutToInnerLayout extends AbstractTestUI { protected Button testButton; private GridLayout gl; protected ComponentContainer vl; @Override - protected void setup() { + protected void setup(VaadinRequest request) { gl = new GridLayout(); gl.setWidth("200px"); gl.setHeight("200px"); @@ -31,6 +30,7 @@ public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase { gl.addComponent(testButton); vl = new VerticalLayout(); + vl.addComponent(new Label("I'm inside the inner layout")); gl.addComponent(vl); addComponent(gl); @@ -48,7 +48,7 @@ public class MoveComponentsFromGridLayoutToInnerLayout extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Click the first button to move it from an outer layout to an inner. Then click the second button to repaint the inner layout."; } diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayoutTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayoutTest.java new file mode 100644 index 0000000000..eb4888ea1a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/MoveComponentsFromGridLayoutToInnerLayoutTest.java @@ -0,0 +1,22 @@ +package com.vaadin.tests.components.gridlayout; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.AbstractTB3Test; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.*; + +public class MoveComponentsFromGridLayoutToInnerLayoutTest extends MultiBrowserTest { + + @Test + public void buttonIsMovedInsideInnerLayout() throws IOException { + openTestURL(); + + $(ButtonElement.class).first().click(); + + compareScreen("buttonClicked"); + } +} \ No newline at end of file -- cgit v1.2.3 From 2da9b502f0b76020ca6bd094e5d53c77d1acd9fb Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Thu, 19 Jun 2014 09:12:59 +0300 Subject: Converted GridLayoutWidthChangeTest to TB4. (#8855) Change-Id: Ida4550689387c048c0eee95420851dc72620ad65 --- .../tests/layouts/GridLayoutWidthChange.html | 47 --------------- .../tests/layouts/GridLayoutWidthChange.java | 65 --------------------- .../layouts/gridlayout/GridLayoutWidthChange.java | 67 ++++++++++++++++++++++ .../gridlayout/GridLayoutWidthChangeTest.java | 24 ++++++++ 4 files changed, 91 insertions(+), 112 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.html delete mode 100644 uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java create mode 100644 uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java create mode 100644 uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChangeTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.html b/uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.html deleted file mode 100644 index f01a1a7026..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - -GridLayoutWidthChange - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GridLayoutWidthChange
open/run/com.vaadin.tests.layouts.GridLayoutWidthChange
waitForVaadin
screenCapture
clickvaadin=runcomvaadintestslayoutsGridLayoutWidthChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
waitForVaadin
screenCapture
- - diff --git a/uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java b/uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java deleted file mode 100644 index c0e6b27c7d..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/GridLayoutWidthChange.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.vaadin.tests.layouts; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.NativeButton; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; - -public class GridLayoutWidthChange extends TestBase { - - private GridLayout generateLayout() { - VerticalLayout fields1 = new VerticalLayout(); - - NativeButton nb = new NativeButton("A button"); - nb.setHeight("300px"); - fields1.addComponent(nb); - - VerticalLayout fields3 = new VerticalLayout(); - fields3.addComponent(new TextField("field14")); - - NativeButton b = new NativeButton("A big button"); - b.setWidth("200px"); - b.setHeight("200px"); - - GridLayout layout = new GridLayout(3, 2); - layout.setWidth("100%"); - layout.addComponent(fields1, 0, 0, 0, 1); - layout.addComponent(b, 2, 1); - - return layout; - } - - @Override - protected void setup() { - final GridLayout layout1 = generateLayout(); - final CustomComponent cc = new CustomComponent(layout1); - cc.setWidth("500px"); - addComponent(cc); - - Button testButton = new Button("Reduce GridLayout parent width", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - cc.setWidth((cc.getWidth() - 10) + "px"); - } - - }); - addComponent(testButton); - } - - @Override - protected String getDescription() { - return "A 100% wide GridLayout is wrapped inside a CustomComponent. When the width of the CustomComponent is reduced, the size of the GridLayout should be reduced accordingly. The Buttons should stay in place vertically and just move closer to each other horizontally."; - } - - @Override - protected Integer getTicketNumber() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java new file mode 100644 index 0000000000..96091bdab5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChange.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.layouts.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class GridLayoutWidthChange extends AbstractTestUI { + + private GridLayout generateLayout() { + VerticalLayout fields1 = new VerticalLayout(); + + NativeButton nb = new NativeButton("A button"); + nb.setHeight("300px"); + fields1.addComponent(nb); + + VerticalLayout fields3 = new VerticalLayout(); + fields3.addComponent(new TextField("field14")); + + NativeButton b = new NativeButton("A big button"); + b.setWidth("200px"); + b.setHeight("200px"); + + GridLayout layout = new GridLayout(3, 2); + layout.setWidth("100%"); + layout.addComponent(fields1, 0, 0, 0, 1); + layout.addComponent(b, 2, 1); + + return layout; + } + + @Override + protected void setup(VaadinRequest request) { + final GridLayout layout1 = generateLayout(); + final CustomComponent cc = new CustomComponent(layout1); + cc.setWidth("500px"); + addComponent(cc); + + Button testButton = new Button("Reduce GridLayout parent width", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + cc.setWidth((cc.getWidth() - 100) + "px"); + } + + }); + addComponent(testButton); + } + + @Override + protected String getTestDescription() { + return "A 100% wide GridLayout is wrapped inside a CustomComponent. When the width of the CustomComponent is reduced, the size of the GridLayout should be reduced accordingly. The Buttons should stay in place vertically and just move closer to each other horizontally."; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChangeTest.java b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChangeTest.java new file mode 100644 index 0000000000..52ea5f4f8e --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/gridlayout/GridLayoutWidthChangeTest.java @@ -0,0 +1,24 @@ +package com.vaadin.tests.layouts.gridlayout; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.AbstractTB3Test; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.*; + +public class GridLayoutWidthChangeTest extends MultiBrowserTest { + + @Test + public void layoutIsReduced() throws IOException { + openTestURL(); + + compareScreen("initial"); + + $(ButtonElement.class).caption("Reduce GridLayout parent width").first().click(); + + compareScreen("buttonMoved"); + } +} \ No newline at end of file -- cgit v1.2.3 From 6e109e4d73b7e3c09da3000a813904b52ea89991 Mon Sep 17 00:00:00 2001 From: Tomi Virkki Date: Wed, 9 Apr 2014 07:24:20 +0300 Subject: Update RichTextArea editor height on resize (#11320) Change-Id: I4d4d054c2e4f068aacd9b324350be4ee696cf3d3 --- client/src/com/vaadin/client/ui/VRichTextArea.java | 91 +--------------------- .../ui/richtextarea/RichTextAreaConnector.java | 27 ++++++- .../RichTextAreaRelativeHeightResize.java | 58 ++++++++++++++ .../RichTextAreaRelativeHeightResizeTest.java | 55 +++++++++++++ 4 files changed, 143 insertions(+), 88 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java create mode 100644 uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/VRichTextArea.java b/client/src/com/vaadin/client/ui/VRichTextArea.java index 52e3782f32..3f63f38067 100644 --- a/client/src/com/vaadin/client/ui/VRichTextArea.java +++ b/client/src/com/vaadin/client/ui/VRichTextArea.java @@ -21,10 +21,6 @@ import java.util.Map; import java.util.Map.Entry; import com.google.gwt.core.client.Scheduler; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.Style.Position; -import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; @@ -32,7 +28,6 @@ import com.google.gwt.event.dom.client.KeyPressEvent; import com.google.gwt.event.dom.client.KeyPressHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Command; -import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; @@ -43,7 +38,6 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ConnectorMap; -import com.vaadin.client.Util; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.richtextarea.VRichTextToolbar; @@ -73,7 +67,8 @@ public class VRichTextArea extends Composite implements Field, KeyPressHandler, /** For internal use only. May be removed or replaced in the future. */ public RichTextArea rta; - private VRichTextToolbar formatter; + /** For internal use only. May be removed or replaced in the future. */ + public VRichTextToolbar formatter; /** For internal use only. May be removed or replaced in the future. */ public HTML html = new HTML(); @@ -82,9 +77,6 @@ public class VRichTextArea extends Composite implements Field, KeyPressHandler, private boolean enabled = true; - private int extraHorizontalPixels = -1; - private int extraVerticalPixels = -1; - /** For internal use only. May be removed or replaced in the future. */ public int maxLength = -1; @@ -193,92 +185,17 @@ public class VRichTextArea extends Composite implements Field, KeyPressHandler, return readOnly; } - /** - * @return space used by components paddings and borders - */ - private int getExtraHorizontalPixels() { - if (extraHorizontalPixels < 0) { - detectExtraSizes(); - } - return extraHorizontalPixels; - } - - /** - * @return space used by components paddings and borders - */ - private int getExtraVerticalPixels() { - if (extraVerticalPixels < 0) { - detectExtraSizes(); - } - return extraVerticalPixels; - } - - /** - * Detects space used by components paddings and borders. - */ - private void detectExtraSizes() { - Element clone = Util.cloneNode(getElement(), false); - DOM.setElementAttribute(clone, "id", ""); - clone.getStyle().setVisibility(Visibility.HIDDEN); - clone.getStyle().setPosition(Position.ABSOLUTE); - // due FF3 bug set size to 10px and later subtract it from extra pixels - clone.getStyle().setWidth(10, Unit.PX); - clone.getStyle().setHeight(10, Unit.PX); - DOM.appendChild(DOM.getParent(getElement()), clone); - extraHorizontalPixels = DOM.getElementPropertyInt(clone, "offsetWidth") - 10; - extraVerticalPixels = DOM.getElementPropertyInt(clone, "offsetHeight") - 10; - - DOM.removeChild(DOM.getParent(getElement()), clone); - } - @Override public void setHeight(String height) { - if (height.endsWith("px")) { - float h = Float - .parseFloat(height.substring(0, height.length() - 2)); - h -= getExtraVerticalPixels(); - if (h < 0) { - h = 0; - } - - super.setHeight(h + "px"); - } else { - super.setHeight(height); - } - + super.setHeight(height); if (height == null || height.equals("")) { rta.setHeight(""); - } else { - /* - * The formatter height will be initially calculated wrong so we - * delay the height setting so the DOM has had time to stabilize. - */ - Scheduler.get().scheduleDeferred(new Command() { - @Override - public void execute() { - int editorHeight = getOffsetHeight() - - getExtraVerticalPixels() - - formatter.getOffsetHeight(); - if (editorHeight < 0) { - editorHeight = 0; - } - rta.setHeight(editorHeight + "px"); - } - }); } } @Override public void setWidth(String width) { - if (width.endsWith("px")) { - float w = Float.parseFloat(width.substring(0, width.length() - 2)); - w -= getExtraHorizontalPixels(); - if (w < 0) { - w = 0; - } - - super.setWidth(w + "px"); - } else if (width.equals("")) { + if (width.equals("")) { /* * IE cannot calculate the width of the 100% iframe correctly if * there is no width specified for the parent. In this case we would diff --git a/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java b/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java index 6b3bf84578..5fe637447e 100644 --- a/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java +++ b/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java @@ -23,6 +23,7 @@ import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.ShortcutActionHandler.BeforeShortcutActionListener; +import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.VRichTextArea; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.Connect.LoadStyle; @@ -31,7 +32,7 @@ import com.vaadin.ui.RichTextArea; @Connect(value = RichTextArea.class, loadStyle = LoadStyle.LAZY) public class RichTextAreaConnector extends AbstractFieldConnector implements - Paintable, BeforeShortcutActionListener { + Paintable, BeforeShortcutActionListener, SimpleManagedLayout { /* * Last value received from the server @@ -47,6 +48,15 @@ public class RichTextAreaConnector extends AbstractFieldConnector implements flush(); } }); + getLayoutManager().registerDependency(this, + getWidget().formatter.getElement()); + } + + @Override + public void onUnregister() { + super.onUnregister(); + getLayoutManager().unregisterDependency(this, + getWidget().formatter.getElement()); } @Override @@ -110,4 +120,19 @@ public class RichTextAreaConnector extends AbstractFieldConnector implements } } } + + @Override + public void layout() { + if (!isUndefinedHeight()) { + int rootElementInnerHeight = getLayoutManager().getInnerHeight( + getWidget().getElement()); + int formatterHeight = getLayoutManager().getOuterHeight( + getWidget().formatter.getElement()); + int editorHeight = rootElementInnerHeight - formatterHeight; + if (editorHeight < 0) { + editorHeight = 0; + } + getWidget().rta.setHeight(editorHeight + "px"); + } + } } diff --git a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java new file mode 100644 index 0000000000..870c6cb8cb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResize.java @@ -0,0 +1,58 @@ +/* + * 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.richtextarea; + +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.RichTextArea; +import com.vaadin.ui.VerticalLayout; + +public class RichTextAreaRelativeHeightResize extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final VerticalLayout layout = new VerticalLayout(); + layout.setSizeFull(); + layout.setHeight("300px"); + + RichTextArea richTextArea = new RichTextArea(); + richTextArea.setSizeFull(); + layout.addComponent(richTextArea); + + addComponent(layout); + addComponent(new Button("Increase height", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + layout.setHeight("400px"); + } + })); + + } + + @Override + protected String getTestDescription() { + return "Tests that a RichTextArea with dynamic height " + + "updates its editor elements height on resize"; + } + + @Override + protected Integer getTicketNumber() { + return 11320; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java new file mode 100644 index 0000000000..5c31ce4dc7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/richtextarea/RichTextAreaRelativeHeightResizeTest.java @@ -0,0 +1,55 @@ +/* + * 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.richtextarea; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class RichTextAreaRelativeHeightResizeTest extends MultiBrowserTest { + + @Test + public void testCenteredClosingAndPostLayout() { + openTestURL(); + + int originalHeight = driver + .findElement(By.cssSelector(".v-richtextarea")).getSize() + .getHeight(); + int originalEditorHeight = driver + .findElement(By.cssSelector(".v-richtextarea iframe")) + .getSize().getHeight(); + + // Increase the component height + driver.findElement(By.cssSelector(".v-button")).click(); + + int newHeight = driver.findElement(By.cssSelector(".v-richtextarea")) + .getSize().getHeight(); + int newEditorHeight = driver + .findElement(By.cssSelector(".v-richtextarea iframe")) + .getSize().getHeight(); + + // Check that the component height changed and that the editor height + // changed equally as much + Assert.assertTrue("RichTextArea height didn't change", + newHeight != originalHeight); + Assert.assertEquals( + "Editor height change didn't match the Component height change", + newHeight - originalHeight, newEditorHeight + - originalEditorHeight); + } +} -- cgit v1.2.3 From 7f769ec77d52aecbbf9d4787ab2e482d3b31a2af Mon Sep 17 00:00:00 2001 From: Juuso Valli Date: Wed, 18 Jun 2014 15:10:28 +0300 Subject: Fix regression with DnD tooltips (#7766) Change-Id: I74e6c35ef0aa30dbb24301bfb5858cedd0008e71 --- client/src/com/vaadin/client/TooltipInfo.java | 6 +- client/src/com/vaadin/client/VTooltip.java | 14 +-- .../DragAndDropWrapperTooltips.html | 53 -------- .../DragAndDropWrapperTooltips.java | 134 --------------------- .../tests/tooltip/DragAndDropWrapperTooltips.java | 134 +++++++++++++++++++++ .../tooltip/DragAndDropWrapperTooltipsTest.java | 44 +++++++ 6 files changed, 189 insertions(+), 196 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html delete mode 100644 uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltips.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltipsTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/TooltipInfo.java b/client/src/com/vaadin/client/TooltipInfo.java index 06940536c8..c1dd5037eb 100644 --- a/client/src/com/vaadin/client/TooltipInfo.java +++ b/client/src/com/vaadin/client/TooltipInfo.java @@ -15,6 +15,8 @@ */ package com.vaadin.client; +import com.vaadin.shared.util.SharedUtil; + public class TooltipInfo { private String title; @@ -79,7 +81,7 @@ public class TooltipInfo { } public boolean equals(TooltipInfo other) { - return (other != null && other.title == title - && other.errorMessageHtml == errorMessageHtml && other.identifier == identifier); + return (other != null && SharedUtil.equals(other.title, title) + && SharedUtil.equals(other.errorMessageHtml, errorMessageHtml) && other.identifier == identifier); } } diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 4db4477caa..d1a2c395f7 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -22,13 +22,13 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DomEvent; import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; import com.google.gwt.event.dom.client.MouseMoveEvent; import com.google.gwt.event.dom.client.MouseMoveHandler; import com.google.gwt.user.client.DOM; @@ -337,7 +337,7 @@ public class VTooltip extends VWindowOverlay { } private class TooltipEventHandler implements MouseMoveHandler, - ClickHandler, KeyDownHandler, FocusHandler, BlurHandler { + KeyDownHandler, FocusHandler, BlurHandler, MouseDownHandler { /** * Current element hovered @@ -403,7 +403,7 @@ public class VTooltip extends VWindowOverlay { } @Override - public void onClick(ClickEvent event) { + public void onMouseDown(MouseDownEvent event) { handleHideEvent(); } @@ -449,9 +449,9 @@ public class VTooltip extends VWindowOverlay { // TooltipInfo contains a reference to the parent component that is // checked in it's equals-method. if (currentElement != null && isTooltipOpen()) { - TooltipInfo currentTooltip = getTooltipFor(currentElement); TooltipInfo newTooltip = getTooltipFor(element); - if (currentTooltip != null && currentTooltip.equals(newTooltip)) { + if (currentTooltipInfo != null + && currentTooltipInfo.equals(newTooltip)) { return; } } @@ -498,7 +498,7 @@ public class VTooltip extends VWindowOverlay { public void connectHandlersToWidget(Widget widget) { Profiler.enter("VTooltip.connectHandlersToWidget"); widget.addDomHandler(tooltipEventHandler, MouseMoveEvent.getType()); - widget.addDomHandler(tooltipEventHandler, ClickEvent.getType()); + widget.addDomHandler(tooltipEventHandler, MouseDownEvent.getType()); widget.addDomHandler(tooltipEventHandler, KeyDownEvent.getType()); widget.addDomHandler(tooltipEventHandler, FocusEvent.getType()); widget.addDomHandler(tooltipEventHandler, BlurEvent.getType()); diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html deleted file mode 100644 index 3c91c8b24f..0000000000 --- a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.draganddropwrapper.DragAndDropWrapperTooltips?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper3/VLabel[0]0,0
screenCapturetooltip-initial
dragvaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper4/VLabel[0]30,41
dropvaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper24,42
showTooltipvaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperTooltips::PID_Swrapper1/VLabel[0]0,0
screenCapturetooltip-after-drag
- - diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.java deleted file mode 100644 index f0010acce8..0000000000 --- a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperTooltips.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.vaadin.tests.components.draganddropwrapper; - -import java.util.Iterator; - -import com.vaadin.event.Transferable; -import com.vaadin.event.TransferableImpl; -import com.vaadin.event.dd.DragAndDropEvent; -import com.vaadin.event.dd.DropHandler; -import com.vaadin.event.dd.DropTarget; -import com.vaadin.event.dd.TargetDetails; -import com.vaadin.event.dd.acceptcriteria.AcceptAll; -import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; -import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.TestUtils; -import com.vaadin.ui.Component; -import com.vaadin.ui.CssLayout; -import com.vaadin.ui.DragAndDropWrapper; -import com.vaadin.ui.Label; -import com.vaadin.ui.VerticalLayout; - -public class DragAndDropWrapperTooltips extends TestBase { - - private final String BASE = ".v-widget.greenblock {vertical-align: middle; float:left; width:60px;height:60px;background: green !important; padding:0; margin:2px;-webkit-transition: width 0.3s ease-in-out;color: white;}"; - private final String B2 = ".v-widget.b2 {background-color: red !important;}"; - private final String B3 = ".v-widget.b3 {background-color: yellow !important;color: black;}"; - private final String B4 = ".v-widget.b4 {background-color: blue !important;}"; - private final String HIDEDRAGSOURCE = ".v-active-drag-source { overflow:hidden; width:0px !important;}"; - private DragAndDropWrapper dragAndDropWrapper; - - @Override - protected void setup() { - TestUtils.injectCSS(getMainWindow(), BASE + B4 + B2 + B3 - + HIDEDRAGSOURCE); - - VerticalLayout l = new VerticalLayout(); - l.setWidth("400px"); - l.setHeight("100px"); - dragAndDropWrapper = new DragAndDropWrapper(cssLayout); - dragAndDropWrapper - .setDescription("Tooltip for the wrapper wrapping all the draggable layouts"); - dragAndDropWrapper.setSizeFull(); - l.addComponent(dragAndDropWrapper); - - addComponent(l); - - for (int i = 1; i <= 4; i++) { - WrappedLabel wl = new WrappedLabel("Block"); - wl.setId("wrapper" + i); - wl.addStyleName("b" + i); - cssLayout.addComponent(wl); - } - - } - - int count; - - private CssLayout cssLayout = new CssLayout() { - }; - - class WrappedLabel extends DragAndDropWrapper { - - private static final long serialVersionUID = 1L; - - public WrappedLabel(String content) { - super(new Label(content + " " + ++count)); - getCompositionRoot().setSizeUndefined(); - setHeight("60px"); // FIXME custom component seems to be broken: - // can't set height with css only - setWidth("60px"); - setDragStartMode(DragStartMode.WRAPPER); - addStyleName("greenblock"); - } - - @Override - public DropHandler getDropHandler() { - return dh; - } - - } - - private DropHandler dh = new DropHandler() { - - @Override - public AcceptCriterion getAcceptCriterion() { - return AcceptAll.get(); - } - - @Override - public void drop(DragAndDropEvent dropEvent) { - Transferable transferable = dropEvent.getTransferable(); - if (transferable instanceof TransferableImpl) { - TransferableImpl ct = (TransferableImpl) transferable; - Component sourceComponent = ct.getSourceComponent(); - if (sourceComponent instanceof WrappedLabel) { - int index = 1; - Iterator componentIterator = cssLayout - .getComponentIterator(); - Component next = componentIterator.next(); - TargetDetails dropTargetData = dropEvent.getTargetDetails(); - DropTarget target = dropTargetData.getTarget(); - while (next != target) { - if (next != sourceComponent) { - index++; - } - next = componentIterator.next(); - } - if (dropTargetData.getData("horizontalLocation").equals( - "LEFT")) { - index--; - if (index < 0) { - index = 0; - } - } - - cssLayout.removeComponent(sourceComponent); - cssLayout.addComponent(sourceComponent, index); - - dragAndDropWrapper - .setDescription("Drag was performed and tooltip was changed"); - } - } - } - }; - - @Override - protected String getDescription() { - return "A tooltip should be shown when hovering the DragAndDropWrapper containing all the draggable layouts"; - } - - @Override - protected Integer getTicketNumber() { - return 7708; - } -} diff --git a/uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltips.java b/uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltips.java new file mode 100644 index 0000000000..606a773141 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltips.java @@ -0,0 +1,134 @@ +package com.vaadin.tests.tooltip; + +import java.util.Iterator; + +import com.vaadin.event.Transferable; +import com.vaadin.event.TransferableImpl; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.DropTarget; +import com.vaadin.event.dd.TargetDetails; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.TestUtils; +import com.vaadin.ui.Component; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class DragAndDropWrapperTooltips extends AbstractTestUI { + + private final String BASE = ".v-widget.greenblock {vertical-align: middle; float:left; width:60px;height:60px;background: green !important; padding:0; margin:2px;-webkit-transition: width 0.3s ease-in-out;color: white;}"; + private final String B2 = ".v-widget.b2 {background-color: red !important;}"; + private final String B3 = ".v-widget.b3 {background-color: yellow !important;color: black;}"; + private final String B4 = ".v-widget.b4 {background-color: blue !important;}"; + private final String HIDEDRAGSOURCE = ".v-active-drag-source { overflow:hidden; width:0px !important;}"; + private DragAndDropWrapper dragAndDropWrapper; + + @Override + protected void setup(VaadinRequest request) { + TestUtils.injectCSS(this, BASE + B4 + B2 + B3 + HIDEDRAGSOURCE); + + VerticalLayout l = new VerticalLayout(); + l.setWidth("400px"); + l.setHeight("100px"); + dragAndDropWrapper = new DragAndDropWrapper(cssLayout); + dragAndDropWrapper + .setDescription("Tooltip for the wrapper wrapping all the draggable layouts"); + dragAndDropWrapper.setSizeFull(); + l.addComponent(dragAndDropWrapper); + + addComponent(l); + + for (int i = 1; i <= 4; i++) { + WrappedLabel wl = new WrappedLabel("Block"); + wl.setId("wrapper" + i); + wl.addStyleName("b" + i); + cssLayout.addComponent(wl); + } + getTooltipConfiguration().setOpenDelay(300); + } + + int count; + + private CssLayout cssLayout = new CssLayout() { + }; + + class WrappedLabel extends DragAndDropWrapper { + + private static final long serialVersionUID = 1L; + + public WrappedLabel(String content) { + super(new Label(content + " " + ++count)); + getCompositionRoot().setSizeUndefined(); + setHeight("60px"); // FIXME custom component seems to be broken: + // can't set height with css only + setWidth("60px"); + setDragStartMode(DragStartMode.WRAPPER); + addStyleName("greenblock"); + } + + @Override + public DropHandler getDropHandler() { + return dh; + } + + } + + private DropHandler dh = new DropHandler() { + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + @Override + public void drop(DragAndDropEvent dropEvent) { + Transferable transferable = dropEvent.getTransferable(); + if (transferable instanceof TransferableImpl) { + TransferableImpl ct = (TransferableImpl) transferable; + Component sourceComponent = ct.getSourceComponent(); + if (sourceComponent instanceof WrappedLabel) { + int index = 1; + Iterator componentIterator = cssLayout + .getComponentIterator(); + Component next = componentIterator.next(); + TargetDetails dropTargetData = dropEvent.getTargetDetails(); + DropTarget target = dropTargetData.getTarget(); + while (next != target) { + if (next != sourceComponent) { + index++; + } + next = componentIterator.next(); + } + if (dropTargetData.getData("horizontalLocation").equals( + "LEFT")) { + index--; + if (index < 0) { + index = 0; + } + } + + cssLayout.removeComponent(sourceComponent); + cssLayout.addComponent(sourceComponent, index); + + dragAndDropWrapper + .setDescription("Drag was performed and tooltip was changed"); + } + } + } + }; + + @Override + protected String getTestDescription() { + return "A tooltip should be shown when hovering the DragAndDropWrapper containing all the draggable layouts"; + } + + @Override + protected Integer getTicketNumber() { + return 7708; + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltipsTest.java b/uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltipsTest.java new file mode 100644 index 0000000000..d913c8cc12 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/DragAndDropWrapperTooltipsTest.java @@ -0,0 +1,44 @@ +/* + * 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.tooltip; + +import org.junit.Test; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.tests.tb3.TooltipTest; + +/** + * + * + * @author Vaadin Ltd + */ +public class DragAndDropWrapperTooltipsTest extends TooltipTest { + @Test + public void testDragAndDropTooltips() throws Exception { + openTestURL(); + LabelElement element = $(LabelElement.class).get(4); + LabelElement targetElement = $(LabelElement.class).get(1); + checkTooltip(element, + "Tooltip for the wrapper wrapping all the draggable layouts"); + new Actions(getDriver()).clickAndHold(element) + .moveToElement(targetElement).perform(); + sleep(500); + checkTooltipNotPresent(); + new Actions(getDriver()).release().perform(); + checkTooltip(element, "Drag was performed and tooltip was changed"); + } +} -- cgit v1.2.3 From 5fe5f05576c166600f6912345f4580b5d0bfa8a1 Mon Sep 17 00:00:00 2001 From: Sauli Tähkäpää Date: Thu, 19 Jun 2014 09:29:15 +0300 Subject: Refactor DateFieldReadOnlyTest to use a predefined locale with 24h time. Change-Id: I32011639b6e0dfdc36d6ede350db27af80549ac3 --- .../com/vaadin/tests/components/datefield/DateFieldReadOnly.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldReadOnly.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldReadOnly.java index 392dbaf9c6..304c978381 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldReadOnly.java +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldReadOnly.java @@ -3,16 +3,18 @@ package com.vaadin.tests.components.datefield; import java.util.Calendar; import java.util.Locale; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; 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.DateField; -public class DateFieldReadOnly extends TestBase { +public class DateFieldReadOnly extends AbstractTestUI { @Override - protected String getDescription() { + protected String getTestDescription() { return "A read-only DateField should not show the popup button and not be editable."; } @@ -22,7 +24,7 @@ public class DateFieldReadOnly extends TestBase { } @Override - protected void setup() { + protected void setup(VaadinRequest request) { final DateField timeField = new DateField("A read-only datefield"); timeField.setResolution(DateField.RESOLUTION_SEC); timeField.setDateFormat("HH:mm:ss"); @@ -30,6 +32,7 @@ public class DateFieldReadOnly extends TestBase { timeField.setIcon(null); timeField.setWidth("8em"); timeField.addStyleName("timeField"); + timeField.setLocale(new Locale("fi")); // Set date so that testing always has same time Calendar c = Calendar.getInstance(Locale.ENGLISH); -- cgit v1.2.3 From d2b0e97c9fb43c1cf84947b42a6de6d58b2368ca Mon Sep 17 00:00:00 2001 From: Juuso Valli Date: Fri, 13 Jun 2014 15:22:29 +0300 Subject: Upgrade tooltip tests from TB2 to TB4 (#14019) Change-Id: I57fcffc5e9fb463759639c95a6b47fe09bfa268f --- .../com/vaadin/tests/components/LongTooltip.html | 324 --------------------- .../com/vaadin/tests/components/LongTooltip.java | 49 ---- .../tests/components/button/ButtonTooltips.java | 40 --- .../tests/components/form/FormTooltipsTest.java | 7 +- .../tests/components/slider/SliderTooltip.html | 72 ----- .../tests/components/ui/TooltipConfiguration.java | 121 -------- .../components/ui/TooltipConfigurationTest.java | 106 ------- uitest/src/com/vaadin/tests/tb3/TooltipTest.java | 27 +- .../com/vaadin/tests/tooltip/ButtonTooltips.java | 34 +++ .../vaadin/tests/tooltip/ButtonTooltipsTest.java | 53 ++++ .../src/com/vaadin/tests/tooltip/LongTooltip.java | 52 ++++ .../com/vaadin/tests/tooltip/LongTooltipTest.java | 47 +++ .../com/vaadin/tests/tooltip/SliderTooltip.java | 42 +++ .../vaadin/tests/tooltip/SliderTooltipTest.java | 40 +++ .../vaadin/tests/tooltip/TooltipConfiguration.java | 121 ++++++++ .../tests/tooltip/TooltipConfigurationTest.java | 73 +++++ 16 files changed, 489 insertions(+), 719 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/LongTooltip.html delete mode 100644 uitest/src/com/vaadin/tests/components/LongTooltip.java delete mode 100644 uitest/src/com/vaadin/tests/components/button/ButtonTooltips.java delete mode 100644 uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html delete mode 100644 uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java delete mode 100644 uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/ButtonTooltips.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/LongTooltip.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/TooltipConfiguration.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/LongTooltip.html b/uitest/src/com/vaadin/tests/components/LongTooltip.html deleted file mode 100644 index a5055741f1..0000000000 --- a/uitest/src/com/vaadin/tests/components/LongTooltip.html +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-right-1
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-right-2
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-right-3
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-right-1
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-right-2
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-right-3
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-left-1
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-left-2
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-lower-left-3
open/run/com.vaadin.tests.components.LongTooltip?restartApplication
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-left-1
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]0,0
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-left-2
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]55,43
pause500
showTooltipvaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]100,20
waitForVisiblevaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
screenCapturetooltip-upper-left-3
- - diff --git a/uitest/src/com/vaadin/tests/components/LongTooltip.java b/uitest/src/com/vaadin/tests/components/LongTooltip.java deleted file mode 100644 index acb498bcee..0000000000 --- a/uitest/src/com/vaadin/tests/components/LongTooltip.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.vaadin.tests.components; - -import com.vaadin.tests.util.LoremIpsum; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.TextField; - -public class LongTooltip extends TestBase { - - @Override - public void setup() { - - GridLayout gl = new GridLayout(2, 2); - gl.setSizeFull(); - TextField f1 = createField(); - TextField f2 = createField(); - TextField f3 = createField(); - TextField f4 = createField(); - gl.addComponent(f1); - gl.addComponent(f2); - gl.addComponent(f3); - gl.addComponent(f4); - - gl.setComponentAlignment(f1, Alignment.TOP_LEFT); - gl.setComponentAlignment(f2, Alignment.TOP_RIGHT); - gl.setComponentAlignment(f3, Alignment.BOTTOM_LEFT); - gl.setComponentAlignment(f4, Alignment.BOTTOM_RIGHT); - - getLayout().setSizeFull(); - getLayout().addComponent(gl); - - } - - private TextField createField() { - final TextField field = new TextField(); - field.setDescription(LoremIpsum.get(1000)); - return field; - } - - @Override - protected String getDescription() { - return "For a given cursor position the tooltip should always appear with the same size in the same position. The tooltip should also always be completely on screen and not cause any scrollbars to appear."; - } - - @Override - protected Integer getTicketNumber() { - return 7100; - } -} diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonTooltips.java b/uitest/src/com/vaadin/tests/components/button/ButtonTooltips.java deleted file mode 100644 index fa639918aa..0000000000 --- a/uitest/src/com/vaadin/tests/components/button/ButtonTooltips.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.vaadin.tests.components.button; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Alignment; -import com.vaadin.ui.Button; -import com.vaadin.ui.VerticalLayout; - -public class ButtonTooltips extends TestBase { - - @Override - protected String getDescription() { - return "Button tooltip's size gets messed up if moving from one tooltip to another before a timer expires."; - } - - @Override - protected Integer getTicketNumber() { - return 8454; - } - - @Override - protected void setup() { - VerticalLayout vl = new VerticalLayout(); - Button button = new Button("One"); - button.setDescription("long descidescidescpription"); - Button button2 = new Button("Two"); - button2.setDescription("Another"); - Button button3 = new Button("One"); - button3.setDescription("long descidescidescpription"); - Button button4 = new Button("Two"); - button4.setDescription("Another"); - vl.addComponent(button); - vl.addComponent(button2); - vl.addComponent(button3); - vl.addComponent(button4); - vl.setComponentAlignment(button, Alignment.TOP_RIGHT); - vl.setComponentAlignment(button2, Alignment.TOP_RIGHT); - addComponent(vl); - - } -} diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java index df18d4082d..cb71fef3ef 100644 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java @@ -33,9 +33,7 @@ public class FormTooltipsTest extends TooltipTest { WebElement fieldElement = $(FormElement.class).first() .$(TextFieldElement.class).first(); checkTooltip(fieldElement, "Fields own tooltip"); - - moveToRoot(); - Thread.sleep(1000); + clearTooltip(); checkTooltipNotPresent(); // first name caption tooltip @@ -43,8 +41,7 @@ public class FormTooltipsTest extends TooltipTest { $(FormElement.class).first().findElement( By.className("v-caption")), "Fields own tooltip"); - moveToRoot(); - Thread.sleep(1000); + clearTooltip(); checkTooltipNotPresent(); // Form should not have a description tooltip diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html deleted file mode 100644 index 6014f557e7..0000000000 --- a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -SliderTooltip - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SliderTooltip
open/run/com.vaadin.tests.components.slider.SliderTest?debug&restartApplication
mouseClickvaadin=runcomvaadintestscomponentssliderSliderTest::PID_Smenu#item024,2
mouseClickvaadin=runcomvaadintestscomponentssliderSliderTest::Root/VOverlay[0]/VMenuBar[0]#item135,12
mouseClickvaadin=runcomvaadintestscomponentssliderSliderTest::Root/VOverlay[1]/VMenuBar[0]#item174,3
mouseClickvaadin=runcomvaadintestscomponentssliderSliderTest::Root/VOverlay[2]/VMenuBar[0]#item230,6
showTooltipvaadin=runcomvaadintestscomponentssliderSliderTest::PID_StestComponent/domChild[2]/domChild[0]0,0
waitForElementPresentvaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]
assertTextvaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]This is a semi-long text that might wrap.
mouseClickvaadin=runcomvaadintestscomponentssliderSliderTest::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]40,16
pause1000
assertElementPositionLeftvaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]-5000
- - diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java deleted file mode 100644 index eeea91b638..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.vaadin.tests.components.ui; - -import com.vaadin.data.Property; -import com.vaadin.data.Property.ValueChangeEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.tests.util.LoremIpsum; -import com.vaadin.ui.NativeButton; -import com.vaadin.ui.TextField; - -public class TooltipConfiguration extends AbstractTestUIWithLog { - - private TextField closeTimeout; - private TextField quickOpenTimeout; - private TextField maxWidth; - private TextField openDelay; - private TextField quickOpenDelay; - - @Override - protected void setup(VaadinRequest request) { - NativeButton componentWithShortTooltip = new NativeButton( - "Short tooltip"); - componentWithShortTooltip.setDescription("This is a short tooltip"); - componentWithShortTooltip.setId("shortTooltip"); - - NativeButton componentWithLongTooltip = new NativeButton("Long tooltip"); - componentWithLongTooltip.setId("longTooltip"); - componentWithLongTooltip.setDescription(LoremIpsum.get(5000)); - - closeTimeout = createIntegerTextField("Close timeout", - getState().tooltipConfiguration.closeTimeout); - closeTimeout.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (closeTimeout.getConvertedValue() != null) { - getTooltipConfiguration().setCloseTimeout( - (Integer) closeTimeout.getConvertedValue()); - } - } - }); - maxWidth = createIntegerTextField("Max width", - getState().tooltipConfiguration.maxWidth); - maxWidth.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (maxWidth.getConvertedValue() != null) { - getTooltipConfiguration().setMaxWidth( - (Integer) maxWidth.getConvertedValue()); - } - } - }); - openDelay = createIntegerTextField("Open delay", - getState().tooltipConfiguration.openDelay); - openDelay.addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (openDelay.getConvertedValue() != null) { - getTooltipConfiguration().setOpenDelay( - (Integer) openDelay.getConvertedValue()); - } - } - }); - - quickOpenDelay = createIntegerTextField("Quick open delay", - getState().tooltipConfiguration.quickOpenDelay); - quickOpenDelay - .addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (quickOpenDelay.getConvertedValue() != null) { - getTooltipConfiguration().setQuickOpenDelay( - (Integer) quickOpenDelay - .getConvertedValue()); - } - } - }); - - quickOpenTimeout = createIntegerTextField("Quick open timeout", - getState().tooltipConfiguration.quickOpenTimeout); - quickOpenTimeout - .addValueChangeListener(new Property.ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - if (quickOpenTimeout.getConvertedValue() != null) { - getTooltipConfiguration().setQuickOpenTimeout( - (Integer) quickOpenTimeout - .getConvertedValue()); - } - } - }); - - getLayout().addComponents(closeTimeout, openDelay, quickOpenDelay, - quickOpenTimeout, maxWidth); - - getLayout().addComponents(componentWithShortTooltip, - componentWithLongTooltip); - - } - - private TextField createIntegerTextField(String caption, int initialValue) { - TextField tf = new TextField(caption); - tf.setId(caption); - tf.setConverter(Integer.class); - tf.setImmediate(true); - tf.setConvertedValue(initialValue); - // makes TB3 tests simpler - no "null" added when clearing a field - tf.setNullRepresentation(""); - return tf; - } - - @Override - protected String getTestDescription() { - return "Tests that tooltip delays can be configured"; - } - - @Override - protected Integer getTicketNumber() { - return 8065; - } - -} diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java deleted file mode 100644 index f3e7554579..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java +++ /dev/null @@ -1,106 +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.components.ui; - -import java.util.NoSuchElementException; - -import org.junit.Assert; -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 TooltipConfigurationTest extends MultiBrowserTest { - - private org.openqa.selenium.By tooltipBy = By - .vaadin("Root/VTooltip[0]/FlowPanel[0]/domChild[1]"); - - @Test - public void testTooltipConfiguration() throws Exception { - openTestURL(); - - WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); - WebElement closeTimeout = vaadinElementById("Close timeout"); - WebElement shortTooltip = vaadinElementById("shortTooltip"); - WebElement longTooltip = vaadinElementById("longTooltip"); - WebElement maxWidth = vaadinElementById("Max width"); - - selectAndType(closeTimeout, "0"); - testBenchElement(shortTooltip).showTooltip(); - waitForElementToBePresent(tooltipBy); - Assert.assertEquals("This is a short tooltip", getTooltip().getText()); - - new Actions(getDriver()).moveToElement(uiRoot, 0, 0).click().perform(); - // uiRoot.click(); - checkTooltipNotPresent(); - - selectAndType(closeTimeout, "3000"); - moveMouseToTopLeft(uiRoot); - testBenchElement(shortTooltip).showTooltip(); - waitForElementToBePresent(tooltipBy); - WebElement tooltip2 = getTooltip(); - Assert.assertEquals("This is a short tooltip", tooltip2.getText()); - - uiRoot.click(); - // assert that tooltip is present - getTooltip(); - selectAndType(closeTimeout, "0"); - testBenchElement(longTooltip).showTooltip(); - waitForElementToBePresent(tooltipBy); - Assert.assertEquals(500, getTooltip().getSize().getWidth()); - - uiRoot.click(); - selectAndType(maxWidth, "100"); - moveMouseToTopLeft(uiRoot); - testBenchElement(longTooltip).showTooltip(); - Assert.assertEquals(100, getTooltip().getSize().getWidth()); - } - - private WebElement getTooltip() { - return getDriver().findElement(tooltipBy); - } - - private void checkTooltipNotPresent() { - try { - WebElement tooltip = getTooltip(); - if (!"".equals(tooltip.getText()) - || tooltip.getLocation().getX() > -999) { - Assert.fail("Found tooltip that shouldn't be visible: " - + tooltip.getText() + " at " + tooltip.getLocation()); - } - } catch (NoSuchElementException e) { - Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools"); - } - } - - private void selectAndType(WebElement element, String value) { - // select and replace text - element.clear(); - // if null representation not set as "", need to move cursor to end and - // remove text "null" - // element.sendKeys("" + Keys.BACK_SPACE + Keys.BACK_SPACE - // + Keys.BACK_SPACE + Keys.BACK_SPACE); - element.sendKeys(value + Keys.ENTER); - } - - private void moveMouseToTopLeft(WebElement element) { - new Actions(getDriver()).moveToElement(element, 0, 0).perform(); - } - -} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java index 86ac8c1f12..86ea44287a 100644 --- a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java +++ b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java @@ -16,11 +16,13 @@ package com.vaadin.tests.tb3; +import java.util.List; import java.util.NoSuchElementException; import org.junit.Assert; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.By; @@ -58,10 +60,20 @@ public abstract class TooltipTest extends MultiBrowserTest { } protected void checkTooltip(String value) throws Exception { + WebElement body = findElement(By.cssSelector("body")); WebElement tooltip = getTooltip(); Assert.assertEquals(value, tooltip.getText()); - Assert.assertTrue("Tooltip should be in viewport", tooltip + Assert.assertTrue("Tooltip overflowed to the left", tooltip .getLocation().getX() >= 0); + Assert.assertTrue("Tooltip overflowed up", + tooltip.getLocation().getY() >= 0); + Assert.assertTrue("Tooltip overflowed to the right", tooltip + .getLocation().getX() + tooltip.getSize().getWidth() < body + .getSize().getWidth()); + Assert.assertTrue("Tooltip overflowed down", tooltip.getLocation() + .getY() + tooltip.getSize().getHeight() < body.getSize() + .getHeight()); + } protected void moveToRoot() { @@ -88,7 +100,18 @@ public abstract class TooltipTest extends MultiBrowserTest { } protected void moveMouseToTopLeft(WebElement element) { - new Actions(getDriver()).moveToElement(element, 0, 0).perform(); + moveMouseTo(element, 0, 0); + } + + protected void moveMouseTo(WebElement element, int offsetX, int offsetY) { + new Actions(getDriver()).moveToElement(element, offsetX, offsetY) + .perform(); } + @Override + public List getBrowsersToTest() { + // TODO Once we figure out how to get mouse hovering work with the IE + // webdriver, exclude them from these tests (#13854) + return getBrowsersExcludingIE(); + } } diff --git a/uitest/src/com/vaadin/tests/tooltip/ButtonTooltips.java b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltips.java new file mode 100644 index 0000000000..d212a13058 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltips.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.VerticalLayout; + +public class ButtonTooltips extends TestBase { + + @Override + protected String getDescription() { + return "Button tooltip's size gets messed up if moving from one tooltip to another before a timer expires."; + } + + @Override + protected Integer getTicketNumber() { + return 8454; + } + + @Override + protected void setup() { + VerticalLayout vl = new VerticalLayout(); + Button button = new Button("One"); + button.setDescription("long descidescidescpription"); + Button button2 = new Button("Two"); + button2.setDescription("Another"); + vl.addComponent(button); + vl.addComponent(button2); + vl.setComponentAlignment(button, Alignment.TOP_RIGHT); + vl.setComponentAlignment(button2, Alignment.TOP_RIGHT); + addComponent(vl); + + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java new file mode 100644 index 0000000000..d64dd900a7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java @@ -0,0 +1,53 @@ +/* + * 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.tooltip; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.TooltipTest; + +/** + * Tests that tooltip sizes do not change when moving between adjacent elements + * + * @author Vaadin Ltd + */ +public class ButtonTooltipsTest extends TooltipTest { + + @Test + public void tooltipSizeWhenMovingBetweenElements() throws Exception { + openTestURL(); + + WebElement buttonOne = $(ButtonElement.class).caption("One").first(); + WebElement buttonTwo = $(ButtonElement.class).caption("Two").first(); + + checkTooltip(buttonOne, "long descidescidescpription"); + int originalWidth = getTooltipElement().getSize().getWidth(); + int originalHeight = getTooltipElement().getSize().getHeight(); + + clearTooltip(); + checkTooltip(buttonTwo, "Another"); + moveMouseTo(buttonOne, 5, 5); + sleep(100); + assertThat(getTooltipElement().getSize().getWidth(), is(originalWidth)); + assertThat(getTooltipElement().getSize().getHeight(), + is(originalHeight)); + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/LongTooltip.java b/uitest/src/com/vaadin/tests/tooltip/LongTooltip.java new file mode 100644 index 0000000000..0eee9d4976 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/LongTooltip.java @@ -0,0 +1,52 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.LoremIpsum; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.TextField; + +public class LongTooltip extends TestBase { + private int tooltipCount = 0; + + @Override + public void setup() { + + GridLayout gl = new GridLayout(2, 2); + gl.setSizeFull(); + TextField f1 = createField(); + TextField f2 = createField(); + TextField f3 = createField(); + TextField f4 = createField(); + gl.addComponent(f1); + gl.addComponent(f2); + gl.addComponent(f3); + gl.addComponent(f4); + + gl.setComponentAlignment(f1, Alignment.TOP_LEFT); + gl.setComponentAlignment(f2, Alignment.TOP_RIGHT); + gl.setComponentAlignment(f3, Alignment.BOTTOM_LEFT); + gl.setComponentAlignment(f4, Alignment.BOTTOM_RIGHT); + + getLayout().setSizeFull(); + getLayout().addComponent(gl); + + } + + private TextField createField() { + final TextField field = new TextField(); + field.setDescription("Tooltip " + Integer.toString(tooltipCount++) + + ": " + LoremIpsum.get(1000)); + return field; + } + + @Override + protected String getDescription() { + return "For a given cursor position the tooltip should always appear with the same size in the same position. The tooltip should also always be completely on screen and not cause any scrollbars to appear."; + } + + @Override + protected Integer getTicketNumber() { + return 7100; + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java new file mode 100644 index 0000000000..191ce6ffec --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java @@ -0,0 +1,47 @@ +/* + * 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.tooltip; + +import java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.TooltipTest; +import com.vaadin.tests.util.LoremIpsum; + +/** + * Test to see if long tooltips behave appropriately + * + * @author Vaadin Ltd + */ +public class LongTooltipTest extends TooltipTest { + + @Test + public void tooltipsDontOverflow() throws Exception { + openTestURL(); + List elements = $(TextFieldElement.class).all(); + checkTooltipNotPresent(); + int i = 0; + for (TextFieldElement element : elements) { + checkTooltip(element, "Tooltip " + Integer.toString(i++) + ": " + + LoremIpsum.get(1000)); + clearTooltip(); + checkTooltipNotPresent(); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java b/uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java new file mode 100644 index 0000000000..8cf7232fab --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Slider; + +public class SliderTooltip extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + Slider slider = new Slider(); + slider.setDescription("Tooltip"); + addComponent(slider); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Testing that sliders have tooltips."; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 14019; + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java new file mode 100644 index 0000000000..743b7c2ab5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java @@ -0,0 +1,40 @@ +/* + * 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.tooltip; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.SliderElement; +import com.vaadin.tests.tb3.TooltipTest; + +/** + * Test that sliders can have tooltips + * + * @author Vaadin Ltd + */ +public class SliderTooltipTest extends TooltipTest { + + @Test + public void sliderHasTooltip() throws Exception { + openTestURL(); + WebElement slider = $(SliderElement.class).first(); + checkTooltipNotPresent(); + checkTooltip(slider, "Tooltip"); + clearTooltip(); + checkTooltipNotPresent(); + } +} diff --git a/uitest/src/com/vaadin/tests/tooltip/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/tooltip/TooltipConfiguration.java new file mode 100644 index 0000000000..f67db4219f --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/TooltipConfiguration.java @@ -0,0 +1,121 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.util.LoremIpsum; +import com.vaadin.ui.NativeButton; +import com.vaadin.ui.TextField; + +public class TooltipConfiguration extends AbstractTestUIWithLog { + + private TextField closeTimeout; + private TextField quickOpenTimeout; + private TextField maxWidth; + private TextField openDelay; + private TextField quickOpenDelay; + + @Override + protected void setup(VaadinRequest request) { + NativeButton componentWithShortTooltip = new NativeButton( + "Short tooltip"); + componentWithShortTooltip.setDescription("This is a short tooltip"); + componentWithShortTooltip.setId("shortTooltip"); + + NativeButton componentWithLongTooltip = new NativeButton("Long tooltip"); + componentWithLongTooltip.setId("longTooltip"); + componentWithLongTooltip.setDescription(LoremIpsum.get(5000)); + + closeTimeout = createIntegerTextField("Close timeout", + getState().tooltipConfiguration.closeTimeout); + closeTimeout.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + if (closeTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setCloseTimeout( + (Integer) closeTimeout.getConvertedValue()); + } + } + }); + maxWidth = createIntegerTextField("Max width", + getState().tooltipConfiguration.maxWidth); + maxWidth.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + if (maxWidth.getConvertedValue() != null) { + getTooltipConfiguration().setMaxWidth( + (Integer) maxWidth.getConvertedValue()); + } + } + }); + openDelay = createIntegerTextField("Open delay", + getState().tooltipConfiguration.openDelay); + openDelay.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + if (openDelay.getConvertedValue() != null) { + getTooltipConfiguration().setOpenDelay( + (Integer) openDelay.getConvertedValue()); + } + } + }); + + quickOpenDelay = createIntegerTextField("Quick open delay", + getState().tooltipConfiguration.quickOpenDelay); + quickOpenDelay + .addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + if (quickOpenDelay.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenDelay( + (Integer) quickOpenDelay + .getConvertedValue()); + } + } + }); + + quickOpenTimeout = createIntegerTextField("Quick open timeout", + getState().tooltipConfiguration.quickOpenTimeout); + quickOpenTimeout + .addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + if (quickOpenTimeout.getConvertedValue() != null) { + getTooltipConfiguration().setQuickOpenTimeout( + (Integer) quickOpenTimeout + .getConvertedValue()); + } + } + }); + + getLayout().addComponents(closeTimeout, openDelay, quickOpenDelay, + quickOpenTimeout, maxWidth); + + getLayout().addComponents(componentWithShortTooltip, + componentWithLongTooltip); + + } + + private TextField createIntegerTextField(String caption, int initialValue) { + TextField tf = new TextField(caption); + tf.setId(caption); + tf.setConverter(Integer.class); + tf.setImmediate(true); + tf.setConvertedValue(initialValue); + // makes TB3 tests simpler - no "null" added when clearing a field + tf.setNullRepresentation(""); + return tf; + } + + @Override + protected String getTestDescription() { + return "Tests that tooltip delays can be configured"; + } + + @Override + protected Integer getTicketNumber() { + return 8065; + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java new file mode 100644 index 0000000000..8f84444400 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java @@ -0,0 +1,73 @@ +/* + * 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.tooltip; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.TooltipTest; + +public class TooltipConfigurationTest extends TooltipTest { + + @Test + public void testTooltipConfiguration() throws Exception { + openTestURL(); + + WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); + WebElement closeTimeout = vaadinElementById("Close timeout"); + WebElement shortTooltip = vaadinElementById("shortTooltip"); + WebElement longTooltip = vaadinElementById("longTooltip"); + WebElement maxWidth = vaadinElementById("Max width"); + + selectAndType(closeTimeout, "0"); + + checkTooltip(shortTooltip, "This is a short tooltip"); + + moveToRoot(); + + checkTooltipNotPresent(); + + selectAndType(closeTimeout, "3000"); + checkTooltip(shortTooltip, "This is a short tooltip"); + + moveToRoot(); + + // The tooltip should still be there despite being "cleared", as the + // timeout hasn't expired yet. + checkTooltip("This is a short tooltip"); + + // assert that tooltip is present + selectAndType(closeTimeout, "0"); + selectAndType(maxWidth, "100"); + + testBenchElement(longTooltip).showTooltip(); + assertThat(getDriver().findElement(By.className("popupContent")) + .getSize().getWidth(), is(100)); + } + + private void selectAndType(WebElement element, String value) { + // select and replace text + element.clear(); + // if null representation not set as "", need to move cursor to end and + // remove text "null" + element.sendKeys(value + Keys.ENTER); + } +} \ No newline at end of file -- cgit v1.2.3 From 32e9e4967612e99e001f70d9b9898ab8b17703f9 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 23 Apr 2014 21:29:54 +0300 Subject: Basic TestBench test for Upload Generates a file to upload locally and TestBench ensures this file is transferred automatically to the browser node using a FileDetector. Change-Id: Ia5b3a48306356c364d49da60b81f1d68f1593939 --- .../components/upload/TestFileUploadTest.java | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/upload/TestFileUploadTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/upload/TestFileUploadTest.java b/uitest/src/com/vaadin/tests/components/upload/TestFileUploadTest.java new file mode 100644 index 0000000000..1887427a72 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/TestFileUploadTest.java @@ -0,0 +1,128 @@ +/* + * 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.upload; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +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.internal.WrapsElement; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.LocalFileDetector; +import org.openqa.selenium.remote.RemoteWebElement; + +import com.vaadin.testbench.elements.UploadElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TestFileUploadTest extends MultiBrowserTest { + + @Override + public List getBrowsersToTest() { + // PhantomJS fails to upload files for unknown reasons + List b = super.getBrowsersToTest(); + b.remove(Browser.PHANTOMJS.getDesiredCapabilities()); + return b; + } + + @Test + public void testUploadAnyFile() throws Exception { + openTestURL(); + + File tempFile = createTempFile(); + fillPathToUploadInput(tempFile.getPath()); + + getSubmitButton().click(); + + String expected = String.format( + "1. Upload finished. Name: %s, Size: %s, md5: %s", + tempFile.getName(), getTempFileContents().length(), + md5(getTempFileContents())); + + String actual = getLogRow(0); + Assert.assertEquals("Upload log row does not match expected", expected, + actual); + } + + private String md5(String string) throws NoSuchAlgorithmException { + byte[] digest = MessageDigest.getInstance("MD5").digest( + string.getBytes()); + BigInteger bigInt = new BigInteger(1, digest); + String hashtext = bigInt.toString(16); + return hashtext; + } + + /** + * @return The generated temp file handle + * @throws IOException + */ + private File createTempFile() throws IOException { + File tempFile = File.createTempFile("TestFileUpload", ".txt"); + BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); + writer.write(getTempFileContents()); + writer.close(); + tempFile.deleteOnExit(); + return tempFile; + } + + private String getTempFileContents() { + return "This is a test file!\nRow 2\nRow3"; + } + + private void fillPathToUploadInput(String tempFileName) throws Exception { + // create a valid path in upload input element. Instead of selecting a + // file by some file browsing dialog, we use the local path directly. + WebElement input = getInput(); + setLocalFileDetector(input); + input.sendKeys(tempFileName); + } + + private WebElement getSubmitButton() { + UploadElement upload = $(UploadElement.class).first(); + WebElement submitButton = upload.findElement(By.className("v-button")); + return submitButton; + } + + private WebElement getInput() { + return getDriver().findElement(By.className("gwt-FileUpload")); + } + + private void setLocalFileDetector(WebElement element) throws Exception { + if (getClass().isAnnotationPresent(RunLocally.class)) { + return; + } + + if (element instanceof WrapsElement) { + element = ((WrapsElement) element).getWrappedElement(); + } + if (element instanceof RemoteWebElement) { + ((RemoteWebElement) element) + .setFileDetector(new LocalFileDetector()); + } else { + throw new IllegalArgumentException( + "Expected argument of type RemoteWebElement, received " + + element.getClass().getName()); + } + } +} -- cgit v1.2.3 From 0f38151da3e89a65e4403d8f53402906fe8dcc37 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 23 Apr 2014 23:44:19 +0300 Subject: Fix moving a single component inside a split panel (#11920) Change-Id: Ib9b3625e4104763143906eb1b7986ef7b3b80737 --- .../com/vaadin/client/ui/VAbstractSplitPanel.java | 8 +++ .../ui/splitpanel/AbstractSplitPanelConnector.java | 33 +++++++++++ .../splitpanel/SplitPanelMoveComponent.java | 64 ++++++++++++++++++++++ .../splitpanel/SplitPanelMoveComponentTest.java | 55 +++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java create mode 100644 uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java index 269db23366..6ee88d51dd 100644 --- a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java +++ b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java @@ -511,6 +511,10 @@ public class VAbstractSplitPanel extends ComplexPanel { firstChild = w; } + public Widget getFirstWidget() { + return firstChild; + } + /** For internal use only. May be removed or replaced in the future. */ public void setSecondWidget(Widget w) { if (secondChild == w) { @@ -525,6 +529,10 @@ public class VAbstractSplitPanel extends ComplexPanel { secondChild = w; } + public Widget getSecondWidget() { + return secondChild; + } + @Override public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { diff --git a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java index ce8b3c8fea..6bf03ad880 100644 --- a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -161,6 +161,35 @@ public abstract class AbstractSplitPanelConnector extends getLayoutManager().setNeedsLayout(this); getWidget().makeScrollable(); + + handleSingleComponentMove(); + } + + /** + * Handles the case when there is only one child component and that + * component is moved between first <-> second. This does not trigger a + * hierarchy change event as the list of children contains the same + * component in both cases. + */ + private void handleSingleComponentMove() { + if (getChildComponents().size() == 1) { + Widget stateFirstChild = null; + Widget stateSecondChild = null; + if (getState().firstChild != null) { + stateFirstChild = ((ComponentConnector) getState().firstChild) + .getWidget(); + } + if (getState().secondChild != null) { + stateSecondChild = ((ComponentConnector) getState().secondChild) + .getWidget(); + } + + if (stateFirstChild == getWidget().getSecondWidget() + || stateSecondChild == getWidget().getFirstWidget()) { + handleHierarchyChange(); + } + } + } @Override @@ -212,6 +241,10 @@ public abstract class AbstractSplitPanelConnector extends @Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { + handleHierarchyChange(); + } + + private void handleHierarchyChange() { /* * When the connector gets detached, the state isn't updated but there's * still a hierarchy change -> verify that the child from the state is diff --git a/uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java b/uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java new file mode 100644 index 0000000000..b788b568c2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponent.java @@ -0,0 +1,64 @@ +/* + * 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.splitpanel; + +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.HorizontalSplitPanel; + +public class SplitPanelMoveComponent extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final HorizontalSplitPanel split = new HorizontalSplitPanel(); + split.setHeight("200px"); + final Button targetComponent = new Button( + "Button in splitpanel. Click to move to the other side"); + split.setFirstComponent(targetComponent); + + targetComponent.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (split.getFirstComponent() != null) { + split.setFirstComponent(null); + split.setSecondComponent(targetComponent); + } else { + split.setSecondComponent(null); + split.setFirstComponent(targetComponent); + + } + } + + }); + + addComponent(split); + } + + @Override + protected String getTestDescription() { + return "Fail to swap components in HorizontalSplitPanel"; + } + + @Override + protected Integer getTicketNumber() { + return 11920; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java b/uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.java new file mode 100644 index 0000000000..1bf5212185 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/splitpanel/SplitPanelMoveComponentTest.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.splitpanel; + +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 SplitPanelMoveComponentTest extends MultiBrowserTest { + + private static final String BUTTON_TEXT = "Button in splitpanel. Click to move to the other side"; + + @Test + public void moveComponent() { + openTestURL(); + Assert.assertEquals(BUTTON_TEXT, getFirstChild().getText()); + getFirstChild().click(); + Assert.assertEquals(BUTTON_TEXT, getSecondChild().getText()); + getSecondChild().click(); + Assert.assertEquals(BUTTON_TEXT, getFirstChild().getText()); + } + + private WebElement getFirstChild() { + WebElement container = getDriver() + .findElement( + By.xpath("//div[contains(@class,'v-splitpanel-first-container')]")); + return container.findElement(By + .xpath("//div[contains(@class, 'v-button')]")); + } + + private WebElement getSecondChild() { + WebElement container = getDriver() + .findElement( + By.xpath("//div[contains(@class,'v-splitpanel-second-container')]")); + return container.findElement(By + .xpath("//div[contains(@class, 'v-button')]")); + } + +} -- cgit v1.2.3 From f846f8d699ad6f599d91f7f86aa419be9b22b5a8 Mon Sep 17 00:00:00 2001 From: Anthony Guerreiro Date: Mon, 23 Jun 2014 14:13:37 +0300 Subject: Fix wrong width on event resize in Vaadin Calendar (#13961) Change-Id: I68775af42c1c6086d347bea81e54bbe3cf7e5a22 --- .../ui/calendar/schedule/DateCellDayEvent.java | 1 + .../calendar/CalendarResizeOverlappingEvents.java | 103 ++++++++++++++ .../CalendarResizeOverlappingEventsTest.java | 153 +++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java index bbbd355a32..3b168b636c 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java @@ -298,6 +298,7 @@ public class DateCellDayEvent extends FocusableHTML implements weekGrid.getCalendar().getEventResizeListener() .eventResized(calendarEvent); } + dateCell.recalculateEventWidths(); } } diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java new file mode 100644 index 0000000000..2025ce2ea7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java @@ -0,0 +1,103 @@ +/* + * 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.calendar; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider; + +/** + * + * @author Vaadin Ltd + */ +public class CalendarResizeOverlappingEvents extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + Calendar calendar = new Calendar(new CalendarEventProvider() { + + @Override + public List getEvents(Date startDate, Date endDate) { + DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd"); + List events = new ArrayList(); + try { + java.util.Calendar today = java.util.Calendar.getInstance(); + + String todayString = dayFormat.format(today.getTime()); + + Date date1 = format.parse(todayString + " 09:00:00"); + Date date2 = format.parse(todayString + " 11:00:00"); + Date date3 = format.parse(todayString + " 12:00:00"); + Date date4 = format.parse(todayString + " 14:00:00"); + Date date5 = format.parse(todayString + " 15:00:00"); + Date date6 = format.parse(todayString + " 17:00:00"); + + CalendarEvent event1 = new BasicEvent("First", "", date1, + date2); + CalendarEvent event2 = new BasicEvent("Second", "", date3, + date4); + CalendarEvent event3 = new BasicEvent("Third", "", date5, + date6); + + events.add(event1); + events.add(event2); + events.add(event3); + } catch (ParseException e) { + } + return events; + } + }); + calendar.setSizeFull(); + setContent(calendar); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Verify the widths of the events are correctly recalculated when these are resized and overlapped"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 13961; + } +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java new file mode 100644 index 0000000000..f664149cce --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java @@ -0,0 +1,153 @@ +/* + * 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.calendar; + +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +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.interactions.Actions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @author Vaadin Ltd + */ +public class CalendarResizeOverlappingEventsTest extends MultiBrowserTest { + + private int noOverlapWidth; + private int oneOverlapWidth; + private int twoOverlapsWidth; + + private WebElement firstEvent; + private WebElement secondEvent; + private WebElement thirdEvent; + + private WebElement firstEventBottomResize; + private WebElement secondEventBottomResize; + private WebElement thirdEventBottomResize; + + @Test + public void testCalendarResizeOverlappingEvents() + throws InterruptedException, IOException { + + openTestURL(); + initParams(); + doTest(); + } + + private void doTest() { + assertWidths(noOverlapWidth, noOverlapWidth, noOverlapWidth); + + dragAndDrop(firstEventBottomResize, 240); + assertWidths(oneOverlapWidth, oneOverlapWidth, oneOverlapWidth); + + dragAndDrop(secondEventBottomResize, 240); + assertWidths(twoOverlapsWidth, twoOverlapsWidth, twoOverlapsWidth); + + dragAndDrop(secondEventBottomResize, -240); + dragAndDrop(firstEventBottomResize, -240); + assertWidths(noOverlapWidth, noOverlapWidth, noOverlapWidth); + + } + + private void assertWidths(int firstEventExpectedWidth, + int secondEventExpectedWidth, int thirdEventExpectedWidth) { + int widthTolerance = 5; + String errorMessage = "Wrong event width after resizing, expected [%d] (+/-%d), obtained [%d]"; + + int actualWidth = firstEvent.getSize().getWidth(); + int expectedWidth = firstEventExpectedWidth; + Assert.assertTrue(String.format(errorMessage, expectedWidth, + widthTolerance, actualWidth), + isAproximateWidth(actualWidth, expectedWidth, widthTolerance)); + + actualWidth = secondEvent.getSize().getWidth(); + expectedWidth = secondEventExpectedWidth; + Assert.assertTrue(String.format(errorMessage, expectedWidth, + widthTolerance, actualWidth), + isAproximateWidth(actualWidth, expectedWidth, widthTolerance)); + + actualWidth = thirdEvent.getSize().getWidth(); + expectedWidth = thirdEventExpectedWidth; + Assert.assertTrue(String.format(errorMessage, expectedWidth, + widthTolerance, actualWidth), + isAproximateWidth(actualWidth, expectedWidth, widthTolerance)); + } + + private boolean isAproximateWidth(int actualWidth, int expectedWidth, + int tolerance) { + return Math.abs(expectedWidth - actualWidth) <= tolerance; + } + + private void dragAndDrop(WebElement element, int yOffset) { + /* + * Selenium doesn't properly drag and drop items in IE8. It tries to + * start dragging an element from a position above the element itself. + */ + if (BrowserUtil.isIE8(getDesiredCapabilities())) { + Actions action = new Actions(getDriver()); + action.moveToElement(element); + action.moveByOffset(0, 1); + action.clickAndHold(); + action.moveByOffset(0, yOffset); + action.release(); + action.build().perform(); + } else { + Actions action = new Actions(getDriver()); + action.dragAndDropBy(element, 0, yOffset); + action.build().perform(); + } + } + + private void initParams() { + WebElement dateSlot = getDriver().findElement( + By.className("v-datecellslot")); + int dateSlotWidth = dateSlot.getSize().getWidth(); + noOverlapWidth = dateSlotWidth; + oneOverlapWidth = dateSlotWidth / 2; + twoOverlapsWidth = dateSlotWidth / 3; + + Comparator startTimeComparator = new Comparator() { + @Override + public int compare(WebElement e1, WebElement e2) { + int e1Top = e1.getLocation().getY(); + int e2Top = e2.getLocation().getY(); + return e1Top - e2Top; + } + }; + + List eventElements = getDriver().findElements( + By.className("v-calendar-event-content")); + Collections.sort(eventElements, startTimeComparator); + firstEvent = eventElements.get(0); + secondEvent = eventElements.get(1); + thirdEvent = eventElements.get(2); + + List resizeBottomElements = getDriver().findElements( + By.className("v-calendar-event-resizebottom")); + Collections.sort(resizeBottomElements, startTimeComparator); + firstEventBottomResize = resizeBottomElements.get(0); + secondEventBottomResize = resizeBottomElements.get(1); + thirdEventBottomResize = resizeBottomElements.get(2); + } +} -- cgit v1.2.3 From 0ff4e15b96b91becdd6c8e38ad20d8272c5455b7 Mon Sep 17 00:00:00 2001 From: Dmitrii Rogozin Date: Wed, 18 Jun 2014 11:37:54 +0300 Subject: Fix problem with IntegerValidator test (#14046) Change-Id: Iaff310ccd2f25ca2d9a4a1043403a3aa1bde2e1a --- .../tests/fieldgroup/IntegerRangeValidator.html | 95 ---------------------- .../tests/tooltip/ValidatorCaptionTooltip.java | 62 ++++++++++++++ .../tests/tooltip/ValidatorCaptionTooltipTest.java | 46 +++++++++++ 3 files changed, 108 insertions(+), 95 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html create mode 100644 uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java create mode 100644 uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html b/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html deleted file mode 100644 index 48d48ede80..0000000000 --- a/uitest/src/com/vaadin/tests/fieldgroup/IntegerRangeValidator.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - -IntegerRangeValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IntegerRangeValidator
open/run/com.vaadin.tests.fieldgroup.BasicPersonForm?restartApplication
mouseClickvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]64,20
enterCharactervaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]64123
showTooltipvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]
waitForElementPresentvaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]
assertTextvaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]Must be between 0 and 150, 64123 is not
assertCSSClassvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]v-errorindicator
showTooltipvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]
enterCharactervaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]10
assertElementNotPresentvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]v-errorindicator
mouseClickvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]69,11
enterCharactervaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VTextField[0]-1
assertCSSClassvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[5]/domChild[0]/domChild[1]v-errorindicator
showTooltipvaadin=runcomvaadintestsfieldgroupBasicPersonForm::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VTextField[0]
assertTextvaadin=runcomvaadintestsfieldgroupBasicPersonForm::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]Must be between 0 and 150, -1 is not
- - diff --git a/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java new file mode 100644 index 0000000000..20dc514c10 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltip.java @@ -0,0 +1,62 @@ +/* + * 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.tooltip; + +import com.vaadin.data.validator.IntegerRangeValidator; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TextField; + +/** + * + * UI test class for Tooltip with integer range validator. + */ +public class ValidatorCaptionTooltip extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TextField fieldWithError = new TextField(); + int min = 0; + int max = 100; + String errorMessage = "Valid value is between " + min + " and " + max + + ". {0} is not."; + IntegerRangeValidator validator = new IntegerRangeValidator( + errorMessage, min, max); + fieldWithError.setValue("142"); + + fieldWithError.addValidator(validator); + fieldWithError.setConverter(Integer.class); + fieldWithError.setImmediate(true); + + TextField fieldWithoutError = new TextField(); + fieldWithoutError.addValidator(validator); + fieldWithoutError.setConverter(Integer.class); + fieldWithoutError.setValue("42"); + addComponent(fieldWithError); + addComponent(fieldWithoutError); + } + + @Override + protected String getTestDescription() { + return "Valid value is from 0 to 100.When the value is not valid. An error tooltip should appear"; + } + + @Override + protected Integer getTicketNumber() { + return 14046; + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java new file mode 100644 index 0000000000..9603b1df36 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ValidatorCaptionTooltipTest.java @@ -0,0 +1,46 @@ +/* + * 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.tooltip; + +import org.junit.Test; + +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.TooltipTest; + +/** + * Test to see if validators create error tooltips correctly. + * + * @author Vaadin Ltd + */ +public class ValidatorCaptionTooltipTest extends TooltipTest { + @Test + public void validatorWithError() throws Exception { + openTestURL(); + + TextFieldElement field = $(TextFieldElement.class).get(0); + String fieldValue = field.getAttribute("value"); + String expected = "Valid value is between 0 and 100. " + fieldValue + + " is not."; + checkTooltip(field, expected); + } + + @Test + public void validatorWithoutError() throws Exception { + openTestURL(); + TextFieldElement field = $(TextFieldElement.class).get(1); + checkTooltip(field, null); + } +} -- cgit v1.2.3