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.

LabelTest.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.vaadin.tests.components.label;
  2. import java.util.ArrayList;
  3. import java.util.LinkedHashMap;
  4. import java.util.List;
  5. import com.vaadin.shared.ui.ContentMode;
  6. import com.vaadin.tests.components.AbstractComponentTest;
  7. import com.vaadin.ui.Label;
  8. public class LabelTest extends AbstractComponentTest<Label> {
  9. private Command<Label, String> setValueCommand = new Command<Label, String>() {
  10. @Override
  11. public void execute(Label c, String value, Object data) {
  12. c.setValue(value);
  13. }
  14. };
  15. private Command<Label, ContentMode> contentModeCommand = new Command<Label, ContentMode>() {
  16. @Override
  17. public void execute(Label c, ContentMode value, Object data) {
  18. c.setContentMode(value);
  19. }
  20. };
  21. @Override
  22. protected Class<Label> getTestClass() {
  23. return Label.class;
  24. }
  25. @Override
  26. protected void createActions() {
  27. super.createActions();
  28. createContentModeSelect(CATEGORY_FEATURES);
  29. createValueSelect(CATEGORY_FEATURES);
  30. }
  31. private void createValueSelect(String category) {
  32. String subCategory = "Set text value";
  33. createCategory(subCategory, category);
  34. List<String> values = new ArrayList<>();
  35. values.add("Test");
  36. values.add("A little longer value");
  37. values.add(
  38. "A very long value with very much text. All in all it is 74 characters long");
  39. values.add("<b>Bold</b>");
  40. values.add(
  41. "<div style=\"height: 70px; width: 15px; border: 1px dashed red\">With border</div>");
  42. createClickAction("(empty string)", subCategory, setValueCommand, "");
  43. createClickAction("(null)", subCategory, setValueCommand, null);
  44. for (String value : values) {
  45. createClickAction(value, subCategory, setValueCommand, value);
  46. }
  47. }
  48. @SuppressWarnings("deprecation")
  49. private void createContentModeSelect(String category) {
  50. LinkedHashMap<String, ContentMode> options = new LinkedHashMap<>();
  51. options.put("Text", ContentMode.TEXT);
  52. options.put("Preformatted", ContentMode.PREFORMATTED);
  53. options.put("XHTML", ContentMode.HTML);
  54. createSelectAction("Content mode", category, options, "Text",
  55. contentModeCommand);
  56. }
  57. }