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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "extensions/renderer/activity_log_converter_strategy.h" | 7 #include "extensions/renderer/activity_log_converter_strategy.h" |
8 #include "extensions/renderer/scoped_persistent.h" | 8 #include "extensions/renderer/scoped_persistent.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
11 | 11 |
12 using content::V8ValueConverter; | 12 using content::V8ValueConverter; |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 class ActivityLogConverterStrategyTest : public testing::Test { | 16 class ActivityLogConverterStrategyTest : public testing::Test { |
17 public: | 17 public: |
18 ActivityLogConverterStrategyTest() | 18 ActivityLogConverterStrategyTest() |
19 : isolate_(v8::Isolate::GetCurrent()) | 19 : isolate_(v8::Isolate::GetCurrent()) |
20 , handle_scope_(isolate_) | 20 , handle_scope_(isolate_) |
21 , context_(v8::Context::New(isolate_)) | 21 , context_(v8::Context::New(isolate_)) |
22 , context_scope_(context()) { | 22 , context_scope_(context()) { |
23 } | 23 } |
24 | 24 |
25 protected: | 25 protected: |
26 virtual void SetUp() { | 26 void SetUp() override { |
27 converter_.reset(V8ValueConverter::create()); | 27 converter_.reset(V8ValueConverter::create()); |
28 strategy_.reset(new ActivityLogConverterStrategy()); | 28 strategy_.reset(new ActivityLogConverterStrategy()); |
29 converter_->SetFunctionAllowed(true); | 29 converter_->SetFunctionAllowed(true); |
30 converter_->SetStrategy(strategy_.get()); | 30 converter_->SetStrategy(strategy_.get()); |
31 } | 31 } |
32 | 32 |
33 testing::AssertionResult VerifyNull(v8::Local<v8::Value> v8_value) { | 33 testing::AssertionResult VerifyNull(v8::Local<v8::Value> v8_value) { |
34 scoped_ptr<base::Value> value( | 34 scoped_ptr<base::Value> value( |
35 converter_->FromV8Value(v8_value, context())); | 35 converter_->FromV8Value(v8_value, context())); |
36 if (value->IsType(base::Value::TYPE_NULL)) | 36 if (value->IsType(base::Value::TYPE_NULL)) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 "[Array]")); | 163 "[Array]")); |
164 EXPECT_TRUE(VerifyString( | 164 EXPECT_TRUE(VerifyString( |
165 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), | 165 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), |
166 "[Function]")); | 166 "[Function]")); |
167 EXPECT_TRUE(VerifyString( | 167 EXPECT_TRUE(VerifyString( |
168 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), | 168 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), |
169 "[Function foo()]")); | 169 "[Function foo()]")); |
170 } | 170 } |
171 | 171 |
172 } // namespace extensions | 172 } // namespace extensions |
OLD | NEW |