예제 #1
0
  @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());
  }
  @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());
  }
예제 #3
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);
  }
예제 #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\""));
  }
예제 #6
0
  @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());
  }
예제 #8
0
 /** Simulates a click event on the item of a SuggestBox with the given index. */
 public static void click(SuggestBox parent, int clickedItemIndex) {
   click(parent, WidgetUtils.getMenuItems(parent).get(clickedItemIndex));
 }
예제 #9
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);
 }
예제 #10
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);
 }
예제 #11
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);
 }
예제 #12
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);
 }
예제 #13
0
 /**
  * @param target
  * @deprecated use {@link Browser#click(Widget)} instead
  */
 public static void click(Widget target) {
   Browser.click(target);
 }