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.

ListSelectStyleNamesTest.java 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.components.listselect;
  17. import java.util.Arrays;
  18. import java.util.HashSet;
  19. import org.junit.Assert;
  20. import org.junit.Test;
  21. import org.openqa.selenium.By;
  22. import com.vaadin.testbench.TestBenchElement;
  23. import com.vaadin.testbench.elements.ButtonElement;
  24. import com.vaadin.testbench.elements.ListSelectElement;
  25. import com.vaadin.testbench.elements.NativeSelectElement;
  26. import com.vaadin.tests.tb3.SingleBrowserTest;
  27. public class ListSelectStyleNamesTest extends SingleBrowserTest {
  28. private NativeSelectElement nativeSelect;
  29. private TestBenchElement nativeSelectSelect;
  30. private ListSelectElement listSelect;
  31. private TestBenchElement listSelectSelect;
  32. @Override
  33. public void setup() throws Exception {
  34. super.setup();
  35. openTestURL();
  36. nativeSelect = $(NativeSelectElement.class).first();
  37. nativeSelectSelect = (TestBenchElement) nativeSelect
  38. .findElement(By.xpath("select"));
  39. listSelect = $(ListSelectElement.class).first();
  40. listSelectSelect = (TestBenchElement) listSelect
  41. .findElement(By.xpath("select"));
  42. }
  43. @Test
  44. public void correctInitialStyleNames() {
  45. assertStyleNames(nativeSelect, "v-select", "v-widget", "custominitial",
  46. "v-select-custominitial");
  47. assertStyleNames(nativeSelectSelect, "v-select-select");
  48. assertStyleNames(listSelect, "v-select", "v-widget", "custominitial",
  49. "v-select-custominitial");
  50. assertStyleNames(listSelectSelect, "v-select-select");
  51. }
  52. @Test
  53. public void addStyleName() {
  54. $(ButtonElement.class).id("add").click();
  55. assertStyleNames(nativeSelect, "v-select", "v-widget", "custominitial",
  56. "v-select-custominitial", "new", "v-select-new");
  57. assertStyleNames(nativeSelectSelect, "v-select-select");
  58. assertStyleNames(listSelect, "v-select", "v-widget", "custominitial",
  59. "v-select-custominitial", "new", "v-select-new");
  60. assertStyleNames(listSelectSelect, "v-select-select");
  61. }
  62. @Test
  63. public void changePrimaryStyleName() {
  64. $(ButtonElement.class).id("add").click();
  65. $(ButtonElement.class).id("changeprimary").click();
  66. assertStyleNames(nativeSelect, "newprimary", "v-widget",
  67. "custominitial", "newprimary-custominitial", "new",
  68. "newprimary-new");
  69. assertStyleNames(nativeSelectSelect, "newprimary-select");
  70. assertStyleNames(listSelect, "newprimary", "v-widget", "custominitial",
  71. "newprimary-custominitial", "new", "newprimary-new");
  72. assertStyleNames(listSelectSelect, "newprimary-select");
  73. }
  74. private void assertStyleNames(TestBenchElement element,
  75. String... styleNames) {
  76. Assert.assertEquals(new HashSet<>(Arrays.asList(styleNames)),
  77. element.getClassNames());
  78. }
  79. }