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.

RichTextAreaDelegateToShortcutHandlerTest.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.vaadin.tests.components.richtextarea;
  2. import java.util.List;
  3. import com.vaadin.testbench.elements.RichTextAreaElement;
  4. import com.vaadin.tests.tb3.MultiBrowserTest;
  5. import org.junit.Test;
  6. import org.openqa.selenium.Keys;
  7. import org.openqa.selenium.WebElement;
  8. import org.openqa.selenium.remote.DesiredCapabilities;
  9. import static org.hamcrest.Matchers.containsString;
  10. import static org.junit.Assert.assertThat;
  11. public class RichTextAreaDelegateToShortcutHandlerTest extends MultiBrowserTest {
  12. @Override
  13. public List<DesiredCapabilities> getBrowsersToTest() {
  14. return getBrowsersExcludingPhantomJS();
  15. }
  16. @Test
  17. public void shouldDelegateToShortcutActionHandler() {
  18. openTestURL();
  19. WebElement textAreaEditor = $(RichTextAreaElement.class).first().getEditorIframe();
  20. textAreaEditor.sendKeys("Test");
  21. textAreaEditor.sendKeys(Keys.ENTER);
  22. assertThat("Shortcut handler has not been invoked",
  23. getLogRow(0), containsString("ShortcutHandler invoked Test"));
  24. textAreaEditor.sendKeys(Keys.chord(Keys.SHIFT, Keys.ENTER));
  25. textAreaEditor.sendKeys("another row");
  26. textAreaEditor.sendKeys(Keys.ENTER);
  27. assertThat("Shortcut handler has not been invoked",
  28. getLogRow(0), containsString("ShortcutHandler invoked Test\nanother row"));
  29. }
  30. }