diff options
author | Guillermo Alvarez <guillermo@vaadin.com> | 2014-09-29 10:50:18 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-10-01 08:58:27 +0000 |
commit | 95281da32ea2371abdddb71d7d39d0857dfeeac9 (patch) | |
tree | b48afa41a5a6c1b6867a6548dc9d543504066d7b /uitest/src/com/vaadin/tests/components/tree | |
parent | 686c2ee15bc02bec6cff0d65990fd5c01a71e144 (diff) | |
download | vaadin-framework-95281da32ea2371abdddb71d7d39d0857dfeeac9.tar.gz vaadin-framework-95281da32ea2371abdddb71d7d39d0857dfeeac9.zip |
TreeItem double click fixed (#14745)
The event wasn't sent immediately and was sometimes
overwritten by following click event.
Change-Id: I7d52030ee8aac2be11b3b3db207d1c7f187d4778
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/tree')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java | 61 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java | 65 |
2 files changed, 126 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java new file mode 100644 index 0000000000..8b7890e63c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClick.java @@ -0,0 +1,61 @@ +package com.vaadin.tests.components.tree; + +import com.vaadin.event.ItemClickEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Tree; + +public class TreeItemDoubleClick extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + final Tree tree = new Tree("Immediate With ItemClickListener"); + tree.setImmediate(true); + tree.setNullSelectionAllowed(false); + + for (int i = 1; i < 6; i++) { + tree.addItem("Tree Item " + i); + } + + ItemClickEvent.ItemClickListener listener = new ItemClickEvent.ItemClickListener() { + @Override + public void itemClick(ItemClickEvent event) { + if (event.isDoubleClick()) { + log.log("Double Click " + event.getItemId()); + } + } + }; + + tree.addItemClickListener(listener); + + addComponent(tree); + + Button button = new Button("Change immediate flag"); + button.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + // this wouldn't work if tree had a value change listener + tree.setImmediate(!tree.isImmediate()); + log.log("tree.isImmediate() is now " + tree.isImmediate()); + } + + }); + + addComponent(button); + + } + + @Override + protected String getTestDescription() { + return "Tests that double click is fired"; + } + + @Override + protected Integer getTicketNumber() { + return 14745; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java new file mode 100644 index 0000000000..95a3f02d60 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java @@ -0,0 +1,65 @@ +/* + * 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.tree; + +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TreeItemDoubleClickTest extends MultiBrowserTest { + + @Test + public void test() throws InterruptedException { + openTestURL(); + String caption = "Tree Item 2"; + doubleClick(getTreeNodeByCaption(caption)); + assertLogText("Double Click " + caption); + + changeImmediate(); + + caption = "Tree Item 3"; + doubleClick(getTreeNodeByCaption(caption)); + assertLogText("Double Click " + caption); + } + + private void changeImmediate() { + $(ButtonElement.class).caption("Change immediate flag").first().click(); + assertLogText("tree.isImmediate() is now"); + } + + private WebElement getTreeNodeByCaption(String caption) { + return getDriver().findElement( + By.xpath("//span[text() = '" + caption + "']")); + } + + private void doubleClick(WebElement element) { + new Actions(getDriver()).doubleClick(element).build().perform(); + + } + + private void assertLogText(String text) { + assertThat( + String.format("Couldn't find text '%s' from the log.", text), + logContainsText(text)); + } + +} |