diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-06-19 13:32:08 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-07-21 14:40:50 +0300 |
commit | 2c5305b1eb0bcde09edc92f622f86978bdbdc0a9 (patch) | |
tree | 54d4da6f57a83be586b4ce36787c362e26e31965 /uitest | |
parent | 6faf90dcece4efdeb0bb97a3f320cc2dbe7fbbda (diff) | |
download | vaadin-framework-2c5305b1eb0bcde09edc92f622f86978bdbdc0a9.tar.gz vaadin-framework-2c5305b1eb0bcde09edc92f622f86978bdbdc0a9.zip |
Update connector hierarch when canceling editor (#16976).
Change-Id: I6e398952f84620955f9f1d61ef5ee90f81e28007
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java | 91 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java | 72 |
2 files changed, 163 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java new file mode 100644 index 0000000000..e6aff73532 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java @@ -0,0 +1,91 @@ +/* + * 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.grid; + +import java.io.Serializable; + +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; + +public class GridCheckBoxDisplay extends AbstractTestUI { + + private static final long serialVersionUID = -5575892909354637168L; + private BeanItemContainer<Todo> todoContainer = new BeanItemContainer<Todo>( + Todo.class); + + @Override + protected void setup(VaadinRequest request) { + todoContainer.addBean(new Todo("Done task", true)); + todoContainer.addBean(new Todo("Not done", false)); + + Grid grid = new Grid(todoContainer); + grid.setSizeFull(); + + grid.setColumnOrder("done", "task"); + grid.getColumn("done").setWidth(75); + grid.getColumn("task").setExpandRatio(1); + + grid.setSelectionMode(Grid.SelectionMode.SINGLE); + + grid.setEditorEnabled(true); + grid.setImmediate(true); + + getLayout().addComponent(grid); + getLayout().setExpandRatio(grid, 1); + + } + + @Override + protected Integer getTicketNumber() { + return 16976; + } + + @Override + public String getDescription() { + return "Verify that checkbox state is correct for all items in editor"; + } + + public class Todo implements Serializable { + private static final long serialVersionUID = -5961103142478316018L; + + private boolean done; + private String task = ""; + + public Todo(String task, boolean done) { + this.task = task; + this.done = done; + } + + public boolean isDone() { + return done; + } + + public void setDone(boolean done) { + this.done = done; + } + + public String getTask() { + return task; + } + + public void setTask(String task) { + this.task = task; + } + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java new file mode 100644 index 0000000000..c430821534 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java @@ -0,0 +1,72 @@ +/* + * 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.grid; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.parallel.TestCategory; +import com.vaadin.tests.tb3.SingleBrowserTest; + +@TestCategory("grid") +public class GridCheckBoxDisplayTest extends SingleBrowserTest { + @Test + public void testAddRow() { + openTestURL(); + + GridElement grid = $(GridElement.class).first(); + + Assert.assertEquals("First item had wrong value", "true", + grid.getCell(0, 0).getText()); + Assert.assertEquals("Second item had wrong value", "false", grid + .getCell(1, 0).getText()); + + // First edit false item and see that the CheckBox is unchecked + grid.getCell(1, 0).doubleClick(); + + CheckBoxElement checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("CheckBox was checked", "unchecked", + checkbox.getValue()); + + closeEditor(); + + // Edit true item and see that the CheckBox is checked + grid.getCell(0, 0).doubleClick(); + + checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("CheckBox was not checked.", "checked", + checkbox.getValue()); + + closeEditor(); + + // Edit false item and confirm that the CheckBox is unchecked again + grid.getCell(1, 0).doubleClick(); + + checkbox = $(CheckBoxElement.class).first(); + Assert.assertEquals("CheckBox was checked", "unchecked", + checkbox.getValue()); + } + + /** + * Closes the grids editor using the cancel button + */ + private void closeEditor() { + findElement(By.className("v-grid-editor-cancel")).click(); + } +} |