Simple radio button unit test using gwtmockito/mockito?

34 views
Skip to first unread message

Jonathan Cook

unread,
Jul 12, 2016, 5:23:37 AM7/12/16
to GWT Users

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


This is the class:

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


Reply all
Reply to author
Forward
0 new messages