| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/float_util.h" | 6 #include "base/float_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "content/common/android/gin_java_bridge_value.h" | 9 #include "content/common/android/gin_java_bridge_value.h" |
| 10 #include "content/renderer/java/gin_java_bridge_value_converter.h" | 10 #include "content/renderer/java/gin_java_bridge_value_converter.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 class GinJavaBridgeValueConverterTest : public testing::Test { | 16 class GinJavaBridgeValueConverterTest : public testing::Test { |
| 17 public: | 17 public: |
| 18 GinJavaBridgeValueConverterTest() | 18 GinJavaBridgeValueConverterTest() |
| 19 : isolate_(v8::Isolate::GetCurrent()) { | 19 : isolate_(v8::Isolate::GetCurrent()) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 protected: | 22 protected: |
| 23 virtual void SetUp() { | 23 void SetUp() override { |
| 24 v8::HandleScope handle_scope(isolate_); | 24 v8::HandleScope handle_scope(isolate_); |
| 25 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_); | 25 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_); |
| 26 context_.Reset(isolate_, v8::Context::New(isolate_, NULL, global)); | 26 context_.Reset(isolate_, v8::Context::New(isolate_, NULL, global)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 virtual void TearDown() { | 29 void TearDown() override { context_.Reset(); } |
| 30 context_.Reset(); | |
| 31 } | |
| 32 | 30 |
| 33 v8::Isolate* isolate_; | 31 v8::Isolate* isolate_; |
| 34 | 32 |
| 35 // Context for the JavaScript in the test. | 33 // Context for the JavaScript in the test. |
| 36 v8::Persistent<v8::Context> context_; | 34 v8::Persistent<v8::Context> context_; |
| 37 }; | 35 }; |
| 38 | 36 |
| 39 TEST_F(GinJavaBridgeValueConverterTest, BasicValues) { | 37 TEST_F(GinJavaBridgeValueConverterTest, BasicValues) { |
| 40 v8::HandleScope handle_scope(isolate_); | 38 v8::HandleScope handle_scope(isolate_); |
| 41 v8::Local<v8::Context> context = | 39 v8::Local<v8::Context> context = |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 base::ListValue* list; | 127 base::ListValue* list; |
| 130 ASSERT_TRUE(list_value->GetAsList(&list)) << typed_array_type; | 128 ASSERT_TRUE(list_value->GetAsList(&list)) << typed_array_type; |
| 131 EXPECT_EQ(1u, list->GetSize()) << typed_array_type; | 129 EXPECT_EQ(1u, list->GetSize()) << typed_array_type; |
| 132 double first_element; | 130 double first_element; |
| 133 ASSERT_TRUE(list->GetDouble(0, &first_element)) << typed_array_type; | 131 ASSERT_TRUE(list->GetDouble(0, &first_element)) << typed_array_type; |
| 134 EXPECT_EQ(42.0, first_element) << typed_array_type; | 132 EXPECT_EQ(42.0, first_element) << typed_array_type; |
| 135 } | 133 } |
| 136 } | 134 } |
| 137 | 135 |
| 138 } // namespace content | 136 } // namespace content |
| OLD | NEW |