Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

GridLayoutDetailsRowTest.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.hamcrest.MatcherAssert.assertThat;
  18. import static org.hamcrest.number.IsCloseTo.closeTo;
  19. import org.junit.Test;
  20. import org.openqa.selenium.By;
  21. import com.vaadin.testbench.elements.GridElement;
  22. import com.vaadin.testbench.elements.GridLayoutElement;
  23. import com.vaadin.testbench.elements.LabelElement;
  24. import com.vaadin.testbench.parallel.TestCategory;
  25. import com.vaadin.tests.tb3.MultiBrowserTest;
  26. /**
  27. * Tests that details row displays GridLayout contents properly.
  28. *
  29. * @author Vaadin Ltd
  30. */
  31. @TestCategory("grid")
  32. public class GridLayoutDetailsRowTest extends MultiBrowserTest {
  33. @Test
  34. public void testLabelHeights() {
  35. openTestURL();
  36. waitForElementPresent(By.className("v-grid"));
  37. GridElement grid = $(GridElement.class).first();
  38. grid.getRow(2).click(5, 5);
  39. waitForElementPresent(By.id("lbl2"));
  40. GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
  41. int gridLayoutHeight = gridLayout.getSize().height;
  42. // height should be divided equally
  43. double expectedHeight = gridLayoutHeight / 4;
  44. assertLabelHeight("lbl1", expectedHeight);
  45. assertLabelHeight("lbl2", expectedHeight);
  46. assertLabelHeight("lbl3", expectedHeight);
  47. assertLabelHeight("lbl4", expectedHeight);
  48. }
  49. private void assertLabelHeight(String id, double expectedHeight) {
  50. // 1px leeway for calculations
  51. assertThat("Unexpected label height.", (double) $(LabelElement.class)
  52. .id(id).getSize().height, closeTo(expectedHeight, 1d));
  53. }
  54. }