gwt java 中的 Fire 事件测试未更改复选框的值
Fire event in gwt java testing not changing the value of checkbox
我在一组中添加了三个单选按钮,当我从浏览器加载页面时它工作正常。
Java代码:
@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。
我可以在点击处理程序中手动设置值,但我不想这样做。单击按钮与触发事件有何不同?单击是否更改单选按钮值然后调用单击处理程序?
尝试在单选按钮上使用以下方法。
setValue(java.lang.Boolean 值,布尔值 fireEvents)
radioButton.setValue(true,true)
我在一组中添加了三个单选按钮,当我从浏览器加载页面时它工作正常。
Java代码:
@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。
我可以在点击处理程序中手动设置值,但我不想这样做。单击按钮与触发事件有何不同?单击是否更改单选按钮值然后调用单击处理程序?
尝试在单选按钮上使用以下方法。 setValue(java.lang.Boolean 值,布尔值 fireEvents)
radioButton.setValue(true,true)