Simple radio button unit test using gwtmockito/mockito?

551 Views Asked by At

I wanted to write a simple unit test avoiding GWTTeseCase for an extension of a radio button.

This is the composite

public class DeselectableRadioButton extends RadioButton {

private Boolean backingValue;

private final class RadioButtonClickHandler implements ClickHandler {

    public RadioButtonClickHandler(Boolean value) {
        backingValue = value;
    }

    @Override
    public void onClick(ClickEvent event) {
        RadioButton button = (RadioButton) event.getSource();
        if (!backingValue) {
            button.setValue(true);
            backingValue = true;
        } else {
            button.setValue(false);
            backingValue = false;
        }
    }
}

/**
 * Constructor creates radio button with name and value
 * 
 * @param name The name to be assigned to the radio button
 * @param value The default value to be given to the radio button
 */
public DeselectableRadioButton(String name, Boolean value) {
    super(name);
    this.setValue(value);
    setupHandlers(value);
}

private void setupHandlers(Boolean value) {
    addClickHandler(new RadioButtonClickHandler(value));
}

}

I was looking at some examples with GWTMockito such as: https://gist.github.com/nbuesing/7090529

But it doesn't seem possible with the current implementation of the widget I have?

Thanks for any help

0

There are 0 best solutions below