aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2015-02-02 16:51:49 +0200
committerVaadin Code Review <review@vaadin.com>2015-02-05 06:50:44 +0000
commit323e8bb4588fcb4eefa6e988cceb8444f963d733 (patch)
tree38d6251431c43fabe3ba4e4c3afdf3edbe939ac3 /uitest/src
parent2a67b961a466b512532b1f554b0fc2903d185f50 (diff)
downloadvaadin-framework-323e8bb4588fcb4eefa6e988cceb8444f963d733.tar.gz
vaadin-framework-323e8bb4588fcb4eefa6e988cceb8444f963d733.zip
Makes it possible to change save/cancel captions in Grid editor (#16551)
Change-Id: I4e303613f66a13b3ad6a9b2284537e5548391a4a
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java16
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java56
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java14
4 files changed, 115 insertions, 7 deletions
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 7a625e2f25..89fff6871b 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -960,6 +960,22 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
c.cancelEditor();
}
}, null);
+
+ createClickAction("Change save caption", "Editor",
+ new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ c.setEditorSaveCaption("ǝʌɐS");
+ }
+ }, null);
+
+ createClickAction("Change cancel caption", "Editor",
+ new Command<Grid, String>() {
+ @Override
+ public void execute(Grid c, String value, Object data) {
+ c.setEditorCancelCaption("ʃǝɔuɐↃ");
+ }
+ }, null);
}
@SuppressWarnings("boxing")
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
index a67b901198..a81d374167 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java
@@ -17,6 +17,7 @@ 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.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -31,11 +32,17 @@ import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
+import com.vaadin.shared.ui.grid.GridConstants;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest;
import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures;
public class GridEditorClientTest extends GridBasicClientFeaturesTest {
+ private static final String[] EDIT_ROW_100 = new String[] { "Component",
+ "Editor", "Edit row 100" };
+ private static final String[] EDIT_ROW_5 = new String[] { "Component",
+ "Editor", "Edit row 5" };
+
@Before
public void setUp() {
openTestURL();
@@ -44,7 +51,7 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
@Test
public void testProgrammaticOpeningClosing() {
- selectMenuPath("Component", "Editor", "Edit row 5");
+ selectMenuPath(EDIT_ROW_5);
assertNotNull(getEditor());
selectMenuPath("Component", "Editor", "Cancel edit");
@@ -55,13 +62,13 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
@Test
public void testProgrammaticOpeningWithScroll() {
- selectMenuPath("Component", "Editor", "Edit row 100");
+ selectMenuPath(EDIT_ROW_100);
assertNotNull(getEditor());
}
@Test(expected = NoSuchElementException.class)
public void testVerticalScrollLocking() {
- selectMenuPath("Component", "Editor", "Edit row 5");
+ selectMenuPath(EDIT_ROW_5);
getGridElement().getCell(200, 0);
}
@@ -89,7 +96,7 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
@Test
public void testWidgetBinding() throws Exception {
- selectMenuPath("Component", "Editor", "Edit row 100");
+ selectMenuPath(EDIT_ROW_100);
WebElement editor = getEditor();
List<WebElement> widgets = editor.findElements(By
@@ -108,7 +115,7 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
@Test
public void testWithSelectionColumn() throws Exception {
selectMenuPath("Component", "State", "Selection mode", "multi");
- selectMenuPath("Component", "State", "Editor", "Edit row 5");
+ selectMenuPath(EDIT_ROW_5);
WebElement editor = getEditor();
List<WebElement> selectorDivs = editor.findElements(By
@@ -122,7 +129,7 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
@Test
public void testSave() {
- selectMenuPath("Component", "Editor", "Edit row 100");
+ selectMenuPath(EDIT_ROW_100);
WebElement textField = getEditor().findElements(
By.className("gwt-TextBox")).get(0);
@@ -140,7 +147,7 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
@Test
public void testProgrammaticSave() {
- selectMenuPath("Component", "Editor", "Edit row 100");
+ selectMenuPath(EDIT_ROW_100);
WebElement textField = getEditor().findElements(
By.className("gwt-TextBox")).get(0);
@@ -152,4 +159,39 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest {
assertEquals("Changed", getGridElement().getCell(100, 0).getText());
}
+
+ @Test
+ public void testCaptionChange() {
+ selectMenuPath(EDIT_ROW_5);
+ assertEquals("Save button caption should've been \""
+ + GridConstants.DEFAULT_SAVE_CAPTION + "\" to begin with",
+ GridConstants.DEFAULT_SAVE_CAPTION, getSaveButton().getText());
+ assertEquals("Cancel button caption should've been \""
+ + GridConstants.DEFAULT_CANCEL_CAPTION + "\" to begin with",
+ GridConstants.DEFAULT_CANCEL_CAPTION, getCancelButton()
+ .getText());
+
+ selectMenuPath("Component", "Editor", "Change Save Caption");
+ assertNotEquals(
+ "Save button caption should've changed while editor is open",
+ GridConstants.DEFAULT_SAVE_CAPTION, getSaveButton().getText());
+
+ getCancelButton().click();
+
+ selectMenuPath("Component", "Editor", "Change Cancel Caption");
+ selectMenuPath(EDIT_ROW_5);
+ assertNotEquals(
+ "Cancel button caption should've changed while editor is closed",
+ GridConstants.DEFAULT_CANCEL_CAPTION, getCancelButton()
+ .getText());
+ }
+
+ protected WebElement getSaveButton() {
+ return getEditor().findElement(By.className("v-grid-editor-save"));
+ }
+
+ protected WebElement getCancelButton() {
+ return getEditor().findElement(By.className("v-grid-editor-cancel"));
+ }
+
}
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
index c6eb8d042b..61dbfbc7c9 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java
@@ -17,6 +17,7 @@ package com.vaadin.tests.components.grid.basicfeatures.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -31,6 +32,7 @@ import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
+import com.vaadin.shared.ui.grid.GridConstants;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.testbench.elements.NotificationElement;
@@ -160,6 +162,32 @@ public class GridEditorTest extends GridBasicFeaturesTest {
.getText());
}
+ @Test
+ public void testCaptionChange() {
+ selectMenuPath(EDIT_ITEM_5);
+ assertEquals("Save button caption should've been \""
+ + GridConstants.DEFAULT_SAVE_CAPTION + "\" to begin with",
+ GridConstants.DEFAULT_SAVE_CAPTION, getSaveButton().getText());
+ assertEquals("Cancel button caption should've been \""
+ + GridConstants.DEFAULT_CANCEL_CAPTION + "\" to begin with",
+ GridConstants.DEFAULT_CANCEL_CAPTION, getCancelButton()
+ .getText());
+
+ selectMenuPath("Component", "Editor", "Change save caption");
+ assertNotEquals(
+ "Save button caption should've changed while editor is open",
+ GridConstants.DEFAULT_SAVE_CAPTION, getSaveButton().getText());
+
+ getCancelButton().click();
+
+ selectMenuPath("Component", "Editor", "Change cancel caption");
+ selectMenuPath(EDIT_ITEM_5);
+ assertNotEquals(
+ "Cancel button caption should've changed while editor is closed",
+ GridConstants.DEFAULT_CANCEL_CAPTION, getCancelButton()
+ .getText());
+ }
+
private void assertEditorOpen() {
assertNotNull("Editor is supposed to be open", getEditor());
assertEquals("Unexpected number of widgets", GridBasicFeatures.COLUMNS,
@@ -257,4 +285,12 @@ public class GridEditorTest extends GridBasicFeaturesTest {
assertEquals("Grid shouldn't scroll vertically while editing",
originalScrollPos, getGridVerticalScrollPos());
}
+
+ private WebElement getSaveButton() {
+ return getDriver().findElement(By.className("v-grid-editor-save"));
+ }
+
+ private WebElement getCancelButton() {
+ return getDriver().findElement(By.className("v-grid-editor-cancel"));
+ }
}
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 25a04b88f9..7a635ad420 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java
@@ -956,6 +956,20 @@ public class GridBasicClientFeaturesWidget extends
}
}, "Component", "Editor");
+ addMenuCommand("Change Save Caption", new ScheduledCommand() {
+ @Override
+ public void execute() {
+ grid.setEditorSaveCaption("ǝʌɐS");
+ }
+ }, "Component", "Editor");
+
+ addMenuCommand("Change Cancel Caption", new ScheduledCommand() {
+ @Override
+ public void execute() {
+ grid.setEditorCancelCaption("ʃǝɔuɐↃ");
+ }
+ }, "Component", "Editor");
+
}
private void configureFooterRow(final FooterRow row) {