Beispiel #1
0
  @Test
  public void testSetData_RendersColumns() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);

    dropDown.setData("columns", new int[] {10, 20});

    verify(remoteObject).set(eq("columns"), eq(new JsonArray().add(10).add(20)));
  }
Beispiel #2
0
  @Test
  public void testSetData_RendersIncorrectTypeAsNull() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);

    dropDown.setData("columns", Boolean.TRUE);

    verify(remoteObject).set(eq("columns"), eq(JsonValue.NULL));
  }
Beispiel #3
0
  @Test
  public void testSetData_RendersMarkupEnabled() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);

    dropDown.setData(RWT.MARKUP_ENABLED, Boolean.TRUE);

    verify(remoteObject).set(eq("markupEnabled"), eq(true));
  }
Beispiel #4
0
  @Test
  public void testDipose_CalledOnControlDispose() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);

    text.dispose();

    verify(remoteObject).destroy();
  }
Beispiel #5
0
  @Test
  public void testSetData_DoesNotRenderDataNotInWhiteList() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);

    WidgetUtil.registerDataKeys("foo", "bar");
    dropDown.setData("fool", "bar");

    verify(remoteObject, never()).set(eq("data"), any(JsonObject.class));
  }
Beispiel #6
0
  @Test
  public void testSetData_RendersDataInWhiteList() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);

    WidgetUtil.registerDataKeys("foo", "bar");
    dropDown.setData("foo", "bar");

    verify(remoteObject).set(eq("data"), eq(new JsonObject().add("foo", "bar")));
  }
Beispiel #7
0
  /*
   * Ensures that checkData calls with an invalid index are silently ignored.
   * This may happen, when the itemCount is reduced during a SetData event.
   * Queued SetData events may then have stale (out-of-bounds) indices.
   * See 235368: [table] [table] ArrayIndexOutOfBoundsException in virtual
   *     TableViewer
   *     https://bugs.eclipse.org/bugs/show_bug.cgi?id=235368
   */
  @Test
  public void testReduceItemCountInSetData() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    shell.setSize(100, 100);
    table = new Table(shell, SWT.VIRTUAL);
    Listener setDataListener = mock(Listener.class);
    table.addListener(SWT.SetData, setDataListener);

    Fixture.fakePhase(PhaseId.READ_DATA);
    table.setItemCount(1);
    ITableAdapter adapter = table.getAdapter(ITableAdapter.class);
    adapter.checkData(0);

    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    table.setItemCount(0);
    while (display.readAndDispatch()) {}
    verifyZeroInteractions(setDataListener);
  }
Beispiel #8
0
  @Test
  public void testDispose_FiresDispose() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    Listener listener = mock(Listener.class);
    dropDown.addListener(SWT.Dispose, listener);

    dropDown.dispose();

    verify(listener).handleEvent(any(Event.class));
  }
Beispiel #9
0
  @Test
  public void testFireDefaultSelectionEvent() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    final List<Event> log = new ArrayList<Event>();
    dropDown.addListener(
        SWT.DefaultSelection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            log.add(event);
          }
        });

    handler.handleNotify("DefaultSelection", new JsonObject().add("index", 2).add("text", "foo"));

    assertEquals(1, log.size());
    assertEquals(2, log.get(0).index);
    assertEquals("foo", log.get(0).text);
  }
Beispiel #10
0
 @Before
 public void setUp() {
   Fixture.setUp();
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
 }