您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

GridLayoutUITest.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.elements.gridlayout;
  17. import org.junit.Assert;
  18. import org.junit.Test;
  19. import org.openqa.selenium.NoSuchElementException;
  20. import org.openqa.selenium.WebElement;
  21. import com.vaadin.testbench.elements.GridLayoutElement;
  22. import com.vaadin.tests.tb3.SingleBrowserTest;
  23. public class GridLayoutUITest extends SingleBrowserTest {
  24. @Test
  25. public void getRows() {
  26. openTestURL();
  27. Assert.assertEquals(1, $(GridLayoutElement.class)
  28. .id(GridLayoutUI.ONE_ROW_ONE_COL).getRowCount());
  29. Assert.assertEquals(10, $(GridLayoutElement.class)
  30. .id(GridLayoutUI.TEN_ROWS_TEN_COLS).getRowCount());
  31. }
  32. @Test
  33. public void getColumns() {
  34. openTestURL();
  35. Assert.assertEquals(1, $(GridLayoutElement.class)
  36. .id(GridLayoutUI.ONE_ROW_ONE_COL).getColumnCount());
  37. Assert.assertEquals(10, $(GridLayoutElement.class)
  38. .id(GridLayoutUI.TEN_ROWS_TEN_COLS).getColumnCount());
  39. }
  40. @Test
  41. public void getCell() {
  42. openTestURL();
  43. GridLayoutElement grid = $(GridLayoutElement.class)
  44. .id(GridLayoutUI.TEN_ROWS_TEN_COLS);
  45. WebElement cell55 = grid.getCell(5, 5);
  46. Assert.assertEquals("v-gridlayout-slot", cell55.getAttribute("class"));
  47. Assert.assertEquals("5-5", cell55.getText());
  48. try {
  49. grid.getCell(4, 4);
  50. Assert.fail("Should throw for empty cell");
  51. } catch (NoSuchElementException e) {
  52. }
  53. WebElement cell77 = grid.getCell(7, 7);
  54. Assert.assertEquals("v-gridlayout-slot", cell77.getAttribute("class"));
  55. Assert.assertEquals("7-7 8-8", cell77.getText());
  56. try {
  57. grid.getCell(7, 8);
  58. Assert.fail("Should throw for merged cell");
  59. } catch (NoSuchElementException e) {
  60. }
  61. }
  62. }