コード例 #1
0
 @Test
 public void testAddClickHandler_with_id_and_click_should_trigger_handler() throws Exception {
   ClickHandler clickHandler = mock(ClickHandler.class);
   buttonWidget.addClickHandler("form", clickHandler);
   ClickEvent clickEvent = mock(ClickEvent.class);
   buttonWidget.onClick(clickEvent);
   verify(clickHandler, times(1)).onClick(clickEvent);
 }
コード例 #2
0
 @Test
 public void
     test_two_AddClickHandler_with_id_twice_and_once_and_click_should_trigger_handler_once_each()
         throws Exception {
   ClickHandler clickHandler1 = mock(ClickHandler.class);
   ClickHandler clickHandler2 = mock(ClickHandler.class);
   buttonWidget.addClickHandler("form1", clickHandler1);
   buttonWidget.addClickHandler("form1", clickHandler1);
   buttonWidget.addClickHandler("form2", clickHandler2);
   ClickEvent clickEvent = mock(ClickEvent.class);
   buttonWidget.onClick(clickEvent);
   verify(clickHandler1, times(1)).onClick(clickEvent);
   verify(clickHandler2, times(1)).onClick(clickEvent);
 }