You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridCheckBoxDisplayTest.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.components.grid;
  17. import org.junit.Assert;
  18. import org.junit.Test;
  19. import org.openqa.selenium.By;
  20. import com.vaadin.testbench.elements.CheckBoxElement;
  21. import com.vaadin.testbench.elements.GridElement;
  22. import com.vaadin.testbench.parallel.TestCategory;
  23. import com.vaadin.tests.legacyelements.LegacyCheckBoxElement;
  24. import com.vaadin.tests.tb3.SingleBrowserTest;
  25. @TestCategory("grid")
  26. public class GridCheckBoxDisplayTest extends SingleBrowserTest {
  27. @Test
  28. public void testAddRow() {
  29. openTestURL();
  30. GridElement grid = $(LegacyGridElement.class).first();
  31. Assert.assertEquals("First item had wrong value", "true",
  32. grid.getCell(0, 0).getText());
  33. Assert.assertEquals("Second item had wrong value", "false",
  34. grid.getCell(1, 0).getText());
  35. // First edit false item and see that the CheckBox is unchecked
  36. grid.getCell(1, 0).doubleClick();
  37. CheckBoxElement checkbox = $(LegacyCheckBoxElement.class).first();
  38. Assert.assertEquals("CheckBox was checked", "unchecked",
  39. checkbox.getValue());
  40. closeEditor();
  41. // Edit true item and see that the CheckBox is checked
  42. grid.getCell(0, 0).doubleClick();
  43. checkbox = $(LegacyCheckBoxElement.class).first();
  44. Assert.assertEquals("CheckBox was not checked.", "checked",
  45. checkbox.getValue());
  46. closeEditor();
  47. // Edit false item and confirm that the CheckBox is unchecked again
  48. grid.getCell(1, 0).doubleClick();
  49. checkbox = $(LegacyCheckBoxElement.class).first();
  50. Assert.assertEquals("CheckBox was checked", "unchecked",
  51. checkbox.getValue());
  52. }
  53. /**
  54. * Closes the grids editor using the cancel button
  55. */
  56. private void closeEditor() {
  57. findElement(By.className("v-grid-editor-cancel")).click();
  58. }
  59. }