@Test
  public void checkRadioButtonClickTwice() {
    tested = false;
    RadioButton r1 = new RadioButton("myRadioGroup", "r1");
    RadioButton r2 = new RadioButton("myRadioGroup", "r2");
    r1.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            tested = !tested;
          }
        });

    r2.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            tested = !tested;
          }
        });

    Assert.assertEquals(false, tested);

    // simule the event
    Browser.click(r1);
    Browser.click(r1);

    Assert.assertEquals(false, tested);
    Assert.assertEquals(true, r1.getValue());
  }
示例#2
0
  @Test
  public void runAsync() {
    // Arrange
    Button b = new Button();
    b.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            GWT.runAsync(
                new RunAsyncCallback() {

                  public void onFailure(Throwable reason) {
                    fail("GWT.runAsync() has called \"onFailure\" callback");
                  }

                  public void onSuccess() {
                    success = true;
                  }
                });
          }
        });

    // Act
    Browser.click(b);

    // Assert
    assertTrue(success);
  }
  @SuppressWarnings("unchecked")
  @Test
  public void checkRPCCallSuccess() {
    // Setup
    Button button = GwtReflectionUtils.getPrivateFieldValue(composite, "button");
    Label label = GwtReflectionUtils.getPrivateFieldValue(composite, "label");

    service.createBean(EasyMock.eq("OCTO"), EasyMock.isA(AsyncCallback.class));

    FooBean expected = new FooBean();
    expected.setName("mocked");

    expectServiceAndCallbackOnSuccess(expected);

    // replay all @Mock objects
    replay();

    Assert.assertEquals("", label.getText());

    // Test
    Browser.click(button);

    // Assert
    // verify all @Mock objects
    verify();

    Assert.assertEquals("Bean \"mocked\" has been created", label.getText());
  }
示例#4
0
  @Test
  public void click() {
    // Arrange
    CheckBox cb = new CheckBox();
    // Pre-Assert
    assertFalse(cb.getValue());

    // Act 1
    Browser.click(cb);

    // Assert 1
    assertTrue(cb.getValue());
    assertEquals("", errorStringBuilder.toString());

    // Act 2
    Browser.click(cb);

    // Assert 2
    assertFalse(cb.getValue());
    assertEquals("", errorStringBuilder.toString());
  }
示例#5
0
  @Test
  public void click_disabled() {
    // Arrange
    CheckBox cb = new CheckBox();
    cb.setEnabled(false);

    // Act
    Browser.click(cb);

    // Assert
    assertFalse(cb.getValue());
    assertTrue(
        errorStringBuilder
            .toString()
            .startsWith(
                "Cannot dispatch 'mouseover' event : the targeted element has to be enabled : <span class=\"gwt-CheckBox gwt-CheckBox-disabled\"><input type=\"checkbox\""));
  }
  @Test
  public void checkRadioButtonClick() {
    tested = false;
    RadioButton r = new RadioButton("myRadioGroup", "foo");
    r.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            tested = !tested;
          }
        });

    Assert.assertEquals(false, tested);

    // simule the event
    Browser.click(r);

    Assert.assertEquals(true, tested);
    Assert.assertEquals(true, r.getValue());
  }
  @SuppressWarnings("unchecked")
  @Test
  public void checkRPCCallFailure() {
    // Setup
    Button button = GwtReflectionUtils.getPrivateFieldValue(composite, "button");
    Label label = GwtReflectionUtils.getPrivateFieldValue(composite, "label");

    service.createBean(EasyMock.eq("OCTO"), EasyMock.isA(AsyncCallback.class));

    expectServiceAndCallbackOnFailure(new Exception("Mocked exception"));

    // replay all @Mock objects
    replay();

    Assert.assertEquals("", label.getText());

    // Test
    Browser.click(button);

    // Assert
    // verify all @Mock objects
    verify();
    Assert.assertEquals("Failure : Mocked exception", label.getText());
  }
 /**
  * @param target
  * @deprecated use {@link Browser#mouseUp(Widget)} instead
  */
 public static void mouseUp(Widget target) {
   Browser.mouseUp(target);
 }
 /**
  * @param target
  * @param keyCode
  * @deprecated use {@link Browser#keyPress(Widget, int)} instead
  */
 public static void keyPress(Widget target, int keyCode) {
   Browser.keyPress(target, keyCode);
 }
示例#10
0
 /**
  * @param target
  * @param keyCode
  * @deprecated use {@link Browser#keyDown(Widget, int)} instead
  */
 public static void keyDown(Widget target, int keyCode) {
   Browser.keyDown(target, keyCode);
 }
示例#11
0
 /**
  * @param target
  * @deprecated use {@link Browser#focus(Widget)} instead
  */
 public static void focus(Widget target) {
   Browser.focus(target);
 }
示例#12
0
 /**
  * @param target
  * @deprecated use {@link Browser#mouseOver(Widget)} instead
  */
 public static void mouseOver(Widget target) {
   Browser.mouseOver(target);
 }
示例#13
0
 /**
  * @param target
  * @deprecated use {@link Browser#mouseDown(Widget)} instead
  */
 public static void mouseDown(Widget target) {
   Browser.mouseDown(target);
 }
示例#14
0
 /**
  * @param parent
  * @param clickedItem
  * @deprecated use {@link Browser#click(MenuBar, MenuItem)} instead
  */
 public static void click(MenuBar parent, MenuItem clickedItem) {
   Browser.click(parent, clickedItem);
 }
示例#15
0
 /**
  * @param target
  * @deprecated use {@link Browser#click(Widget)} instead
  */
 public static void click(Widget target) {
   Browser.click(target);
 }
示例#16
0
 /**
  * @param target
  * @deprecated use {@link Browser#change(Widget)} instead
  */
 public static void change(Widget target) {
   Browser.change(target);
 }
示例#17
0
 /**
  * @param target
  * @deprecated use {@link Browser#blur(Widget)} instead
  */
 public static void blur(Widget target) {
   Browser.blur(target);
 }
示例#18
0
 /**
  * @param target
  * @deprecated use {@link Browser#mouseOut(Widget)} instead
  */
 @Deprecated
 public static void mouseOut(Widget target) {
   Browser.mouseOut(target);
 }
示例#19
0
 /**
  * @param panel
  * @param index
  * @deprecated use {@link Browser#click(ComplexPanel, int)} instead
  */
 public static void click(ComplexPanel panel, int index) {
   Browser.click(panel, index);
 }
示例#20
0
 /**
  * @param parent
  * @param clickedItemIndex
  * @deprecated use {@link Browser#click(MenuBar, int)} instead
  */
 public static void click(MenuBar parent, int clickedItemIndex) {
   Browser.click(parent, clickedItemIndex);
 }
示例#21
0
 /**
  * @param target
  * @deprecated use {@link Browser#mouseWheel(Widget)} instead
  */
 public static void mouseWheel(Widget target) {
   Browser.mouseWheel(target);
 }
示例#22
0
 /**
  * @param grid
  * @param row
  * @param column
  * @deprecated use {@link Browser#click(Grid, int, int)} instead
  */
 public static void click(Grid grid, int row, int column) {
   Browser.click(grid, row, column);
 }
示例#23
0
 /**
  * @param target
  * @deprecated use {@link Browser#mouseMove(Widget)} instead
  */
 public static void mouseMove(Widget target) {
   Browser.mouseMove(target);
 }