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.

HeaderFooterClickLeftRightMiddleTest.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.hamcrest.MatcherAssert.assertThat;
  18. import java.io.IOException;
  19. import java.util.Arrays;
  20. import org.junit.Test;
  21. import org.openqa.selenium.By;
  22. import com.vaadin.testbench.elements.TableElement;
  23. import com.vaadin.tests.tb3.MultiBrowserTest;
  24. /**
  25. * Tests Table Footer ClickListener
  26. *
  27. * @since
  28. * @author Vaadin Ltd
  29. */
  30. public class HeaderFooterClickLeftRightMiddleTest extends MultiBrowserTest {
  31. @Test
  32. public void testFooter() throws IOException {
  33. openTestURL();
  34. waitForElementPresent(By.className("v-table"));
  35. TableElement table = $(TableElement.class).first();
  36. table.getHeaderCell(0).click();
  37. assertAnyLogText("1. Click on header col1 using left");
  38. table.getHeaderCell(0).contextClick();
  39. assertAnyLogText("2. Click on header col1 using right");
  40. table.getHeaderCell(0).doubleClick();
  41. assertAnyLogText("4. Double click on header col1 using left",
  42. "5. Double click on header col1 using left");
  43. table.getFooterCell(1).click();
  44. assertAnyLogText("5. Click on footer col2 using left",
  45. "6. Click on footer col2 using left");
  46. table.getFooterCell(1).contextClick();
  47. assertAnyLogText("6. Click on footer col2 using right",
  48. "7. Click on footer col2 using right");
  49. table.getFooterCell(1).doubleClick();
  50. assertAnyLogText("8. Double click on footer col2 using left",
  51. "10. Double click on footer col2 using left");
  52. }
  53. private void assertAnyLogText(String... texts) {
  54. assertThat(String.format(
  55. "Correct log text was not found, expected any of %s",
  56. Arrays.asList(texts)), logContainsAnyText(texts));
  57. }
  58. private boolean logContainsAnyText(String... texts) {
  59. for (String text : texts) {
  60. if (logContainsText(text)) {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. }