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.

ComboBoxValueChangeTest.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.vaadin.tests.server.components;
  2. import org.junit.Before;
  3. import com.vaadin.server.ServerRpcManager;
  4. import com.vaadin.server.ServerRpcMethodInvocation;
  5. import com.vaadin.shared.ui.combobox.ComboBoxServerRpc;
  6. import com.vaadin.ui.AbstractField;
  7. import com.vaadin.ui.ComboBox;
  8. /**
  9. * Check that the value change listener for a combo box is triggered exactly
  10. * once when setting the value, at the correct time.
  11. *
  12. * See <a href="http://dev.vaadin.com/ticket/4394">Ticket 4394</a>.
  13. */
  14. public class ComboBoxValueChangeTest extends
  15. AbstractFieldValueChangeTestBase<Object> {
  16. @Before
  17. public void setUp() {
  18. ComboBox combo = new ComboBox() {
  19. @Override
  20. public String getConnectorId() {
  21. return "id";
  22. }
  23. };
  24. combo.addItem("myvalue");
  25. super.setUp(combo);
  26. }
  27. @Override
  28. protected void setValue(AbstractField<Object> field) {
  29. ComboBox combo = (ComboBox) field;
  30. ServerRpcMethodInvocation invocation = new ServerRpcMethodInvocation(
  31. combo.getConnectorId(), ComboBoxServerRpc.class,
  32. "setSelectedItem", 1);
  33. invocation.setParameters(new Object[] { "myvalue" });
  34. try {
  35. ServerRpcManager.applyInvocation(combo, invocation);
  36. } catch (Exception e) {
  37. throw new RuntimeException(e);
  38. }
  39. }
  40. }