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.

CompatibilityElementComponentGetCaptionBaseTest.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package com.vaadin.tests.elements;
  2. import org.junit.Assert;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. import com.vaadin.testbench.elements.AbstractComponentElement;
  6. import com.vaadin.testbench.elements.AbstractLayoutElement;
  7. import com.vaadin.testbench.elements.CheckBoxElement;
  8. import com.vaadin.testbench.elements.ColorPickerElement;
  9. import com.vaadin.testbench.elements.ComboBoxElement;
  10. import com.vaadin.testbench.elements.DateFieldElement;
  11. import com.vaadin.testbench.elements.ListSelectElement;
  12. import com.vaadin.testbench.elements.OptionGroupElement;
  13. import com.vaadin.testbench.elements.TableElement;
  14. import com.vaadin.testbench.elements.TextAreaElement;
  15. import com.vaadin.testbench.elements.TextFieldElement;
  16. import com.vaadin.testbench.elements.TreeElement;
  17. import com.vaadin.testbench.elements.TreeTableElement;
  18. import com.vaadin.testbench.elements.TwinColSelectElement;
  19. import com.vaadin.tests.tb3.MultiBrowserTest;
  20. /*
  21. * Copyright 2000-2014 Vaadin Ltd.
  22. *
  23. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  24. * use this file except in compliance with the License. You may obtain a copy of
  25. * the License at
  26. *
  27. * http://www.apache.org/licenses/LICENSE-2.0
  28. *
  29. * Unless required by applicable law or agreed to in writing, software
  30. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  31. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  32. * License for the specific language governing permissions and limitations under
  33. * the License.
  34. */
  35. /**
  36. *
  37. * Test class which have test methods for all components added in the testUI
  38. * class. Open TestURL is called only once before tests. Parent class should
  39. * override protected Class<?> getUIClass() to specify which testUI should be
  40. * used
  41. */
  42. public abstract class CompatibilityElementComponentGetCaptionBaseTest
  43. extends MultiBrowserTest {
  44. AbstractLayoutElement mainLayout;
  45. @Before
  46. public void init() {
  47. openTestURL();
  48. }
  49. @Test
  50. public void getComboboxCaptionTest() {
  51. ComboBoxElement elem = mainLayout.$(ComboBoxElement.class).get(0);
  52. testCaption(elem, 0);
  53. }
  54. @Test
  55. public void getTableCaptionTest() {
  56. TableElement elem = mainLayout.$(TableElement.class).get(0);
  57. testCaption(elem, 1);
  58. }
  59. @Test
  60. public void getTreeTableCaptionTest() {
  61. TreeTableElement elem = mainLayout.$(TreeTableElement.class).get(0);
  62. testCaption(elem, 2);
  63. }
  64. @Test
  65. public void getTreeCaptionTest() {
  66. TreeElement elem = mainLayout.$(TreeElement.class).get(0);
  67. testCaption(elem, 3);
  68. }
  69. @Test
  70. public void getTwinColSelectCaptionTest() {
  71. TwinColSelectElement elem = mainLayout.$(TwinColSelectElement.class)
  72. .get(0);
  73. testCaption(elem, 4);
  74. }
  75. @Test
  76. public void getOptionGroupCaptionTest() {
  77. OptionGroupElement elem = mainLayout.$(OptionGroupElement.class).get(0);
  78. testCaption(elem, 5);
  79. }
  80. @Test
  81. public void getListSelectCaptionTest() {
  82. ListSelectElement elem = mainLayout.$(ListSelectElement.class).get(0);
  83. testCaption(elem, 6);
  84. }
  85. @Test
  86. public void getColorPickerCaptionTest() {
  87. ColorPickerElement elem = mainLayout.$(ColorPickerElement.class).get(0);
  88. testCaption(elem, 7);
  89. }
  90. @Test
  91. public void getCheckBoxCaptionTest() {
  92. CheckBoxElement elem = mainLayout.$(CheckBoxElement.class).get(0);
  93. testCaption(elem, 8);
  94. }
  95. @Test
  96. public void getTextFieldCaptionTest() {
  97. TextFieldElement elem = mainLayout.$(TextFieldElement.class).get(0);
  98. testCaption(elem, 9);
  99. }
  100. @Test
  101. public void getTextAreaCaptionTest() {
  102. TextAreaElement elem = mainLayout.$(TextAreaElement.class).get(0);
  103. testCaption(elem, 10);
  104. }
  105. @Test
  106. public void getDateFieldCaptionTest() {
  107. DateFieldElement elem = mainLayout.$(DateFieldElement.class).get(0);
  108. testCaption(elem, 11);
  109. }
  110. private void testCaption(AbstractComponentElement elem, int caption_index) {
  111. String actual = elem.getCaption();
  112. String expected = CompatibilityElementComponentGetCaptionBase.DEFAULT_CAPTIONS[caption_index];
  113. Assert.assertTrue("Error with class:" + elem.getAttribute("class"),
  114. expected.equals(actual));
  115. }
  116. }