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

Unified Diff: gin/wrappable_unittest.cc

Issue 113893005: [gin] Introduce Wrappable::GetObjectTemplate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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/wrappable.cc ('k') | mojo/apps/js/bindings/gl/context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/wrappable_unittest.cc
diff --git a/gin/wrappable_unittest.cc b/gin/wrappable_unittest.cc
index 3499eedcc18ca0b8a21a1ef8fc5f960bfa0d1598..35035ce19d74916ff62fc5977491a12a34bc4797 100644
--- a/gin/wrappable_unittest.cc
+++ b/gin/wrappable_unittest.cc
@@ -19,6 +19,8 @@ class MyObject : public Wrappable<MyObject> {
public:
static WrapperInfo kWrapperInfo;
+ static v8::Local<v8::ObjectTemplate> GetObjectTemplate(v8::Isolate* isolate);
+
static gin::Handle<MyObject> Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new MyObject());
}
@@ -44,35 +46,22 @@ class MyObjectBlink : public Wrappable<MyObjectBlink> {
};
WrapperInfo MyObject::kWrapperInfo = { kEmbedderNativeGin };
-WrapperInfo MyObject2::kWrapperInfo = { kEmbedderNativeGin };
-WrapperInfo MyObjectBlink::kWrapperInfo = { kEmbedderNativeGin };
-
-void RegisterTemplates(v8::Isolate* isolate) {
- PerIsolateData* data = PerIsolateData::From(isolate);
- DCHECK(data->GetObjectTemplate(&MyObject::kWrapperInfo).IsEmpty());
-
- v8::Handle<v8::ObjectTemplate> templ = ObjectTemplateBuilder(isolate)
+v8::Local<v8::ObjectTemplate> MyObject::GetObjectTemplate(
+ v8::Isolate* isolate) {
+ return ObjectTemplateBuilder(isolate)
.SetProperty("value", &MyObject::value, &MyObject::set_value)
.Build();
- templ->SetInternalFieldCount(kNumberOfInternalFields);
- data->SetObjectTemplate(&MyObject::kWrapperInfo, templ);
-
- templ = v8::ObjectTemplate::New(isolate);
- templ->SetInternalFieldCount(kNumberOfInternalFields);
- data->SetObjectTemplate(&MyObject2::kWrapperInfo, templ);
-
- templ = v8::ObjectTemplate::New(isolate);
- templ->SetInternalFieldCount(kNumberOfInternalFields);
- data->SetObjectTemplate(&MyObjectBlink::kWrapperInfo, templ);
}
+WrapperInfo MyObject2::kWrapperInfo = { kEmbedderNativeGin };
+WrapperInfo MyObjectBlink::kWrapperInfo = { kEmbedderNativeGin };
+
typedef V8Test WrappableTest;
TEST_F(WrappableTest, WrapAndUnwrap) {
v8::Isolate* isolate = instance_->isolate();
v8::HandleScope handle_scope(isolate);
- RegisterTemplates(isolate);
Handle<MyObject> obj = MyObject::Create(isolate);
v8::Handle<v8::Value> wrapper = ConvertToV8(isolate, obj.get());
@@ -87,8 +76,6 @@ TEST_F(WrappableTest, UnwrapFailures) {
v8::Isolate* isolate = instance_->isolate();
v8::HandleScope handle_scope(isolate);
- RegisterTemplates(isolate);
-
// Something that isn't an object.
v8::Handle<v8::Value> thing = v8::Number::New(42);
MyObject* unwrapped = NULL;
@@ -117,7 +104,6 @@ TEST_F(WrappableTest, GetAndSetProperty) {
v8::Isolate* isolate = instance_->isolate();
v8::HandleScope handle_scope(isolate);
- RegisterTemplates(isolate);
gin::Handle<MyObject> obj = MyObject::Create(isolate);
obj->set_value(42);
« no previous file with comments | « gin/wrappable.cc ('k') | mojo/apps/js/bindings/gl/context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698