protected void setUp() throws Exception {
   Fixture.setUp();
   display = new Display();
   shell = new Shell(display, SWT.NONE);
   lca = new ScaleLCA();
   Fixture.fakeNewRequest(display);
 }
Exemplo n.º 2
0
  @Test
  public void testFireFocusEventBeforeMouseEvent() {
    final java.util.List<TypedEvent> eventLog = new ArrayList<TypedEvent>();
    Button button = new Button(shell, SWT.PUSH);
    getRemoteObject(button).setHandler(new ButtonOperationHandler(button));
    Fixture.markInitialized(button);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent event) {
            eventLog.add(event);
          }
        });
    button.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent event) {
            eventLog.add(event);
          }
        });
    Fixture.fakeNewRequest();
    fakeMouseDownRequest(button, 1, 2);
    Fixture.fakeSetProperty(getId(display), "focusControl", getId(button));
    Fixture.fakeNotifyOperation(getId(button), EVENT_FOCUS_IN, null);

    Fixture.executeLifeCycleFromServerThread();

    assertEquals(FocusEvent.class, eventLog.get(0).getClass());
    assertEquals(MouseEvent.class, eventLog.get(1).getClass());
  }
Exemplo n.º 3
0
  @Test
  public void testSelectionAfterRemoveAll() {
    combo = new Combo(shell, SWT.READ_ONLY);
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    combo.add("item 1");
    combo.select(0);
    Button button = new Button(shell, SWT.PUSH);
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            combo.removeAll();
            combo.add("replacement for item 1");
            combo.select(0);
          }
        });

    // Simulate button click that executes widgetSelected
    Fixture.fakeNotifyOperation(getId(button), ClientMessageConst.EVENT_SELECTION, null);
    Fixture.executeLifeCycleFromServerThread();

    Message message = Fixture.getProtocolMessage();
    assertEquals(new Integer(0), message.findSetProperty(combo, PROP_SELECTION_INDEX));
  }
Exemplo n.º 4
0
 @Before
 public void setUp() {
   Fixture.setUp();
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   display = new Display();
   shell = new Shell(display);
   text = new Text(shell, SWT.NONE);
 }
Exemplo n.º 5
0
 @Before
 public void setUp() {
   Fixture.setUp();
   display = new Display();
   shell = new Shell(display);
   progressBar = new ProgressBar(shell, SWT.NONE);
   lca = new ProgressBarLCA();
   Fixture.fakeNewRequest();
 }
Exemplo n.º 6
0
 @Before
 public void setUp() {
   Fixture.setUp();
   display = new Display();
   shell = new Shell(display, SWT.NONE);
   combo = new Combo(shell, SWT.NONE);
   lca = new ComboLCA();
   Fixture.fakeNewRequest();
 }
 @Before
 public void setUp() {
   Fixture.setUp();
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   display = new Display();
   menuItem = mock(MenuItem.class);
   menuItem.display = display;
   acceleratorSupport = new AcceleratorBinding(menuItem);
 }
Exemplo n.º 8
0
  @Test
  public void testReadData_TextAndSelection() {
    Fixture.fakeSetParameter(getId(combo), "text", "abc");
    Fixture.fakeSetParameter(getId(combo), "selectionStart", Integer.valueOf(1));
    Fixture.fakeSetParameter(getId(combo), "selectionLength", Integer.valueOf(1));

    lca.readData(combo);

    assertEquals(new Point(1, 2), combo.getSelection());
  }
 @Before
 public void setUp() {
   Fixture.setUp();
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   display = new Display();
   shell = new Shell(display);
   tree = new Tree(shell, SWT.NONE);
   column = new TreeColumn(tree, SWT.NONE);
   eventLog = new ArrayList<Event>();
 }
Exemplo n.º 10
0
  @Test
  public void testFireDefaultSelectionEvent() {
    SelectionListener listener = mock(SelectionListener.class);
    combo.addSelectionListener(listener);

    Fixture.fakeNotifyOperation(getId(combo), ClientMessageConst.EVENT_DEFAULT_SELECTION, null);
    Fixture.readDataAndProcessAction(combo);

    verify(listener, times(1)).widgetDefaultSelected(any(SelectionEvent.class));
  }
Exemplo n.º 11
0
  @Test
  public void testRenderItemHeightUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setFont(new Font(display, "Arial", 16, SWT.NONE));
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "itemHeight"));
  }
Exemplo n.º 12
0
  @Test
  public void testRenderItemsUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setItems(new String[] {"a", "b", "c"});
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "items"));
  }
Exemplo n.º 13
0
  public void testRenderAddSelectionListener() throws Exception {
    Scale scale = new Scale(shell, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(scale);
    Fixture.preserveWidgets();

    scale.addSelectionListener(new SelectionAdapter() {});
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.TRUE, message.findListenProperty(scale, "selection"));
  }
Exemplo n.º 14
0
  public void testRenderPageIncrementUnchanged() throws IOException {
    Scale scale = new Scale(shell, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(scale);

    scale.setPageIncrement(20);
    Fixture.preserveWidgets();
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(scale, "pageIncrement"));
  }
Exemplo n.º 15
0
  @Test
  public void testRenderMaxmumUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(progressBar);

    progressBar.setMaximum(10);
    Fixture.preserveWidgets();
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(progressBar, "maximum"));
  }
Exemplo n.º 16
0
  @Test
  public void testRenderStateUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(progressBar);

    progressBar.setState(SWT.ERROR);
    Fixture.preserveWidgets();
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(progressBar, "state"));
  }
Exemplo n.º 17
0
  @Test
  public void testRenderListVisibleUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setListVisible(true);
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "listVisible"));
  }
Exemplo n.º 18
0
  @Test
  public void testRenderTextLimitUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setTextLimit(10);
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "textLimit"));
  }
Exemplo n.º 19
0
  @Test
  public void testListenDefaultSelection() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addListener(SWT.DefaultSelection, mock(Listener.class));
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "Selection"));
    assertEquals(Boolean.TRUE, message.findListenProperty(combo, "DefaultSelection"));
  }
Exemplo n.º 20
0
  public void testRenderSelectionListenerUnchanged() throws Exception {
    Scale scale = new Scale(shell, SWT.NONE);
    Fixture.markInitialized(display);
    Fixture.markInitialized(scale);
    Fixture.preserveWidgets();

    scale.addSelectionListener(new SelectionAdapter() {});
    Fixture.preserveWidgets();
    lca.renderChanges(scale);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(scale, "selection"));
  }
Exemplo n.º 21
0
  @Test
  public void testRenderSelectionListenerUnchanged() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addSelectionListener(new SelectionAdapter() {});
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findListenOperation(combo, "selection"));
  }
Exemplo n.º 22
0
  @Test
  public void testRenderSelectionUnchanged() throws IOException {
    combo.setText("foo bar");
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setSelection(new Point(1, 3));
    Fixture.preserveWidgets();
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(combo, "selection"));
  }
Exemplo n.º 23
0
  @Test
  public void testRenderTextLimitResetWithNegative() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);

    combo.setTextLimit(10);
    Fixture.preserveWidgets();
    combo.setTextLimit(-5);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(JSONObject.NULL, message.findSetProperty(combo, "textLimit"));
  }
  public void testStartupRequestWithParameter() throws Exception {
    RWTFactory.getEntryPointManager().registerByPath("/rap", DefaultEntryPoint.class, null);
    Fixture.fakeNewGetRequest();
    Fixture.fakeRequestParam("param", "value");
    RWTFactory.getServiceManager().getHandler().service();

    Fixture.fakeNewRequest();
    Fixture.fakeRequestParam("param", null);
    Fixture.fakeRequestParam(RequestParams.RWT_INITIALIZE, "true");
    RWTFactory.getServiceManager().getHandler().service();

    assertEquals("value", ContextProvider.getRequest().getParameter("param"));
  }
Exemplo n.º 25
0
 @Test
 public void testEditablePreserveValues() {
   Fixture.markInitialized(display);
   Fixture.preserveWidgets();
   WidgetAdapter adapter = WidgetUtil.getAdapter(combo);
   assertEquals(Boolean.TRUE, adapter.getPreserved(ComboLCA.PROP_EDITABLE));
   Fixture.clearPreserved();
   // textLimit
   combo.setTextLimit(10);
   Fixture.preserveWidgets();
   Integer textLimit = (Integer) adapter.getPreserved(ComboLCA.PROP_TEXT_LIMIT);
   assertEquals(new Integer(10), textLimit);
 }
Exemplo n.º 26
0
  @Test
  public void testRemoveListenSelection() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Listener listener = mock(Listener.class);
    combo.addListener(SWT.Selection, listener);
    Fixture.preserveWidgets();

    combo.removeListener(SWT.Selection, listener);
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.FALSE, message.findListenProperty(combo, "Selection"));
  }
Exemplo n.º 27
0
  @Test
  public void testRenderAddVerifyListener() throws Exception {
    Fixture.markInitialized(display);
    Fixture.markInitialized(combo);
    Fixture.preserveWidgets();

    combo.addVerifyListener(
        new VerifyListener() {
          public void verifyText(VerifyEvent event) {}
        });
    lca.renderChanges(combo);

    Message message = Fixture.getProtocolMessage();
    assertEquals(Boolean.TRUE, message.findListenProperty(combo, "Modify"));
  }
Exemplo n.º 28
0
 @Before
 public void setUp() {
   Fixture.setUp();
   new Display();
   gc = mock(GC.class);
   dispatcher = new GCOperationDispatcher(gc, ClientCanvasTestUtil.createDrawings(3));
 }
Exemplo n.º 29
0
 @Test
 public void testPreserveValues() {
   Fixture.preserveWidgets();
   WidgetAdapter adapter = WidgetUtil.getAdapter(progressBar);
   Object preserved = adapter.getPreserved(ProgressBarLCA.PROP_STATE);
   assertNull(preserved);
 }
  @Test
  public void testPreservesOptions() {
    Fixture.fakePhase(PhaseId.READ_DATA);
    when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS);
    GeolocationOptions options =
        new GeolocationOptions().setFrequency(10).enableHighAccuracy().setMaximumAge(10);
    when(adapter.getOptions()).thenReturn(options);

    synchronizer.preserveValues(object);

    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId()
                    + "."
                    + GeolocationSynchronizer.PROP_ENABLE_HIGH_ACCURACY));
    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_FREQUENCY));
    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_MAXIMUM_AGE));
  }