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.

CustomLayoutDeclarativeTest.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.vaadin.tests.server.component.customlayout;
  2. import org.junit.Test;
  3. import com.vaadin.tests.design.DeclarativeTestBase;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.CustomLayout;
  6. import com.vaadin.ui.Label;
  7. /**
  8. * Tests declarative support for {@link CustomLayout}.
  9. *
  10. * @author Vaadin Ltd
  11. */
  12. public class CustomLayoutDeclarativeTest
  13. extends DeclarativeTestBase<CustomLayout> {
  14. @Test
  15. public void testEmpty() {
  16. String design = "<vaadin-custom-layout>";
  17. CustomLayout expected = new CustomLayout();
  18. test(design, expected);
  19. }
  20. @Test
  21. public void testWithChildren() {
  22. String design = "<vaadin-custom-layout>" + //
  23. "<vaadin-button plain-text :location='b'></vaadin-button>" + //
  24. "<vaadin-label plain-text :location='l'></vaadin-label>" + //
  25. "</vaadin-custom-layout>";
  26. CustomLayout expected = new CustomLayout();
  27. expected.addComponent(new Button(), "b");
  28. expected.addComponent(new Label(), "l");
  29. test(design, expected);
  30. }
  31. @Test
  32. public void testWithOneChild() {
  33. String design = "<vaadin-custom-layout><vaadin-button plain-text></vaadin-button></vaadin-custom-layout>";
  34. CustomLayout expected = new CustomLayout();
  35. expected.addComponent(new Button());
  36. test(design, expected);
  37. }
  38. @Test
  39. public void testWithTemplate() {
  40. String design = "<vaadin-custom-layout template-name='template.html'></vaadin-custom-layout>";
  41. CustomLayout expected = new CustomLayout("template.html");
  42. test(design, expected);
  43. }
  44. @Test
  45. public void testWithDuplicateLocations() {
  46. String design = "<vaadin-custom-layout>" + //
  47. "<vaadin-button plain-text :location='foo'></vaadin-button>" + //
  48. "<vaadin-label plain-text :location='foo'></vaadin-label>" + //
  49. "</vaadin-custom-layout>";
  50. CustomLayout expected = new CustomLayout();
  51. expected.addComponent(new Button(), "foo");
  52. expected.addComponent(new Label(), "foo");
  53. testRead(design, expected);
  54. String written = "<vaadin-custom-layout>" + //
  55. "<vaadin-label plain-text :location='foo'></vaadin-label>" + //
  56. "</vaadin-custom-layout>";
  57. testWrite(written, expected);
  58. }
  59. protected void test(String design, CustomLayout expected) {
  60. testRead(design, expected);
  61. testWrite(design, expected);
  62. }
  63. }