Fix Mac compile errors.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@189 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-02-22 00:05:36 +00:00
parent 06a6f0ce7c
commit 0c0da498d0

View File

@ -7,6 +7,8 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "test_handler.h" #include "test_handler.h"
namespace {
bool g_V8TestV8HandlerExecuteCalled; bool g_V8TestV8HandlerExecuteCalled;
bool g_V8TestV8HandlerExecute2Called; bool g_V8TestV8HandlerExecute2Called;
@ -312,6 +314,8 @@ public:
bool binding_test_; bool binding_test_;
}; };
} // namespace
// Verify window binding // Verify window binding
TEST(V8Test, Binding) TEST(V8Test, Binding)
{ {
@ -354,6 +358,8 @@ TEST(V8Test, Extension)
ASSERT_TRUE(g_V8TestV8HandlerExecute2Called); ASSERT_TRUE(g_V8TestV8HandlerExecute2Called);
} }
namespace {
// Using a delegate so that the code below can remain inline. // Using a delegate so that the code below can remain inline.
class CefV8HandlerDelegate class CefV8HandlerDelegate
{ {
@ -365,9 +371,6 @@ public:
CefString& exception) = 0; CefString& exception) = 0;
}; };
// Verify context works to allow async v8 callbacks
TEST(V8Test, Context)
{
class DelegatingV8Handler : public CefThreadSafeBase<CefV8Handler> class DelegatingV8Handler : public CefThreadSafeBase<CefV8Handler>
{ {
public: public:
@ -530,8 +533,8 @@ TEST(V8Test, Context)
CefRefPtr<CefV8Value> rv; CefRefPtr<CefV8Value> rv;
CefString exception; CefString exception;
CefRefPtr<CefV8Value> empty; CefRefPtr<CefV8Value> empty;
ASSERT_TRUE(funcIFrame_->ExecuteFunctionWithContext( ASSERT_TRUE(funcIFrame_->ExecuteFunctionWithContext(contextIFrame_, empty,
contextIFrame_, empty, args, rv, exception)); args, rv, exception));
} }
void AsyncTestContext(CefRefPtr<CefV8Context> ec, void AsyncTestContext(CefRefPtr<CefV8Context> ec,
@ -564,22 +567,20 @@ TEST(V8Test, Context)
currentMainFrame->LoadURL("http://tests/begin.html"); currentMainFrame->LoadURL("http://tests/begin.html");
} }
void AsyncTestException( void AsyncTestException(CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Value> func) CefRefPtr<CefV8Value> func)
{ {
CefV8ValueList args; CefV8ValueList args;
CefRefPtr<CefV8Value> rv; CefRefPtr<CefV8Value> rv;
CefString exception; CefString exception;
CefRefPtr<CefV8Value> empty; CefRefPtr<CefV8Value> empty;
ASSERT_TRUE(func->ExecuteFunctionWithContext( ASSERT_TRUE(func->ExecuteFunctionWithContext(context, empty, args, rv,
context, empty, args, rv, exception)); exception));
if(exception == "Uncaught My Exception") if(exception == "Uncaught My Exception")
got_exception_.yes(); got_exception_.yes();
} }
void AsyncTestNavigation( void AsyncTestNavigation(CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Context> context,
CefRefPtr<CefV8Value> func) CefRefPtr<CefV8Value> func)
{ {
CefV8ValueList args; CefV8ValueList args;
@ -587,8 +588,8 @@ TEST(V8Test, Context)
CefRefPtr<CefV8Value> rv; CefRefPtr<CefV8Value> rv;
CefString exception; CefString exception;
CefRefPtr<CefV8Value> global = context->GetGlobal(); CefRefPtr<CefV8Value> global = context->GetGlobal();
ASSERT_TRUE(func->ExecuteFunctionWithContext( ASSERT_TRUE(func->ExecuteFunctionWithContext(context, global, args, rv,
context, global, args, rv, exception)); exception));
if(exception.empty()) if(exception.empty())
got_navigation_.yes(); got_navigation_.yes();
} }
@ -635,8 +636,7 @@ TEST(V8Test, Context)
else else
return false; return false;
if(got_hello_main_ && got_hello_iframe_ && funcIFrame_->IsFunction()) if(got_hello_main_ && got_hello_iframe_ && funcIFrame_->IsFunction()) {
{
// NB: At this point, enteredURL == http://tests/iframe.html which is // NB: At this point, enteredURL == http://tests/iframe.html which is
// expected since the iframe made the call on its own. The unexpected // expected since the iframe made the call on its own. The unexpected
// behavior is that in the call to fromIFrame (below) the enteredURL // behavior is that in the call to fromIFrame (below) the enteredURL
@ -663,11 +663,9 @@ TEST(V8Test, Context)
CefRefPtr<CefV8Value> funcException = arguments[0]; CefRefPtr<CefV8Value> funcException = arguments[0];
CefRefPtr<CefV8Value> funcNavigate = arguments[1]; CefRefPtr<CefV8Value> funcNavigate = arguments[1];
CefPostTask(TID_UI, NewCefRunnableMethod(this, CefPostTask(TID_UI, NewCefRunnableMethod(this,
&TestContextHandler::AsyncTestException, &TestContextHandler::AsyncTestException, cc, funcException));
cc, funcException));
CefPostTask(TID_UI, NewCefRunnableMethod(this, CefPostTask(TID_UI, NewCefRunnableMethod(this,
&TestContextHandler::AsyncTestNavigation, &TestContextHandler::AsyncTestNavigation, cc, funcNavigate));
cc, funcNavigate));
return true; return true;
} }
} else if (name == "end") { } else if (name == "end") {
@ -695,6 +693,11 @@ TEST(V8Test, Context)
TrackCallback got_testcomplete_; TrackCallback got_testcomplete_;
}; };
} // namespace
// Verify context works to allow async v8 callbacks
TEST(V8Test, Context)
{
CefRefPtr<TestContextHandler> handler = new TestContextHandler(); CefRefPtr<TestContextHandler> handler = new TestContextHandler();
handler->ExecuteTest(); handler->ExecuteTest();