summaryrefslogtreecommitdiffstats
path: root/gin/test
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-29 03:21:48 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-29 03:21:48 +0000
commitb520e13a9cddc9089d5ff0bf1c168a0abb6b7ec9 (patch)
treed76d8a9997fe450fab28a52af87000a21f72578d /gin/test
parentd4d1e4b16a0c7f496b00232314ba9405014f8f36 (diff)
downloadchromium_src-b520e13a9cddc9089d5ff0bf1c168a0abb6b7ec9.zip
chromium_src-b520e13a9cddc9089d5ff0bf1c168a0abb6b7ec9.tar.gz
chromium_src-b520e13a9cddc9089d5ff0bf1c168a0abb6b7ec9.tar.bz2
Implement gin::ObjectTemplateBuilder
BUG= Review URL: https://codereview.chromium.org/93813002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/test')
-rw-r--r--gin/test/gtest.cc24
1 files changed, 8 insertions, 16 deletions
diff --git a/gin/test/gtest.cc b/gin/test/gtest.cc
index a0cf70c..d5e4d8c 100644
--- a/gin/test/gtest.cc
+++ b/gin/test/gtest.cc
@@ -9,6 +9,7 @@
#include "gin/arguments.h"
#include "gin/converter.h"
#include "gin/function_template.h"
+#include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h"
#include "gin/public/wrapper_info.h"
#include "gin/wrappable.h"
@@ -18,13 +19,7 @@ namespace gin {
namespace {
-void Fail(const v8::FunctionCallbackInfo<v8::Value>& info) {
- Arguments args(info);
-
- std::string description;
- if (!args.GetNext(&description))
- return args.ThrowError();
-
+void Fail(const std::string& description) {
FAIL() << description;
}
@@ -53,15 +48,12 @@ v8::Local<v8::ObjectTemplate> GTest::GetTemplate(v8::Isolate* isolate) {
v8::Local<v8::ObjectTemplate> templ =
data->GetObjectTemplate(&g_wrapper_info);
if (templ.IsEmpty()) {
- templ = v8::ObjectTemplate::New();
- templ->Set(StringToSymbol(isolate, "fail"),
- v8::FunctionTemplate::New(Fail));
- templ->Set(StringToSymbol(isolate, "expectTrue"),
- CreateFunctionTemplate(isolate, base::Bind(ExpectTrue)));
- templ->Set(StringToSymbol(isolate, "expectFalse"),
- CreateFunctionTemplate(isolate, base::Bind(ExpectFalse)));
- templ->Set(StringToSymbol(isolate, "expectEqual"),
- CreateFunctionTemplate(isolate, base::Bind(ExpectEqual)));
+ templ = ObjectTemplateBuilder(isolate)
+ .SetMethod("fail", Fail)
+ .SetMethod("expectTrue", ExpectTrue)
+ .SetMethod("expectFalse", ExpectFalse)
+ .SetMethod("expectEqual", ExpectEqual)
+ .Build();
data->SetObjectTemplate(&g_wrapper_info, templ);
}
return templ;