gwt java测试中的Fire事件未更改复选框的值
我在一个组中添加了三个单选按钮,当我从浏览器加载页面时效果很好 Java代码:gwt java测试中的Fire事件未更改复选框的值,java,unit-testing,gwt,radio-button,Java,Unit Testing,Gwt,Radio Button,我在一个组中添加了三个单选按钮,当我从浏览器加载页面时效果很好 Java代码: @UiHandler({ "RadioButton1", "RadioButton2", "RadioButton3" }) void radioButtonClickHandler(ClickEvent event){ if(RadioButton1.getValue()){ // do something } else if(RadioButton2.getValue()) { //
@UiHandler({
"RadioButton1",
"RadioButton2",
"RadioButton3"
})
void radioButtonClickHandler(ClickEvent event){
if(RadioButton1.getValue()){
// do something
} else if(RadioButton2.getValue()) {
// do something
} else if (RadioButton3.getValue()){
// do something
}
}
我正在尝试为这个函数编写测试用例
public void TestRadio1ClickEvent(){
// all values set
// Value of Radiobutton2 set to true
view.RadioButton1.fireEvent(new ClickEvent() {});
assertTrue(view.RadioButton1.getValue());
assertFalse(view.RadioButton2.getValue());
assertFalse(view.RadioButton3.getValue());
}
当我触发单击事件时,单选按钮的值不会更改。RadioButton1的值保持为false,RadioButton2的值保持为true
我可以在click handler中手动设置值,但我不想这样做。点击按钮与触发事件有何不同?单击是否更改单选按钮值,然后调用单击处理程序?尝试在单选按钮上使用以下方法。 setValue(java.lang.Boolean值,Boolean fireEvents)
尝试在单选按钮上使用以下方法。 setValue(java.lang.Boolean值,Boolean fireEvents)
radioButton.setValue(true,true)