Applications using CEF may wish to write unit tests to verify expected CEF API behaviors without necessarily initializing CEF. GoogleTest supports this concept via gMock. We could rather easily generate mocks for CEF API classes using the existing translator tooling. Alternatively, we could use the Mock class generator provided by Google.
Example mock headers:
#include <include/cef_browser.h>
#include <include/cef_frame.h>
#include "gmock/gmock.h"
class MockCefBrowser : public CefBrowser {
public:
MockCefBrowser() {};
...
MOCK_METHOD(CefRefPtr<CefFrame>, GetMainFrame, ());
...
private:
IMPLEMENT_REFCOUNTING(MockCefBrowser);
};
class MockCefFrame : public CefFrame {
public:
MockCefFrame() {};
...
MOCK_METHOD(CefString, GetURL, ());
...
private:
IMPLEMENT_REFCOUNTING(MockCefFrame);
};
Original report by me.
Applications using CEF may wish to write unit tests to verify expected CEF API behaviors without necessarily initializing CEF. GoogleTest supports this concept via gMock. We could rather easily generate mocks for CEF API classes using the existing translator tooling. Alternatively, we could use the Mock class generator provided by Google.
Example mock headers:
Example test code: