| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/values.h" | 8 #include "base/values.h" |
| 9 #include "content/renderer/v8_value_converter.h" | 9 #include "content/renderer/v8_value_converter.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 if (expected_value) | 130 if (expected_value) |
| 131 EXPECT_TRUE(expected_value->Equals(temp)); | 131 EXPECT_TRUE(expected_value->Equals(temp)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Context for the JavaScript in the test. | 134 // Context for the JavaScript in the test. |
| 135 v8::Persistent<v8::Context> context_; | 135 v8::Persistent<v8::Context> context_; |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 TEST_F(V8ValueConverterTest, BasicRoundTrip) { | 138 TEST_F(V8ValueConverterTest, BasicRoundTrip) { |
| 139 DictionaryValue original_root; | 139 DictionaryValue original_root; |
| 140 original_root.Set("null", Value::CreateNullValue()); | 140 original_root.Set("null", base::NullValue()); |
| 141 original_root.Set("true", Value::CreateBooleanValue(true)); | 141 original_root.Set("true", base::TrueValue()); |
| 142 original_root.Set("false", Value::CreateBooleanValue(false)); | 142 original_root.Set("false", base::FalseValue()); |
| 143 original_root.Set("positive-int", Value::CreateIntegerValue(42)); | 143 original_root.Set("positive-int", Value::CreateIntegerValue(42)); |
| 144 original_root.Set("negative-int", Value::CreateIntegerValue(-42)); | 144 original_root.Set("negative-int", Value::CreateIntegerValue(-42)); |
| 145 original_root.Set("zero", Value::CreateIntegerValue(0)); | 145 original_root.Set("zero", Value::CreateIntegerValue(0)); |
| 146 original_root.Set("double", Value::CreateDoubleValue(88.8)); | 146 original_root.Set("double", Value::CreateDoubleValue(88.8)); |
| 147 original_root.Set("big-integral-double", | 147 original_root.Set("big-integral-double", |
| 148 Value::CreateDoubleValue(pow(2.0, 53))); | 148 Value::CreateDoubleValue(pow(2.0, 53))); |
| 149 original_root.Set("string", Value::CreateStringValue("foobar")); | 149 original_root.Set("string", Value::CreateStringValue("foobar")); |
| 150 original_root.Set("empty-string", Value::CreateStringValue("")); | 150 original_root.Set("empty-string", Value::CreateStringValue("")); |
| 151 | 151 |
| 152 DictionaryValue* original_sub1 = new DictionaryValue(); | 152 DictionaryValue* original_sub1 = new DictionaryValue(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 v8::Handle<v8::Script> script(v8::Script::New(v8::String::New(source))); | 317 v8::Handle<v8::Script> script(v8::Script::New(v8::String::New(source))); |
| 318 v8::Handle<v8::Object> object = script->Run().As<v8::Object>(); | 318 v8::Handle<v8::Object> object = script->Run().As<v8::Object>(); |
| 319 ASSERT_FALSE(object.IsEmpty()); | 319 ASSERT_FALSE(object.IsEmpty()); |
| 320 | 320 |
| 321 V8ValueConverter converter; | 321 V8ValueConverter converter; |
| 322 scoped_ptr<DictionaryValue> result( | 322 scoped_ptr<DictionaryValue> result( |
| 323 static_cast<DictionaryValue*>(converter.FromV8Value(object, context_))); | 323 static_cast<DictionaryValue*>(converter.FromV8Value(object, context_))); |
| 324 ASSERT_TRUE(result.get()); | 324 ASSERT_TRUE(result.get()); |
| 325 EXPECT_EQ(0u, result->size()); | 325 EXPECT_EQ(0u, result->size()); |
| 326 } | 326 } |
| OLD | NEW |