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.

ComboBoxDeclarativeTest.java 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.vaadin.v7.tests.server.component.combobox;
  2. import org.junit.Test;
  3. import com.vaadin.tests.design.DeclarativeTestBase;
  4. import com.vaadin.v7.shared.ui.combobox.FilteringMode;
  5. import com.vaadin.v7.ui.ComboBox;
  6. public class ComboBoxDeclarativeTest extends DeclarativeTestBase<ComboBox> {
  7. @Test
  8. public void testReadOnlyWithOptionsRead() {
  9. testRead(getReadOnlyWithOptionsDesign(),
  10. getReadOnlyWithOptionsExpected());
  11. }
  12. private ComboBox getReadOnlyWithOptionsExpected() {
  13. ComboBox cb = new ComboBox();
  14. cb.setTextInputAllowed(false);
  15. cb.addItem("Hello");
  16. cb.addItem("World");
  17. return cb;
  18. }
  19. private String getReadOnlyWithOptionsDesign() {
  20. return "<vaadin7-combo-box text-input-allowed='false'><option>Hello</option><option>World</option></vaadin7-combo-box>";
  21. }
  22. @Test
  23. public void testReadOnlyWithOptionsWrite() {
  24. testWrite(stripOptionTags(getReadOnlyWithOptionsDesign()),
  25. getReadOnlyWithOptionsExpected());
  26. }
  27. @Test
  28. public void testBasicRead() {
  29. testRead(getBasicDesign(), getBasicExpected());
  30. }
  31. @Test
  32. public void testBasicWrite() {
  33. testWrite(getBasicDesign(), getBasicExpected());
  34. }
  35. @Test
  36. public void testReadOnlyValue() {
  37. String design = "<vaadin7-combo-box readonly value='foo'><option selected>foo</option></vaadin7-combo-box>";
  38. ComboBox comboBox = new ComboBox();
  39. comboBox.addItems("foo", "bar");
  40. comboBox.setValue("foo");
  41. comboBox.setReadOnly(true);
  42. testRead(design, comboBox);
  43. // Selects items are not written out by default
  44. String design2 = "<vaadin7-combo-box readonly></vaadin7-combo-box>";
  45. testWrite(design2, comboBox);
  46. }
  47. private String getBasicDesign() {
  48. return "<vaadin7-combo-box input-prompt=\"Select something\" filtering-mode=\"off\" scroll-to-selected-item='false'>";
  49. }
  50. private ComboBox getBasicExpected() {
  51. ComboBox cb = new ComboBox();
  52. cb.setInputPrompt("Select something");
  53. cb.setTextInputAllowed(true);
  54. cb.setFilteringMode(FilteringMode.OFF);
  55. cb.setScrollToSelectedItem(false);
  56. return cb;
  57. }
  58. }