@Test
  public void testFiresPresentationChangeToFullScreen() {
    environment.getRemoteObject().setHandler(new VideoOperationHandler(video));
    video.addPresentationListener(presentationListener);
    JsonObject parameters = new JsonObject();
    parameters.add(PROPERTY_PRESENTATION, Presentation.FULL_SCREEN.name());

    environment.dispatchNotify(Constants.EVENT_PRESENTATION, parameters);

    verify(presentationListener).presentationChanged(Presentation.FULL_SCREEN);
  }
  @Test
  public void testFiresPlaybackChange() {
    environment.getRemoteObject().setHandler(new VideoOperationHandler(video));
    video.addPlaybackListener(playbackListener);
    JsonObject parameters = new JsonObject();
    parameters.add(PROPERTY_PLAYBACK, Playback.ERROR.name());

    environment.dispatchNotify(Constants.EVENT_PLAYBACK, parameters);

    verify(playbackListener).playbackChanged(Playback.ERROR);
  }
  @Test
  public void testRendersPlaybackPlayOnce() {
    environment.getRemoteObject().setHandler(new VideoOperationHandler(video));
    video.addPlaybackListener(playbackListener);
    environment.newRequest();
    JsonObject parameters = new JsonObject();
    parameters.add(PROPERTY_PLAYBACK, Playback.PLAY.name());

    environment.dispatchNotify(Constants.EVENT_PLAYBACK, parameters);

    verify(playbackListener).playbackChanged(Playback.PLAY);
    assertFalse(hasOperation(WidgetUtil.getId(video), SET, null));
  }
  @Test
  public void testDoesNotSetTextReplacementWithWebClient() {
    environment.setClient(mock(WebClient.class));
    TextReplacementData data = mock(TextReplacementData.class);
    when(data.getId()).thenReturn("r42");

    decorator.setTextReplacement(data);

    verify(text, never()).setData(TEXT_REPLACEMENT.getKey(), "r42");
  }
 @Before
 public void setUp() {
   Display display = new Display();
   parent = new Shell(display);
   video = new Video("http://test.com", parent);
   playbackListener = mock(PlaybackListener.class);
   presentationListener = mock(PresentationListener.class);
   new Button(parent, SWT.PUSH);
   lifeCycleAdapter = (AbstractWidgetLCA) video.getAdapter(WidgetLifeCycleAdapter.class);
   environment.newRequest();
 }
  @Test
  public void testActivatesItemOnlyIfDifferentFromClientItem() {
    SwipeItemProvider itemProvider = mockProvider(2);
    mockSwipeItem(itemProvider, 0, true);
    mockSwipeItem(itemProvider, 1, true);
    Swipe swipe = new Swipe(shell, itemProvider);
    swipe.show(0);
    JsonObject properties = new JsonObject();
    properties.add("item", 1);

    environment.dispatchNotify("Swipe", properties);

    verify(remoteObject, times(1)).set("active", 0);
    verify(remoteObject, never()).set("active", 1);
  }
 @Before
 public void setUp() {
   shell = new Shell(new Display());
   remoteObject = environment.getRemoteObject();
 }