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.

HeaderClickTest.java 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.table;
  17. import static org.junit.Assert.assertEquals;
  18. import java.io.IOException;
  19. import org.junit.Test;
  20. import com.vaadin.testbench.TestBenchElement;
  21. import com.vaadin.testbench.elements.CheckBoxElement;
  22. import com.vaadin.testbench.elements.TableElement;
  23. import com.vaadin.testbench.elements.TextFieldElement;
  24. import com.vaadin.tests.tb3.MultiBrowserTest;
  25. /**
  26. * Tests Table Footer ClickListener
  27. *
  28. * @since
  29. * @author Vaadin Ltd
  30. */
  31. public class HeaderClickTest extends MultiBrowserTest {
  32. @Test
  33. public void testFooter() throws IOException {
  34. openTestURL();
  35. TableElement table = $(TableElement.class).first();
  36. TestBenchElement header0 = table.getHeaderCell(0);
  37. header0.click();
  38. TextFieldElement tf = $(TextFieldElement.class).first();
  39. assertEquals("col1", tf.getValue());
  40. table = $(TableElement.class).first();
  41. TestBenchElement header1 = table.getHeaderCell(1);
  42. header1.click();
  43. tf = $(TextFieldElement.class).first();
  44. assertEquals("col2", tf.getValue());
  45. table = $(TableElement.class).first();
  46. TestBenchElement header2 = table.getHeaderCell(2);
  47. header2.click();
  48. tf = $(TextFieldElement.class).first();
  49. assertEquals("col3", tf.getValue());
  50. CheckBoxElement cb = $(CheckBoxElement.class).first();
  51. cb.click();
  52. table = $(TableElement.class).first();
  53. header0 = table.getHeaderCell(0);
  54. header0.click();
  55. tf = $(TextFieldElement.class).first();
  56. assertEquals("col1", tf.getValue());
  57. table = $(TableElement.class).first();
  58. header1 = table.getHeaderCell(1);
  59. header1.click();
  60. tf = $(TextFieldElement.class).first();
  61. assertEquals("col2", tf.getValue());
  62. table = $(TableElement.class).first();
  63. header2 = table.getHeaderCell(2);
  64. header2.click();
  65. tf = $(TextFieldElement.class).first();
  66. assertEquals("col3", tf.getValue());
  67. cb = $(CheckBoxElement.class).get(1);
  68. cb.click();
  69. table = $(TableElement.class).first();
  70. header0 = table.getHeaderCell(0);
  71. header0.click();
  72. tf = $(TextFieldElement.class).first();
  73. assertEquals("col1", tf.getValue());
  74. table = $(TableElement.class).first();
  75. header1 = table.getHeaderCell(1);
  76. header1.click();
  77. tf = $(TextFieldElement.class).first();
  78. assertEquals("col2", tf.getValue());
  79. table = $(TableElement.class).first();
  80. header2 = table.getHeaderCell(2);
  81. header2.click();
  82. tf = $(TextFieldElement.class).first();
  83. assertEquals("col3", tf.getValue());
  84. cb = $(CheckBoxElement.class).get(2);
  85. cb.click();
  86. table = $(TableElement.class).first();
  87. header0 = table.getHeaderCell(0);
  88. header0.click();
  89. tf = $(TextFieldElement.class).first();
  90. assertEquals("col1", tf.getValue());
  91. table = $(TableElement.class).first();
  92. header1 = table.getHeaderCell(1);
  93. header1.click();
  94. tf = $(TextFieldElement.class).first();
  95. assertEquals("col2", tf.getValue());
  96. table = $(TableElement.class).first();
  97. header2 = table.getHeaderCell(2);
  98. header2.click();
  99. tf = $(TextFieldElement.class).first();
  100. assertEquals("col3", tf.getValue());
  101. cb = $(CheckBoxElement.class).get(2);
  102. cb.click();
  103. tf = $(TextFieldElement.class).first();
  104. assertEquals("col3", tf.getValue());
  105. }
  106. }