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.

GridWidthIncreaseTest.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 static org.junit.Assert.assertEquals;
  18. import java.io.IOException;
  19. import org.junit.Test;
  20. import org.openqa.selenium.remote.DesiredCapabilities;
  21. import com.vaadin.testbench.elements.ButtonElement;
  22. import com.vaadin.testbench.elements.GridElement;
  23. import com.vaadin.testbench.parallel.BrowserUtil;
  24. import com.vaadin.testbench.parallel.TestCategory;
  25. import com.vaadin.tests.tb3.MultiBrowserTest;
  26. @TestCategory("grid")
  27. public class GridWidthIncreaseTest extends MultiBrowserTest {
  28. private static int INCREASE_COUNT = 3;
  29. @Test
  30. public void testColumnsExpandWithGrid() throws IOException {
  31. openTestURL();
  32. GridElement grid = $(LegacyGridElement.class).first();
  33. double accuracy = 1.0d;
  34. DesiredCapabilities cap = getDesiredCapabilities();
  35. if (BrowserUtil.isIE(cap, 8) || BrowserUtil.isIE(cap, 9)
  36. || BrowserUtil.isPhantomJS(cap)) {
  37. accuracy = 2.0d;
  38. }
  39. for (int i = 0; i < INCREASE_COUNT; ++i) {
  40. $(ButtonElement.class).first().click();
  41. int prevWidth = 0;
  42. for (int c = 0; c < GridWidthIncrease.COLUMN_COUNT; ++c) {
  43. int width = grid.getCell(0, c).getSize().getWidth();
  44. if (c > 0) {
  45. // check that columns are roughly the same width.
  46. assertEquals("Difference in column widths", prevWidth,
  47. width, accuracy);
  48. }
  49. prevWidth = width;
  50. }
  51. /*
  52. * Column widths should be the same as table wrapper size. Since
  53. * Selenium doesn't support subpixels correctly, we use a rough
  54. * estimation.
  55. */
  56. assertEquals(grid.getRow(0).getSize().getWidth(),
  57. grid.getTableWrapper().getSize().getWidth(), accuracy);
  58. }
  59. }
  60. }