Search in sources :

Example 1 with SubmitHandler

use of com.google.gwt.user.client.ui.FormPanel.SubmitHandler in project gwt-test-utils by gwt-test-utils.

the class BrowserTest method submit.

@Test()
public void submit() {
    // Given
    final StringBuilder sb = new StringBuilder();
    FormPanel form = new FormPanel();
    form.addSubmitHandler(new SubmitHandler() {

        public void onSubmit(SubmitEvent event) {
            sb.append("onSubmit");
        }
    });
    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            sb.append(" complete : ").append(event.getResults());
        }
    });
    // Attach to the DOM
    RootPanel.get().add(form);
    // Given
    Browser.submit(form, "mock result");
    // Then
    assertThat(sb.toString()).isEqualTo("onSubmit complete : mock result");
}
Also used : SubmitHandler(com.google.gwt.user.client.ui.FormPanel.SubmitHandler) SubmitCompleteEvent(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) SubmitCompleteHandler(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler) SubmitEvent(com.google.gwt.user.client.ui.FormPanel.SubmitEvent) Test(org.junit.Test)

Example 2 with SubmitHandler

use of com.google.gwt.user.client.ui.FormPanel.SubmitHandler in project gwt-test-utils by gwt-test-utils.

the class BrowserTest method submitThrowsErrorIfNotAttached.

@Test(expected = AssertionError.class)
public void submitThrowsErrorIfNotAttached() {
    // Given
    final StringBuilder sb = new StringBuilder();
    FormPanel form = new FormPanel();
    form.addSubmitHandler(new SubmitHandler() {

        public void onSubmit(SubmitEvent event) {
            sb.append("onSubmit");
        }
    });
    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            sb.append(" complete : ").append(event.getResults());
        }
    });
    // When
    Browser.submit(form, "mock result");
}
Also used : SubmitHandler(com.google.gwt.user.client.ui.FormPanel.SubmitHandler) SubmitCompleteEvent(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) SubmitCompleteHandler(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler) SubmitEvent(com.google.gwt.user.client.ui.FormPanel.SubmitEvent) Test(org.junit.Test)

Aggregations

SubmitCompleteEvent (com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent)2 SubmitCompleteHandler (com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler)2 SubmitEvent (com.google.gwt.user.client.ui.FormPanel.SubmitEvent)2 SubmitHandler (com.google.gwt.user.client.ui.FormPanel.SubmitHandler)2 Test (org.junit.Test)2