コード例 #1
0
  @Test
  public void testCreatesWidget() throws IOException {
    lifeCycleAdapter.renderInitialization(video);

    assertTrue(MessageUtil.hasCreateOperation("tabris.widgets.Video"));
    JsonObject properties =
        MessageUtil.getOperationProperties(WidgetUtil.getId(video), CREATE, null);
    assertEquals(video.getURL().toString(), properties.get(Constants.PROPERTY_URL).asString());
  }
コード例 #2
0
  @Test
  public void testRendersHeadPointer() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.stepToTime(23);
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties = MessageUtil.getOperationProperties(WidgetUtil.getId(video), SET, null);
    assertEquals(23, properties.get(keyForEnum(PlaybackOptions.HEAD_POSITION)).asInt());
  }
コード例 #3
0
  @Test
  public void testRendersRepeat() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.setRepeat(true);
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties = MessageUtil.getOperationProperties(WidgetUtil.getId(video), SET, null);
    assertTrue(properties.get(keyForEnum(PlaybackOptions.REPEAT)).asBoolean());
  }
コード例 #4
0
  @Test
  public void testRendersControlsVisible() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.setPlayerControlsVisible(false);
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties = MessageUtil.getOperationProperties(WidgetUtil.getId(video), SET, null);
    assertFalse(properties.get(keyForEnum(PlaybackOptions.CONTROLS_VISIBLE)).asBoolean());
  }
コード例 #5
0
  @Test
  public void testRendersSpeedBackward() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.fastBackward(-2);
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties = MessageUtil.getOperationProperties(WidgetUtil.getId(video), SET, null);
    assertEquals(-2, properties.get(keyForEnum(PlaybackOptions.SPEED)).asDouble(), 0);
  }
コード例 #6
0
 @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();
 }
コード例 #7
0
  @Test
  public void testRendersPresentationListener() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.addPresentationListener(presentationListener);
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties =
        MessageUtil.getOperationProperties(WidgetUtil.getId(video), LISTEN, null);
    assertNotNull(properties.get(Constants.EVENT_PRESENTATION));
  }
コード例 #8
0
  @Test
  public void testRendersPlaybackMode() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.play();
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties = MessageUtil.getOperationProperties(WidgetUtil.getId(video), SET, null);
    assertEquals(
        keyForEnum(Playback.PLAY), properties.get(keyForEnum(PlaybackOptions.PLAYBACK)).asString());
  }
コード例 #9
0
  @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);
  }
コード例 #10
0
  @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);
  }
コード例 #11
0
  @Test
  public void testRendersPresentationMode() throws IOException {
    lifeCycleAdapter.preserveValues(video);

    video.setFullscreen(true);
    lifeCycleAdapter.renderChanges(video);

    JsonObject properties = MessageUtil.getOperationProperties(WidgetUtil.getId(video), SET, null);
    assertEquals(
        keyForEnum(Presentation.FULL_SCREEN),
        properties.get(keyForEnum(PlaybackOptions.PRESENTATION)).asString());
  }
コード例 #12
0
  @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));
  }
コード例 #13
0
  @Test
  public void testCreatesParent() throws IOException {
    lifeCycleAdapter.renderInitialization(video);

    assertTrue(isParentOfCreate("tabris.widgets.Video", WidgetUtil.getId(video.getParent())));
  }