OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gin/per_context_data.h" | 5 #include "gin/per_context_data.h" |
6 | 6 |
7 #include "gin/public/context_holder.h" | 7 #include "gin/public/context_holder.h" |
8 #include "gin/public/isolate_holder.h" | 8 #include "gin/public/isolate_holder.h" |
9 #include "gin/test/v8_test.h" | 9 #include "gin/test/v8_test.h" |
10 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
11 | 11 |
12 namespace gin { | 12 namespace gin { |
13 | 13 |
14 typedef V8Test PerContextDataTest; | 14 typedef V8Test PerContextDataTest; |
15 | 15 |
16 // Verifies PerContextData can be looked up by context and that it is not | 16 // Verifies PerContextData can be looked up by context and that it is not |
17 // available once ContextHolder is destroyed. | 17 // available once ContextHolder is destroyed. |
18 TEST_F(PerContextDataTest, LookupAndDestruction) { | 18 TEST_F(PerContextDataTest, LookupAndDestruction) { |
19 v8::Isolate::Scope isolate_scope(instance_->isolate()); | 19 v8::Isolate::Scope isolate_scope(instance_->isolate()); |
20 v8::HandleScope handle_scope(instance_->isolate()); | 20 v8::HandleScope handle_scope(instance_->isolate()); |
21 v8::Handle<v8::Context> context = v8::Context::New( | 21 v8::Local<v8::Context> context = v8::Context::New( |
22 instance_->isolate(), NULL, v8::Handle<v8::ObjectTemplate>()); | 22 instance_->isolate(), NULL, v8::Local<v8::ObjectTemplate>()); |
23 { | 23 { |
24 ContextHolder context_holder(instance_->isolate()); | 24 ContextHolder context_holder(instance_->isolate()); |
25 context_holder.SetContext(context); | 25 context_holder.SetContext(context); |
26 PerContextData* per_context_data = PerContextData::From(context); | 26 PerContextData* per_context_data = PerContextData::From(context); |
27 EXPECT_TRUE(per_context_data != NULL); | 27 EXPECT_TRUE(per_context_data != NULL); |
28 EXPECT_EQ(&context_holder, per_context_data->context_holder()); | 28 EXPECT_EQ(&context_holder, per_context_data->context_holder()); |
29 } | 29 } |
30 PerContextData* per_context_data = PerContextData::From(context); | 30 PerContextData* per_context_data = PerContextData::From(context); |
31 EXPECT_TRUE(per_context_data == NULL); | 31 EXPECT_TRUE(per_context_data == NULL); |
32 } | 32 } |
33 | 33 |
34 } // namespace gin | 34 } // namespace gin |
OLD | NEW |