@Test void callsCreatedHandlerOnAfterCreatedWhenHandlerIsAvailable() { Configuration config = mock(Configuration.class); CefClient client = mock(CefClient.class); CefBrowser cefBrowser = mock(CefBrowser.class); when(client.createBrowser(any(), anyBoolean(), anyBoolean())).thenReturn(cefBrowser); Browser browser = new Browser("-dummy name-", config, client); Consumer<Browser> createdHandler = mock(Consumer.class); browser.addCreatedHandler(createdHandler); ArgumentCaptor<CefLifeSpanHandler> lifeSpanCaptor = ArgumentCaptor.forClass(CefLifeSpanHandler.class); verify(client).addLifeSpanHandler(lifeSpanCaptor.capture()); lifeSpanCaptor.getValue().onAfterCreated(cefBrowser); verify(createdHandler).accept(browser); }
public void addCreatedHandler(Consumer<Browser> createdHandler) { this.createdHandlers.add(createdHandler); if(nativeBrowserCreated) { createdHandler.accept(this); } }
Browser { public void addCreatedHandler(Consumer<Browser> createdHandler) { this.createdHandlers.add(createdHandler); if(nativeBrowserCreated) { createdHandler.accept(this); } } }
Browser { public void addCreatedHandler(Consumer<Browser> createdHandler) { this.createdHandlers.add(createdHandler); if(nativeBrowserCreated) { createdHandler.accept(this); } } Browser(String name, Configuration config, CefClient client); }
Browser { public void addCreatedHandler(Consumer<Browser> createdHandler) { this.createdHandlers.add(createdHandler); if(nativeBrowserCreated) { createdHandler.accept(this); } } Browser(String name, Configuration config, CefClient client); Component getBrowserUi(); T assumeUiApi(String apiId, Class<T> api); void close(Runnable onAfterClose); CefBrowser getNativeBrowser(); @Override String toString(); void addCreatedHandler(Consumer<Browser> createdHandler); String getName(); void addClosedHandler(Consumer<Browser> browserClosed); }
Browser { public void addCreatedHandler(Consumer<Browser> createdHandler) { this.createdHandlers.add(createdHandler); if(nativeBrowserCreated) { createdHandler.accept(this); } } Browser(String name, Configuration config, CefClient client); Component getBrowserUi(); T assumeUiApi(String apiId, Class<T> api); void close(Runnable onAfterClose); CefBrowser getNativeBrowser(); @Override String toString(); void addCreatedHandler(Consumer<Browser> createdHandler); String getName(); void addClosedHandler(Consumer<Browser> browserClosed);  }