Ejemplo n.º 1
0
 private void assertLoadProperties(
     List<JsonObject> list, TestItem firstItem, TestItem secondItem) {
   JsonObject properties1 = list.get(0);
   assertEquals(0, properties1.get("index").asInt());
   assertEquals(
       WidgetUtil.getId(firstItem.getLoadedComposite()), properties1.get("control").asString());
   JsonObject properties2 = list.get(1);
   assertEquals(1, properties2.get("index").asInt());
   assertEquals(
       WidgetUtil.getId(secondItem.getLoadedComposite()), properties2.get("control").asString());
 }
Ejemplo n.º 2
0
  @Test
  public void testRenderCellToolTipText() {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);
    getRemoteObject(table).setHandler(new TableOperationHandler(table));
    createTableItems(table, 5);
    final ICellToolTipAdapter adapter = CellToolTipUtil.getAdapter(table);
    adapter.setCellToolTipProvider(
        new ICellToolTipProvider() {
          @Override
          public void getToolTipText(Item item, int columnIndex) {
            StringBuilder buffer = new StringBuilder();
            buffer.append("[");
            buffer.append(WidgetUtil.getId(item));
            buffer.append(",");
            buffer.append(columnIndex);
            buffer.append("]");
            adapter.setCellToolTipText(buffer.toString());
          }
        });

    String itemId = WidgetUtil.getId(table.getItem(2));
    fakeCellToolTipRequest(table, itemId, 0);
    Fixture.executeLifeCycleFromServerThread();

    TestMessage message = Fixture.getProtocolMessage();
    String expected = "[" + itemId + ",0]";
    assertEquals(expected, message.findSetProperty(table, "cellToolTipText").asString());
  }
Ejemplo n.º 3
0
  @Test
  public void testSetsParent() {
    SwipeItemProvider itemProvider = mockProvider(0);

    Swipe swipe = new Swipe(shell, itemProvider);

    verify(remoteObject).set("parent", WidgetUtil.getId(swipe.getControl()));
  }
Ejemplo n.º 4
0
  @Test
  public void testRenderParent() throws IOException {
    lca.renderInitialization(column);

    TestMessage message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(column);
    assertEquals(WidgetUtil.getId(column.getParent()), getParent(operation));
  }
Ejemplo n.º 5
0
 private Composite createFacade() {
   Composite facade = new Composite(composite, SWT.NONE);
   facade.setData(GROUPED_EVENT_COMPOSITE, WidgetUtil.getId(composite));
   facade.setData(RWT.CUSTOM_VARIANT, GROUPED_EVENT_COMPOSITE);
   addLayoutDataWithExclude(facade);
   layoutFacade(facade);
   addResizeListener(facade);
   return facade;
 }
  @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());
  }
Ejemplo n.º 7
0
  @Test
  public void testRenderDispose() throws IOException {
    lca.renderDispose(column);

    TestMessage message = Fixture.getProtocolMessage();
    Operation operation = message.getOperation(0);
    assertTrue(operation instanceof DestroyOperation);
    assertEquals(WidgetUtil.getId(column), operation.getTarget());
  }
  @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());
  }
Ejemplo n.º 9
0
 private Composite findFacade() {
   String compositeId = WidgetUtil.getId(composite);
   Control[] children = composite.getChildren();
   for (Control child : children) {
     if (compositeId.equals(child.getData(GROUPED_EVENT_COMPOSITE))) {
       return (Composite) child;
     }
   }
   return null;
 }
Ejemplo n.º 10
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());
  }
Ejemplo n.º 11
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());
  }
Ejemplo n.º 12
0
 @Before
 public void setUp() {
   Fixture.setUp();
   display = new Display();
   shell = new Shell(display);
   grid = new Grid(shell, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   column = new GridColumn(grid, SWT.NONE);
   lca = (GridColumnLCA) WidgetUtil.getLCA(column);
   Fixture.fakeNewRequest();
 }
Ejemplo n.º 13
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);
  }
Ejemplo n.º 14
0
  @Test
  public void testRenderContent() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    String contentId = WidgetUtil.getId(content);

    sc.setContent(content);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(contentId, message.findSetProperty(sc, "content").asString());
  }
Ejemplo n.º 15
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());
  }
Ejemplo n.º 16
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));
  }
Ejemplo n.º 17
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());
  }
Ejemplo n.º 18
0
  @Test
  public void testFiresPresentationChangeToFullScreenOnce() {
    environment.getRemoteObject().setHandler(new VideoOperationHandler(video));
    video.addPresentationListener(presentationListener);
    environment.newRequest();
    JsonObject parameters = new JsonObject();
    parameters.add(PROPERTY_PRESENTATION, Presentation.FULL_SCREEN.name());

    environment.dispatchNotify(Constants.EVENT_PRESENTATION, parameters);

    verify(presentationListener).presentationChanged(Presentation.FULL_SCREEN);
    assertFalse(hasOperation(WidgetUtil.getId(video), SET, null));
  }
Ejemplo n.º 19
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));
  }
Ejemplo n.º 20
0
 @Test
 public void testPreserveValues() {
   RemoteAdapter adapter = WidgetUtil.getAdapter(sc);
   assertEquals(null, adapter.getPreserved(PROP_SHOW_FOCUSED_CONTROL));
   hScroll.setSelection(23);
   vScroll.setSelection(42);
   sc.setShowFocusedControl(true);
   assertEquals(23, hScroll.getSelection());
   assertEquals(42, vScroll.getSelection());
   Rectangle rectangle = new Rectangle(12, 30, 20, 40);
   sc.setBounds(rectangle);
   Fixture.markInitialized(display);
   Fixture.preserveWidgets();
   assertEquals(Boolean.TRUE, adapter.getPreserved(PROP_SHOW_FOCUSED_CONTROL));
 }
Ejemplo n.º 21
0
 @Override
 public void renderInitialization(CTabFolder folder) throws IOException {
   RemoteObject remoteObject = createRemoteObject(folder, TYPE);
   remoteObject.setHandler(new CTabFolderOperationHandler(folder));
   remoteObject.set("parent", WidgetUtil.getId(folder.getParent()));
   remoteObject.set("style", createJsonArray(getStyles(folder, ALLOWED_STYLES)));
   JsonArray toolTipTexts =
       new JsonArray()
           .add(SWT.getMessage("SWT_Minimize"))
           .add(SWT.getMessage("SWT_Maximize"))
           .add(SWT.getMessage("SWT_Restore"))
           .add(SWT.getMessage("SWT_ShowList"))
           .add(SWT.getMessage("SWT_Close"));
   remoteObject.set(PROP_TOOLTIP_TEXTS, toolTipTexts);
   // Always listen for Selection and Folder.
   // Currently required for item's control visibility and bounds update.
   remoteObject.listen(PROP_SELECTION_LISTENER, true);
   // Currently required for always sending close/showList notify operations.
   remoteObject.listen(PROP_FOLDER_LISTENER, true);
 }
Ejemplo n.º 22
0
  @Test
  public void testRenderCellToolTipText_null() {
    Fixture.markInitialized(display);
    Fixture.markInitialized(table);
    getRemoteObject(table).setHandler(new TableOperationHandler(table));
    createTableItems(table, 5);
    final ICellToolTipAdapter adapter = CellToolTipUtil.getAdapter(table);
    adapter.setCellToolTipProvider(
        new ICellToolTipProvider() {
          @Override
          public void getToolTipText(Item item, int columnIndex) {
            adapter.setCellToolTipText(null);
          }
        });

    String itemId = WidgetUtil.getId(table.getItem(2));
    fakeCellToolTipRequest(table, itemId, 0);
    Fixture.executeLifeCycleFromServerThread();

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(table, "cellToolTipText"));
  }
Ejemplo n.º 23
0
  @Test
  public void testCreatesParent() throws IOException {
    lifeCycleAdapter.renderInitialization(video);

    assertTrue(isParentOfCreate("tabris.widgets.Video", WidgetUtil.getId(video.getParent())));
  }
Ejemplo n.º 24
0
 private Widget findWidget(String widgetID, Shell shell) {
   return WidgetUtil.find(shell, widgetID);
 }