Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BasicCrudGridEditorRowTest.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.fieldgroup;
  17. import static org.junit.Assert.assertFalse;
  18. import com.vaadin.tests.components.grid.LegacyGridElement;
  19. import org.junit.Assert;
  20. import org.junit.Before;
  21. import org.junit.Test;
  22. import org.openqa.selenium.By;
  23. import org.openqa.selenium.Keys;
  24. import org.openqa.selenium.WebElement;
  25. import org.openqa.selenium.interactions.Actions;
  26. import com.vaadin.testbench.elements.CheckBoxElement;
  27. import com.vaadin.testbench.elements.GridElement;
  28. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  29. import com.vaadin.testbench.elements.GridElement.GridEditorElement;
  30. import com.vaadin.testbench.parallel.TestCategory;
  31. import com.vaadin.tests.legacyelements.LegacyDateFieldElement;
  32. import com.vaadin.tests.tb3.MultiBrowserTest;
  33. @TestCategory("grid")
  34. public class BasicCrudGridEditorRowTest extends MultiBrowserTest {
  35. private GridElement grid;
  36. @Before
  37. public void openTest() {
  38. openTestURL();
  39. grid = $(LegacyGridElement.class).first();
  40. }
  41. @Test
  42. public void lookAndFeel() throws Exception {
  43. GridCellElement ritaBirthdate = grid.getCell(2, 3);
  44. compareScreen("grid");
  45. // Open editor row
  46. new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
  47. compareScreen("editorrow");
  48. }
  49. @Test
  50. public void editorRowOneInvalidValue() throws Exception {
  51. GridCellElement ritaBirthdate = grid.getCell(2, 3);
  52. // Open editor row
  53. new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
  54. GridEditorElement editor = grid.getEditor();
  55. LegacyDateFieldElement dateField = editor
  56. .$(LegacyDateFieldElement.class).first();
  57. WebElement input = dateField.findElement(By.xpath("input"));
  58. // input.click();
  59. input.sendKeys("Invalid", Keys.TAB);
  60. editor.save();
  61. Assert.assertTrue("Editor wasn't displayed.", editor.isDisplayed());
  62. Assert.assertTrue("DateField wasn't displayed.",
  63. dateField.isDisplayed());
  64. Assert.assertTrue("DateField didn't have 'v-invalid' css class.",
  65. hasCssClass(dateField, "v-datefield-error"));
  66. }
  67. @Test
  68. public void testCheckboxInEditorWorks() {
  69. GridCellElement ritaBirthdate = grid.getCell(2, 3);
  70. // Open editor row
  71. new Actions(getDriver()).doubleClick(ritaBirthdate).perform();
  72. // Get CheckBox
  73. GridEditorElement editor = grid.getEditor();
  74. CheckBoxElement cb = editor.getField(5).wrap(CheckBoxElement.class);
  75. // Check values
  76. String value = cb.getValue();
  77. cb.click(5, 5);
  78. Assert.assertNotEquals("Checkbox value did not change", value,
  79. cb.getValue());
  80. }
  81. @Test
  82. public void testNoTopStyleSetOnEditorOpenWithFooterOnTop() {
  83. GridCellElement cell = grid.getCell(2, 3);
  84. // Open editor row
  85. new Actions(getDriver()).doubleClick(cell).perform();
  86. // Close editor
  87. new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
  88. cell = grid.getCell(14, 3);
  89. // Open editor row
  90. new Actions(getDriver()).doubleClick(cell).perform();
  91. String attribute = grid.getEditor().getAttribute("style").toLowerCase();
  92. assertFalse("Style should not contain top.",
  93. attribute.contains("top:"));
  94. }
  95. }