From 6ed909f2c61f7d434d1c91549dcda27cfa3698a8 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 15 Dec 2014 16:31:26 +0200 Subject: Change "editor row" to just "editor" in method names and javadoc (#13334) Change-Id: Idafdbe3d71a38a979e1eeb07c527f66ce61ccfa9 --- .../vaadin/tests/components/grid/EditorRowUI.java | 49 ------ .../tests/components/grid/EditorRowUITest.java | 63 -------- .../vaadin/tests/components/grid/GridEditorUI.java | 49 ++++++ .../tests/components/grid/GridEditorUITest.java | 63 ++++++++ .../grid/basicfeatures/GridBasicFeatures.java | 42 +++--- .../grid/basicfeatures/GridBasicFeaturesTest.java | 4 +- .../client/GridClientCompositeEditorRowTest.java | 13 -- .../client/GridClientCompositeEditorTest.java | 13 ++ .../basicfeatures/client/GridEditorClientTest.java | 155 +++++++++++++++++++ .../client/GridEditorRowClientTest.java | 155 ------------------- .../basicfeatures/server/GridEditorRowTest.java | 168 --------------------- .../grid/basicfeatures/server/GridEditorTest.java | 168 +++++++++++++++++++++ .../client/grid/GridBasicClientFeaturesWidget.java | 34 ++--- 13 files changed, 487 insertions(+), 489 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java delete mode 100644 uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java create mode 100644 uitest/src/com/vaadin/tests/components/grid/GridEditorUI.java create mode 100644 uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java delete mode 100644 uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorRowTest.java create mode 100644 uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorTest.java create mode 100644 uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java delete mode 100644 uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorRowClientTest.java delete mode 100644 uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorRowTest.java create mode 100644 uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java b/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java deleted file mode 100644 index 3891583098..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.util.PersonContainer; -import com.vaadin.ui.Grid; -import com.vaadin.ui.PasswordField; -import com.vaadin.ui.TextField; - -public class EditorRowUI extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - PersonContainer container = PersonContainer.createWithTestData(); - - Grid grid = new Grid(container); - - // Don't use address since there's no converter - grid.removeColumn("address"); - - grid.setEditorRowEnabled(true); - - grid.setEditorRowField("firstName", new PasswordField()); - - TextField lastNameField = (TextField) grid - .getEditorRowField("lastName"); - lastNameField.setMaxLength(50); - - grid.getEditorRowField("phoneNumber").setReadOnly(true); - - addComponent(grid); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java b/uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java deleted file mode 100644 index 269f997c95..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.openqa.selenium.Keys; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.elements.GridElement; -import com.vaadin.testbench.elements.GridElement.GridCellElement; -import com.vaadin.testbench.elements.NotificationElement; -import com.vaadin.testbench.elements.PasswordFieldElement; -import com.vaadin.tests.annotations.TestCategory; -import com.vaadin.tests.tb3.MultiBrowserTest; - -@TestCategory("grid") -public class EditorRowUITest extends MultiBrowserTest { - - @Test - public void testEditorRow() { - setDebug(true); - openTestURL(); - - assertFalse("Sanity check", - isElementPresent(PasswordFieldElement.class)); - - openEditorRow(5); - new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); - - openEditorRow(10); - - assertTrue("Edtor row should be opened with a password field", - isElementPresent(PasswordFieldElement.class)); - - assertFalse("Notification was present", - isElementPresent(NotificationElement.class)); - } - - private void openEditorRow(int rowIndex) { - GridElement grid = $(GridElement.class).first(); - - GridCellElement cell = grid.getCell(rowIndex, 1); - - new Actions(driver).moveToElement(cell).doubleClick().build().perform(); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridEditorUI.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorUI.java new file mode 100644 index 0000000000..fe4b4342a2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorUI.java @@ -0,0 +1,49 @@ +/* + * 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 com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.PersonContainer; +import com.vaadin.ui.Grid; +import com.vaadin.ui.PasswordField; +import com.vaadin.ui.TextField; + +public class GridEditorUI extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + PersonContainer container = PersonContainer.createWithTestData(); + + Grid grid = new Grid(container); + + // Don't use address since there's no converter + grid.removeColumn("address"); + + grid.setEditorEnabled(true); + + grid.setEditorField("firstName", new PasswordField()); + + TextField lastNameField = (TextField) grid + .getEditorField("lastName"); + lastNameField.setMaxLength(50); + + grid.getEditorField("phoneNumber").setReadOnly(true); + + addComponent(grid); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java new file mode 100644 index 0000000000..6c386eec03 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorUITest.java @@ -0,0 +1,63 @@ +/* + * 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 static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridCellElement; +import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.testbench.elements.PasswordFieldElement; +import com.vaadin.tests.annotations.TestCategory; +import com.vaadin.tests.tb3.MultiBrowserTest; + +@TestCategory("grid") +public class GridEditorUITest extends MultiBrowserTest { + + @Test + public void testEditor() { + setDebug(true); + openTestURL(); + + assertFalse("Sanity check", + isElementPresent(PasswordFieldElement.class)); + + openEditor(5); + new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); + + openEditor(10); + + assertTrue("Edtor should be opened with a password field", + isElementPresent(PasswordFieldElement.class)); + + assertFalse("Notification was present", + isElementPresent(NotificationElement.class)); + } + + private void openEditor(int rowIndex) { + GridElement grid = $(GridElement.class).first(); + + GridCellElement cell = grid.getCell(rowIndex, 1); + + new Actions(driver).moveToElement(cell).doubleClick().build().perform(); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java index 62f3488447..9aceef70bb 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -189,7 +189,7 @@ public class GridBasicFeatures extends AbstractComponentTest { grid.setSelectionMode(SelectionMode.NONE); - grid.getEditorRowField(getColumnProperty(3)).setReadOnly(true); + grid.getEditorField(getColumnProperty(3)).setReadOnly(true); createGridActions(); @@ -203,7 +203,7 @@ public class GridBasicFeatures extends AbstractComponentTest { createRowActions(); - createEditorRowActions(); + createEditorActions(); addHeightActions(); @@ -853,48 +853,46 @@ public class GridBasicFeatures extends AbstractComponentTest { }, null); } - protected void createEditorRowActions() { - createBooleanAction("Enabled", "Editor row", false, + protected void createEditorActions() { + createBooleanAction("Enabled", "Editor", false, new Command() { @Override public void execute(Grid c, Boolean value, Object data) { - c.setEditorRowEnabled(value); + c.setEditorEnabled(value); } }); - createClickAction("Edit item 5", "Editor row", - new Command() { - @Override - public void execute(Grid c, String value, Object data) { - c.editItem(5); - } - }, null); + createClickAction("Edit item 5", "Editor", new Command() { + @Override + public void execute(Grid c, String value, Object data) { + c.editItem(5); + } + }, null); - createClickAction("Edit item 100", "Editor row", + createClickAction("Edit item 100", "Editor", new Command() { @Override public void execute(Grid c, String value, Object data) { c.editItem(100); } }, null); - createClickAction("Save", "Editor row", new Command() { + createClickAction("Save", "Editor", new Command() { @Override public void execute(Grid c, String value, Object data) { try { - c.saveEditorRow(); + c.saveEditor(); } catch (CommitException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, null); - createClickAction("Cancel edit", "Editor row", - new Command() { - @Override - public void execute(Grid c, String value, Object data) { - c.cancelEditorRow(); - } - }, null); + createClickAction("Cancel edit", "Editor", new Command() { + @Override + public void execute(Grid c, String value, Object data) { + c.cancelEditor(); + } + }, null); } @SuppressWarnings("boxing") diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java index 50e1034b50..279f75492e 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java @@ -90,11 +90,11 @@ public abstract class GridBasicFeaturesTest extends MultiBrowserTest { return footerCells; } - protected WebElement getEditorRow() { + protected WebElement getEditor() { List elems = getGridElement().findElements( By.className("v-grid-editor-row")); - assertLessThanOrEqual("number of editor rows", elems.size(), 1); + assertLessThanOrEqual("number of editors", elems.size(), 1); return elems.isEmpty() ? null : elems.get(0); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorRowTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorRowTest.java deleted file mode 100644 index 1fa8549b1c..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorRowTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.vaadin.tests.components.grid.basicfeatures.client; - -import org.junit.Before; - -public class GridClientCompositeEditorRowTest extends GridEditorRowClientTest { - - @Override - @Before - public void setUp() { - setUseComposite(true); - super.setUp(); - } -} diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorTest.java new file mode 100644 index 0000000000..29e6fed68c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientCompositeEditorTest.java @@ -0,0 +1,13 @@ +package com.vaadin.tests.components.grid.basicfeatures.client; + +import org.junit.Before; + +public class GridClientCompositeEditorTest extends GridEditorClientTest { + + @Override + @Before + public void setUp() { + setUseComposite(true); + super.setUp(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java new file mode 100644 index 0000000000..5db7f3a0b9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java @@ -0,0 +1,155 @@ +/* + * 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.basicfeatures.client; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; +import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; + +public class GridEditorClientTest extends GridBasicClientFeaturesTest { + + @Before + public void setUp() { + openTestURL(); + selectMenuPath("Component", "Editor", "Enabled"); + } + + @Test + public void testProgrammaticOpeningClosing() { + selectMenuPath("Component", "Editor", "Edit row 5"); + assertNotNull(getEditor()); + + selectMenuPath("Component", "Editor", "Cancel edit"); + assertNull(getEditor()); + assertEquals("Row 5 edit cancelled", + findElement(By.className("grid-editor-log")).getText()); + } + + @Test + public void testProgrammaticOpeningWithScroll() { + selectMenuPath("Component", "Editor", "Edit row 100"); + assertNotNull(getEditor()); + } + + @Test(expected = NoSuchElementException.class) + public void testVerticalScrollLocking() { + selectMenuPath("Component", "Editor", "Edit row 5"); + getGridElement().getCell(200, 0); + } + + @Test + public void testKeyboardOpeningClosing() { + + getGridElement().getCell(4, 0).click(); + + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + assertNotNull(getEditor()); + + new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); + assertNull(getEditor()); + assertEquals("Row 4 edit cancelled", + findElement(By.className("grid-editor-log")).getText()); + + // Disable editor + selectMenuPath("Component", "Editor", "Enabled"); + + getGridElement().getCell(5, 0).click(); + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + assertNull(getEditor()); + } + + @Test + public void testWidgetBinding() throws Exception { + selectMenuPath("Component", "Editor", "Edit row 100"); + WebElement editor = getEditor(); + + List widgets = editor.findElements(By + .className("gwt-TextBox")); + + assertEquals(GridBasicFeatures.COLUMNS, widgets.size()); + + assertEquals("(100, 0)", widgets.get(0).getAttribute("value")); + assertEquals("(100, 1)", widgets.get(1).getAttribute("value")); + assertEquals("(100, 2)", widgets.get(2).getAttribute("value")); + + assertEquals("100", widgets.get(7).getAttribute("value")); + assertEquals("100", widgets.get(9).getAttribute("value")); + } + + @Test + public void testWithSelectionColumn() throws Exception { + selectMenuPath("Component", "State", "Selection mode", "multi"); + selectMenuPath("Component", "State", "Editor", "Edit row 5"); + + WebElement editor = getEditor(); + List selectorDivs = editor.findElements(By + .cssSelector("div")); + + assertTrue("selector column cell should've been empty", selectorDivs + .get(0).getAttribute("innerHTML").isEmpty()); + assertFalse("normal column cell shoul've had contents", selectorDivs + .get(1).getAttribute("innerHTML").isEmpty()); + } + + @Test + public void testSave() { + selectMenuPath("Component", "Editor", "Edit row 100"); + + WebElement textField = getEditor().findElements( + By.className("gwt-TextBox")).get(0); + + textField.clear(); + textField.sendKeys("Changed"); + + WebElement saveButton = getEditor().findElement( + By.className("v-editor-row-save")); + + saveButton.click(); + + assertEquals("Changed", getGridElement().getCell(100, 0).getText()); + } + + @Test + public void testProgrammaticSave() { + selectMenuPath("Component", "Editor", "Edit row 100"); + + WebElement textField = getEditor().findElements( + By.className("gwt-TextBox")).get(0); + + textField.clear(); + textField.sendKeys("Changed"); + + selectMenuPath("Component", "Editor", "Save"); + + assertEquals("Changed", getGridElement().getCell(100, 0).getText()); + } +} diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorRowClientTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorRowClientTest.java deleted file mode 100644 index f3c49db39e..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorRowClientTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.basicfeatures.client; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; -import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; - -public class GridEditorRowClientTest extends GridBasicClientFeaturesTest { - - @Before - public void setUp() { - openTestURL(); - selectMenuPath("Component", "Editor row", "Enabled"); - } - - @Test - public void testProgrammaticOpeningClosing() { - selectMenuPath("Component", "Editor row", "Edit row 5"); - assertNotNull(getEditorRow()); - - selectMenuPath("Component", "Editor row", "Cancel edit"); - assertNull(getEditorRow()); - assertEquals("Row 5 edit cancelled", - findElement(By.className("editor-row-log")).getText()); - } - - @Test - public void testProgrammaticOpeningWithScroll() { - selectMenuPath("Component", "Editor row", "Edit row 100"); - assertNotNull(getEditorRow()); - } - - @Test(expected = NoSuchElementException.class) - public void testVerticalScrollLocking() { - selectMenuPath("Component", "Editor row", "Edit row 5"); - getGridElement().getCell(200, 0); - } - - @Test - public void testKeyboardOpeningClosing() { - - getGridElement().getCell(4, 0).click(); - - new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - - assertNotNull(getEditorRow()); - - new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); - assertNull(getEditorRow()); - assertEquals("Row 4 edit cancelled", - findElement(By.className("editor-row-log")).getText()); - - // Disable editor row - selectMenuPath("Component", "Editor row", "Enabled"); - - getGridElement().getCell(5, 0).click(); - new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertNull(getEditorRow()); - } - - @Test - public void testWidgetBinding() throws Exception { - selectMenuPath("Component", "Editor row", "Edit row 100"); - WebElement editorRow = getEditorRow(); - - List widgets = editorRow.findElements(By - .className("gwt-TextBox")); - - assertEquals(GridBasicFeatures.COLUMNS, widgets.size()); - - assertEquals("(100, 0)", widgets.get(0).getAttribute("value")); - assertEquals("(100, 1)", widgets.get(1).getAttribute("value")); - assertEquals("(100, 2)", widgets.get(2).getAttribute("value")); - - assertEquals("100", widgets.get(7).getAttribute("value")); - assertEquals("100", widgets.get(9).getAttribute("value")); - } - - @Test - public void testWithSelectionColumn() throws Exception { - selectMenuPath("Component", "State", "Selection mode", "multi"); - selectMenuPath("Component", "State", "Editor row", "Edit row 5"); - - WebElement editorRow = getEditorRow(); - List selectorDivs = editorRow.findElements(By - .cssSelector("div")); - - assertTrue("selector column cell should've been empty", selectorDivs - .get(0).getAttribute("innerHTML").isEmpty()); - assertFalse("normal column cell shoul've had contents", selectorDivs - .get(1).getAttribute("innerHTML").isEmpty()); - } - - @Test - public void testSave() { - selectMenuPath("Component", "Editor row", "Edit row 100"); - - WebElement textField = getEditorRow().findElements( - By.className("gwt-TextBox")).get(0); - - textField.clear(); - textField.sendKeys("Changed"); - - WebElement saveButton = getEditorRow().findElement( - By.className("v-editor-row-save")); - - saveButton.click(); - - assertEquals("Changed", getGridElement().getCell(100, 0).getText()); - } - - @Test - public void testProgrammaticSave() { - selectMenuPath("Component", "Editor row", "Edit row 100"); - - WebElement textField = getEditorRow().findElements( - By.className("gwt-TextBox")).get(0); - - textField.clear(); - textField.sendKeys("Changed"); - - selectMenuPath("Component", "Editor row", "Save"); - - assertEquals("Changed", getGridElement().getCell(100, 0).getText()); - } -} diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorRowTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorRowTest.java deleted file mode 100644 index f07d33080d..0000000000 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorRowTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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.basicfeatures.server; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; -import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; - -public class GridEditorRowTest extends GridBasicFeaturesTest { - - @Before - public void setUp() { - openTestURL(); - selectMenuPath("Component", "Editor row", "Enabled"); - } - - @Test - public void testProgrammaticOpeningClosing() { - selectMenuPath("Component", "Editor row", "Edit item 5"); - assertEditorRowOpen(); - - selectMenuPath("Component", "Editor row", "Cancel edit"); - assertEditorRowClosed(); - } - - @Test - public void testProgrammaticOpeningWhenDisabled() { - selectMenuPath("Component", "Editor row", "Enabled"); - selectMenuPath("Component", "Editor row", "Edit item 5"); - assertEditorRowClosed(); - assertEquals( - "5. Exception occured, java.lang.IllegalStateExceptionEditor row is not enabled", - getLogRow(0)); - } - - @Test - public void testDisablingWhileOpen() { - selectMenuPath("Component", "Editor row", "Edit item 5"); - selectMenuPath("Component", "Editor row", "Enabled"); - assertEditorRowOpen(); - assertEquals( - "5. Exception occured, java.lang.IllegalStateExceptionCannot disable the editor row while an item (5) is being edited.", - getLogRow(0)); - - } - - @Test - public void testProgrammaticOpeningWithScroll() { - selectMenuPath("Component", "Editor row", "Edit item 100"); - assertEditorRowOpen(); - } - - @Test(expected = NoSuchElementException.class) - public void testVerticalScrollLocking() { - selectMenuPath("Component", "Editor row", "Edit item 5"); - getGridElement().getCell(200, 0); - } - - @Test - public void testKeyboardOpeningClosing() { - - getGridElement().getCell(4, 0).click(); - assertEditorRowClosed(); - - new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertEditorRowOpen(); - - new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); - assertEditorRowClosed(); - - // Disable editor row - selectMenuPath("Component", "Editor row", "Enabled"); - getGridElement().getCell(5, 0).click(); - new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); - assertEditorRowClosed(); - } - - @Test - public void testComponentBinding() { - selectMenuPath("Component", "State", "Editor row", "Edit item 100"); - - List widgets = getEditorWidgets(); - assertEquals("Number of widgets", GridBasicFeatures.COLUMNS, - widgets.size()); - - assertEquals("(100, 0)", widgets.get(0).getAttribute("value")); - assertEquals("(100, 1)", widgets.get(1).getAttribute("value")); - assertEquals("(100, 2)", widgets.get(2).getAttribute("value")); - assertEquals("100", widgets.get(9).getAttribute("value")); - } - - @Test - public void testSave() { - selectMenuPath("Component", "Editor row", "Edit item 100"); - - WebElement textField = getEditorWidgets().get(0); - - textField.click(); - - textField.sendKeys(" changed"); - - WebElement saveButton = getEditorRow().findElement( - By.className("v-editor-row-save")); - - saveButton.click(); - - assertEquals("(100, 0) changed", getGridElement().getCell(100, 0) - .getText()); - } - - @Test - public void testProgrammaticSave() { - selectMenuPath("Component", "Editor row", "Edit item 100"); - - WebElement textField = getEditorWidgets().get(0); - - textField.click(); - - textField.sendKeys(" changed"); - - selectMenuPath("Component", "Editor row", "Save"); - - assertEquals("(100, 0) changed", getGridElement().getCell(100, 0) - .getText()); - } - - private void assertEditorRowOpen() { - assertNotNull("Editor row open", getEditorRow()); - assertEquals("Number of widgets", GridBasicFeatures.COLUMNS, - getEditorWidgets().size()); - } - - private void assertEditorRowClosed() { - assertNull("Editor row closed", getEditorRow()); - } - - private List getEditorWidgets() { - assertNotNull(getEditorRow()); - return getEditorRow().findElements(By.className("v-textfield")); - - } -} diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java new file mode 100644 index 0000000000..2afa9ec04e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java @@ -0,0 +1,168 @@ +/* + * 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.basicfeatures.server; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; +import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; + +public class GridEditorTest extends GridBasicFeaturesTest { + + @Before + public void setUp() { + openTestURL(); + selectMenuPath("Component", "Editor", "Enabled"); + } + + @Test + public void testProgrammaticOpeningClosing() { + selectMenuPath("Component", "Editor", "Edit item 5"); + assertEditorOpen(); + + selectMenuPath("Component", "Editor", "Cancel edit"); + assertEditorClosed(); + } + + @Test + public void testProgrammaticOpeningWhenDisabled() { + selectMenuPath("Component", "Editor", "Enabled"); + selectMenuPath("Component", "Editor", "Edit item 5"); + assertEditorClosed(); + boolean thrown = getLogRow(0).startsWith( + "5. Exception occured, java.lang.IllegalStateException"); + assertTrue("IllegalStateException thrown", thrown); + } + + @Test + public void testDisablingWhileOpen() { + selectMenuPath("Component", "Editor", "Edit item 5"); + selectMenuPath("Component", "Editor", "Enabled"); + assertEditorOpen(); + boolean thrown = getLogRow(0).startsWith( + "5. Exception occured, java.lang.IllegalStateException"); + assertTrue("IllegalStateException thrown", thrown); + } + + @Test + public void testProgrammaticOpeningWithScroll() { + selectMenuPath("Component", "Editor", "Edit item 100"); + assertEditorOpen(); + } + + @Test(expected = NoSuchElementException.class) + public void testVerticalScrollLocking() { + selectMenuPath("Component", "Editor", "Edit item 5"); + getGridElement().getCell(200, 0); + } + + @Test + public void testKeyboardOpeningClosing() { + + getGridElement().getCell(4, 0).click(); + assertEditorClosed(); + + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + assertEditorOpen(); + + new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); + assertEditorClosed(); + + // Disable Editor + selectMenuPath("Component", "Editor", "Enabled"); + getGridElement().getCell(5, 0).click(); + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + assertEditorClosed(); + } + + @Test + public void testComponentBinding() { + selectMenuPath("Component", "State", "Editor", "Edit item 100"); + + List widgets = getEditorWidgets(); + assertEquals("Number of widgets", GridBasicFeatures.COLUMNS, + widgets.size()); + + assertEquals("(100, 0)", widgets.get(0).getAttribute("value")); + assertEquals("(100, 1)", widgets.get(1).getAttribute("value")); + assertEquals("(100, 2)", widgets.get(2).getAttribute("value")); + assertEquals("100", widgets.get(9).getAttribute("value")); + } + + @Test + public void testSave() { + selectMenuPath("Component", "Editor", "Edit item 100"); + + WebElement textField = getEditorWidgets().get(0); + + textField.click(); + + textField.sendKeys(" changed"); + + WebElement saveButton = getEditor().findElement( + By.className("v-editor-row-save")); + + saveButton.click(); + + assertEquals("(100, 0) changed", getGridElement().getCell(100, 0) + .getText()); + } + + @Test + public void testProgrammaticSave() { + selectMenuPath("Component", "Editor", "Edit item 100"); + + WebElement textField = getEditorWidgets().get(0); + + textField.click(); + + textField.sendKeys(" changed"); + + selectMenuPath("Component", "Editor", "Save"); + + assertEquals("(100, 0) changed", getGridElement().getCell(100, 0) + .getText()); + } + + private void assertEditorOpen() { + assertNotNull("Editor open", getEditor()); + assertEquals("Number of widgets", GridBasicFeatures.COLUMNS, + getEditorWidgets().size()); + } + + private void assertEditorClosed() { + assertNull("Editor closed", getEditor()); + } + + private List getEditorWidgets() { + assertNotNull(getEditor()); + return getEditor().findElements(By.className("v-textfield")); + + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index 71fc47277f..f66347bd2d 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -46,7 +46,7 @@ import com.vaadin.client.widget.escalator.Cell; import com.vaadin.client.widget.escalator.FlyweightCell; import com.vaadin.client.widget.grid.CellReference; import com.vaadin.client.widget.grid.CellStyleGenerator; -import com.vaadin.client.widget.grid.EditorRowHandler; +import com.vaadin.client.widget.grid.EditorHandler; import com.vaadin.client.widget.grid.RowReference; import com.vaadin.client.widget.grid.RowStyleGenerator; import com.vaadin.client.widget.grid.datasources.ListDataSource; @@ -92,19 +92,19 @@ public class GridBasicClientFeaturesWidget extends TEXT_RENDERER, HTML_RENDERER, NUMBER_RENDERER, DATE_RENDERER; } - private class TestEditorRowHandler implements EditorRowHandler> { + private class TestEditorHandler implements EditorHandler> { private Map, TextBox> widgets = new HashMap, TextBox>(); private Label log = new Label(); { - log.addStyleName("editor-row-log"); + log.addStyleName("grid-editor-log"); addSouth(log, 20); } @Override - public void bind(EditorRowRequest> request) { + public void bind(EditorRequest> request) { List rowData = ds.getRow(request.getRowIndex()); boolean hasSelectionColumn = !(grid.getSelectionModel() instanceof None); @@ -117,13 +117,13 @@ public class GridBasicClientFeaturesWidget extends } @Override - public void cancel(EditorRowRequest> request) { + public void cancel(EditorRequest> request) { log.setText("Row " + request.getRowIndex() + " edit cancelled"); request.invokeCallback(); } @Override - public void save(EditorRowRequest> request) { + public void save(EditorRequest> request) { log.setText("Row " + request.getRowIndex() + " edit committed"); List rowData = ds.getRow(request.getRowIndex()); @@ -252,7 +252,7 @@ public class GridBasicClientFeaturesWidget extends grid.setDataSource(ds); grid.addSelectAllHandler(ds.getSelectAllHandler()); grid.setSelectionMode(SelectionMode.NONE); - grid.setEditorRowHandler(new TestEditorRowHandler()); + grid.setEditorHandler(new TestEditorHandler()); sorter = new ListSorter>(grid); @@ -377,7 +377,7 @@ public class GridBasicClientFeaturesWidget extends createColumnsMenu(); createHeaderMenu(); createFooterMenu(); - createEditorRowMenu(); + createEditorMenu(); createInternalsMenu(); createDataSourceMenu(); @@ -906,41 +906,41 @@ public class GridBasicClientFeaturesWidget extends }, menuPath); } - private void createEditorRowMenu() { + private void createEditorMenu() { addMenuCommand("Enabled", new ScheduledCommand() { @Override public void execute() { - grid.setEditorRowEnabled(!grid.isEditorRowEnabled()); + grid.setEditorEnabled(!grid.isEditorEnabled()); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Edit row 5", new ScheduledCommand() { @Override public void execute() { grid.editRow(5); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Edit row 100", new ScheduledCommand() { @Override public void execute() { grid.editRow(100); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Save", new ScheduledCommand() { @Override public void execute() { - grid.saveEditorRow(); + grid.saveEditor(); } - }, "Component", "Editor row"); + }, "Component", "Editor"); addMenuCommand("Cancel edit", new ScheduledCommand() { @Override public void execute() { - grid.cancelEditorRow(); + grid.cancelEditor(); } - }, "Component", "Editor row"); + }, "Component", "Editor"); } -- cgit v1.2.3