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.

NativeSelectTest.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.vaadin.v7.ui;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertNotNull;
  4. import java.util.Collections;
  5. import org.junit.Test;
  6. import com.vaadin.v7.data.util.IndexedContainer;
  7. import com.vaadin.v7.shared.ui.select.AbstractSelectState;
  8. public class NativeSelectTest {
  9. @Test
  10. public void rpcRegisteredConstructorNoArg() {
  11. assertFocusRpcRegistered(new NativeSelect());
  12. }
  13. @Test
  14. public void rpcRegisteredConstructorString() {
  15. assertFocusRpcRegistered(new NativeSelect("foo"));
  16. }
  17. @Test
  18. public void rpcRegisteredConstructorStringCollection() {
  19. assertFocusRpcRegistered(
  20. new NativeSelect("foo", Collections.singleton("Hello")));
  21. }
  22. @Test
  23. public void rpcRegisteredConstructorStringContainer() {
  24. assertFocusRpcRegistered(
  25. new NativeSelect("foo", new IndexedContainer()));
  26. }
  27. @Test
  28. public void getState_listSelectHasCustomState() {
  29. TestNativeSelect select = new TestNativeSelect();
  30. AbstractSelectState state = select.getState();
  31. assertEquals("Unexpected state class", AbstractSelectState.class,
  32. state.getClass());
  33. }
  34. private static class TestNativeSelect extends NativeSelect {
  35. @Override
  36. public AbstractSelectState getState() {
  37. return super.getState();
  38. }
  39. }
  40. private void assertFocusRpcRegistered(NativeSelect s) {
  41. assertNotNull("RPC is not correctly registered", s.getRpcManager(
  42. "com.vaadin.shared.communication.FieldRpc$FocusAndBlurServerRpc"));
  43. }
  44. }