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.

TextAreaDeclarativeTest.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.v7.tests.server.component.textarea;
  17. import java.io.IOException;
  18. import org.jsoup.nodes.Element;
  19. import org.jsoup.parser.Tag;
  20. import org.junit.Test;
  21. import com.vaadin.tests.design.DeclarativeTestBase;
  22. import com.vaadin.ui.declarative.DesignContext;
  23. import com.vaadin.v7.ui.TextArea;
  24. /**
  25. * Tests declarative support for implementations of {@link TextArea}.
  26. *
  27. * @since 7.4
  28. * @author Vaadin Ltd
  29. */
  30. public class TextAreaDeclarativeTest extends DeclarativeTestBase<TextArea> {
  31. @Test
  32. public void testTextArea() {
  33. String design = "<vaadin7-text-area rows=6 wordwrap=false>Hello World!</vaadin7-text-area>";
  34. TextArea ta = new TextArea();
  35. ta.setRows(6);
  36. ta.setWordwrap(false);
  37. ta.setValue("Hello World!");
  38. testRead(design, ta);
  39. testWrite(design, ta);
  40. }
  41. @Test
  42. public void testHtmlEntities() throws IOException {
  43. String design = "<vaadin7-text-area>&amp; Test</vaadin7-text-area>";
  44. TextArea read = read(design);
  45. assertEquals("& Test", read.getValue());
  46. read.setValue("&amp; Test");
  47. DesignContext dc = new DesignContext();
  48. Element root = new Element(Tag.valueOf("vaadin-text-area"), "");
  49. read.writeDesign(root, dc);
  50. assertEquals("&amp;amp; Test", root.html());
  51. }
  52. @Test
  53. public void testReadOnlyValue() {
  54. String design = "<vaadin7-text-area readonly rows=6 wordwrap=false>Hello World!</vaadin7-text-area>";
  55. TextArea ta = new TextArea();
  56. ta.setRows(6);
  57. ta.setWordwrap(false);
  58. ta.setValue("Hello World!");
  59. ta.setReadOnly(true);
  60. testRead(design, ta);
  61. testWrite(design, ta);
  62. }
  63. }