summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-12-12 15:21:55 +0200
committerLeif Åstrand <leif@vaadin.com>2014-12-12 15:21:55 +0200
commitb7c01560877c3d1006422a84abb59e18ce357fad (patch)
treeda3322e27e1613e034df0fb702b24a84be5fcefc /uitest
parentde3ae6ef86e786d0383ea799001255deee6e03f3 (diff)
downloadvaadin-framework-b7c01560877c3d1006422a84abb59e18ce357fad.tar.gz
vaadin-framework-b7c01560877c3d1006422a84abb59e18ce357fad.zip
Refactor server-side editor row to work in real(er) cases (#13334)
- Don't configure fields for properties without columns - Rename "bind" to "set" to match the getter - Make it possible to get a field before editing has started - Remove setting of editable since the field can be configured directly - Remove error handler concept since we have not tests and no use cases - Unbind and detach field when removing a column Change-Id: I38ead4e680cdbab2525fe08ff09ed045255e2d4f
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java49
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.java65
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java2
3 files changed, 115 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java b/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.java
new file mode 100644
index 0000000000..3891583098
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/EditorRowUI.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 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
new file mode 100644
index 0000000000..0d4de5074c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/EditorRowUITest.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.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);
+ assertFalse("Remove this when grid is fixed",
+ isElementPresent(PasswordFieldElement.class));
+ 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/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index e61edb4e65..a5c93edad0 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -180,7 +180,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
grid.setSelectionMode(SelectionMode.NONE);
- grid.setPropertyEditable(getColumnProperty(3), false);
+ grid.getEditorRowField(getColumnProperty(3)).setReadOnly(true);
createGridActions();