Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: gin/test/gtest.cc

Issue 93813002: Implement gin::ObjectTemplateBuilder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/object_template_builder.cc ('k') | mojo/apps/js/threading.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/test/gtest.cc
diff --git a/gin/test/gtest.cc b/gin/test/gtest.cc
index a0cf70c75f5eacb4c7b7b152892e159b1a0f8d20..d5e4d8c44f3139eb2484030eaac250821ad13666 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;
« no previous file with comments | « gin/object_template_builder.cc ('k') | mojo/apps/js/threading.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698