mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add JavaScript binding example to cefclient.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@590 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
18
cef.gyp
18
cef.gyp
@ -221,8 +221,10 @@
|
|||||||
'libcef_dll_wrapper',
|
'libcef_dll_wrapper',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'tests/cefclient/cefclient_switches.cpp',
|
'tests/cefclient/client_app.cpp',
|
||||||
'tests/cefclient/cefclient_switches.h',
|
'tests/cefclient/client_app.h',
|
||||||
|
'tests/cefclient/client_switches.cpp',
|
||||||
|
'tests/cefclient/client_switches.h',
|
||||||
'tests/unittests/command_line_unittest.cc',
|
'tests/unittests/command_line_unittest.cc',
|
||||||
'tests/unittests/cookie_unittest.cc',
|
'tests/unittests/cookie_unittest.cc',
|
||||||
'tests/unittests/navigation_unittest.cc',
|
'tests/unittests/navigation_unittest.cc',
|
||||||
@ -232,9 +234,7 @@
|
|||||||
'tests/unittests/scheme_handler_unittest.cc',
|
'tests/unittests/scheme_handler_unittest.cc',
|
||||||
'tests/unittests/stream_unittest.cc',
|
'tests/unittests/stream_unittest.cc',
|
||||||
'tests/unittests/string_unittest.cc',
|
'tests/unittests/string_unittest.cc',
|
||||||
'tests/unittests/test_app.cc',
|
'tests/unittests/client_app_delegates.cc',
|
||||||
'tests/unittests/test_app.h',
|
|
||||||
'tests/unittests/test_app_tests.cc',
|
|
||||||
'tests/unittests/test_handler.cc',
|
'tests/unittests/test_handler.cc',
|
||||||
'tests/unittests/test_handler.h',
|
'tests/unittests/test_handler.h',
|
||||||
'tests/unittests/test_suite.cc',
|
'tests/unittests/test_suite.cc',
|
||||||
@ -940,13 +940,13 @@
|
|||||||
'.',
|
'.',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
|
'tests/cefclient/client_app.cpp',
|
||||||
|
'tests/cefclient/client_app.h',
|
||||||
|
'tests/cefclient/process_helper_mac.cpp',
|
||||||
|
'tests/unittests/client_app_delegates.h',
|
||||||
'tests/unittests/process_message_unittest.cc',
|
'tests/unittests/process_message_unittest.cc',
|
||||||
'tests/unittests/test_app.cc',
|
|
||||||
'tests/unittests/test_app.h',
|
|
||||||
'tests/unittests/test_app_tests.cc',
|
|
||||||
'tests/unittests/test_handler.cc',
|
'tests/unittests/test_handler.cc',
|
||||||
'tests/unittests/test_handler.h',
|
'tests/unittests/test_handler.h',
|
||||||
'tests/unittests/test_helper_mac.cc',
|
|
||||||
'tests/unittests/test_util.cc',
|
'tests/unittests/test_util.cc',
|
||||||
'tests/unittests/test_util.h',
|
'tests/unittests/test_util.h',
|
||||||
'tests/unittests/v8_unittest.cc',
|
'tests/unittests/v8_unittest.cc',
|
||||||
|
@ -80,10 +80,14 @@
|
|||||||
'cefclient_sources_common': [
|
'cefclient_sources_common': [
|
||||||
'tests/cefclient/cefclient.cpp',
|
'tests/cefclient/cefclient.cpp',
|
||||||
'tests/cefclient/cefclient.h',
|
'tests/cefclient/cefclient.h',
|
||||||
'tests/cefclient/cefclient_switches.cpp',
|
'tests/cefclient/client_app.cpp',
|
||||||
'tests/cefclient/cefclient_switches.h',
|
'tests/cefclient/client_app.h',
|
||||||
|
'tests/cefclient/client_app_delegates.cpp',
|
||||||
'tests/cefclient/client_handler.cpp',
|
'tests/cefclient/client_handler.cpp',
|
||||||
'tests/cefclient/client_handler.h',
|
'tests/cefclient/client_handler.h',
|
||||||
|
'tests/cefclient/client_switches.cpp',
|
||||||
|
'tests/cefclient/client_switches.h',
|
||||||
|
'tests/cefclient/res/binding.html',
|
||||||
'tests/cefclient/res/localstorage.html',
|
'tests/cefclient/res/localstorage.html',
|
||||||
'tests/cefclient/res/logo.png',
|
'tests/cefclient/res/logo.png',
|
||||||
'tests/cefclient/res/xmlhttprequest.html',
|
'tests/cefclient/res/xmlhttprequest.html',
|
||||||
@ -110,13 +114,14 @@
|
|||||||
'tests/cefclient/resource_util_mac.mm',
|
'tests/cefclient/resource_util_mac.mm',
|
||||||
],
|
],
|
||||||
'cefclient_sources_mac_helper': [
|
'cefclient_sources_mac_helper': [
|
||||||
'tests/cefclient/cefclient_helper_mac.cc',
|
'tests/cefclient/process_helper_mac.cpp',
|
||||||
],
|
],
|
||||||
'cefclient_bundle_resources_mac': [
|
'cefclient_bundle_resources_mac': [
|
||||||
'tests/cefclient/mac/cefclient.icns',
|
'tests/cefclient/mac/cefclient.icns',
|
||||||
'tests/cefclient/mac/English.lproj/InfoPlist.strings',
|
'tests/cefclient/mac/English.lproj/InfoPlist.strings',
|
||||||
'tests/cefclient/mac/English.lproj/MainMenu.xib',
|
'tests/cefclient/mac/English.lproj/MainMenu.xib',
|
||||||
'tests/cefclient/mac/Info.plist',
|
'tests/cefclient/mac/Info.plist',
|
||||||
|
'tests/cefclient/res/binding.html',
|
||||||
'tests/cefclient/res/localstorage.html',
|
'tests/cefclient/res/localstorage.html',
|
||||||
'tests/cefclient/res/logo.png',
|
'tests/cefclient/res/logo.png',
|
||||||
'tests/cefclient/res/xmlhttprequest.html',
|
'tests/cefclient/res/xmlhttprequest.html',
|
||||||
@ -127,6 +132,7 @@
|
|||||||
'tests/cefclient/resource_util_linux.cpp',
|
'tests/cefclient/resource_util_linux.cpp',
|
||||||
],
|
],
|
||||||
'cefclient_bundle_resources_linux': [
|
'cefclient_bundle_resources_linux': [
|
||||||
|
'tests/cefclient/res/binding.html',
|
||||||
'tests/cefclient/res/localstorage.html',
|
'tests/cefclient/res/localstorage.html',
|
||||||
'tests/cefclient/res/logo.png',
|
'tests/cefclient/res/logo.png',
|
||||||
'tests/cefclient/res/xmlhttprequest.html',
|
'tests/cefclient/res/xmlhttprequest.html',
|
||||||
|
104
tests/cefclient/binding_test.cpp
Normal file
104
tests/cefclient/binding_test.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "cefclient/binding_test.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||||
|
#include "cefclient/resource_util.h"
|
||||||
|
|
||||||
|
namespace binding_test {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const char* kTestUrl = "http://tests/binding";
|
||||||
|
const char* kMessageName = "binding_test";
|
||||||
|
|
||||||
|
// Handle messages in the browser process.
|
||||||
|
class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
|
||||||
|
public:
|
||||||
|
ProcessMessageDelegate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// From ClientHandler::ProcessMessageDelegate.
|
||||||
|
virtual bool OnProcessMessageRecieved(
|
||||||
|
CefRefPtr<ClientHandler> handler,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||||
|
std::string message_name = message->GetName();
|
||||||
|
if (message_name == kMessageName) {
|
||||||
|
// Handle the message.
|
||||||
|
std::string result;
|
||||||
|
|
||||||
|
CefRefPtr<CefListValue> args = message->GetArgumentList();
|
||||||
|
if (args->GetSize() >= 0 && args->GetType(0) == VTYPE_STRING) {
|
||||||
|
// Our result is a reverse of the original message.
|
||||||
|
result = args->GetString(0);
|
||||||
|
std::reverse(result.begin(), result.end());
|
||||||
|
} else {
|
||||||
|
result = "Invalid request";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the result back to the render process.
|
||||||
|
CefRefPtr<CefProcessMessage> response =
|
||||||
|
CefProcessMessage::Create(kMessageName);
|
||||||
|
response->GetArgumentList()->SetString(0, result);
|
||||||
|
browser->SendProcessMessage(PID_RENDERER, response);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(ProcessMessageDelegate);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle resource loading in the browser process.
|
||||||
|
class RequestDelegate: public ClientHandler::RequestDelegate {
|
||||||
|
public:
|
||||||
|
RequestDelegate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// From ClientHandler::RequestDelegate.
|
||||||
|
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||||
|
CefRefPtr<ClientHandler> handler,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefRequest> request) OVERRIDE {
|
||||||
|
std::string url = request->GetURL();
|
||||||
|
if (url == kTestUrl) {
|
||||||
|
// Show the binding contents
|
||||||
|
CefRefPtr<CefStreamReader> stream =
|
||||||
|
GetBinaryResourceReader("binding.html");
|
||||||
|
ASSERT(stream.get());
|
||||||
|
return new CefStreamResourceHandler("text/html", stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(RequestDelegate);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void CreateProcessMessageDelegates(
|
||||||
|
ClientHandler::ProcessMessageDelegateSet& delegates) {
|
||||||
|
delegates.insert(new ProcessMessageDelegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRequestDelegates(ClientHandler::RequestDelegateSet& delegates) {
|
||||||
|
delegates.insert(new RequestDelegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunTest(CefRefPtr<CefBrowser> browser) {
|
||||||
|
// Load the test URL.
|
||||||
|
browser->GetMainFrame()->LoadURL(kTestUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace binding_test
|
24
tests/cefclient/binding_test.h
Normal file
24
tests/cefclient/binding_test.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef CEF_TESTS_CEFCLIENT_BINDING_TEST_H_
|
||||||
|
#define CEF_TESTS_CEFCLIENT_BINDING_TEST_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cefclient/client_app.h"
|
||||||
|
#include "cefclient/client_handler.h"
|
||||||
|
|
||||||
|
namespace binding_test {
|
||||||
|
|
||||||
|
// Delegate creation. Called from ClientApp and ClientHandler.
|
||||||
|
void CreateProcessMessageDelegates(
|
||||||
|
ClientHandler::ProcessMessageDelegateSet& delegates);
|
||||||
|
void CreateRequestDelegates(ClientHandler::RequestDelegateSet& delegates);
|
||||||
|
|
||||||
|
// Run the test.
|
||||||
|
void RunTest(CefRefPtr<CefBrowser> browser);
|
||||||
|
|
||||||
|
} // namespace binding_test
|
||||||
|
|
||||||
|
#endif // CEF_TESTS_CEFCLIENT_BINDING_TEST_H_
|
@ -12,8 +12,8 @@
|
|||||||
#include "include/cef_command_line.h"
|
#include "include/cef_command_line.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_runnable.h"
|
#include "include/cef_runnable.h"
|
||||||
#include "cefclient/cefclient_switches.h"
|
|
||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
|
#include "cefclient/client_switches.h"
|
||||||
#include "cefclient/string_util.h"
|
#include "cefclient/string_util.h"
|
||||||
#include "cefclient/util.h"
|
#include "cefclient/util.h"
|
||||||
|
|
||||||
@ -28,33 +28,6 @@ int GetIntValue(const CefString& str) {
|
|||||||
return atoi(stdStr.c_str());
|
return atoi(stdStr.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientApp implementation.
|
|
||||||
class ClientApp : public CefApp,
|
|
||||||
public CefProxyHandler {
|
|
||||||
public:
|
|
||||||
ClientApp(cef_proxy_type_t proxy_type, const CefString& proxy_config)
|
|
||||||
: proxy_type_(proxy_type),
|
|
||||||
proxy_config_(proxy_config) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// CefApp methods
|
|
||||||
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
|
||||||
|
|
||||||
// CefProxyHandler methods
|
|
||||||
virtual void GetProxyForUrl(const CefString& url,
|
|
||||||
CefProxyInfo& proxy_info) OVERRIDE {
|
|
||||||
proxy_info.proxyType = proxy_type_;
|
|
||||||
if (!proxy_config_.empty())
|
|
||||||
CefString(&proxy_info.proxyList) = proxy_config_;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
cef_proxy_type_t proxy_type_;
|
|
||||||
CefString proxy_config_;
|
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(ClientApp);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefRefPtr<ClientHandler> g_handler;
|
CefRefPtr<ClientHandler> g_handler;
|
||||||
@ -87,7 +60,8 @@ CefRefPtr<CefCommandLine> AppGetCommandLine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns the application settings based on command line arguments.
|
// Returns the application settings based on command line arguments.
|
||||||
void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app) {
|
void AppGetSettings(CefSettings& settings, CefRefPtr<ClientApp> app) {
|
||||||
|
ASSERT(app.get());
|
||||||
ASSERT(g_command_line.get());
|
ASSERT(g_command_line.get());
|
||||||
if (!g_command_line.get())
|
if (!g_command_line.get())
|
||||||
return;
|
return;
|
||||||
@ -179,7 +153,7 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app) {
|
|||||||
|
|
||||||
if (has_proxy) {
|
if (has_proxy) {
|
||||||
// Provide a ClientApp instance to handle proxy resolution.
|
// Provide a ClientApp instance to handle proxy resolution.
|
||||||
app = new ClientApp(proxy_type, proxy_config);
|
app->SetProxyConfig(proxy_type, proxy_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +255,7 @@ void AppGetBrowserSettings(CefBrowserSettings& settings) {
|
|||||||
void RunGetSourceTest(CefRefPtr<CefBrowser> browser) {
|
void RunGetSourceTest(CefRefPtr<CefBrowser> browser) {
|
||||||
class Visitor : public CefStringVisitor {
|
class Visitor : public CefStringVisitor {
|
||||||
public:
|
public:
|
||||||
Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
|
explicit Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
|
||||||
virtual void Visit(const CefString& string) OVERRIDE {
|
virtual void Visit(const CefString& string) OVERRIDE {
|
||||||
std::string source = StringReplace(string, "<", "<");
|
std::string source = StringReplace(string, "<", "<");
|
||||||
source = StringReplace(source, ">", ">");
|
source = StringReplace(source, ">", ">");
|
||||||
@ -300,7 +274,7 @@ void RunGetSourceTest(CefRefPtr<CefBrowser> browser) {
|
|||||||
void RunGetTextTest(CefRefPtr<CefBrowser> browser) {
|
void RunGetTextTest(CefRefPtr<CefBrowser> browser) {
|
||||||
class Visitor : public CefStringVisitor {
|
class Visitor : public CefStringVisitor {
|
||||||
public:
|
public:
|
||||||
Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
|
explicit Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
|
||||||
virtual void Visit(const CefString& string) OVERRIDE {
|
virtual void Visit(const CefString& string) OVERRIDE {
|
||||||
std::string text = StringReplace(string, "<", "<");
|
std::string text = StringReplace(string, "<", "<");
|
||||||
text = StringReplace(text, ">", ">");
|
text = StringReplace(text, ">", ">");
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "include/cef_base.h"
|
#include "include/cef_base.h"
|
||||||
|
#include "cefclient/client_app.h"
|
||||||
|
|
||||||
class CefApp;
|
class CefApp;
|
||||||
class CefBrowser;
|
class CefBrowser;
|
||||||
@ -29,7 +30,7 @@ void AppInitCommandLine(int argc, const char* const* argv);
|
|||||||
CefRefPtr<CefCommandLine> AppGetCommandLine();
|
CefRefPtr<CefCommandLine> AppGetCommandLine();
|
||||||
|
|
||||||
// Returns the application settings based on command line arguments.
|
// Returns the application settings based on command line arguments.
|
||||||
void AppGetSettings(CefSettings& settings, CefRefPtr<CefApp>& app);
|
void AppGetSettings(CefSettings& settings, CefRefPtr<ClientApp> app);
|
||||||
|
|
||||||
// Returns the application browser settings based on command line arguments.
|
// Returns the application browser settings based on command line arguments.
|
||||||
void AppGetBrowserSettings(CefBrowserSettings& settings);
|
void AppGetBrowserSettings(CefBrowserSettings& settings);
|
||||||
|
@ -28,6 +28,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
|||||||
// Binary
|
// Binary
|
||||||
//
|
//
|
||||||
|
|
||||||
|
IDS_BINDING BINARY "res\\binding.html"
|
||||||
IDS_LOGO BINARY "res\\logo.png"
|
IDS_LOGO BINARY "res\\logo.png"
|
||||||
IDS_LOGOBALL BINARY "res\\logoball.png"
|
IDS_LOGOBALL BINARY "res\\logoball.png"
|
||||||
IDS_LOCALSTORAGE BINARY "res\\localstorage.html"
|
IDS_LOCALSTORAGE BINARY "res\\localstorage.html"
|
||||||
@ -65,6 +66,7 @@ BEGIN
|
|||||||
MENUITEM "Popup Window", ID_TESTS_POPUP
|
MENUITEM "Popup Window", ID_TESTS_POPUP
|
||||||
MENUITEM "Request", ID_TESTS_REQUEST
|
MENUITEM "Request", ID_TESTS_REQUEST
|
||||||
MENUITEM "Scheme Handler", ID_TESTS_SCHEME_HANDLER
|
MENUITEM "Scheme Handler", ID_TESTS_SCHEME_HANDLER
|
||||||
|
MENUITEM "JavaScript Binding", ID_TESTS_BINDING
|
||||||
MENUITEM "Local Storage", ID_TESTS_LOCALSTORAGE
|
MENUITEM "Local Storage", ID_TESTS_LOCALSTORAGE
|
||||||
MENUITEM "XMLHttpRequest", ID_TESTS_XMLHTTPREQUEST
|
MENUITEM "XMLHttpRequest", ID_TESTS_XMLHTTPREQUEST
|
||||||
MENUITEM "Accelerated 2D Canvas", ID_TESTS_ACCELERATED2DCANVAS
|
MENUITEM "Accelerated 2D Canvas", ID_TESTS_ACCELERATED2DCANVAS
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_runnable.h"
|
#include "include/cef_runnable.h"
|
||||||
|
#include "cefclient/binding_test.h"
|
||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
#include "cefclient/scheme_test.h"
|
#include "cefclient/scheme_test.h"
|
||||||
#include "cefclient/string_util.h"
|
#include "cefclient/string_util.h"
|
||||||
@ -76,6 +77,14 @@ gboolean SchemeHandlerActivated(GtkWidget* widget) {
|
|||||||
return FALSE; // Don't stop this message.
|
return FALSE; // Don't stop this message.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback for Debug > JavaScript Binding... menu item.
|
||||||
|
gboolean BindingActivated(GtkWidget* widget) {
|
||||||
|
if (g_handler.get() && g_handler->GetBrowserId())
|
||||||
|
binding_test::RunTest(g_handler->GetBrowser());
|
||||||
|
|
||||||
|
return FALSE; // Don't stop this message.
|
||||||
|
}
|
||||||
|
|
||||||
// Callback for Debug > Popup Window... menu item.
|
// Callback for Debug > Popup Window... menu item.
|
||||||
gboolean PopupWindowActivated(GtkWidget* widget) {
|
gboolean PopupWindowActivated(GtkWidget* widget) {
|
||||||
if (g_handler.get() && g_handler->GetBrowserId())
|
if (g_handler.get() && g_handler->GetBrowserId())
|
||||||
@ -191,6 +200,8 @@ GtkWidget* CreateMenuBar() {
|
|||||||
G_CALLBACK(XMLHttpRequestActivated));
|
G_CALLBACK(XMLHttpRequestActivated));
|
||||||
AddMenuEntry(debug_menu, "Scheme Handler",
|
AddMenuEntry(debug_menu, "Scheme Handler",
|
||||||
G_CALLBACK(SchemeHandlerActivated));
|
G_CALLBACK(SchemeHandlerActivated));
|
||||||
|
AddMenuEntry(debug_menu, "JavaScript Binding",
|
||||||
|
G_CALLBACK(BindingActivated));
|
||||||
AddMenuEntry(debug_menu, "Popup Window",
|
AddMenuEntry(debug_menu, "Popup Window",
|
||||||
G_CALLBACK(PopupWindowActivated));
|
G_CALLBACK(PopupWindowActivated));
|
||||||
AddMenuEntry(debug_menu, "Accelerated 2D Canvas",
|
AddMenuEntry(debug_menu, "Accelerated 2D Canvas",
|
||||||
@ -219,9 +230,10 @@ static gboolean HandleFocus(GtkWidget* widget,
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
CefMainArgs main_args(argc, argv);
|
CefMainArgs main_args(argc, argv);
|
||||||
|
CefRefPtr<ClientApp> app(new ClientApp);
|
||||||
|
|
||||||
// Execute the secondary process, if any.
|
// Execute the secondary process, if any.
|
||||||
int exit_code = CefExecuteProcess(main_args, NULL);
|
int exit_code = CefExecuteProcess(main_args, app.get());
|
||||||
if (exit_code >= 0)
|
if (exit_code >= 0)
|
||||||
return exit_code;
|
return exit_code;
|
||||||
|
|
||||||
@ -236,13 +248,12 @@ int main(int argc, char* argv[]) {
|
|||||||
AppInitCommandLine(argc, argv);
|
AppInitCommandLine(argc, argv);
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
CefRefPtr<CefApp> app;
|
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
AppGetSettings(settings, app);
|
AppGetSettings(settings, app);
|
||||||
|
|
||||||
// Initialize CEF.
|
// Initialize CEF.
|
||||||
CefInitialize(main_args, settings, app);
|
CefInitialize(main_args, settings, app.get());
|
||||||
|
|
||||||
// Register the scheme handler.
|
// Register the scheme handler.
|
||||||
InitSchemeTest();
|
InitSchemeTest();
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
||||||
// be found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "include/cef_app.h"
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
CefMainArgs main_args(argc, argv);
|
|
||||||
|
|
||||||
// Execute the secondary process.
|
|
||||||
return CefExecuteProcess(main_args, NULL);
|
|
||||||
}
|
|
@ -11,6 +11,7 @@
|
|||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_runnable.h"
|
#include "include/cef_runnable.h"
|
||||||
|
#include "cefclient/binding_test.h"
|
||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
#include "cefclient/resource_util.h"
|
#include "cefclient/resource_util.h"
|
||||||
#include "cefclient/scheme_test.h"
|
#include "cefclient/scheme_test.h"
|
||||||
@ -228,6 +229,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
- (IBAction)testLocalStorage:(id)sender;
|
- (IBAction)testLocalStorage:(id)sender;
|
||||||
- (IBAction)testXMLHttpRequest:(id)sender;
|
- (IBAction)testXMLHttpRequest:(id)sender;
|
||||||
- (IBAction)testSchemeHandler:(id)sender;
|
- (IBAction)testSchemeHandler:(id)sender;
|
||||||
|
- (IBAction)testBinding:(id)sender;
|
||||||
- (IBAction)testPopupWindow:(id)sender;
|
- (IBAction)testPopupWindow:(id)sender;
|
||||||
- (IBAction)testAccelerated2DCanvas:(id)sender;
|
- (IBAction)testAccelerated2DCanvas:(id)sender;
|
||||||
- (IBAction)testAcceleratedLayers:(id)sender;
|
- (IBAction)testAcceleratedLayers:(id)sender;
|
||||||
@ -267,6 +269,9 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
[testMenu addItemWithTitle:@"Scheme Handler"
|
[testMenu addItemWithTitle:@"Scheme Handler"
|
||||||
action:@selector(testSchemeHandler:)
|
action:@selector(testSchemeHandler:)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
|
[testMenu addItemWithTitle:@"JavaScript Binding"
|
||||||
|
action:@selector(testBinding:)
|
||||||
|
keyEquivalent:@""];
|
||||||
[testMenu addItemWithTitle:@"Local Storage"
|
[testMenu addItemWithTitle:@"Local Storage"
|
||||||
action:@selector(testLocalStorage:)
|
action:@selector(testLocalStorage:)
|
||||||
keyEquivalent:@""];
|
keyEquivalent:@""];
|
||||||
@ -409,6 +414,11 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
RunSchemeTest(g_handler->GetBrowser());
|
RunSchemeTest(g_handler->GetBrowser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)testBinding:(id)sender {
|
||||||
|
if (g_handler.get() && g_handler->GetBrowserId())
|
||||||
|
binding_test::RunTest(g_handler->GetBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
- (IBAction)testPopupWindow:(id)sender {
|
- (IBAction)testPopupWindow:(id)sender {
|
||||||
if (g_handler.get() && g_handler->GetBrowserId())
|
if (g_handler.get() && g_handler->GetBrowserId())
|
||||||
RunPopupTest(g_handler->GetBrowser());
|
RunPopupTest(g_handler->GetBrowser());
|
||||||
@ -457,9 +467,10 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
CefMainArgs main_args(argc, argv);
|
CefMainArgs main_args(argc, argv);
|
||||||
|
CefRefPtr<ClientApp> app(new ClientApp);
|
||||||
|
|
||||||
// Execute the secondary process, if any.
|
// Execute the secondary process, if any.
|
||||||
int exit_code = CefExecuteProcess(main_args, NULL);
|
int exit_code = CefExecuteProcess(main_args, app.get());
|
||||||
if (exit_code >= 0)
|
if (exit_code >= 0)
|
||||||
return exit_code;
|
return exit_code;
|
||||||
|
|
||||||
@ -476,13 +487,12 @@ int main(int argc, char* argv[]) {
|
|||||||
AppInitCommandLine(argc, argv);
|
AppInitCommandLine(argc, argv);
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
CefRefPtr<CefApp> app;
|
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
AppGetSettings(settings, app);
|
AppGetSettings(settings, app);
|
||||||
|
|
||||||
// Initialize CEF.
|
// Initialize CEF.
|
||||||
CefInitialize(main_args, settings, app);
|
CefInitialize(main_args, settings, app.get());
|
||||||
|
|
||||||
// Initialize tests.
|
// Initialize tests.
|
||||||
InitSchemeTest();
|
InitSchemeTest();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_runnable.h"
|
#include "include/cef_runnable.h"
|
||||||
|
#include "cefclient/binding_test.h"
|
||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
#include "cefclient/resource.h"
|
#include "cefclient/resource.h"
|
||||||
#include "cefclient/scheme_test.h"
|
#include "cefclient/scheme_test.h"
|
||||||
@ -53,9 +54,10 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
|||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
CefMainArgs main_args(hInstance);
|
CefMainArgs main_args(hInstance);
|
||||||
|
CefRefPtr<ClientApp> app(new ClientApp);
|
||||||
|
|
||||||
// Execute the secondary process, if any.
|
// Execute the secondary process, if any.
|
||||||
int exit_code = CefExecuteProcess(main_args, NULL);
|
int exit_code = CefExecuteProcess(main_args, app.get());
|
||||||
if (exit_code >= 0)
|
if (exit_code >= 0)
|
||||||
return exit_code;
|
return exit_code;
|
||||||
|
|
||||||
@ -67,13 +69,12 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
|||||||
AppInitCommandLine(0, NULL);
|
AppInitCommandLine(0, NULL);
|
||||||
|
|
||||||
CefSettings settings;
|
CefSettings settings;
|
||||||
CefRefPtr<CefApp> app;
|
|
||||||
|
|
||||||
// Populate the settings based on command line arguments.
|
// Populate the settings based on command line arguments.
|
||||||
AppGetSettings(settings, app);
|
AppGetSettings(settings, app);
|
||||||
|
|
||||||
// Initialize CEF.
|
// Initialize CEF.
|
||||||
CefInitialize(main_args, settings, app);
|
CefInitialize(main_args, settings, app.get());
|
||||||
|
|
||||||
// Register the scheme handler.
|
// Register the scheme handler.
|
||||||
InitSchemeTest();
|
InitSchemeTest();
|
||||||
@ -372,6 +373,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
|||||||
if (browser.get())
|
if (browser.get())
|
||||||
RunSchemeTest(browser);
|
RunSchemeTest(browser);
|
||||||
return 0;
|
return 0;
|
||||||
|
case ID_TESTS_BINDING: // Test JavaScript binding
|
||||||
|
if (browser.get())
|
||||||
|
binding_test::RunTest(browser);
|
||||||
|
return 0;
|
||||||
case ID_TESTS_LOCALSTORAGE: // Test localStorage
|
case ID_TESTS_LOCALSTORAGE: // Test localStorage
|
||||||
if (browser.get())
|
if (browser.get())
|
||||||
RunLocalStorageTest(browser);
|
RunLocalStorageTest(browser);
|
||||||
|
@ -2,13 +2,17 @@
|
|||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "tests/unittests/test_app.h"
|
// This file is shared by cefclient and cef_unittests so don't include using
|
||||||
|
// a qualified path.
|
||||||
|
#include "client_app.h" // NOLINT(build/include)
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "include/cef_process_message.h"
|
#include "include/cef_process_message.h"
|
||||||
#include "include/cef_task.h"
|
#include "include/cef_task.h"
|
||||||
#include "include/cef_v8.h"
|
#include "include/cef_v8.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -97,11 +101,11 @@ void SetList(CefRefPtr<CefListValue> source, CefRefPtr<CefV8Value> target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Handles the native implementation for the test_app extension.
|
// Handles the native implementation for the client_app extension.
|
||||||
class TestAppExtensionHandler : public CefV8Handler {
|
class ClientAppExtensionHandler : public CefV8Handler {
|
||||||
public:
|
public:
|
||||||
explicit TestAppExtensionHandler(CefRefPtr<TestApp> test_app)
|
explicit ClientAppExtensionHandler(CefRefPtr<ClientApp> client_app)
|
||||||
: test_app_(test_app) {
|
: client_app_(client_app) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Execute(const CefString& name,
|
virtual bool Execute(const CefString& name,
|
||||||
@ -139,7 +143,8 @@ class TestAppExtensionHandler : public CefV8Handler {
|
|||||||
std::string name = arguments[0]->GetStringValue();
|
std::string name = arguments[0]->GetStringValue();
|
||||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||||
int browser_id = context->GetBrowser()->GetIdentifier();
|
int browser_id = context->GetBrowser()->GetIdentifier();
|
||||||
test_app_->SetMessageCallback(name, browser_id, context, arguments[1]);
|
client_app_->SetMessageCallback(name, browser_id, context,
|
||||||
|
arguments[1]);
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
} else if (name == "removeMessageCallback") {
|
} else if (name == "removeMessageCallback") {
|
||||||
@ -148,7 +153,7 @@ class TestAppExtensionHandler : public CefV8Handler {
|
|||||||
std::string name = arguments[0]->GetStringValue();
|
std::string name = arguments[0]->GetStringValue();
|
||||||
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||||
int browser_id = context->GetBrowser()->GetIdentifier();
|
int browser_id = context->GetBrowser()->GetIdentifier();
|
||||||
bool removed = test_app_->RemoveMessageCallback(name, browser_id);
|
bool removed = client_app_->RemoveMessageCallback(name, browser_id);
|
||||||
retval = CefV8Value::CreateBool(removed);
|
retval = CefV8Value::CreateBool(removed);
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
@ -161,19 +166,20 @@ class TestAppExtensionHandler : public CefV8Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CefRefPtr<TestApp> test_app_;
|
CefRefPtr<ClientApp> client_app_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(TestAppExtensionHandler);
|
IMPLEMENT_REFCOUNTING(ClientAppExtensionHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
TestApp::TestApp() {
|
ClientApp::ClientApp()
|
||||||
CreateTests(tests_);
|
: proxy_type_(PROXY_TYPE_DIRECT) {
|
||||||
|
CreateRenderDelegates(render_delegates_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::SetMessageCallback(const std::string& message_name,
|
void ClientApp::SetMessageCallback(const std::string& message_name,
|
||||||
int browser_id,
|
int browser_id,
|
||||||
CefRefPtr<CefV8Context> context,
|
CefRefPtr<CefV8Context> context,
|
||||||
CefRefPtr<CefV8Value> function) {
|
CefRefPtr<CefV8Value> function) {
|
||||||
@ -184,7 +190,7 @@ void TestApp::SetMessageCallback(const std::string& message_name,
|
|||||||
std::make_pair(context, function)));
|
std::make_pair(context, function)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestApp::RemoveMessageCallback(const std::string& message_name,
|
bool ClientApp::RemoveMessageCallback(const std::string& message_name,
|
||||||
int browser_id) {
|
int browser_id) {
|
||||||
DCHECK(CefCurrentlyOn(TID_RENDERER));
|
DCHECK(CefCurrentlyOn(TID_RENDERER));
|
||||||
|
|
||||||
@ -198,60 +204,57 @@ bool TestApp::RemoveMessageCallback(const std::string& message_name,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
void ClientApp::GetProxyForUrl(const CefString& url,
|
||||||
bool TestApp::TestFailed() {
|
CefProxyInfo& proxy_info) {
|
||||||
CefRefPtr<CefCommandLine> command_line =
|
proxy_info.proxyType = proxy_type_;
|
||||||
CefCommandLine::GetGlobalCommandLine();
|
if (!proxy_config_.empty())
|
||||||
if (command_line->HasSwitch("single-process")) {
|
CefString(&proxy_info.proxyList) = proxy_config_;
|
||||||
// Check for a failure on the current test only.
|
|
||||||
return ::testing::UnitTest::GetInstance()->current_test_info()->result()->
|
|
||||||
Failed();
|
|
||||||
} else {
|
|
||||||
// Check for any global failure.
|
|
||||||
return ::testing::UnitTest::GetInstance()->Failed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::OnWebKitInitialized() {
|
void ClientApp::OnWebKitInitialized() {
|
||||||
// Register the test_app extension.
|
// Register the client_app extension.
|
||||||
std::string test_app_code =
|
std::string app_code =
|
||||||
"var test_app;"
|
"var app;"
|
||||||
"if (!test_app)"
|
"if (!app)"
|
||||||
" test_app = {};"
|
" app = {};"
|
||||||
"(function() {"
|
"(function() {"
|
||||||
" test_app.sendMessage = function(name, arguments) {"
|
" app.sendMessage = function(name, arguments) {"
|
||||||
" native function sendMessage();"
|
" native function sendMessage();"
|
||||||
" return sendMessage(name, arguments);"
|
" return sendMessage(name, arguments);"
|
||||||
" };"
|
" };"
|
||||||
" test_app.setMessageCallback = function(name, callback) {"
|
" app.setMessageCallback = function(name, callback) {"
|
||||||
" native function setMessageCallback();"
|
" native function setMessageCallback();"
|
||||||
" return setMessageCallback(name, callback);"
|
" return setMessageCallback(name, callback);"
|
||||||
" };"
|
" };"
|
||||||
|
" app.removeMessageCallback = function(name) {"
|
||||||
|
" native function removeMessageCallback();"
|
||||||
|
" return removeMessageCallback(name);"
|
||||||
|
" };"
|
||||||
"})();";
|
"})();";
|
||||||
CefRegisterExtension("v8/test_app", test_app_code,
|
CefRegisterExtension("v8/app", app_code,
|
||||||
new TestAppExtensionHandler(this));
|
new ClientAppExtensionHandler(this));
|
||||||
|
|
||||||
// Execute test callbacks.
|
// Execute delegate callbacks.
|
||||||
TestSet::iterator it = tests_.begin();
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||||
for (; it != tests_.end(); ++it)
|
for (; it != render_delegates_.end(); ++it)
|
||||||
(*it)->OnWebKitInitialized(this);
|
(*it)->OnWebKitInitialized(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Context> context) {
|
CefRefPtr<CefV8Context> context) {
|
||||||
// Execute test callbacks.
|
// Execute delegate callbacks.
|
||||||
TestSet::iterator it = tests_.begin();
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||||
for (; it != tests_.end(); ++it)
|
for (; it != render_delegates_.end(); ++it)
|
||||||
(*it)->OnContextCreated(this, browser, frame, context);
|
(*it)->OnContextCreated(this, browser, frame, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Context> context) {
|
CefRefPtr<CefV8Context> context) {
|
||||||
// Execute test callbacks.
|
// Execute delegate callbacks.
|
||||||
TestSet::iterator it = tests_.begin();
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||||
for (; it != tests_.end(); ++it)
|
for (; it != render_delegates_.end(); ++it)
|
||||||
(*it)->OnContextReleased(this, browser, frame, context);
|
(*it)->OnContextReleased(this, browser, frame, context);
|
||||||
|
|
||||||
// Remove any JavaScript callbacks registered for the context that has been
|
// Remove any JavaScript callbacks registered for the context that has been
|
||||||
@ -267,7 +270,7 @@ void TestApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestApp::OnProcessMessageRecieved(
|
bool ClientApp::OnProcessMessageRecieved(
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefProcessId source_process,
|
CefProcessId source_process,
|
||||||
CefRefPtr<CefProcessMessage> message) {
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
@ -275,9 +278,9 @@ bool TestApp::OnProcessMessageRecieved(
|
|||||||
|
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
// Execute test callbacks.
|
// Execute delegate callbacks.
|
||||||
TestSet::iterator it = tests_.begin();
|
RenderDelegateSet::iterator it = render_delegates_.begin();
|
||||||
for (; it != tests_.end() && !handled; ++it) {
|
for (; it != render_delegates_.end() && !handled; ++it) {
|
||||||
handled = (*it)->OnProcessMessageRecieved(this, browser, source_process,
|
handled = (*it)->OnProcessMessageRecieved(this, browser, source_process,
|
||||||
message);
|
message);
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef CEF_TESTS_UNITTESTS_TEST_APP_H_
|
#ifndef CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
||||||
#define CEF_TESTS_UNITTESTS_TEST_APP_H_
|
#define CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -12,41 +12,43 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include "include/cef_app.h"
|
#include "include/cef_app.h"
|
||||||
|
|
||||||
class TestApp : public CefApp,
|
class ClientApp : public CefApp,
|
||||||
|
public CefProxyHandler,
|
||||||
public CefRenderProcessHandler {
|
public CefRenderProcessHandler {
|
||||||
public:
|
public:
|
||||||
// Interface for renderer tests. All tests must be returned via CreateTests.
|
// Interface for renderer delegates. All RenderDelegates must be returned via
|
||||||
// Do not perform work in the test constructor as this will slow down every
|
// CreateRenderDelegates. Do not perform work in the RenderDelegate
|
||||||
// test run.
|
// constructor.
|
||||||
class Test : public virtual CefBase {
|
class RenderDelegate : public virtual CefBase {
|
||||||
public:
|
public:
|
||||||
// Called when WebKit is initialized. Used to register V8 extensions.
|
// Called when WebKit is initialized. Used to register V8 extensions.
|
||||||
virtual void OnWebKitInitialized(CefRefPtr<TestApp> test_app) {
|
virtual void OnWebKitInitialized(CefRefPtr<ClientApp> app) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called when a V8 context is created. Used to create V8 window bindings
|
// Called when a V8 context is created. Used to create V8 window bindings
|
||||||
// and set message callbacks. Tests should check for unique URLs to avoid
|
// and set message callbacks. RenderDelegates should check for unique URLs
|
||||||
// interfering with each other.
|
// to avoid interfering with each other.
|
||||||
virtual void OnContextCreated(CefRefPtr<TestApp> test_app,
|
virtual void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Context> context) {
|
CefRefPtr<CefV8Context> context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called when a V8 context is released. Used to clean up V8 window
|
// Called when a V8 context is released. Used to clean up V8 window
|
||||||
// bindings. Tests should check for unique URLs to avoid interfering with
|
// bindings. RenderDelegates should check for unique URLs to avoid
|
||||||
// each other.
|
// interfering with each other.
|
||||||
virtual void OnContextReleased(CefRefPtr<TestApp> test_app,
|
virtual void OnContextReleased(CefRefPtr<ClientApp> app,
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Context> context) {
|
CefRefPtr<CefV8Context> context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called when a process message is received. Return true if the message was
|
// Called when a process message is received. Return true if the message was
|
||||||
// handled and should not be passed on to other handlers. Tests should check
|
// handled and should not be passed on to other handlers. RenderDelegates
|
||||||
// for unique message names to avoid interfering with each other.
|
// should check for unique message names to avoid interfering with each
|
||||||
|
// other.
|
||||||
virtual bool OnProcessMessageRecieved(
|
virtual bool OnProcessMessageRecieved(
|
||||||
CefRefPtr<TestApp> test_app,
|
CefRefPtr<ClientApp> app,
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefProcessId source_process,
|
CefProcessId source_process,
|
||||||
CefRefPtr<CefProcessMessage> message) {
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
@ -54,14 +56,21 @@ class TestApp : public CefApp,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::set<CefRefPtr<Test> > TestSet;
|
typedef std::set<CefRefPtr<RenderDelegate> > RenderDelegateSet;
|
||||||
|
|
||||||
TestApp();
|
ClientApp();
|
||||||
|
|
||||||
|
// Set the proxy configuration. Should only be called during initialization.
|
||||||
|
void SetProxyConfig(cef_proxy_type_t proxy_type,
|
||||||
|
const CefString& proxy_config) {
|
||||||
|
proxy_type_ = proxy_type;
|
||||||
|
proxy_config_ = proxy_config;
|
||||||
|
}
|
||||||
|
|
||||||
// Set a JavaScript callback for the specified |message_name| and |browser_id|
|
// Set a JavaScript callback for the specified |message_name| and |browser_id|
|
||||||
// combination. Will automatically be removed when the associated context is
|
// combination. Will automatically be removed when the associated context is
|
||||||
// released. Callbacks can also be set in JavaScript using the
|
// released. Callbacks can also be set in JavaScript using the
|
||||||
// test_app.setMessageCallback function.
|
// app.setMessageCallback function.
|
||||||
void SetMessageCallback(const std::string& message_name,
|
void SetMessageCallback(const std::string& message_name,
|
||||||
int browser_id,
|
int browser_id,
|
||||||
CefRefPtr<CefV8Context> context,
|
CefRefPtr<CefV8Context> context,
|
||||||
@ -69,22 +78,25 @@ class TestApp : public CefApp,
|
|||||||
|
|
||||||
// Removes the JavaScript callback for the specified |message_name| and
|
// Removes the JavaScript callback for the specified |message_name| and
|
||||||
// |browser_id| combination. Returns true if a callback was removed. Callbacks
|
// |browser_id| combination. Returns true if a callback was removed. Callbacks
|
||||||
// can also be removed in JavaScript using the test_app.removeMessageCallback
|
// can also be removed in JavaScript using the app.removeMessageCallback
|
||||||
// function.
|
// function.
|
||||||
bool RemoveMessageCallback(const std::string& message_name,
|
bool RemoveMessageCallback(const std::string& message_name,
|
||||||
int browser_id);
|
int browser_id);
|
||||||
|
|
||||||
// Returns true if the currently running test has failed.
|
|
||||||
static bool TestFailed();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Creates all of the test objects. Implemented in test_app_tests.cc.
|
// Creates all of the RenderDelegate objects. Implemented in
|
||||||
static void CreateTests(TestSet& tests);
|
// client_app_delegates.
|
||||||
|
static void CreateRenderDelegates(RenderDelegateSet& delegates);
|
||||||
|
|
||||||
// CefApp methods.
|
// CefApp methods.
|
||||||
|
virtual CefRefPtr<CefProxyHandler> GetProxyHandler() OVERRIDE { return this; }
|
||||||
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
|
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
|
||||||
OVERRIDE { return this; }
|
OVERRIDE { return this; }
|
||||||
|
|
||||||
|
// CefProxyHandler methods.
|
||||||
|
virtual void GetProxyForUrl(const CefString& url,
|
||||||
|
CefProxyInfo& proxy_info) OVERRIDE;
|
||||||
|
|
||||||
// CefRenderProcessHandler methods.
|
// CefRenderProcessHandler methods.
|
||||||
virtual void OnWebKitInitialized() OVERRIDE;
|
virtual void OnWebKitInitialized() OVERRIDE;
|
||||||
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||||
@ -98,16 +110,20 @@ class TestApp : public CefApp,
|
|||||||
CefProcessId source_process,
|
CefProcessId source_process,
|
||||||
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
||||||
|
|
||||||
|
// Proxy configuration.
|
||||||
|
cef_proxy_type_t proxy_type_;
|
||||||
|
CefString proxy_config_;
|
||||||
|
|
||||||
// Map of message callbacks.
|
// Map of message callbacks.
|
||||||
typedef std::map<std::pair<std::string, int>,
|
typedef std::map<std::pair<std::string, int>,
|
||||||
std::pair<CefRefPtr<CefV8Context>, CefRefPtr<CefV8Value> > >
|
std::pair<CefRefPtr<CefV8Context>, CefRefPtr<CefV8Value> > >
|
||||||
CallbackMap;
|
CallbackMap;
|
||||||
CallbackMap callback_map_;
|
CallbackMap callback_map_;
|
||||||
|
|
||||||
// Set of supported tests.
|
// Set of supported RenderDelegates.
|
||||||
TestSet tests_;
|
RenderDelegateSet render_delegates_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(TestApp);
|
IMPLEMENT_REFCOUNTING(ClientApp);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_TESTS_UNITTESTS_TEST_APP_H_
|
#endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
@ -8,7 +8,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
|
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||||
|
#include "cefclient/binding_test.h"
|
||||||
#include "cefclient/cefclient.h"
|
#include "cefclient/cefclient.h"
|
||||||
|
#include "cefclient/resource_util.h"
|
||||||
#include "cefclient/string_util.h"
|
#include "cefclient/string_util.h"
|
||||||
|
|
||||||
|
|
||||||
@ -21,11 +24,28 @@ ClientHandler::ClientHandler()
|
|||||||
m_StopHwnd(NULL),
|
m_StopHwnd(NULL),
|
||||||
m_ReloadHwnd(NULL),
|
m_ReloadHwnd(NULL),
|
||||||
m_bFormElementHasFocus(false) {
|
m_bFormElementHasFocus(false) {
|
||||||
|
CreateProcessMessageDelegates(process_message_delegates_);
|
||||||
|
CreateRequestDelegates(request_delegates_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientHandler::~ClientHandler() {
|
ClientHandler::~ClientHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClientHandler::OnProcessMessageRecieved(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
// Execute delegate callbacks.
|
||||||
|
ProcessMessageDelegateSet::iterator it = process_message_delegates_.begin();
|
||||||
|
for (; it != process_message_delegates_.end() && !handled; ++it) {
|
||||||
|
handled = (*it)->OnProcessMessageRecieved(this, browser, source_process,
|
||||||
|
message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||||
REQUIRE_UI_THREAD();
|
REQUIRE_UI_THREAD();
|
||||||
@ -102,6 +122,45 @@ void ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
|
|||||||
frame->LoadString(ss.str(), failedUrl);
|
frame->LoadString(ss.str(), failedUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefRequest> request) {
|
||||||
|
std::string url = request->GetURL();
|
||||||
|
if (url == "http://tests/request") {
|
||||||
|
// Show the request contents
|
||||||
|
std::string dump;
|
||||||
|
DumpRequestContents(request, dump);
|
||||||
|
CefRefPtr<CefStreamReader> stream =
|
||||||
|
CefStreamReader::CreateForData(
|
||||||
|
static_cast<void*>(const_cast<char*>(dump.c_str())),
|
||||||
|
dump.size());
|
||||||
|
ASSERT(stream.get());
|
||||||
|
return new CefStreamResourceHandler("text/plain", stream);
|
||||||
|
} else if (url == "http://tests/localstorage") {
|
||||||
|
// Show the localstorage contents
|
||||||
|
CefRefPtr<CefStreamReader> stream =
|
||||||
|
GetBinaryResourceReader("localstorage.html");
|
||||||
|
ASSERT(stream.get());
|
||||||
|
return new CefStreamResourceHandler("text/html", stream);
|
||||||
|
} else if (url == "http://tests/xmlhttprequest") {
|
||||||
|
// Show the xmlhttprequest contents
|
||||||
|
CefRefPtr<CefStreamReader> stream =
|
||||||
|
GetBinaryResourceReader("xmlhttprequest.html");
|
||||||
|
ASSERT(stream.get());
|
||||||
|
return new CefStreamResourceHandler("text/html", stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefResourceHandler> handler;
|
||||||
|
|
||||||
|
// Execute delegate callbacks.
|
||||||
|
RequestDelegateSet::iterator it = request_delegates_.begin();
|
||||||
|
for (; it != request_delegates_.end() && !handler.get(); ++it)
|
||||||
|
handler = (*it)->GetResourceHandler(this, browser, frame, request);
|
||||||
|
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
|
||||||
bool isLoading,
|
bool isLoading,
|
||||||
bool canGoBack,
|
bool canGoBack,
|
||||||
@ -204,3 +263,16 @@ void ClientHandler::ShowDevTools() {
|
|||||||
|
|
||||||
void ClientHandler::CloseDevTools() {
|
void ClientHandler::CloseDevTools() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
void ClientHandler::CreateProcessMessageDelegates(
|
||||||
|
ProcessMessageDelegateSet& delegates) {
|
||||||
|
// Create the binding test delegates.
|
||||||
|
binding_test::CreateProcessMessageDelegates(delegates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
void ClientHandler::CreateRequestDelegates(RequestDelegateSet& delegates) {
|
||||||
|
// Create the binding test delegates.
|
||||||
|
binding_test::CreateRequestDelegates(delegates);
|
||||||
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "include/cef_client.h"
|
#include "include/cef_client.h"
|
||||||
#include "cefclient/util.h"
|
#include "cefclient/util.h"
|
||||||
@ -25,6 +26,42 @@ class ClientHandler : public CefClient,
|
|||||||
public CefDisplayHandler,
|
public CefDisplayHandler,
|
||||||
public CefGeolocationHandler {
|
public CefGeolocationHandler {
|
||||||
public:
|
public:
|
||||||
|
// Interface for process message delegates. Do not perform work in the
|
||||||
|
// RenderDelegate constructor.
|
||||||
|
class ProcessMessageDelegate : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
// Called when a process message is received. Return true if the message was
|
||||||
|
// handled and should not be passed on to other handlers.
|
||||||
|
// ProcessMessageDelegates should check for unique message names to avoid
|
||||||
|
// interfering with each other.
|
||||||
|
virtual bool OnProcessMessageRecieved(
|
||||||
|
CefRefPtr<ClientHandler> handler,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::set<CefRefPtr<ProcessMessageDelegate> >
|
||||||
|
ProcessMessageDelegateSet;
|
||||||
|
|
||||||
|
// Interface for request handler delegates. Do not perform work in the
|
||||||
|
// RequestDelegate constructor.
|
||||||
|
class RequestDelegate : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
// Called to retrieve a resource handler.
|
||||||
|
virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
|
||||||
|
CefRefPtr<ClientHandler> handler,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefRequest> request) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::set<CefRefPtr<RequestDelegate> > RequestDelegateSet;
|
||||||
|
|
||||||
ClientHandler();
|
ClientHandler();
|
||||||
virtual ~ClientHandler();
|
virtual ~ClientHandler();
|
||||||
|
|
||||||
@ -44,6 +81,10 @@ class ClientHandler : public CefClient,
|
|||||||
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
|
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
virtual bool OnProcessMessageRecieved(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message)
|
||||||
|
OVERRIDE;
|
||||||
|
|
||||||
// CefLifeSpanHandler methods
|
// CefLifeSpanHandler methods
|
||||||
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
virtual bool OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||||
@ -129,6 +170,13 @@ class ClientHandler : public CefClient,
|
|||||||
void SetLoading(bool isLoading);
|
void SetLoading(bool isLoading);
|
||||||
void SetNavState(bool canGoBack, bool canGoForward);
|
void SetNavState(bool canGoBack, bool canGoForward);
|
||||||
|
|
||||||
|
// Create all of ProcessMessageDelegate objects.
|
||||||
|
static void CreateProcessMessageDelegates(
|
||||||
|
ProcessMessageDelegateSet& delegates);
|
||||||
|
|
||||||
|
// Create all of RequestDelegateSet objects.
|
||||||
|
static void CreateRequestDelegates(RequestDelegateSet& delegates);
|
||||||
|
|
||||||
// The child browser window
|
// The child browser window
|
||||||
CefRefPtr<CefBrowser> m_Browser;
|
CefRefPtr<CefBrowser> m_Browser;
|
||||||
|
|
||||||
@ -156,6 +204,10 @@ class ClientHandler : public CefClient,
|
|||||||
// True if a form element currently has focus
|
// True if a form element currently has focus
|
||||||
bool m_bFormElementHasFocus;
|
bool m_bFormElementHasFocus;
|
||||||
|
|
||||||
|
// Registered delegates.
|
||||||
|
ProcessMessageDelegateSet process_message_delegates_;
|
||||||
|
RequestDelegateSet request_delegates_;
|
||||||
|
|
||||||
// Include the default reference counting implementation.
|
// Include the default reference counting implementation.
|
||||||
IMPLEMENT_REFCOUNTING(ClientHandler);
|
IMPLEMENT_REFCOUNTING(ClientHandler);
|
||||||
// Include the default locking implementation.
|
// Include the default locking implementation.
|
||||||
|
@ -7,10 +7,6 @@
|
|||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_stream.h"
|
|
||||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
|
||||||
#include "cefclient/resource_util.h"
|
|
||||||
#include "cefclient/string_util.h"
|
|
||||||
|
|
||||||
// ClientHandler::ClientLifeSpanHandler implementation
|
// ClientHandler::ClientLifeSpanHandler implementation
|
||||||
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||||
@ -24,38 +20,6 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
|
||||||
CefRefPtr<CefBrowser> browser,
|
|
||||||
CefRefPtr<CefFrame> frame,
|
|
||||||
CefRefPtr<CefRequest> request) {
|
|
||||||
std::string url = request->GetURL();
|
|
||||||
if (url == "http://tests/request") {
|
|
||||||
// Show the request contents
|
|
||||||
std::string dump;
|
|
||||||
DumpRequestContents(request, dump);
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
CefStreamReader::CreateForData(
|
|
||||||
static_cast<void*>(const_cast<char*>(dump.c_str())),
|
|
||||||
dump.size());
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/plain", stream);
|
|
||||||
} else if (url == "http://tests/localstorage") {
|
|
||||||
// Show the localstorage contents
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
GetBinaryResourceReader("localstorage.html");
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/html", stream);
|
|
||||||
} else if (url == "http://tests/xmlhttprequest") {
|
|
||||||
// Show the xmlhttprequest contents
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
GetBinaryResourceReader("xmlhttprequest.html");
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/html", stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url) {
|
const CefString& url) {
|
||||||
|
@ -7,11 +7,7 @@
|
|||||||
#include "cefclient/client_handler.h"
|
#include "cefclient/client_handler.h"
|
||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_stream.h"
|
|
||||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
|
||||||
#include "cefclient/cefclient.h"
|
#include "cefclient/cefclient.h"
|
||||||
#include "cefclient/resource_util.h"
|
|
||||||
#include "cefclient/string_util.h"
|
|
||||||
|
|
||||||
// ClientHandler::ClientLifeSpanHandler implementation
|
// ClientHandler::ClientLifeSpanHandler implementation
|
||||||
|
|
||||||
@ -26,38 +22,6 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
|
||||||
CefRefPtr<CefBrowser> browser,
|
|
||||||
CefRefPtr<CefFrame> frame,
|
|
||||||
CefRefPtr<CefRequest> request) {
|
|
||||||
std::string url = request->GetURL();
|
|
||||||
if (url == "http://tests/request") {
|
|
||||||
// Show the request contents
|
|
||||||
std::string dump;
|
|
||||||
DumpRequestContents(request, dump);
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
CefStreamReader::CreateForData(
|
|
||||||
static_cast<void*>(const_cast<char*>(dump.c_str())),
|
|
||||||
dump.size());
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/plain", stream);
|
|
||||||
} else if (url == "http://tests/localstorage") {
|
|
||||||
// Show the localstorage contents
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
GetBinaryResourceReader("localstorage.html");
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/html", stream);
|
|
||||||
} else if (url == "http://tests/xmlhttprequest") {
|
|
||||||
// Show the xmlhttprequest contents
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
GetBinaryResourceReader("xmlhttprequest.html");
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/html", stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url) {
|
const CefString& url) {
|
||||||
|
@ -6,11 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "include/cef_browser.h"
|
#include "include/cef_browser.h"
|
||||||
#include "include/cef_frame.h"
|
#include "include/cef_frame.h"
|
||||||
#include "include/cef_stream.h"
|
|
||||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
|
||||||
#include "cefclient/resource.h"
|
#include "cefclient/resource.h"
|
||||||
#include "cefclient/resource_util.h"
|
|
||||||
#include "cefclient/string_util.h"
|
|
||||||
|
|
||||||
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
||||||
const CefPopupFeatures& popupFeatures,
|
const CefPopupFeatures& popupFeatures,
|
||||||
@ -23,38 +19,6 @@ bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> parentBrowser,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
|
||||||
CefRefPtr<CefBrowser> browser,
|
|
||||||
CefRefPtr<CefFrame> frame,
|
|
||||||
CefRefPtr<CefRequest> request) {
|
|
||||||
std::string url = request->GetURL();
|
|
||||||
if (url == "http://tests/request") {
|
|
||||||
// Show the request contents
|
|
||||||
std::string dump;
|
|
||||||
DumpRequestContents(request, dump);
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
CefStreamReader::CreateForData(
|
|
||||||
static_cast<void*>(const_cast<char*>(dump.c_str())),
|
|
||||||
dump.size());
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/plain", stream);
|
|
||||||
} else if (url == "http://tests/localstorage") {
|
|
||||||
// Show the localstorage contents
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
GetBinaryResourceReader(IDS_LOCALSTORAGE);
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/html", stream);
|
|
||||||
} else if (url == "http://tests/xmlhttprequest") {
|
|
||||||
// Show the xmlhttprequest contents
|
|
||||||
CefRefPtr<CefStreamReader> stream =
|
|
||||||
GetBinaryResourceReader(IDS_XMLHTTPREQUEST);
|
|
||||||
ASSERT(stream.get());
|
|
||||||
return new CefStreamResourceHandler("text/html", stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
const CefString& url) {
|
const CefString& url) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// This file is shared by cefclient and cef_unittests so don't include using
|
// This file is shared by cefclient and cef_unittests so don't include using
|
||||||
// a qualified path.
|
// a qualified path.
|
||||||
#include "cefclient_switches.h" // NOLINT(build/include)
|
#include "client_switches.h" // NOLINT(build/include)
|
||||||
|
|
||||||
namespace cefclient {
|
namespace cefclient {
|
||||||
|
|
@ -3,12 +3,15 @@
|
|||||||
// be found in the LICENSE file.
|
// be found in the LICENSE file.
|
||||||
|
|
||||||
#include "include/cef_app.h"
|
#include "include/cef_app.h"
|
||||||
#include "tests/unittests/test_app.h"
|
|
||||||
|
// This file is shared by cefclient and cef_unittests so don't include using
|
||||||
|
// a qualified path.
|
||||||
|
#include "client_app.h" // NOLINT(build/include)
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
CefMainArgs main_args(argc, argv);
|
CefMainArgs main_args(argc, argv);
|
||||||
|
|
||||||
CefRefPtr<CefApp> app(new TestApp);
|
CefRefPtr<CefApp> app(new ClientApp);
|
||||||
|
|
||||||
// Execute the secondary process.
|
// Execute the secondary process.
|
||||||
return CefExecuteProcess(main_args, app);
|
return CefExecuteProcess(main_args, app);
|
27
tests/cefclient/res/binding.html
Normal file
27
tests/cefclient/res/binding.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Binding Test</title>
|
||||||
|
<script language="JavaScript">
|
||||||
|
|
||||||
|
// Register the callback for messages from the browser process.
|
||||||
|
app.setMessageCallback('binding_test', function(name, args) {
|
||||||
|
document.getElementById('result').value = "Response: "+args[0];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send a message to the browser process.
|
||||||
|
function sendMessage() {
|
||||||
|
var msg = document.getElementById("message").value;
|
||||||
|
app.sendMessage('binding_test', [msg]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form>
|
||||||
|
Message: <input type="text" id="message" value="My Message">
|
||||||
|
<br/><input type="button" onclick="sendMessage();" value="Send Message">
|
||||||
|
<br/>You should see the reverse of your message below:
|
||||||
|
<br/><textarea rows="10" cols="40" id="result"></textarea>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -37,11 +37,13 @@
|
|||||||
#define ID_TESTS_XMLHTTPREQUEST 32770
|
#define ID_TESTS_XMLHTTPREQUEST 32770
|
||||||
#define ID_TESTS_DRAGDROP 32771
|
#define ID_TESTS_DRAGDROP 32771
|
||||||
#define ID_TESTS_GEOLOCATION 32772
|
#define ID_TESTS_GEOLOCATION 32772
|
||||||
|
#define ID_TESTS_BINDING 32773
|
||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
#define IDS_LOGO 1000
|
#define IDS_BINDING 1000
|
||||||
#define IDS_LOGOBALL 1001
|
#define IDS_LOGO 1001
|
||||||
#define IDS_LOCALSTORAGE 1002
|
#define IDS_LOGOBALL 1002
|
||||||
#define IDS_XMLHTTPREQUEST 1003
|
#define IDS_LOCALSTORAGE 1003
|
||||||
|
#define IDS_XMLHTTPREQUEST 1004
|
||||||
|
|
||||||
// Avoid files associated with MacOS
|
// Avoid files associated with MacOS
|
||||||
#define _X86_
|
#define _X86_
|
||||||
|
@ -24,8 +24,9 @@ CefRefPtr<CefStreamReader> GetBinaryResourceReader(int binaryId);
|
|||||||
|
|
||||||
// Load the resource with the specified name.
|
// Load the resource with the specified name.
|
||||||
bool LoadBinaryResource(const char* resource_name, std::string& resource_data);
|
bool LoadBinaryResource(const char* resource_name, std::string& resource_data);
|
||||||
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name);
|
||||||
|
|
||||||
#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_
|
#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "cefclient/resource_util.h"
|
#include "cefclient/resource_util.h"
|
||||||
#include "include/cef_stream.h"
|
#include "include/cef_stream.h"
|
||||||
#include "include/wrapper/cef_byte_read_handler.h"
|
#include "include/wrapper/cef_byte_read_handler.h"
|
||||||
|
#include "cefclient/util.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
|
||||||
@ -37,4 +38,24 @@ CefRefPtr<CefStreamReader> GetBinaryResourceReader(int binaryId) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
|
||||||
|
// Map of resource labels to BINARY id values.
|
||||||
|
static struct _resource_map {
|
||||||
|
char* name;
|
||||||
|
int id;
|
||||||
|
} resource_map[] = {
|
||||||
|
{"binding.html", IDS_BINDING},
|
||||||
|
{"localstorage.html", IDS_LOCALSTORAGE},
|
||||||
|
{"xmlhttprequest.html", IDS_XMLHTTPREQUEST},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(resource_map)/sizeof(_resource_map); ++i) {
|
||||||
|
if (!strcmp(resource_map[i].name, resource_name))
|
||||||
|
return GetBinaryResourceReader(resource_map[i].id);
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(FALSE); // The resource should be found.
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // OS_WIN
|
#endif // OS_WIN
|
||||||
|
17
tests/unittests/client_app_delegates.cc
Normal file
17
tests/unittests/client_app_delegates.cc
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "tests/cefclient/client_app.h"
|
||||||
|
|
||||||
|
// static
|
||||||
|
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||||
|
// Bring in the process message tests.
|
||||||
|
extern void CreateProcessMessageRendererTests(
|
||||||
|
ClientApp::RenderDelegateSet& delegates);
|
||||||
|
CreateProcessMessageRendererTests(delegates);
|
||||||
|
|
||||||
|
// Bring in the V8 tests.
|
||||||
|
extern void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates);
|
||||||
|
CreateV8RendererTests(delegates);
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "include/cef_process_message.h"
|
#include "include/cef_process_message.h"
|
||||||
#include "include/cef_task.h"
|
#include "include/cef_task.h"
|
||||||
#include "tests/unittests/test_app.h"
|
#include "tests/cefclient/client_app.h"
|
||||||
#include "tests/unittests/test_handler.h"
|
#include "tests/unittests/test_handler.h"
|
||||||
#include "tests/unittests/test_util.h"
|
#include "tests/unittests/test_util.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
@ -40,12 +40,12 @@ CefRefPtr<CefProcessMessage> CreateTestMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renderer side.
|
// Renderer side.
|
||||||
class SendRecvRendererTest : public TestApp::Test {
|
class SendRecvRendererTest : public ClientApp::RenderDelegate {
|
||||||
public:
|
public:
|
||||||
SendRecvRendererTest() {}
|
SendRecvRendererTest() {}
|
||||||
|
|
||||||
virtual bool OnProcessMessageRecieved(
|
virtual bool OnProcessMessageRecieved(
|
||||||
CefRefPtr<TestApp> test_app,
|
CefRefPtr<ClientApp> app,
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefProcessId source_process,
|
CefProcessId source_process,
|
||||||
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||||
@ -90,9 +90,9 @@ class SendRecvTestHandler : public TestHandler {
|
|||||||
"<html><head>\n"
|
"<html><head>\n"
|
||||||
"<script>\n"
|
"<script>\n"
|
||||||
"function cb(name, args) {\n"
|
"function cb(name, args) {\n"
|
||||||
" test_app.sendMessage(name, args);\n"
|
" app.sendMessage(name, args);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"test_app.setMessageCallback('"+std::string(kSendRecvMsg)+"', cb);\n"
|
"app.setMessageCallback('"+std::string(kSendRecvMsg)+"', cb);\n"
|
||||||
"</script>\n"
|
"</script>\n"
|
||||||
"<body>TEST JAVASCRIPT</body>\n"
|
"<body>TEST JAVASCRIPT</body>\n"
|
||||||
"</head></html>";
|
"</head></html>";
|
||||||
@ -176,8 +176,9 @@ TEST(ProcessMessageTest, Copy) {
|
|||||||
|
|
||||||
|
|
||||||
// Entry point for creating process message renderer test objects.
|
// Entry point for creating process message renderer test objects.
|
||||||
// Called from test_app_tests.cc.
|
// Called from client_app_delegates.cc.
|
||||||
void CreateProcessMessageRendererTests(TestApp::TestSet& tests) {
|
void CreateProcessMessageRendererTests(
|
||||||
|
ClientApp::RenderDelegateSet& delegates) {
|
||||||
// For ProcessMessageTest.SendRecv
|
// For ProcessMessageTest.SendRecv
|
||||||
tests.insert(new SendRecvRendererTest);
|
delegates.insert(new SendRecvRendererTest);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "include/cef_app.h"
|
#include "include/cef_app.h"
|
||||||
#include "include/cef_task.h"
|
#include "include/cef_task.h"
|
||||||
#include "tests/unittests/test_app.h"
|
#include "tests/cefclient/client_app.h"
|
||||||
#include "tests/unittests/test_suite.h"
|
#include "tests/unittests/test_suite.h"
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
@ -51,7 +51,7 @@ int main(int argc, char* argv[]) {
|
|||||||
CefMainArgs main_args(argc, argv);
|
CefMainArgs main_args(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CefRefPtr<CefApp> app(new TestApp);
|
CefRefPtr<CefApp> app(new ClientApp);
|
||||||
|
|
||||||
// Execute the secondary process, if any.
|
// Execute the secondary process, if any.
|
||||||
int exit_code = CefExecuteProcess(main_args, app);
|
int exit_code = CefExecuteProcess(main_args, app);
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
|
||||||
// can be found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "tests/unittests/test_app.h"
|
|
||||||
|
|
||||||
// static
|
|
||||||
void TestApp::CreateTests(TestSet& tests) {
|
|
||||||
// Bring in the process message tests.
|
|
||||||
extern void CreateProcessMessageRendererTests(TestApp::TestSet& tests);
|
|
||||||
CreateProcessMessageRendererTests(tests);
|
|
||||||
|
|
||||||
// Bring in the V8 tests.
|
|
||||||
extern void CreateV8RendererTests(TestApp::TestSet& tests);
|
|
||||||
CreateV8RendererTests(tests);
|
|
||||||
}
|
|
@ -3,6 +3,7 @@
|
|||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "tests/unittests/test_handler.h"
|
#include "tests/unittests/test_handler.h"
|
||||||
|
#include "include/cef_command_line.h"
|
||||||
#include "include/cef_runnable.h"
|
#include "include/cef_runnable.h"
|
||||||
#include "include/cef_stream.h"
|
#include "include/cef_stream.h"
|
||||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||||
@ -114,3 +115,16 @@ void WaitForThread(CefThreadId thread_id) {
|
|||||||
CefPostTask(thread_id, NewCefRunnableFunction(&NotifyEvent, &event));
|
CefPostTask(thread_id, NewCefRunnableFunction(&NotifyEvent, &event));
|
||||||
event.Wait();
|
event.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TestFailed() {
|
||||||
|
CefRefPtr<CefCommandLine> command_line =
|
||||||
|
CefCommandLine::GetGlobalCommandLine();
|
||||||
|
if (command_line->HasSwitch("single-process")) {
|
||||||
|
// Check for a failure on the current test only.
|
||||||
|
return ::testing::UnitTest::GetInstance()->current_test_info()->result()->
|
||||||
|
Failed();
|
||||||
|
} else {
|
||||||
|
// Check for any global failure.
|
||||||
|
return ::testing::UnitTest::GetInstance()->Failed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -114,4 +114,7 @@ void WaitForThread(CefThreadId thread_id);
|
|||||||
#define WaitForIOThread() WaitForThread(TID_IO)
|
#define WaitForIOThread() WaitForThread(TID_IO)
|
||||||
#define WaitForUIThread() WaitForThread(TID_UI)
|
#define WaitForUIThread() WaitForThread(TID_UI)
|
||||||
|
|
||||||
|
// Returns true if the currently running test has failed.
|
||||||
|
bool TestFailed();
|
||||||
|
|
||||||
#endif // CEF_TESTS_UNITTESTS_TEST_HANDLER_H_
|
#endif // CEF_TESTS_UNITTESTS_TEST_HANDLER_H_
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// can be found in the LICENSE file.
|
// can be found in the LICENSE file.
|
||||||
|
|
||||||
#include "tests/unittests/test_suite.h"
|
#include "tests/unittests/test_suite.h"
|
||||||
#include "tests/cefclient/cefclient_switches.h"
|
#include "tests/cefclient/client_switches.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/test/test_suite.h"
|
#include "base/test/test_suite.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "include/cef_task.h"
|
#include "include/cef_task.h"
|
||||||
#include "include/cef_v8.h"
|
#include "include/cef_v8.h"
|
||||||
#include "tests/unittests/test_app.h"
|
#include "tests/cefclient/client_app.h"
|
||||||
#include "tests/unittests/test_handler.h"
|
#include "tests/unittests/test_handler.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ enum V8TestMode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Renderer side.
|
// Renderer side.
|
||||||
class V8RendererTest : public TestApp::Test {
|
class V8RendererTest : public ClientApp::RenderDelegate {
|
||||||
public:
|
public:
|
||||||
V8RendererTest() {}
|
V8RendererTest() {}
|
||||||
|
|
||||||
@ -1384,7 +1384,7 @@ class V8RendererTest : public TestApp::Test {
|
|||||||
DestroyTest();
|
DestroyTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnContextCreated(CefRefPtr<TestApp> test_app,
|
virtual void OnContextCreated(CefRefPtr<ClientApp> app,
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefV8Context> context) OVERRIDE {
|
CefRefPtr<CefV8Context> context) OVERRIDE {
|
||||||
@ -1443,12 +1443,12 @@ class V8RendererTest : public TestApp::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual bool OnProcessMessageRecieved(
|
virtual bool OnProcessMessageRecieved(
|
||||||
CefRefPtr<TestApp> test_app,
|
CefRefPtr<ClientApp> app,
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefProcessId source_process,
|
CefProcessId source_process,
|
||||||
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
CefRefPtr<CefProcessMessage> message) OVERRIDE {
|
||||||
if (message->GetName() == kV8TestMsg) {
|
if (message->GetName() == kV8TestMsg) {
|
||||||
test_app_ = test_app;
|
app_ = app;
|
||||||
browser_ = browser;
|
browser_ = browser;
|
||||||
|
|
||||||
V8TestMode test_mode =
|
V8TestMode test_mode =
|
||||||
@ -1467,7 +1467,7 @@ class V8RendererTest : public TestApp::Test {
|
|||||||
// Return from the test.
|
// Return from the test.
|
||||||
void DestroyTest() {
|
void DestroyTest() {
|
||||||
// Check if the test has failed.
|
// Check if the test has failed.
|
||||||
bool result = !TestApp::TestFailed();
|
bool result = !TestFailed();
|
||||||
|
|
||||||
// Return the result to the browser process.
|
// Return the result to the browser process.
|
||||||
CefRefPtr<CefProcessMessage> return_msg =
|
CefRefPtr<CefProcessMessage> return_msg =
|
||||||
@ -1475,7 +1475,7 @@ class V8RendererTest : public TestApp::Test {
|
|||||||
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
||||||
EXPECT_TRUE(browser_->SendProcessMessage(PID_BROWSER, return_msg));
|
EXPECT_TRUE(browser_->SendProcessMessage(PID_BROWSER, return_msg));
|
||||||
|
|
||||||
test_app_ = NULL;
|
app_ = NULL;
|
||||||
browser_ = NULL;
|
browser_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1486,7 +1486,7 @@ class V8RendererTest : public TestApp::Test {
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<TestApp> test_app_;
|
CefRefPtr<ClientApp> app_;
|
||||||
CefRefPtr<CefBrowser> browser_;
|
CefRefPtr<CefBrowser> browser_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(SendRecvRendererTest);
|
IMPLEMENT_REFCOUNTING(SendRecvRendererTest);
|
||||||
@ -1562,9 +1562,9 @@ class V8TestHandler : public TestHandler {
|
|||||||
|
|
||||||
|
|
||||||
// Entry point for creating V8 renderer test objects.
|
// Entry point for creating V8 renderer test objects.
|
||||||
// Called from test_app_tests.cc.
|
// Called from client_app_delegates.cc.
|
||||||
void CreateV8RendererTests(TestApp::TestSet& tests) {
|
void CreateV8RendererTests(ClientApp::RenderDelegateSet& delegates) {
|
||||||
tests.insert(new V8RendererTest);
|
delegates.insert(new V8RendererTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user