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

Unified Diff: gin/test/gtest.cc

Issue 76923003: First cut at gin::Bind() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix return 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
« gin/function_template_util.cc ('K') | « gin/gin.gyp ('k') | no next file » | 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 962bd9a4f7e438bb8c333a71f056d07305d2db46..14206d95ffede1486447eae17df900732a883d46 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_util.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,17 @@ 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) {
+ CallbackHolderBase::Register(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)));
abarth-chromium 2013/11/22 09:17:13 This looks really nice.
templ->Set(StringToSymbol(isolate, "expectEqual"),
v8::FunctionTemplate::New(ExpectEqual));
data->SetObjectTemplate(&g_wrapper_info, templ);
« gin/function_template_util.cc ('K') | « gin/gin.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698