diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2015-05-25 18:05:31 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-05-28 14:59:25 +0000 |
commit | 550bd1e5e42b97de54ebcd02fda17325d52ef67d (patch) | |
tree | 8de850a53e8584722b0ca354609cc5c82efb735c /uitest | |
parent | 9f6cfbce67583dd5c5133d1de5c1fedc58916de0 (diff) | |
download | vaadin-framework-550bd1e5e42b97de54ebcd02fda17325d52ef67d.tar.gz vaadin-framework-550bd1e5e42b97de54ebcd02fda17325d52ef67d.zip |
Focus the field in the the active cell when manually opening Grid editor
Also move focus back to Grid when manually closing the editor.
Change-Id: I3ec54c00500ddd3872e7d20109191ac7db8bb950
Diffstat (limited to 'uitest')
3 files changed, 116 insertions, 3 deletions
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 04f5e1558d..87b0ba17de 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 @@ -33,6 +33,7 @@ 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.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; @@ -74,6 +75,22 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest { } @Test + public void testMouseOpeningClosing() { + + getGridElement().getCell(4, 0).doubleClick(); + assertNotNull(getEditor()); + + getCancelButton().click(); + assertNull(getEditor()); + + // Disable editor + selectMenuPath("Component", "Editor", "Enabled"); + + getGridElement().getCell(4, 0).doubleClick(); + assertNull(getEditor()); + } + + @Test public void testKeyboardOpeningClosing() { getGridElement().getCell(4, 0).click(); @@ -219,6 +236,44 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest { editor.getErrorMessage()); } + @Test + public void testFocusOnMouseOpen() { + + GridCellElement cell = getGridElement().getCell(4, 2); + + cell.doubleClick(); + + WebElement focused = getFocusedElement(); + + assertEquals("", "input", focused.getTagName()); + assertEquals("", cell.getText(), focused.getAttribute("value")); + } + + @Test + public void testFocusOnKeyboardOpen() { + + GridCellElement cell = getGridElement().getCell(4, 2); + + cell.click(); + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + WebElement focused = getFocusedElement(); + + assertEquals("", "input", focused.getTagName()); + assertEquals("", cell.getText(), focused.getAttribute("value")); + } + + @Test + public void testNoFocusOnProgrammaticOpen() { + + selectMenuPath(EDIT_ROW_5); + + WebElement focused = getFocusedElement(); + + // GWT menubar loses focus after clicking a menuitem + assertEquals("Focus should be in body", "body", focused.getTagName()); + } + protected WebElement getSaveButton() { return getEditor().findElement(By.className("v-grid-editor-save")); } 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 5f42bd66d3..0c39b3e509 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 @@ -95,6 +95,20 @@ public class GridEditorTest extends GridBasicFeaturesTest { } @Test + public void testMouseOpeningClosing() { + + getGridElement().getCell(4, 0).doubleClick(); + assertEditorOpen(); + + getCancelButton().click(); + assertEditorClosed(); + + selectMenuPath(TOGGLE_EDIT_ENABLED); + getGridElement().getCell(4, 0).doubleClick(); + assertEditorClosed(); + } + + @Test public void testKeyboardOpeningClosing() { getGridElement().getCell(4, 0).click(); @@ -234,7 +248,7 @@ public class GridEditorTest extends GridBasicFeaturesTest { } @Test - public void testNoScrollAfterEditByAPI() { + public void testNoScrollAfterProgrammaticOpen() { int originalScrollPos = getGridVerticalScrollPos(); selectMenuPath(EDIT_ITEM_5); @@ -245,7 +259,7 @@ public class GridEditorTest extends GridBasicFeaturesTest { } @Test - public void testNoScrollAfterEditByMouse() { + public void testNoScrollAfterMouseOpen() { int originalScrollPos = getGridVerticalScrollPos(); GridCellElement cell_5_0 = getGridElement().getCell(5, 0); @@ -257,7 +271,7 @@ public class GridEditorTest extends GridBasicFeaturesTest { } @Test - public void testNoScrollAfterEditByKeyboard() { + public void testNoScrollAfterKeyboardOpen() { int originalScrollPos = getGridVerticalScrollPos(); GridCellElement cell_5_0 = getGridElement().getCell(5, 0); @@ -294,6 +308,49 @@ public class GridEditorTest extends GridBasicFeaturesTest { } @Test + public void testFocusOnMouseOpen() { + + GridCellElement cell = getGridElement().getCell(4, 2); + + cell.doubleClick(); + + WebElement focused = getFocusedElement(); + + assertEquals("", "input", focused.getTagName()); + assertEquals("", cell.getText(), focused.getAttribute("value")); + } + + @Test + public void testFocusOnKeyboardOpen() { + + GridCellElement cell = getGridElement().getCell(4, 2); + + cell.click(); + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + WebElement focused = getFocusedElement(); + + assertEquals("", "input", focused.getTagName()); + assertEquals("", cell.getText(), focused.getAttribute("value")); + } + + @Test + public void testNoFocusOnProgrammaticOpen() { + + selectMenuPath(EDIT_ITEM_5); + + WebElement focused = getFocusedElement(); + + assertEquals("Focus should remain in the menu", "menu", + focused.getAttribute("id")); + } + + @Override + protected WebElement getFocusedElement() { + return (WebElement) executeScript("return document.activeElement;"); + } + + @Test public void testUneditableColumn() { selectMenuPath(EDIT_ITEM_5); assertEditorOpen(); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java index e9c126f232..bda1a0c33e 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/PureGWTTestApplication.java @@ -98,6 +98,7 @@ public abstract class PureGWTTestApplication<T> extends DockLayoutPanel private Menu() { title = ""; menubar = new MenuBar(); + menubar.getElement().setId("menu"); children = new ArrayList<Menu>(); items = new ArrayList<Command>(); } |