OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/test/values_test_util.h" | 8 #include "base/test/values_test_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/renderer/v8_value_converter_impl.h" | 10 #include "content/renderer/v8_value_converter_impl.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class V8ValueConverterImplTest : public testing::Test { | 26 class V8ValueConverterImplTest : public testing::Test { |
27 protected: | 27 protected: |
28 virtual void SetUp() { | 28 virtual void SetUp() { |
29 v8::HandleScope handle_scope; | 29 v8::HandleScope handle_scope; |
30 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); | 30 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); |
31 context_ = v8::Context::New(NULL, global); | 31 context_ = v8::Context::New(NULL, global); |
32 } | 32 } |
33 | 33 |
34 virtual void TearDown() { | 34 virtual void TearDown() { |
35 context_.Dispose(); | 35 context_.Dispose(context_->GetIsolate()); |
36 } | 36 } |
37 | 37 |
38 std::string GetString(DictionaryValue* value, const std::string& key) { | 38 std::string GetString(DictionaryValue* value, const std::string& key) { |
39 std::string temp; | 39 std::string temp; |
40 if (!value->GetString(key, &temp)) { | 40 if (!value->GetString(key, &temp)) { |
41 ADD_FAILURE(); | 41 ADD_FAILURE(); |
42 return ""; | 42 return ""; |
43 } | 43 } |
44 return temp; | 44 return temp; |
45 } | 45 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 EXPECT_TRUE(Value::Equals(base::test::ParseJson("{ \"bar\": null }").get(), | 537 EXPECT_TRUE(Value::Equals(base::test::ParseJson("{ \"bar\": null }").get(), |
538 actual_object.get())); | 538 actual_object.get())); |
539 | 539 |
540 // Everything is null because JSON stringification preserves array length. | 540 // Everything is null because JSON stringification preserves array length. |
541 scoped_ptr<Value> actual_array(converter.FromV8Value(array, context_)); | 541 scoped_ptr<Value> actual_array(converter.FromV8Value(array, context_)); |
542 EXPECT_TRUE(Value::Equals(base::test::ParseJson("[ null, null, null ]").get(), | 542 EXPECT_TRUE(Value::Equals(base::test::ParseJson("[ null, null, null ]").get(), |
543 actual_array.get())); | 543 actual_array.get())); |
544 } | 544 } |
545 | 545 |
546 } // namespace content | 546 } // namespace content |
OLD | NEW |