The reason why i would like that is to test at compilation time my tdd test suite for the code that i write for cef.
An example should be that i write an extension and i have code in a c++ test which should verify that everything works properly.
i tried to do a dummy non ui application but it does not seem to work. Essentially i guess i would need only the v8 layer plus the cef binders (but not sure about that)
the code below does not give any particular error, but there will never be a call to onWebKitInitialized or OnContextCreated.
How can i fix it ?
- Code: Select all
/************************************************************************
* Client
/************************************************************************/
class Client : public CefClient
{
public:
private:
// CefBase
IMPLEMENT_REFCOUNTING(CefClient);
};
/************************************************************************
* RenderProcess
/************************************************************************/
class RenderPocess : public CefRenderProcessHandler{
private :
IMPLEMENT_REFCOUNTING(RenderProcess);
public :
virtual void OnWebKitInitialized() override {
int i = 0;
}
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override {
int i = 0;
}
virtual void OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) override {
int i = 0;
}
};
/************************************************************************
* BrowserHandler
/************************************************************************/
class BrowserHandler : public CefBrowserProcessHandler
{
private :
IMPLEMENT_REFCOUNTING(CefBrowserProcessHandler);
public:
// CefBrowserProcessHandler
virtual void OnContextInitialized() override {
std::string url = "www.google.com";
CefWindowInfo windowInfo;
windowInfo.SetAsOffScreen(NULL);
CefBrowserSettings browserSettings;
CefRefPtr<Client> handler(new Client());
CefRefPtr<CefBrowser> browser = CefBrowserHost::CreateBrowserSync(windowInfo, handler.get(), url, browserSettings, NULL);
}
protected:
};
/************************************************************************
* APPLICATION
/************************************************************************/
class Application : public CefApp{
private :
IMPLEMENT_REFCOUNTING(Application);
public:
Application() : CefApp() {
browser = CefRefPtr<BrowserHandler>(new BrowserHandler());
renderProcess = CefRefPtr<RenderPocess>(new RenderPocess());
}
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
return browser;
}
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override {
return renderProcess;
}
CefRefPtr<BrowserHandler> browser;
CefRefPtr<RenderPocess> renderProcess;
};
/************************************************************************
* MAIN
/************************************************************************/
int main(int n , char* c[])
{
CefMainArgs mainArgs;
CefRefPtr<CefApp> application(new Application);
int exit_code = CefExecuteProcess(mainArgs,application);
if (exit_code >= 0) {
return 1;
}
CefSettings settings;
settings.single_process = true;
settings.multi_threaded_message_loop = false;
CefInitialize(mainArgs, settings, application.get());
CefRunMessageLoop(); // <--- do i really need this if i have no UI
// Shut down CEF.
CefShutdown();
return 0;
}