diff options
author | Artur Signell <artur@vaadin.com> | 2016-01-17 16:56:33 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-01-22 09:34:34 +0000 |
commit | 610736d9f373d4b37fd39ff8f90aabd13eab7926 (patch) | |
tree | f185b3c0e3b4fdfea95af8d6dbd54cecd453b4f5 /uitest/src/com/vaadin | |
parent | 1099c1eddd3477b50bcd3e5bab585109db25d5ca (diff) | |
download | vaadin-framework-610736d9f373d4b37fd39ff8f90aabd13eab7926.tar.gz vaadin-framework-610736d9f373d4b37fd39ff8f90aabd13eab7926.zip |
Make Checkbox label send context click events also (#19456)
Change-Id: Ic23a84357e1d0d333905ce6b3931c41ee90148f6
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClick.java | 38 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java | 54 |
2 files changed, 92 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClick.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClick.java new file mode 100644 index 0000000000..9b37db10b1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClick.java @@ -0,0 +1,38 @@ +/* + * 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.event.ContextClickEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.CheckBox; + +public class CheckboxContextClick extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + final CheckBox cb = new CheckBox("Right-click me", true); + cb.addContextClickListener(new ContextClickEvent.ContextClickListener() { + @Override + public void contextClick(ContextClickEvent event) { + log("checkbox context clicked"); + } + }); + + addComponent(cb); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java new file mode 100644 index 0000000000..1903687527 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckboxContextClickTest.java @@ -0,0 +1,54 @@ +/* + * 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 java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class CheckboxContextClickTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return getBrowsersSupportingContextMenu(); + } + + @Test + public void contextClickCheckboxAndText() { + openTestURL(); + CheckBoxElement checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("checked", checkbox.getValue()); + WebElement input = checkbox.findElement(By.xpath("input")); + WebElement label = checkbox.findElement(By.xpath("label")); + + new Actions(getDriver()).contextClick(input).perform(); + Assert.assertEquals("1. checkbox context clicked", getLogRow(0)); + Assert.assertEquals("checked", checkbox.getValue()); + + new Actions(getDriver()).contextClick(label).perform(); + Assert.assertEquals("2. checkbox context clicked", getLogRow(0)); + Assert.assertEquals("checked", checkbox.getValue()); + } + +} |