@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));
  }
Exemple #2
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);
 }
 public void testExpanded() {
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   Display display = new Display();
   Composite shell = new Shell(display, SWT.NONE);
   Twistie twistie = new Twistie(shell, SWT.NONE);
   twistie.setExpanded(true);
   assertTrue(twistie.isExpanded());
 }
 @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);
 }
 @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>();
 }
  @Test
  public void testPreservesValues() {
    Fixture.fakePhase(PhaseId.READ_DATA);
    when(adapter.getFlavor()).thenReturn(NeedsPositionFlavor.CONTINUOUS);
    synchronizer.preserveValues(object);

    assertNotNull(
        RWT.getServiceStore()
            .getAttribute(
                synchronizer.getObjectId() + "." + GeolocationSynchronizer.PROP_NEEDS_POSITION));
  }
 public void testComputeSize() {
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   Display display = new Display();
   Composite shell = new Shell(display, SWT.NONE);
   Twistie twistie = new Twistie(shell, SWT.NONE);
   Point expected = new Point(11, 11);
   assertEquals(expected, twistie.computeSize(SWT.DEFAULT, SWT.DEFAULT));
   // fixed size
   expected = new Point(11, 11);
   assertEquals(expected, twistie.computeSize(50, 50));
 }
 public void testColors() {
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
   Display display = new Display();
   Composite shell = new Shell(display, SWT.NONE);
   Twistie twistie = new Twistie(shell, SWT.NONE);
   Color decorationColor = Graphics.getColor(255, 0, 0);
   twistie.setDecorationColor(decorationColor);
   assertEquals(decorationColor, twistie.getDecorationColor());
   Color hoverColor = Graphics.getColor(0, 255, 0);
   twistie.setHoverDecorationColor(hoverColor);
   assertEquals(hoverColor, twistie.getHoverDecorationColor());
 }
Exemple #9
0
  @Test
  public void testReadText_WithVerifyListener() {
    Fixture.fakePhase(PhaseId.PROCESS_ACTION);
    Fixture.markInitialized(display);
    Fixture.markInitialized(shell);
    Fixture.markInitialized(combo);
    combo.setText("some text");
    VerifyListener listener = mock(VerifyListener.class);
    combo.addVerifyListener(listener);

    Fixture.fakeSetParameter(getId(combo), "text", "verify me");
    Fixture.executeLifeCycleFromServerThread();

    assertEquals("verify me", combo.getText());
    ArgumentCaptor<VerifyEvent> captor = ArgumentCaptor.forClass(VerifyEvent.class);
    verify(listener, times(1)).verifyText(captor.capture());
    VerifyEvent event = captor.getValue();
    assertEquals("verify me", event.text);
    assertEquals(0, event.start);
    assertEquals(9, event.end);
  }
  @Test
  public void testRenderChanges() {
    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.renderChanges(object);

    verify(synchronizer)
        .renderProperty(
            eq(GeolocationSynchronizer.PROP_NEEDS_POSITION),
            any(NeedsPositionFlavor.class),
            any(NeedsPositionFlavor.class));
    verify(synchronizer)
        .renderProperty(
            eq(GeolocationSynchronizer.PROP_MAXIMUM_AGE), any(Integer.class), any(Integer.class));
    verify(synchronizer)
        .renderProperty(
            eq(GeolocationSynchronizer.PROP_FREQUENCY), any(Integer.class), any(Integer.class));
  }
 @Before
 public void setUp() {
   Fixture.setUp();
   Fixture.fakePhase(PhaseId.PROCESS_ACTION);
 }