Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: content/renderer/v8_value_converter_impl_unittest.cc

Issue 14081010: Cleanup: Remove unnecessary ".get()" from scoped_ptrs<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some gtk issues Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/test/values_test_util.h" 9 #include "base/test/values_test_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 return child->IsNull(); 141 return child->IsNull();
142 } 142 }
143 143
144 void TestWeirdType(const V8ValueConverterImpl& converter, 144 void TestWeirdType(const V8ValueConverterImpl& converter,
145 v8::Handle<v8::Value> val, 145 v8::Handle<v8::Value> val,
146 base::Value::Type expected_type, 146 base::Value::Type expected_type,
147 scoped_ptr<base::Value> expected_value) { 147 scoped_ptr<base::Value> expected_value) {
148 scoped_ptr<base::Value> raw(converter.FromV8Value(val, context_)); 148 scoped_ptr<base::Value> raw(converter.FromV8Value(val, context_));
149 149
150 if (expected_value.get()) { 150 if (expected_value) {
151 ASSERT_TRUE(raw.get()); 151 ASSERT_TRUE(raw.get());
152 EXPECT_TRUE(expected_value->Equals(raw.get())); 152 EXPECT_TRUE(expected_value->Equals(raw.get()));
153 EXPECT_EQ(expected_type, raw->GetType()); 153 EXPECT_EQ(expected_type, raw->GetType());
154 } else { 154 } else {
155 EXPECT_FALSE(raw.get()); 155 EXPECT_FALSE(raw.get());
156 } 156 }
157 157
158 v8::Handle<v8::Object> object(v8::Object::New()); 158 v8::Handle<v8::Object> object(v8::Object::New());
159 object->Set(v8::String::New("test"), val); 159 object->Set(v8::String::New("test"), val);
160 scoped_ptr<base::DictionaryValue> dictionary( 160 scoped_ptr<base::DictionaryValue> dictionary(
161 static_cast<base::DictionaryValue*>( 161 static_cast<base::DictionaryValue*>(
162 converter.FromV8Value(object, context_))); 162 converter.FromV8Value(object, context_)));
163 ASSERT_TRUE(dictionary.get()); 163 ASSERT_TRUE(dictionary.get());
164 164
165 if (expected_value.get()) { 165 if (expected_value) {
166 base::Value* temp = NULL; 166 base::Value* temp = NULL;
167 ASSERT_TRUE(dictionary->Get("test", &temp)); 167 ASSERT_TRUE(dictionary->Get("test", &temp));
168 EXPECT_EQ(expected_type, temp->GetType()); 168 EXPECT_EQ(expected_type, temp->GetType());
169 EXPECT_TRUE(expected_value->Equals(temp)); 169 EXPECT_TRUE(expected_value->Equals(temp));
170 } else { 170 } else {
171 EXPECT_FALSE(dictionary->HasKey("test")); 171 EXPECT_FALSE(dictionary->HasKey("test"));
172 } 172 }
173 173
174 v8::Handle<v8::Array> array(v8::Array::New()); 174 v8::Handle<v8::Array> array(v8::Array::New());
175 array->Set(0, val); 175 array->Set(0, val);
176 scoped_ptr<base::ListValue> list( 176 scoped_ptr<base::ListValue> list(
177 static_cast<base::ListValue*>(converter.FromV8Value(array, context_))); 177 static_cast<base::ListValue*>(converter.FromV8Value(array, context_)));
178 ASSERT_TRUE(list.get()); 178 ASSERT_TRUE(list.get());
179 if (expected_value.get()) { 179 if (expected_value) {
180 base::Value* temp = NULL; 180 base::Value* temp = NULL;
181 ASSERT_TRUE(list->Get(0, &temp)); 181 ASSERT_TRUE(list->Get(0, &temp));
182 EXPECT_EQ(expected_type, temp->GetType()); 182 EXPECT_EQ(expected_type, temp->GetType());
183 EXPECT_TRUE(expected_value->Equals(temp)); 183 EXPECT_TRUE(expected_value->Equals(temp));
184 } else { 184 } else {
185 // Arrays should preserve their length, and convert unconvertible 185 // Arrays should preserve their length, and convert unconvertible
186 // types into null. 186 // types into null.
187 base::Value* temp = NULL; 187 base::Value* temp = NULL;
188 ASSERT_TRUE(list->Get(0, &temp)); 188 ASSERT_TRUE(list->Get(0, &temp));
189 EXPECT_EQ(base::Value::TYPE_NULL, temp->GetType()); 189 EXPECT_EQ(base::Value::TYPE_NULL, temp->GetType());
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 641
642 // The actual result. 642 // The actual result.
643 scoped_ptr<base::Value> actual_dictionary( 643 scoped_ptr<base::Value> actual_dictionary(
644 converter.FromV8Value(recursive_object, context_)); 644 converter.FromV8Value(recursive_object, context_));
645 ASSERT_TRUE(actual_dictionary.get()); 645 ASSERT_TRUE(actual_dictionary.get());
646 646
647 EXPECT_TRUE(expected_dictionary.Equals(actual_dictionary.get())); 647 EXPECT_TRUE(expected_dictionary.Equals(actual_dictionary.get()));
648 } 648 }
649 649
650 } // namespace content 650 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/v8_value_converter_impl.cc ('k') | content/renderer/webplugin_delegate_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698