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.

TextAreaEventPropagationModifierKeysTest.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.ui;
  17. import java.util.List;
  18. import org.junit.Assert;
  19. import org.junit.Test;
  20. import org.openqa.selenium.Keys;
  21. import org.openqa.selenium.WebElement;
  22. import org.openqa.selenium.interactions.Actions;
  23. import org.openqa.selenium.remote.DesiredCapabilities;
  24. import com.vaadin.testbench.elements.TextAreaElement;
  25. import com.vaadin.testbench.parallel.Browser;
  26. import com.vaadin.tests.tb3.MultiBrowserTest;
  27. public class TextAreaEventPropagationModifierKeysTest extends MultiBrowserTest {
  28. @Test
  29. public void textAreaShiftEnterEventPropagation()
  30. throws InterruptedException {
  31. openTestURL();
  32. WebElement textArea = $(TextAreaElement.class).first();
  33. Actions builder = new Actions(driver);
  34. builder.click(textArea);
  35. builder.sendKeys(textArea, "first line asdf");
  36. builder.keyDown(Keys.SHIFT);
  37. builder.sendKeys(Keys.ENTER);
  38. builder.keyUp(Keys.SHIFT);
  39. builder.sendKeys(textArea, "second line jkl;");
  40. builder.perform();
  41. // Should have triggered shortcut
  42. Assert.assertEquals("1. Shift-Enter button pressed", getLogRow(0));
  43. }
  44. @Test
  45. public void textAreaCtrlEnterEventPropagation() throws InterruptedException {
  46. openTestURL();
  47. WebElement textArea = $(TextAreaElement.class).first();
  48. Actions builder = new Actions(driver);
  49. builder.click(textArea);
  50. builder.sendKeys(textArea, "first line asdf");
  51. builder.keyDown(Keys.CONTROL);
  52. builder.sendKeys(Keys.ENTER);
  53. builder.keyUp(Keys.CONTROL);
  54. builder.sendKeys(textArea, "second line jkl;");
  55. builder.perform();
  56. // Should have triggered shortcut
  57. Assert.assertEquals("1. Ctrl-Enter button pressed", getLogRow(0));
  58. }
  59. @Override
  60. public List<DesiredCapabilities> getBrowsersToTest() {
  61. // IE8 and Firefox can't handle ctrl.
  62. // IE9-11 has issues with shift and ctrl
  63. return getBrowserCapabilities(Browser.CHROME, Browser.PHANTOMJS);
  64. }
  65. @Override
  66. protected Class<?> getUIClass() {
  67. return TextAreaEventPropagation.class;
  68. }
  69. }