diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-23 20:26:51 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-23 20:26:51 +0000 |
commit | 314cde1222cbc81c1d42054fc379235598f0125a (patch) | |
tree | a9a698a4acebe708171d972cd1151455bc9da916 /gin/test | |
parent | 52e48aed8d0ec12cfb7b22434805758cfee5d41c (diff) | |
download | chromium_src-314cde1222cbc81c1d42054fc379235598f0125a.zip chromium_src-314cde1222cbc81c1d42054fc379235598f0125a.tar.gz chromium_src-314cde1222cbc81c1d42054fc379235598f0125a.tar.bz2 |
First cut at gin::Bind().
BUG=
Review URL: https://codereview.chromium.org/76923003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/test')
-rw-r--r-- | gin/test/gtest.cc | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/gin/test/gtest.cc b/gin/test/gtest.cc index 962bd9a..422d3ec 100644 --- a/gin/test/gtest.cc +++ b/gin/test/gtest.cc @@ -4,44 +4,26 @@ #include "gin/test/gtest.h" +#include "base/bind.h" +#include "base/logging.h" #include "gin/arguments.h" #include "gin/converter.h" +#include "gin/function_template.h" #include "gin/per_isolate_data.h" #include "gin/public/wrapper_info.h" +#include "gin/wrappable.h" #include "testing/gtest/include/gtest/gtest.h" -using v8::ObjectTemplate; - namespace gin { namespace { -void ExpectTrue(const v8::FunctionCallbackInfo<v8::Value>& info) { - Arguments args(info); - - bool value = false; - std::string description; - - if (!args.GetNext(&value) || - !args.GetNext(&description)) { - return args.ThrowError(); - } - - EXPECT_TRUE(value) << description; +void ExpectTrue(bool condition, const std::string& description) { + EXPECT_TRUE(condition) << description; } -void ExpectFalse(const v8::FunctionCallbackInfo<v8::Value>& info) { - Arguments args(info); - - bool value = false; - std::string description; - - if (!args.GetNext(&value) || - !args.GetNext(&description)) { - return args.ThrowError(); - } - - EXPECT_FALSE(value) << description; +void ExpectFalse(bool condition, const std::string& description) { + EXPECT_FALSE(condition) << description; } void ExpectEqual(const v8::FunctionCallbackInfo<v8::Value>& info) { @@ -60,15 +42,16 @@ WrapperInfo g_wrapper_info = { kEmbedderNativeGin }; const char GTest::kModuleName[] = "gtest"; -v8::Local<ObjectTemplate> GTest::GetTemplate(v8::Isolate* isolate) { +v8::Local<v8::ObjectTemplate> GTest::GetTemplate(v8::Isolate* isolate) { PerIsolateData* data = PerIsolateData::From(isolate); - v8::Local<ObjectTemplate> templ = data->GetObjectTemplate(&g_wrapper_info); + v8::Local<v8::ObjectTemplate> templ = + data->GetObjectTemplate(&g_wrapper_info); if (templ.IsEmpty()) { - templ = ObjectTemplate::New(); + templ = v8::ObjectTemplate::New(); templ->Set(StringToSymbol(isolate, "expectTrue"), - v8::FunctionTemplate::New(ExpectTrue)); + CreateFunctionTempate(isolate, base::Bind(ExpectTrue))); templ->Set(StringToSymbol(isolate, "expectFalse"), - v8::FunctionTemplate::New(ExpectFalse)); + CreateFunctionTempate(isolate, base::Bind(ExpectFalse))); templ->Set(StringToSymbol(isolate, "expectEqual"), v8::FunctionTemplate::New(ExpectEqual)); data->SetObjectTemplate(&g_wrapper_info, templ); |