@Test public void testSetupPrintCommandOnPageLoad() { final HTMLDocument document = mock(HTMLDocument.class); final Window window = mock(Window.class); document.body = mock(HTMLBodyElement.class); doNothing().when(helper).setTimeout(any(), anyInt()); helper.setupPrintCommandOnPageLoad(document, window); document.body.onload.onInvoke(mock(Event.class)); verify(helper).setTimeout(commandArgumentCaptor.capture(), eq(10)); commandArgumentCaptor.getValue().execute(); verify(window).focus(); verify(window).print(); verify(window).close(); }
void setupPrintCommandOnPageLoad(final HTMLDocument printDocument, final Window printWindow) { printDocument.body.onload = (e) -> { setTimeout(() -> { printWindow.focus(); printWindow.print(); printWindow.close(); }, 10); return true; }; }
PrintHelper { void setupPrintCommandOnPageLoad(final HTMLDocument printDocument, final Window printWindow) { printDocument.body.onload = (e) -> { setTimeout(() -> { printWindow.focus(); printWindow.print(); printWindow.close(); }, 10); return true; }; } }
PrintHelper { void setupPrintCommandOnPageLoad(final HTMLDocument printDocument, final Window printWindow) { printDocument.body.onload = (e) -> { setTimeout(() -> { printWindow.focus(); printWindow.print(); printWindow.close(); }, 10); return true; }; }  }
PrintHelper { void setupPrintCommandOnPageLoad(final HTMLDocument printDocument, final Window printWindow) { printDocument.body.onload = (e) -> { setTimeout(() -> { printWindow.focus(); printWindow.print(); printWindow.close(); }, 10); return true; }; }  void print(final HTMLElement element); }
PrintHelper { void setupPrintCommandOnPageLoad(final HTMLDocument printDocument, final Window printWindow) { printDocument.body.onload = (e) -> { setTimeout(() -> { printWindow.focus(); printWindow.print(); printWindow.close(); }, 10); return true; }; }  void print(final HTMLElement element);  }