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.

GridInTabSheetTest.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright 2000-2014 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 static org.junit.Assert.assertEquals;
  18. import static org.junit.Assert.assertFalse;
  19. import org.junit.Test;
  20. import com.vaadin.testbench.elements.ButtonElement;
  21. import com.vaadin.testbench.elements.GridElement;
  22. import com.vaadin.testbench.elements.NotificationElement;
  23. import com.vaadin.testbench.elements.TabSheetElement;
  24. import com.vaadin.testbench.parallel.TestCategory;
  25. import com.vaadin.tests.tb3.MultiBrowserTest;
  26. @TestCategory("grid")
  27. public class GridInTabSheetTest extends MultiBrowserTest {
  28. @Test
  29. public void testRemoveAllRowsAndAddThreeNewOnes() {
  30. setDebug(true);
  31. openTestURL();
  32. for (int i = 0; i < 3; ++i) {
  33. removeGridRow();
  34. }
  35. for (int i = 0; i < 3; ++i) {
  36. addGridRow();
  37. assertEquals("" + (100 + i), getGridElement().getCell(i, 1)
  38. .getText());
  39. }
  40. assertNoNotification();
  41. }
  42. private void assertNoNotification() {
  43. assertFalse("There was an unexpected error notification",
  44. isElementPresent(NotificationElement.class));
  45. }
  46. @Test
  47. public void testAddManyRowsWhenGridIsHidden() {
  48. setDebug(true);
  49. openTestURL();
  50. TabSheetElement tabsheet = $(TabSheetElement.class).first();
  51. tabsheet.openTab("Label");
  52. for (int i = 0; i < 50; ++i) {
  53. addGridRow();
  54. }
  55. tabsheet.openTab("Grid");
  56. assertNoNotification();
  57. }
  58. @Test
  59. public void testAddCellStyleGeneratorWhenGridIsHidden() {
  60. setDebug(true);
  61. openTestURL();
  62. TabSheetElement tabsheet = $(TabSheetElement.class).first();
  63. tabsheet.openTab("Label");
  64. addCellStyleGenerator();
  65. tabsheet.openTab("Grid");
  66. assertNoNotification();
  67. }
  68. private void removeGridRow() {
  69. $(ButtonElement.class).caption("Remove row from Grid").first().click();
  70. }
  71. private void addGridRow() {
  72. $(ButtonElement.class).caption("Add row to Grid").first().click();
  73. }
  74. private void addCellStyleGenerator() {
  75. $(ButtonElement.class).caption("Add CellStyleGenerator").first()
  76. .click();
  77. }
  78. private GridElement getGridElement() {
  79. return $(GridElement.class).first();
  80. }
  81. }