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.

TreeDeclarativeTest.java 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.v7.tests.server.component.tree;
  2. import org.junit.Test;
  3. import com.vaadin.server.ExternalResource;
  4. import com.vaadin.tests.design.DeclarativeTestBase;
  5. import com.vaadin.v7.ui.Tree;
  6. import com.vaadin.v7.ui.Tree.TreeDragMode;
  7. /**
  8. * Tests the declarative support for implementations of {@link Tree}.
  9. *
  10. * @since 7.4
  11. * @author Vaadin Ltd
  12. */
  13. public class TreeDeclarativeTest extends DeclarativeTestBase<Tree> {
  14. @Test
  15. public void testDragMode() {
  16. String design = "<vaadin7-tree drag-mode='node' />";
  17. Tree tree = new Tree();
  18. tree.setDragMode(TreeDragMode.NODE);
  19. testRead(design, tree);
  20. testWrite(design, tree);
  21. }
  22. @Test
  23. public void testEmpty() {
  24. testRead("<vaadin7-tree />", new Tree());
  25. testWrite("<vaadin7-tree />", new Tree());
  26. }
  27. @Test
  28. public void testNodes() {
  29. String design = "<vaadin7-tree>" //
  30. + " <node text='Node'/>" //
  31. + " <node text='Parent'>" //
  32. + " <node text='Child'>" //
  33. + " <node text='Grandchild'/>" //
  34. + " </node>" //
  35. + " </node>" //
  36. + " <node text='With icon' icon='http://example.com/icon.png'/>" //
  37. + "</vaadin7-tree>";
  38. Tree tree = new Tree();
  39. tree.addItem("Node");
  40. tree.addItem("Parent");
  41. tree.addItem("Child");
  42. tree.setParent("Child", "Parent");
  43. tree.addItem("Grandchild");
  44. tree.setParent("Grandchild", "Child");
  45. tree.addItem("With icon");
  46. tree.setItemIcon("With icon",
  47. new ExternalResource("http://example.com/icon.png"));
  48. testRead(design, tree);
  49. testWrite(design, tree, true);
  50. }
  51. }