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.

Labels.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package com.vaadin.tests.components.label;
  2. import com.vaadin.shared.ui.ContentMode;
  3. import com.vaadin.tests.components.ComponentTestCase;
  4. import com.vaadin.tests.util.LoremIpsum;
  5. import com.vaadin.ui.Label;
  6. public class Labels extends ComponentTestCase<Label> {
  7. @Override
  8. protected Class<Label> getTestClass() {
  9. return Label.class;
  10. }
  11. @Override
  12. protected void initializeComponents() {
  13. Label l;
  14. l = createLabel(
  15. "This is an undefined\nwide\nlabel which do not wrap. It should be clipped at the end of the screen"
  16. + LoremIpsum.get(1000));
  17. l.setWidth(null);
  18. addTestComponent(l);
  19. l = createLabel("This is a 200px wide simple label which\n\n\nwrap");
  20. l.setWidth("200px");
  21. addTestComponent(l);
  22. l = createLabel("This is a 100% wide simple label which should wrap. "
  23. + LoremIpsum.get(1500));
  24. l.setWidth("100%");
  25. addTestComponent(l);
  26. l = createLabel(
  27. "This is a\n\n 100%\t\t\t \twide simple with fixed 65px height. It should wrap. "
  28. + LoremIpsum.get(5000));
  29. l.setWidth("100%");
  30. l.setHeight("65px");
  31. addTestComponent(l);
  32. l = createLabel(
  33. "<div style='border: 1px solid red'><h1>Hello\n\n\n</h1><p/><h2>I am a rich Label</h3></div>",
  34. "This is an XHTML label with rich content");
  35. l.setContentMode(ContentMode.HTML);
  36. addTestComponent(l);
  37. l = createLabel(
  38. "<div style='border: 1px solid blue'><h1>Hello</h1><p/><h2>I am a rich Label</h3></div>",
  39. "This is an XHTML label with fixed 200px width and rich content");
  40. l.setContentMode(ContentMode.HTML);
  41. l.setWidth("200px");
  42. addTestComponent(l);
  43. l = createLabel("Some UTF8 characters: äöÄÖ≤≠∉Ġå2²");
  44. addTestComponent(l);
  45. }
  46. private Label createLabel(String text, String caption) {
  47. Label l = new Label(text);
  48. l.setCaption(caption);
  49. return l;
  50. }
  51. private Label createLabel(String text) {
  52. return createLabel(text, null);
  53. }
  54. @Override
  55. protected String getTestDescription() {
  56. return "A generic test for Labels in different configurations";
  57. }
  58. }