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

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