diff options
author | Henri Sara <hesara@vaadin.com> | 2015-07-01 16:18:42 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-07-08 10:59:39 +0300 |
commit | de2ba005c775d3c5c79491f2890cb457456c0de1 (patch) | |
tree | 5ba655c044aed6b2bfca30c29d505546c0fa7911 /uitest/src | |
parent | 1784f12ee888cefad2c964e2f758841460ef75c6 (diff) | |
download | vaadin-framework-de2ba005c775d3c5c79491f2890cb457456c0de1.tar.gz vaadin-framework-de2ba005c775d3c5c79491f2890cb457456c0de1.zip |
Migrate ComboBoxNoTextInput test from TB2 to TB4
Change-Id: I3c2e5022639da785ab76eb8cf12b979195b76ff3
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInput.java | 46 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java | 61 |
2 files changed, 107 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInput.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInput.java new file mode 100644 index 0000000000..6b0e42666f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInput.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.components.combobox; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.CheckBox; + +public class ComboBoxNoTextInput extends ComboBoxSelecting { + + @Override + protected void setup(VaadinRequest request) { + super.setup(request); + comboBox.setTextInputAllowed(true); + + final CheckBox textInputCheckBox = new CheckBox("Text Input", true); + textInputCheckBox.setId("textInput"); + textInputCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + comboBox.setTextInputAllowed(textInputCheckBox.getValue()); + } + }); + addComponent(textInputCheckBox); + } + + @Override + protected String getTestDescription() { + return "ComboBox should open popup on click when text input is not allowed."; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.java new file mode 100644 index 0000000000..cb4cd54559 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxNoTextInputTest.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.combobox; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ComboBoxNoTextInputTest extends MultiBrowserTest { + + @Test + public void testComboBoxNoTextInputPopupOpensOnClick() throws Exception { + openTestURL(); + + // deactivate text input + click($(CheckBoxElement.class).id("textInput")); + + // click and check that popup appears + ComboBoxElement cb = $(ComboBoxElement.class).first(); + click(cb); + // popup is opened lazily + waitForElementPresent(By.vaadin("//com.vaadin.ui.ComboBox[0]#popup")); + } + + @Test + public void testComboBoxWithTextInputNoPopupOpensOnClick() throws Exception { + openTestURL(); + + // click and check that no popup appears + ComboBoxElement cb = $(ComboBoxElement.class).first(); + click(cb); + // popup is opened lazily + sleep(1000); + Assert.assertFalse(cb.isElementPresent(By.vaadin("#popup"))); + } + + private void click(ComboBoxElement cb) throws Exception { + WebElement element = cb.findElement(By.vaadin("#textbox")); + ((TestBenchElementCommands) element).click(8, 7); + } + +} |